Don't remove client's teams from teams list on "ROUNDFINISHED 0", just send team removal message to others.
authorunc0rr
Wed, 29 Feb 2012 23:44:49 +0400
changeset 6753 e95b1f62d0de
parent 6752 11d898afe582
child 6754 744b9430557a
Don't remove client's teams from teams list on "ROUNDFINISHED 0", just send team removal message to others. This should fix problems with ghost teams in frontend. Not tested at all, successfully built on first attempt, which is considered as a bad sign :D Server still thinks game proceeds, so restart isn't possible.
gameServer/Actions.hs
gameServer/HWProtoInRoomState.hs
--- a/gameServer/Actions.hs	Tue Feb 28 21:25:36 2012 -0500
+++ b/gameServer/Actions.hs	Wed Feb 29 23:44:49 2012 +0400
@@ -36,6 +36,7 @@
     | MoveToRoom RoomIndex
     | MoveToLobby B.ByteString
     | RemoveTeam B.ByteString
+    | SendTeamRemovalMessage B.ByteString
     | RemoveRoom
     | UnreadyRoomClients
     | JoinLobby
@@ -304,6 +305,20 @@
         notReadyMessage p nicks = if p < 38 then "NOT_READY" : nicks else "CLIENT_FLAGS" : "-r" : nicks
 
 
+processAction (SendTeamRemovalMessage teamName) = do
+    chans <- othersChans
+    mapM_ processAction [
+        AnswerClients chans ["EM", rmTeamMsg],
+        ModifyRoom (\r -> r{
+                gameInfo = liftM (\g -> g{
+                roundMsgs = roundMsgs g Seq.|> rmTeamMsg
+                }) $ gameInfo r
+            })
+        ]
+    where
+        rmTeamMsg = toEngineMsg $ 'F' `B.cons` teamName
+    
+    
 processAction (RemoveTeam teamName) = do
     rnc <- gets roomsClients
     ri <- clientRoomA
@@ -316,17 +331,14 @@
                 ]
         else
             mapM_ processAction [
-                AnswerClients chans ["EM", rmTeamMsg],
+                SendTeamRemovalMessage teamName,
                 ModifyRoom (\r -> r{
                     teams = Prelude.filter (\t -> teamName /= teamname t) $ teams r,
                         gameInfo = liftM (\g -> g{
-                        leftTeams = teamName : leftTeams g,
-                        roundMsgs = roundMsgs g Seq.|> rmTeamMsg
+                        leftTeams = teamName : leftTeams g
                         }) $ gameInfo r
                     })
                 ]
-    where
-        rmTeamMsg = toEngineMsg $ 'F' `B.cons` teamName
 
 
 processAction (RemoveClientTeams clId) = do
--- a/gameServer/HWProtoInRoomState.hs	Tue Feb 28 21:25:36 2012 -0500
+++ b/gameServer/HWProtoInRoomState.hs	Wed Feb 29 23:44:49 2012 +0400
@@ -210,6 +210,7 @@
     cl <- thisClient
     rm <- thisRoom
     chans <- roomClientsChans
+    let clTeams = map teamname . filter (\t -> teamowner t == nick cl) . teams $ rm
 
     if isJust $ gameInfo rm then
         if isMaster cl && isCorrect then
@@ -224,7 +225,7 @@
                 : UnreadyRoomClients
                 : answerRemovedTeams chans rm
             else if not isCorrect then
-                return [RemoveClientTeams clId]
+                return $ map SendTeamRemovalMessage clTeams
                 else
                 return []
         else