--- a/hedgewars/uFLNetProtocol.pas Sat Nov 21 17:07:06 2015 +0300
+++ b/hedgewars/uFLNetProtocol.pas Sat Nov 21 23:56:41 2015 +0300
@@ -5,6 +5,9 @@
procedure sendChatLine(msg: PChar); cdecl;
procedure joinRoom(roomName: PChar); cdecl;
+procedure partRoom(msg: PChar); cdecl;
+
+procedure ResetNetState;
implementation
uses uFLNetTypes, uFLTypes, uFLUICallback, uFLNet;
@@ -12,6 +15,8 @@
type
PHandler = procedure (var t: TCmdData);
+var isInRoom: boolean;
+
procedure handler_ASKPASSWORD(var p: TCmdParamS);
begin
end;
@@ -33,7 +38,10 @@
var s: string;
begin
s:= p.str1 + #10 + p.str2;
- sendUI(mtLobbyChatLine, @s[1], length(s));
+ if isInRoom then
+ sendUI(mtRoomChatLine, @s[1], length(s))
+ else
+ sendUI(mtLobbyChatLine, @s[1], length(s));
end;
procedure handler_CLIENT_FLAGS(var p: TCmdParamS);
@@ -87,7 +95,12 @@
procedure handler_JOINED_s(var s: TCmdParamS);
begin
if s.str1 = 'qmlfrontend' then // we joined a room
- sendNet('LIST');
+ begin
+ isInRoom:= true;
+ sendUI(mtMoveToRoom, nil, 0);
+ end;
+
+ sendUI(mtAddRoomClient, @s.str1[1], length(s.str1));
end;
procedure handler_JOINING(var p: TCmdParamS);
@@ -96,10 +109,13 @@
procedure handler_KICKED(var p: TCmdParam);
begin
+ isInRoom:= false;
+ sendUI(mtMoveToLobby, nil, 0);
end;
procedure handler_LEFT(var p: TCmdParamS);
begin
+ sendUI(mtRemoveLobbyClient, @p.str1[1], length(p.str1));
end;
procedure handler_LEFT_s(var s: TCmdParamS);
@@ -112,7 +128,11 @@
procedure handler_LOBBY_JOINED_s(var s: TCmdParamS);
begin
- if s.str1 = 'qmlfrontend' then sendNet('LIST');
+ if s.str1 = 'qmlfrontend' then
+ begin
+ sendUI(mtMoveToLobby, nil, 0);
+ sendNet('LIST');
+ end;
sendUI(mtAddLobbyClient, @s.str1[1], length(s.str1));
end;
@@ -276,5 +296,25 @@
sendNet(roomName);
end;
+procedure partRoom(msg: PChar); cdecl;
+var s: string;
+begin
+ if isInRoom then
+ begin
+ isInRoom:= false;
+ s:= 'PART';
+ if length(msg) > 0 then
+ s:= s + #10 + msg;
+ sendNet(s);
+ sendUI(mtMoveToLobby, nil, 0);
+ end
+end;
+
+
+procedure ResetNetState;
+begin
+ isInRoom:= false;
+end;
+
end.