Push demo to idle checker on game finish
authorunc0rr
Wed, 28 Aug 2013 23:11:05 +0400
changeset 9433 f0a8ac191839
parent 9431 0f5961910e27
child 9435 59eec19cb31a
Push demo to idle checker on game finish
gameServer/Actions.hs
gameServer/HWProtoChecker.hs
gameServer/HandlerUtils.hs
--- a/gameServer/Actions.hs	Tue Aug 27 17:22:07 2013 +0400
+++ b/gameServer/Actions.hs	Wed Aug 28 23:11:05 2013 +0400
@@ -651,9 +651,17 @@
     ri <- clientRoomA
     rnc <- gets roomsClients
 
-    io $ do
+    allci <- io $ do
         r <- room'sM rnc id ri
         saveReplay r
+        allClientsM rnc
+
+    readyCheckersIds <- liftM (filter (client'sM isReadyChecker rnc)) allClientsS
+    when (not $ null readyCheckersIds) $ do
+        modify (\s -> s{clientIndex = Just $ head readyCheckersIds})
+        processAction CheckRecord
+    where
+        isReadyChecker cl = isChecker cl && isReady cl
 
 
 processAction CheckRecord = do
@@ -666,10 +674,12 @@
             , ModifyClient $ \c -> c{checkInfo = cinfo}
             ]
 
+
 processAction (CheckFailed msg) = do
     Just (CheckInfo fileName _) <- client's checkInfo
     io $ moveFailedRecord fileName
 
+
 processAction (CheckSuccess info) = do
     Just (CheckInfo fileName teams) <- client's checkInfo
     si <- gets serverInfo
--- a/gameServer/HWProtoChecker.hs	Tue Aug 27 17:22:07 2013 +0400
+++ b/gameServer/HWProtoChecker.hs	Wed Aug 28 23:11:05 2013 +0400
@@ -11,14 +11,14 @@
 
 handleCmd_checker :: CmdHandler
 
-handleCmd_checker ["READY"] = return [CheckRecord]
+handleCmd_checker ["READY"] = return [ModifyClient $ \c -> c{isReady = True}, CheckRecord]
 
 handleCmd_checker ["CHECKED", "FAIL", msg] = do
     isChecking <- liftM (isJust . checkInfo) thisClient
     if not isChecking then
         return []
         else
-        return [CheckFailed msg, ModifyClient $ \c -> c{checkInfo = Nothing}]
+        return [CheckFailed msg, ModifyClient $ \c -> c{isReady = False, checkInfo = Nothing}]
 
 
 handleCmd_checker ("CHECKED" : "OK" : info) = do
@@ -26,6 +26,6 @@
     if not isChecking then
         return []
         else
-        return [CheckSuccess info, ModifyClient $ \c -> c{checkInfo = Nothing}]
+        return [CheckSuccess info, ModifyClient $ \c -> c{isReady = False, checkInfo = Nothing}]
 
 handleCmd_checker _ = return [ProtocolError "Unknown command"]
--- a/gameServer/HandlerUtils.hs	Tue Aug 27 17:22:07 2013 +0400
+++ b/gameServer/HandlerUtils.hs	Wed Aug 28 23:11:05 2013 +0400
@@ -64,5 +64,5 @@
 clientByNick n = do
     (_, rnc) <- ask
     let allClientIDs = allClients rnc
-    return $ find (\clId -> n == nick (client rnc clId)) allClientIDs
+    return $ find (\clId -> let cl = client rnc clId in n == nick cl && not (isChecker cl)) allClientIDs