gameServer/Actions.hs
changeset 7757 c20e6c80e249
parent 7748 f160fbc139b1
child 7766 98edc0724a28
--- a/gameServer/Actions.hs	Mon Oct 15 10:10:54 2012 -0400
+++ b/gameServer/Actions.hs	Tue Oct 16 00:05:58 2012 +0400
@@ -55,6 +55,7 @@
     | RemoveClientTeams ClientIndex
     | ModifyClient (ClientInfo -> ClientInfo)
     | ModifyClient2 ClientIndex (ClientInfo -> ClientInfo)
+    | ModifyRoomClients (ClientInfo -> ClientInfo)
     | ModifyRoom (RoomInfo -> RoomInfo)
     | ModifyServerInfo (ServerInfo -> ServerInfo)
     | AddRoom B.ByteString B.ByteString
@@ -182,6 +183,12 @@
     io $ modifyClient rnc f ci
     return ()
 
+processAction (ModifyRoomClients f) = do
+    rnc <- gets roomsClients
+    ri <- clientRoomA
+    roomClIDs <- io $ roomClientsIndicesM rnc ri
+    io $ mapM_ (modifyClient rnc f) roomClIDs
+
 
 processAction (ModifyRoom f) = do
     rnc <- gets roomsClients
@@ -315,9 +322,11 @@
     roomPlayers <- roomClientsS ri
     roomClIDs <- io $ roomClientsIndicesM rnc ri
     pr <- client's clientProto
-    processAction $ AnswerClients (map sendChan roomPlayers) $ notReadyMessage pr (map nick roomPlayers)
-    io $ mapM_ (modifyClient rnc (\cl -> cl{isReady = False})) roomClIDs
-    processAction $ ModifyRoom (\r -> r{readyPlayers = 0})
+    mapM_ processAction [
+        AnswerClients (map sendChan roomPlayers) $ notReadyMessage pr (map nick roomPlayers)
+        , ModifyRoomClients (\cl -> cl{isReady = False})
+        , ModifyRoom (\r -> r{readyPlayers = 0})
+        ]
     where
         notReadyMessage p nicks = if p < 38 then "NOT_READY" : nicks else "CLIENT_FLAGS" : "-r" : nicks