Reimplement ROUNDFINISHED
authorunc0rr
Mon, 19 Jul 2010 23:10:33 +0400
changeset 3655 1ae653467897
parent 3654 18189fbc7530
child 3656 c74a4a407146
Reimplement ROUNDFINISHED
gameServer/HWProtoInRoomState.hs
--- a/gameServer/HWProtoInRoomState.hs	Mon Jul 19 23:00:10 2010 +0400
+++ b/gameServer/HWProtoInRoomState.hs	Mon Jul 19 23:10:33 2010 +0400
@@ -195,26 +195,27 @@
     where
         (isLegal, isKeepAlive) = checkNetCmd msg
 
-{-
-handleCmd_inRoom clID clients rooms ["ROUNDFINISHED"] =
-    if isMaster client then
-        [ModifyRoom
+
+handleCmd_inRoom ["ROUNDFINISHED"] = do
+    cl <- thisClient
+    r <- thisRoom
+    chans <- roomClientsChans
+
+    if isMaster cl && (gameinprogress r) then
+        return $ (ModifyRoom
                 (\r -> r{
                     gameinprogress = False,
                     readyPlayers = 0,
                     roundMsgs = empty,
                     leftTeams = [],
                     teamsAtStart = []}
-                ),
-        UnreadyRoomClients
-        ] ++ answerRemovedTeams
-    else
-        []
+                ))
+            : UnreadyRoomClients
+            : answerRemovedTeams chans r
+        else
+        return []
     where
-        client = clients IntMap.! clID
-        room = rooms IntMap.! (roomID client)
-        answerRemovedTeams = map (\t -> AnswerThisRoom ["REMOVE_TEAM", t]) $ leftTeams room
--}
+        answerRemovedTeams chans = map (\t -> AnswerClients chans ["REMOVE_TEAM", t]) . leftTeams
 
 handleCmd_inRoom ["TOGGLE_RESTRICT_JOINS"] = do
     cl <- thisClient