Bring leftTeams back (with a fix) as it is apparently needed for spectators.
authorunc0rr
Sat, 26 May 2012 22:27:57 +0400
changeset 7126 8daa5c8e84c0
parent 7124 cfee05712896
child 7128 574b385ce7df
Bring leftTeams back (with a fix) as it is apparently needed for spectators.
gameServer/Actions.hs
gameServer/CoreTypes.hs
--- a/gameServer/Actions.hs	Fri May 25 00:06:42 2012 +0400
+++ b/gameServer/Actions.hs	Sat May 26 22:27:57 2012 +0400
@@ -312,17 +312,19 @@
     ri <- clientRoomA
     thisRoomChans <- liftM (map sendChan) $ roomClientsS ri
     clNick <- client's nick
-    
-    mapM_ processAction [
+    answerRemovedTeams <- io $ 
+         room'sM rnc (map (\t -> AnswerClients thisRoomChans ["REMOVE_TEAM", t]) . leftTeams . fromJust . gameInfo) ri
+         
+    mapM_ processAction $ 
         SaveReplay
-        , ModifyRoom
+        : ModifyRoom
             (\r -> r{
                 gameInfo = Nothing,
                 readyPlayers = 0
                 }
             )
-        , UnreadyRoomClients
-        ]
+        : UnreadyRoomClients
+        : answerRemovedTeams
 
         
 processAction (SendTeamRemovalMessage teamName) = do
@@ -352,7 +354,10 @@
     inGame <- io $ room'sM rnc (isJust . gameInfo) ri
     chans <- othersChans
     mapM_ processAction $ 
-        ModifyRoom (\r -> r{teams = Prelude.filter (\t -> teamName /= teamname t) $ teams r})
+        ModifyRoom (\r -> r{
+            teams = Prelude.filter (\t -> teamName /= teamname t) $ teams r
+            , gameInfo = liftM (\g -> g{leftTeams = teamName : leftTeams g}) $ gameInfo r
+            })
         : AnswerClients chans ["REMOVE_TEAM", teamName]
         : [SendTeamRemovalMessage teamName | inGame]
 
--- a/gameServer/CoreTypes.hs	Fri May 25 00:06:42 2012 +0400
+++ b/gameServer/CoreTypes.hs	Sat May 26 22:27:57 2012 +0400
@@ -67,6 +67,7 @@
     GameInfo
     {
         roundMsgs :: Seq B.ByteString,
+        leftTeams :: [B.ByteString],
         teamsAtStart :: [TeamInfo],
         teamsInGameNumber :: Int,
         allPlayersHaveRegisteredAccounts :: Bool,
@@ -78,6 +79,7 @@
 newGameInfo = 
     GameInfo
         Data.Sequence.empty
+        []
 
 data RoomInfo =
     RoomInfo