gameServer/HWProtoInRoomState.hs
changeset 7757 c20e6c80e249
parent 7537 833a0c34fafc
child 7765 1e162c1d6dc7
--- a/gameServer/HWProtoInRoomState.hs	Mon Oct 15 10:10:54 2012 -0400
+++ b/gameServer/HWProtoInRoomState.hs	Tue Oct 16 00:05:58 2012 +0400
@@ -181,8 +181,9 @@
                     (\r -> r{
                         gameInfo = Just $ newGameInfo (teams rm) (length $ teams rm) allPlayersRegistered (mapParams rm) (params rm)
                         }
-                    ),
-                AnswerClients chans ["RUN_GAME"]
+                    )
+                , AnswerClients chans ["RUN_GAME"]
+                , ModifyRoomClients (\c -> c{isInGame = True})
                 ]
             else
             return [Warning "Less than two clans!"]
@@ -206,17 +207,20 @@
 
 
 handleCmd_inRoom ["ROUNDFINISHED", correctly] = do
-    clId <- asks fst
     cl <- thisClient
     rm <- thisRoom
     let clTeams = map teamname . filter (\t -> teamowner t == nick cl) . teams $ rm
 
-    if isJust $ gameInfo rm then
-        if (isMaster cl && isCorrect) then
-            return [FinishGame]
-            else return $ map SendTeamRemovalMessage clTeams
+    if isInGame cl then
+        if isJust $ gameInfo rm then
+            if (isMaster cl && isCorrect) then
+                return [ModifyClient (\c -> c{isInGame = False}), FinishGame]
+                else
+                return $ (ModifyClient (\c -> c{isInGame = False})) : map SendTeamRemovalMessage clTeams
+            else
+            return [ModifyClient (\c -> c{isInGame = False})]
         else
-        return []
+        return [] -- don't accept this message twice
     where
         isCorrect = correctly == "1"