Fix some issues with rejoining (rejoining client still desyncs though)
authorunc0rr
Wed, 02 Jul 2014 23:55:00 +0400
changeset 10349 a51de45dcc42
parent 10348 8a90df36bccb
child 10350 4e919f7b9d92
Fix some issues with rejoining (rejoining client still desyncs though)
gameServer/HWProtoLobbyState.hs
hedgewars/uIO.pas
hedgewars/uTeams.pas
--- a/gameServer/HWProtoLobbyState.hs	Wed Jul 02 11:40:57 2014 -0400
+++ b/gameServer/HWProtoLobbyState.hs	Wed Jul 02 23:55:00 2014 +0400
@@ -83,7 +83,7 @@
             else
             (
                 MoveToRoom jRI
-                : ModifyClient (\c -> c{isJoinedMidGame = isJust $ gameInfo jRoom})
+                : ModifyClient (\c -> c{isJoinedMidGame = isJust $ gameInfo jRoom, teamsInGame = fromIntegral $ length clTeams})
                 : AnswerClients chans ["CLIENT_FLAGS", "-r", nick cl]
                 : [(AnswerClients [sendChan cl] $ "JOINED" : nicks) | not $ null nicks]
             )
--- a/hedgewars/uIO.pas	Wed Jul 02 11:40:57 2014 -0400
+++ b/hedgewars/uIO.pas	Wed Jul 02 23:55:00 2014 +0400
@@ -76,7 +76,7 @@
 FillChar(command^, sizeof(TCmd), 0);
 command^.loTime:= Time;
 command^.str:= str;
-if command^.cmd <> 'F' then dec(command^.len, 2); // cut timestamp
+if (command^.cmd <> 'F') and (command^.cmd <> 'G') then dec(command^.len, 2); // cut timestamp
 if headcmd = nil then
     begin
     headcmd:= command;
@@ -369,8 +369,8 @@
              end;
         'F': ParseCommand('teamgone u' + copy(headcmd^.str, 2, Pred(headcmd^.len)), true);
         'G': ParseCommand('teamback u' + copy(headcmd^.str, 2, Pred(headcmd^.len)), true);
-        'f': ParseCommand('teamgone s' + copy(headcmd^.str, 2, headcmd^.len - 3), true);
-        'g': ParseCommand('teamback s' + copy(headcmd^.str, 2, headcmd^.len - 3), true);
+        'f': ParseCommand('teamgone s' + copy(headcmd^.str, 2, Pred(headcmd^.len)), true);
+        'g': ParseCommand('teamback s' + copy(headcmd^.str, 2, Pred(headcmd^.len)), true);
         'N': begin
             tmpflag:= false;
             lastTurnChecksum:= SDLNet_Read32(@headcmd^.str[2]);
--- a/hedgewars/uTeams.pas	Wed Jul 02 11:40:57 2014 -0400
+++ b/hedgewars/uTeams.pas	Wed Jul 02 23:55:00 2014 +0400
@@ -519,8 +519,13 @@
     with Team do
         if skippedTurns < 3 then
             begin
-                inc(skippedTurns);
-                ParseCommand('/skip', true);
+            inc(skippedTurns);
+            for i:= 0 to cMaxHHIndex do
+                with Hedgehogs[i] do
+                    if Gear <> nil then
+                        Gear^.State:= Gear^.State and (not gstHHDriven);
+
+            ParseCommand('/skip', true);
             end
         else
             for i:= 0 to cMaxHHIndex do