Mark team for deletion when letting others know it has left during game. Should help with quitters problem.
authorunc0rr
Wed, 23 May 2012 23:30:50 +0400
changeset 7120 9257cf8e7af2
parent 7119 2737c488756b
child 7121 ce5e70fe4eb3
Mark team for deletion when letting others know it has left during game. Should help with quitters problem.
gameServer/Actions.hs
--- a/gameServer/Actions.hs	Wed May 23 23:24:03 2012 +0400
+++ b/gameServer/Actions.hs	Wed May 23 23:30:50 2012 +0400
@@ -332,8 +332,9 @@
         AnswerClients chans ["EM", rmTeamMsg],
         ModifyRoom (\r -> r{
                 gameInfo = liftM (\g -> g{
-                teamsInGameNumber = teamsInGameNumber g - 1,
-                roundMsgs = roundMsgs g Seq.|> rmTeamMsg
+                teamsInGameNumber = teamsInGameNumber g - 1
+                , roundMsgs = roundMsgs g Seq.|> rmTeamMsg
+                , leftTeams = teamName : leftTeams g
                 }) $ gameInfo r
             })
         ]
@@ -354,18 +355,13 @@
     chans <- othersChans
     if not $ inGame then
             mapM_ processAction [
-                AnswerClients chans ["REMOVE_TEAM", teamName],
                 ModifyRoom (\r -> r{teams = Prelude.filter (\t -> teamName /= teamname t) $ teams r})
+                , AnswerClients chans ["REMOVE_TEAM", teamName]
                 ]
         else
             mapM_ processAction [
-                SendTeamRemovalMessage teamName,
-                ModifyRoom (\r -> r{
-                    teams = Prelude.filter (\t -> teamName /= teamname t) $ teams r,
-                        gameInfo = liftM (\g -> g{
-                        leftTeams = teamName : leftTeams g
-                        }) $ gameInfo r
-                    })
+                ModifyRoom (\r -> r{teams = Prelude.filter (\t -> teamName /= teamname t) $ teams r})
+                , SendTeamRemovalMessage teamName
                 ]