Node message revamp

This commit is contained in:
mysticbbs 2012-03-10 03:58:11 -05:00
parent 728a8c6ab7
commit 55eb65c029
3 changed files with 167 additions and 109 deletions

View File

@ -27,8 +27,8 @@ Var
Procedure FullReDraw;
Var
Count : Byte;
Temp : Byte;
Count : Byte;
Temp : Byte;
Begin
If Not Full Then Exit;
@ -80,8 +80,8 @@ Begin
Session.io.OutRaw (strPadR(strI2S(CurRoom), 2, ' '));
Session.io.AnsiGotoXY (Session.io.ScreenInfo[5].X, Session.io.ScreenInfo[5].Y);
Session.io.AnsiColor (Session.io.ScreenInfo[5].A);
Session.io.AnsiGotoXY (Session.io.ScreenInfo[5].X, Session.io.ScreenInfo[5].Y);
Session.io.AnsiColor (Session.io.ScreenInfo[5].A);
Session.io.OutRaw (strPadR(Room.Name, 40, ' '));
End;
@ -96,12 +96,12 @@ Function GetKeyNodeChatFunc (Forced: Boolean) : Boolean;
Procedure AddText (Str : String);
Var
Count : Byte;
Count : Integer;
Begin
If TextPos < 200 Then
If TextPos < mysMaxMsgLines Then
Inc (TextPos)
Else
For Count := 2 to 200 Do
For Count := 2 to mysMaxMsgLines Do
Session.Msgs.MsgText[Count - 1] := Session.Msgs.MsgText[Count];
Session.Msgs.MsgText[TextPos] := Str;
@ -111,10 +111,12 @@ Var
Str : String;
StrLen : Byte;
Indent : Byte;
Lines : Byte;
Lines : Integer;
OldAttr : Byte;
OldX : Byte;
OldY : Byte;
MsgFile : File of NodeMsgRec;
Msg : NodeMsgRec;
Begin
GetKeyNodeChatFunc := False;
@ -122,32 +124,31 @@ Begin
If (TimerSeconds - ChatUpdate <> 0) or Forced Then Begin
Assign (NodeMsgFile, Session.TempPath + 'chat.tmp');
FileMode := 66;
{$I-} Reset (NodeMsgFile); {$I+}
If IoResult = 0 Then Begin
Assign (MsgFile, Session.TempPath + 'chat.tmp');
If ioReset(MsgFile, SizeOf(Msg), fmRWDN) Then Begin
OldAttr := Screen.TextAttr;
OldX := Screen.CursorX;
OldY := Screen.CursorY;
While Not Eof(NodeMsgFile) Do Begin
Read (NodeMsgFile, NodeMsg);
While Not Eof(MsgFile) Do Begin
Read (MsgFile, Msg);
If NodeMsg.MsgType in [1, 4..7] Then Begin
If Msg.MsgType in [1, 4..7] Then Begin
Session.io.OutRaw (Session.io.Pipe2Ansi(16));
Case NodeMsg.MsgType of
1 : If NodeMsg.Room = 0 Then
Str := strReplace(Session.GetPrompt(319), '|&1', NodeMsg.FromWho)
Case Msg.MsgType of
1 : If Msg.Room = 0 Then
Str := strReplace(Session.GetPrompt(319), '|&1', Msg.FromWho)
Else
If NodeMsg.Room = CurRoom Then
Str := strReplace(Session.GetPrompt(181), '|&1', NodeMsg.FromWho)
If Msg.Room = CurRoom Then
Str := strReplace(Session.GetPrompt(181), '|&1', Msg.FromWho)
Else
Continue;
4 : Str := strReplace(Session.GetPrompt(218), '|&1', NodeMsg.FromWho);
4 : Str := strReplace(Session.GetPrompt(218), '|&1', Msg.FromWho);
5 : Str := Session.GetPrompt(226);
6 : Str := strReplace(Session.GetPrompt(229), '|&1', NodeMsg.FromWho);
6 : Str := strReplace(Session.GetPrompt(229), '|&1', Msg.FromWho);
7 : Begin
Reset (RoomFile);
Seek (RoomFile, CurRoom - 1);
@ -167,13 +168,13 @@ Begin
Repeat
Inc (Lines);
If Length(Str + NodeMsg.Message) > 79 Then Begin
Str := Str + Copy(NodeMsg.Message, 1, 79 - StrLen);
If Length(Str + Msg.Message) > 79 Then Begin
Str := Str + Copy(Msg.Message, 1, 79 - StrLen);
AddText(Str);
Delete (NodeMsg.Message, 1, 79 - StrLen);
Delete (Msg.Message, 1, 79 - StrLen);
Str := strRep(' ', Indent);
End Else Begin
AddText(Str + NodeMsg.Message);
AddText(Str + Msg.Message);
Break;
End;
Until False;
@ -201,14 +202,14 @@ Begin
Session.io.AnsiClrEOL;
End;
Session.io.OutPipe (Str);
Session.io.OutPipeLn (NodeMsg.Message);
Session.io.OutPipe (Str);
Session.io.OutPipeLn (Msg.Message);
End;
End;
End;
Close (NodeMsgFile);
Erase (NodeMsgFile);
Close (MsgFile);
Erase (MsgFile);
If Not Full And Not Forced Then Begin
Session.io.PromptInfo[1] := Session.User.ThisUser.Handle;
@ -251,25 +252,21 @@ Procedure Node_Chat;
Begin
Session.io.OutFullLn (Session.GetPrompt(332));
For A := 1 to Config.INetTNNodes Do Begin
Assign (ChatFile, Config.DataPath + 'chat' + strI2S(A) + '.dat');
{$I-} Reset (ChatFile); {$I+}
If IoResult = 0 Then Begin
Read (ChatFile, Temp);
Close (ChatFile);
For A := 1 to Config.INetTNNodes Do
If GetChatRecord(A, Temp) Then
If Temp.InChat Then Begin
Reset (RoomFile);
Seek (RoomFile, Temp.Room - 1);
Read (RoomFile, RM);
Close (RoomFile);
Session.io.PromptInfo[1] := Temp.Name;
Session.io.PromptInfo[2] := strI2S(A);
Session.io.PromptInfo[3] := strI2S(Temp.Room);
Session.io.PromptInfo[4] := RM.Name;
Session.io.OutFullLn (Session.GetPrompt(333));
End;
End;
End;
Session.io.OutFullLn (Session.GetPrompt(453));
@ -289,18 +286,12 @@ Procedure Node_Chat;
If Text = '' Then Exit;
For Count := 1 to Config.INetTNNodes Do Begin
Assign (ChatFile, Config.DataPath + 'chat' + strI2S(Count) + '.dat');
{$I-} Reset (ChatFile); {$I+}
If IoResult = 0 Then Begin
Read (ChatFile, Temp);
Close (ChatFile);
For Count := 1 to Config.INetTNNodes Do
If GetChatRecord(Count, Temp) Then
If strUpper(Temp.Name) = UserName Then Begin
Send_Node_Message (4, strI2S(Count) + ';' + Text, 0);
Exit;
End;
End;
End;
Send_Node_Message (5, strI2S(Session.NodeNum) + ';' + 'User ' + UserName + ' not found', 0); //++lang
End;
@ -397,6 +388,8 @@ Begin
FullReDraw;
Session.AllowMessages := False;
GetKeyFunc := GetKeyNodeChatFunc;
Repeat
@ -485,6 +478,8 @@ Begin
Chat.InChat := False;
Chat.Available := Avail;
Session.AllowMessages := True;
Assign (ChatFile, Config.DataPath + 'chat' + strI2S(Session.NodeNum) + '.dat');
Reset (ChatFile);
Write (ChatFile, Chat);

