gameServer/Actions.hs
changeset 7775 835ad028fb66
parent 7766 98edc0724a28
child 7898 ba735701ce7f
--- a/gameServer/Actions.hs	Sun Oct 21 16:38:54 2012 +0400
+++ b/gameServer/Actions.hs	Sun Oct 21 17:00:35 2012 +0400
@@ -261,12 +261,16 @@
     thisRoomChans <- liftM (map sendChan) $ roomClientsS ri
     let newRoomName = if proto < 42 then nick newMaster else oldRoomName
     mapM_ processAction [
-        ModifyRoom (\r -> r{masterID = newMasterId, name = newRoomName, isRestrictedJoins = False, isRestrictedTeams = False})
-        , ModifyClient2 newMasterId (\c -> c{isMaster = True})
+        ModifyRoom (\r -> r{masterID = newMasterId
+                , name = newRoomName
+                , isRestrictedJoins = False
+                , isRestrictedTeams = False
+                , readyPlayers = if isReady newMaster then readyPlayers r else readyPlayers r + 1})
+        , ModifyClient2 newMasterId (\c -> c{isMaster = True, isReady = True})
         , AnswerClients [sendChan newMaster] ["ROOM_CONTROL_ACCESS", "1"]
         , AnswerClients thisRoomChans ["WARNING", "New room admin is " `B.append` nick newMaster]
         , AnswerClients thisRoomChans ["CLIENT_FLAGS", "-h", oldMaster]
-        , AnswerClients thisRoomChans ["CLIENT_FLAGS", "+h", nick newMaster]
+        , AnswerClients thisRoomChans ["CLIENT_FLAGS", "+hr", nick newMaster]
         ]
 
     newRoom' <- io $ room'sM rnc id ri
@@ -279,7 +283,6 @@
     rnc <- gets roomsClients
     proto <- client's clientProto
     n <- client's nick
-    chan <- client's sendChan
 
     let rm = newRoom{
             masterID = clId,
@@ -296,8 +299,6 @@
 
     mapM_ processAction [
         AnswerClients chans ("ROOM" : "ADD" : roomInfo n rm)
-        , AnswerClients [chan] ["CLIENT_FLAGS", "+h", n]
-        , ModifyClient (\cl -> cl{isMaster = True})
         ]
 
 
@@ -323,9 +324,9 @@
     roomPlayers <- roomClientsS ri
     pr <- client's clientProto
     mapM_ processAction [
-        AnswerClients (map sendChan roomPlayers) $ notReadyMessage pr (map nick roomPlayers)
-        , ModifyRoomClients (\cl -> cl{isReady = False})
-        , ModifyRoom (\r -> r{readyPlayers = 0})
+        AnswerClients (map sendChan roomPlayers) $ notReadyMessage pr . map nick . filter (not . isMaster) $ roomPlayers
+        , ModifyRoomClients (\cl -> cl{isReady = isMaster cl})
+        , ModifyRoom (\r -> r{readyPlayers = 1})
         ]
     where
         notReadyMessage p nicks = if p < 38 then "NOT_READY" : nicks else "CLIENT_FLAGS" : "-r" : nicks