Send ROOM UPD message when team is added/deleted from room, and when game starts or finishes
authorunc0rr
Fri, 02 Nov 2012 00:09:40 +0400
changeset 7921 6b074de32bea
parent 7919 c7d258a4358e
child 7924 351f970c60e1
child 7927 a96614777ce6
Send ROOM UPD message when team is added/deleted from room, and when game starts or finishes
gameServer/Actions.hs
gameServer/HWProtoInRoomState.hs
--- a/gameServer/Actions.hs	Thu Nov 01 08:59:16 2012 -0400
+++ b/gameServer/Actions.hs	Fri Nov 02 00:09:40 2012 +0400
@@ -62,6 +62,7 @@
     | ModifyRoom (RoomInfo -> RoomInfo)
     | ModifyServerInfo (ServerInfo -> ServerInfo)
     | AddRoom B.ByteString B.ByteString
+    | SendUpdateOnThisRoom
     | CheckRegistered
     | ClearAccountsCache
     | ProcessAccountInfo AccountInfo
@@ -319,6 +320,16 @@
     io $ removeRoom rnc ri
 
 
+processAction SendUpdateOnThisRoom = do
+    Just clId <- gets clientIndex
+    proto <- client's clientProto
+    rnc <- gets roomsClients
+    ri <- io $ clientRoomM rnc clId
+    rm <- io $ room'sM rnc id ri
+    chans <- liftM (map sendChan) $! sameProtoClientsS proto
+    processAction $ AnswerClients chans ("ROOM" : "UPD" : name rm : roomInfo (name rm) rm)
+
+
 processAction UnreadyRoomClients = do
     ri <- clientRoomA
     roomPlayers <- roomClientsS ri
@@ -348,6 +359,7 @@
                 }
             )
         : UnreadyRoomClients
+        : SendUpdateOnThisRoom
         : answerRemovedTeams
 
 
--- a/gameServer/HWProtoInRoomState.hs	Thu Nov 01 08:59:16 2012 -0400
+++ b/gameServer/HWProtoInRoomState.hs	Fri Nov 02 00:09:40 2012 +0400
@@ -72,6 +72,7 @@
                 [Warning "restricted"]
             else
                 [ModifyRoom (\r -> r{teams = teams r ++ [newTeam ci clNick r teamColor]}),
+                SendUpdateOnThisRoom,
                 ModifyClient (\c -> c{teamsInGame = teamsInGame c + 1, clientClan = Just teamColor}),
                 AnswerClients clChan ["TEAM_ACCEPTED", tName],
                 AnswerClients othChans $ teamToNet $ newTeam ci clNick rm teamColor,
@@ -106,6 +107,7 @@
                 [ProtocolError "Not team owner!"]
             else
                 [RemoveTeam tName,
+                SendUpdateOnThisRoom,
                 ModifyClient
                     (\c -> c{
                         teamsInGame = teamsInGame c - 1,
@@ -194,6 +196,7 @@
                         }
                     )
                 , AnswerClients chans ["RUN_GAME"]
+                , SendUpdateOnThisRoom
                 , AnswerClients chans $ "CLIENT_FLAGS" : "+g" : nicks
                 , ModifyRoomClients (\c -> c{isInGame = True})
                 ]