View File

@ -4,7 +4,11 @@ Unit bbs_NodeInfo;
Interface
Function Is_User_Online (Name : String) : Word;
Uses
bbs_Common;
Function GetChatRecord (Node: Byte; Var Chat: ChatRec) : Boolean;
Function IsUserOnline (UserName: String) : Word;
Procedure Show_Whos_Online;
Procedure Send_Node_Message (MsgType: Byte; Data: String; Room: Byte);
Function CheckNodeMessages : Boolean;
@ -17,12 +21,25 @@ Uses
m_DateTime,
m_Strings,
m_FileIO,
bbs_Common,
bbs_Core,
bbs_User,
bbs_UserChat;
Function Is_User_Online (Name: String) : Word;
Function GetChatRecord (Node: Byte; Var Chat: ChatRec) : Boolean;
Begin
Result := False;
Assign (ChatFile, Config.DataPath + 'chat' + strI2S(Node) + '.dat');
If Not ioReset(ChatFile, SizeOf(ChatFile), fmRWDN) Then Exit;
Read (ChatFile, Chat);
Close (ChatFile);
Result := True;
End;
Function IsUserOnline (UserName: String) : Word;
Var
TempChat : ChatRec;
Count : Word;
@ -30,19 +47,11 @@ Begin
Result := 0;
For Count := 1 to Config.INetTNNodes Do Begin
Assign (ChatFile, Config.DataPath + 'chat' + strI2S(Count) + '.dat');
{$I-} Reset(ChatFile); {$I+}
If IoResult <> 0 Then Continue;
Read (ChatFile, TempChat);
Close (ChatFile);
If (Count <> Session.NodeNum) and (TempChat.Active) and (TempChat.Name = Name) Then Begin
Result := Count;
Exit;
End;
If GetChatRecord(Count, TempChat) Then
If (Count <> Session.NodeNum) and (TempChat.Active) and (TempChat.Name = UserName) Then Begin
Result := Count;
Exit;
End;
End;
End;
@ -74,7 +83,7 @@ Begin
Close (ChatFile);
{$IFDEF WINDOWS}
Screen.SetWindowTitle (WinConsoleTitle + strI2S(Session.NodeNum) + ' - ' + Session.User.ThisUser.Handle + ' - ' + Action);
Screen.SetWindowTitle (WinConsoleTitle + strI2S(Session.NodeNum) + ' - ' + Session.User.ThisUser.Handle + ' - ' + strStripPipe(Action));
{$ENDIF}
End;
@ -122,6 +131,9 @@ Var
A, B, C : Byte;
Temp : ChatRec;
Str : String[3];
NodeMsgFile : File of NodeMsgRec;
NodeMsg : NodeMsgRec;
Begin
If Data = '' Then Begin
Repeat
@ -156,17 +168,8 @@ Begin
End;
End;
For A := B to C Do Begin
FileMode := 66;
Assign (ChatFile, Config.DataPath + 'chat' + strI2S(A) + '.dat');
{$I-} Reset (ChatFile); {$I+}
If IoResult = 0 Then Begin
Read (ChatFile, Temp);
Close (ChatFile);
For A := B to C Do
If GetChatRecord(A, Temp) Then Begin
If (Not Temp.Active) and (ToNode > 0) Then Begin
Session.io.OutFullLn (Session.GetPrompt(147));
Exit;
@ -208,61 +211,62 @@ Begin
Close (NodeMsgFile);
End;
End;
End;
End;
Function CheckNodeMessages : Boolean;
Var
Str : String;
Image : TConsoleImageRec;
Str : String;
Image : TConsoleImageRec;
Msg : NodeMsgRec;
MsgFile : File of NodeMsgRec;
Begin
Result := False;
FileMode := 66;
Assign (NodeMsgFile, Session.TempPath + 'chat.tmp');
Assign (MsgFile, Session.TempPath + 'chat.tmp');
If Not ioReset(NodeMsgFile, SizeOf(NodeMsg), fmReadWrite + fmDenyAll) Then
If Not ioReset(MsgFile, SizeOf(Msg), fmReadWrite + fmDenyAll) Then
Exit;
If FileSize(NodeMsgFile) = 0 Then Begin
Close (NodeMsgFile);
If FileSize(MsgFile) = 0 Then Begin
Close (MsgFile);
Exit;
End;
Session.InMessage := True;
CheckNodeMessages := True;
Read (NodeMsgFile, NodeMsg);
KillRecord (NodeMsgFile, 1, SizeOf(NodeMsg));
Close (NodeMsgFile);
Read (MsgFile, Msg);
KillRecord (MsgFile, 1, SizeOf(Msg));
Close (MsgFile);
Screen.GetScreenImage (1, 1, 79, 24, Image);
Session.io.PromptInfo[1] := NodeMsg.FromWho;
Session.io.PromptInfo[2] := strI2S(NodeMsg.FromNode);
Session.io.PromptInfo[3] := NodeMsg.Message;
Session.io.PromptInfo[1] := Msg.FromWho;
Session.io.PromptInfo[2] := strI2S(Msg.FromNode);
Session.io.PromptInfo[3] := Msg.Message;
Case NodeMsg.MsgType of
Case Msg.MsgType of
2 : Begin
Session.io.OutFullLn (Session.GetPrompt(179) + NodeMsg.Message);
Session.io.OutFullLn (Session.GetPrompt(179) + Msg.Message);
Session.io.OutFullLn (Session.GetPrompt(180));
End;
3 : Begin
Session.io.OutFullLn (Session.GetPrompt(144) + '|CR' + NodeMsg.Message);
Session.io.OutFull (Session.GetPrompt(145));
Session.io.OutFullLn (Session.GetPrompt(144) + '|CR' + Msg.Message);
Session.io.OutFull (Session.GetPrompt(145));
End;
8 : If Session.io.GetYN('|CL|15|&1 is requesting user to user chat. Accept? |11', True) Then Begin
Send_Node_Message (10, strI2S(NodeMsg.FromNode) + ';C', 0);
OpenUserChat(False, NodeMsg.FromNode);
Send_Node_Message (10, strI2S(Msg.FromNode) + ';C', 0);
OpenUserChat(False, Msg.FromNode);
End;
9 : Begin
Send_Node_Message (10, strI2S(NodeMsg.FromNode) + ';C', 0);
OpenUserChat(True, NodeMsg.FromNode);
Send_Node_Message (10, strI2S(Msg.FromNode) + ';C', 0);
OpenUserChat(True, Msg.FromNode);
End;
10: OpenUserChat(False, NodeMsg.FromNode);
10: OpenUserChat(False, Msg.FromNode);
End;
If Result And (NodeMsg.MsgType = 3) Then
If Result And (Msg.MsgType = 3) Then
If Session.io.OneKey(#13 + 'R', True) = 'R' Then Begin
Session.io.OutFullLn(Session.GetPrompt(360));

View File

@ -19,12 +19,13 @@ Uses
Procedure PageUserForChat;
Var
Str : String;
ToNode : Byte;
ReqType : Byte = 8;
Str : String;
ToNode : Byte;
ReqType : Byte = 8;
TempChat : ChatRec;
Begin
Repeat
Session.io.OutFull ('|CR|09Enter node to chat with (?/List): ');
Session.io.OutFull ('|CR|09Enter node to chat with |01[|10?|01/|10List|01]|09: ');
Str := Session.io.GetInput(3, 3, 12, '');
@ -34,11 +35,10 @@ Begin
ToNode := strS2I(Str);
// pull chat record
If (ToNode = Session.NodeNum) {or user unavailable} Then Begin
Session.io.OutFull('|CR|15That user is marked unavailable|CR|CR|PA');
Exit;
If (Not GetChatRecord(ToNode, TempChat)) or (ToNode = Session.NodeNum) or
(Not TempChat.Active) or (Not TempChat.Available) Then Begin
Session.io.OutFull('|CR|15That user is marked unavailable.|CR|CR|PA');
Exit;
End;
If Session.User.Access(Config.ACSSysop) Then
@ -48,14 +48,73 @@ Begin
FileErase (Config.DataPath + 'userchat.' + strI2S(ToNode));
FileErase (Config.DataPath + 'userchat.' + strI2S(Session.NodeNum));
Session.io.OutFull('|CRSending chat request to <username>...|DE|DE|CR');
Session.io.PromptInfo[1] := TempChat.Name;
Session.io.OutFull('|CRSending chat request to |&1...|DE|DE|CR');
Send_Node_Message (ReqType, strI2S(ToNode) + ';C' + Str, 0);
End;
Procedure OpenUserChat (Forced: Boolean; ToNode: Byte);
Var
fOut : File;
fIn : File;
Ch : Char;
Done : Boolean = False;
Begin
session.io.outfull('|CRstarting user2user chat|CR|PA');
Session.io.OutFullLn('|CR|15Chat mode begin.|CR');
Assign (fOut, Config.DataPath + 'userchat.' + strI2S(ToNode));
Assign (fIn, Config.DataPath + 'userchat.' + strI2S(Session.NodeNum));
FileMode := 66;
ReWrite (fOut, 1);
ReWrite (fIn, 1);
While Not Done Do Begin
If Not Eof(fIn) Then
While Not Eof(fIn) Do Begin
BlockRead (fIn, Ch, 1);
If Ch = #255 Then Begin
Done := True;
Break;
End;
Session.io.AnsiColor (Session.Lang.LineChat2);
Session.io.BufAddChar (Ch);
End;
Session.io.BufFlush;
If Done Then Break;
Ch := Session.io.InKey(25);
Case Ch of
#27 : If Not Forced Then Begin
Ch := #255;
BlockWrite (fOut, Ch, 1);
Break;
End;
Else
If Ch in [#32..#254] Then Begin
BlockWrite (fOut, Ch, 1);
Session.io.AnsiColor (Session.Lang.LineChat1);
Session.io.BufAddChar (Ch);
End;
End;
End;
Close(fOut);
Close(fIn);
Erase(fOut);
Erase(fIn);
Session.io.OutFullLn('|CR|CR|15Chat mode complete.|DE|DE|DE');
End;
End.
End.