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

View File

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

View File

@ -19,12 +19,13 @@ Uses
Procedure PageUserForChat; Procedure PageUserForChat;
Var Var
Str : String; Str : String;
ToNode : Byte; ToNode : Byte;
ReqType : Byte = 8; ReqType : Byte = 8;
TempChat : ChatRec;
Begin Begin
Repeat 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, ''); Str := Session.io.GetInput(3, 3, 12, '');
@ -34,11 +35,10 @@ Begin
ToNode := strS2I(Str); ToNode := strS2I(Str);
// pull chat record If (Not GetChatRecord(ToNode, TempChat)) or (ToNode = Session.NodeNum) or
(Not TempChat.Active) or (Not TempChat.Available) Then Begin
If (ToNode = Session.NodeNum) {or user unavailable} Then Begin Session.io.OutFull('|CR|15That user is marked unavailable.|CR|CR|PA');
Session.io.OutFull('|CR|15That user is marked unavailable|CR|CR|PA'); Exit;
Exit;
End; End;
If Session.User.Access(Config.ACSSysop) Then If Session.User.Access(Config.ACSSysop) Then
@ -48,14 +48,73 @@ Begin
FileErase (Config.DataPath + 'userchat.' + strI2S(ToNode)); FileErase (Config.DataPath + 'userchat.' + strI2S(ToNode));
FileErase (Config.DataPath + 'userchat.' + strI2S(Session.NodeNum)); 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); Send_Node_Message (ReqType, strI2S(ToNode) + ';C' + Str, 0);
End; End;
Procedure OpenUserChat (Forced: Boolean; ToNode: Byte); Procedure OpenUserChat (Forced: Boolean; ToNode: Byte);
Var
fOut : File;
fIn : File;
Ch : Char;
Done : Boolean = False;
Begin 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. End.