Also consider game finished when the last player reports ROUNDFINISHED despite the correctness parameter.
authorunc0rr
Thu, 01 Mar 2012 23:35:13 +0400
changeset 6756 344d32bb1328
parent 6755 788bb2e0db21
child 6757 ed9b3a567a3d
Also consider game finished when the last player reports ROUNDFINISHED despite the correctness parameter.
gameServer/Actions.hs
gameServer/CoreTypes.hs
gameServer/HWProtoInRoomState.hs
--- a/gameServer/Actions.hs	Wed Feb 29 18:30:37 2012 -0500
+++ b/gameServer/Actions.hs	Thu Mar 01 23:35:13 2012 +0400
@@ -311,6 +311,7 @@
         AnswerClients chans ["EM", rmTeamMsg],
         ModifyRoom (\r -> r{
                 gameInfo = liftM (\g -> g{
+                teamsInGameNumber = teamsInGameNumber g - 1,
                 roundMsgs = roundMsgs g Seq.|> rmTeamMsg
                 }) $ gameInfo r
             })
--- a/gameServer/CoreTypes.hs	Wed Feb 29 18:30:37 2012 -0500
+++ b/gameServer/CoreTypes.hs	Thu Mar 01 23:35:13 2012 +0400
@@ -69,6 +69,7 @@
         roundMsgs :: Seq B.ByteString,
         leftTeams :: [B.ByteString],
         teamsAtStart :: [TeamInfo],
+        teamsInGameNumber :: Int,
         allPlayersHaveRegisteredAccounts :: Bool,
         giMapParams :: Map.Map B.ByteString B.ByteString,
         giParams :: Map.Map B.ByteString [B.ByteString]
--- a/gameServer/HWProtoInRoomState.hs	Wed Feb 29 18:30:37 2012 -0500
+++ b/gameServer/HWProtoInRoomState.hs	Thu Mar 01 23:35:13 2012 +0400
@@ -179,7 +179,7 @@
             return [
                 ModifyRoom
                     (\r -> r{
-                        gameInfo = Just $ newGameInfo (teams rm) allPlayersRegistered (mapParams rm) (params rm)
+                        gameInfo = Just $ newGameInfo (teams rm) (length $ teams rm) allPlayersRegistered (mapParams rm) (params rm)
                         }
                     ),
                 AnswerClients chans ["RUN_GAME"]
@@ -211,9 +211,10 @@
     rm <- thisRoom
     chans <- roomClientsChans
     let clTeams = map teamname . filter (\t -> teamowner t == nick cl) . teams $ rm
+    let isLastPlayer = (teamsInGameNumber . fromJust . gameInfo $ rm) == length clTeams
 
     if isJust $ gameInfo rm then
-        if isMaster cl && isCorrect then
+        if (isMaster cl && isCorrect) || isLastPlayer then
             return $
                 SaveReplay
                 : ModifyRoom