# HG changeset patch # User unc0rr # Date 1361042896 -14400 # Node ID f4475782cf4558b0de317f84c802a24c404ca2fe # Parent 3889dab021b84a2e54325f947648d74cc90cf649 Some more work on checker diff -r 3889dab021b8 -r f4475782cf45 gameServer/Actions.hs --- a/gameServer/Actions.hs Fri Feb 15 00:12:19 2013 +0400 +++ b/gameServer/Actions.hs Sat Feb 16 23:28:16 2013 +0400 @@ -78,6 +78,8 @@ | SaveReplay | Stats | CheckRecord + | CheckFailed B.ByteString + | CheckSuccess [B.ByteString] type CmdHandler = [B.ByteString] -> Reader (ClientIndex, IRnC) [Action] @@ -681,7 +683,20 @@ processAction $ AnswerClients [c] ("REPLAY" : l) +processAction CheckRecord = do + p <- client's clientProto + c <- client's sendChan + l <- io $ loadReplay (fromIntegral p) + when (not $ null l) $ + processAction $ AnswerClients [c] ("REPLAY" : l) + +processAction (CheckFailed msg) = return () + +processAction (CheckSuccess info) = return () + #else processAction SaveReplay = return () processAction CheckRecord = return () +processAction (CheckFailed _) = return () +processAction (CheckSuccess _) = return () #endif diff -r 3889dab021b8 -r f4475782cf45 gameServer/CoreTypes.hs --- a/gameServer/CoreTypes.hs Fri Feb 15 00:12:19 2013 +0400 +++ b/gameServer/CoreTypes.hs Sat Feb 16 23:28:16 2013 +0400 @@ -17,6 +17,13 @@ type ClientChan = Chan [B.ByteString] +data CheckInfo = + CheckInfo + { + recordFileName :: B.ByteString, + recordTeams :: [TeamInfo] + } + data ClientInfo = ClientInfo { @@ -39,6 +46,7 @@ isChecker :: Bool, isKickedFromServer :: Bool, clientClan :: !(Maybe B.ByteString), + checkInfo :: Maybe CheckInfo, teamsInGame :: Word } diff -r 3889dab021b8 -r f4475782cf45 gameServer/HWProtoChecker.hs --- a/gameServer/HWProtoChecker.hs Fri Feb 15 00:12:19 2013 +0400 +++ b/gameServer/HWProtoChecker.hs Sat Feb 16 23:28:16 2013 +0400 @@ -18,4 +18,19 @@ handleCmd_checker ["READY"] = return [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}] + + +handleCmd_checker ("CHECKED" : "OK" : info) = do + isChecking <- liftM (isJust . checkInfo) thisClient + if not isChecking then + return [] + else + return [CheckSuccess info, ModifyClient $ \c -> c{checkInfo = Nothing}] + handleCmd_checker _ = return [ProtocolError "Unknown command"] diff -r 3889dab021b8 -r f4475782cf45 gameServer/NetRoutines.hs --- a/gameServer/NetRoutines.hs Fri Feb 15 00:12:19 2013 +0400 +++ b/gameServer/NetRoutines.hs Sat Feb 16 23:28:16 2013 +0400 @@ -45,6 +45,7 @@ False False Nothing + Nothing 0 ) diff -r 3889dab021b8 -r f4475782cf45 gameServer/OfficialServer/checker.hs --- a/gameServer/OfficialServer/checker.hs Fri Feb 15 00:12:19 2013 +0400 +++ b/gameServer/OfficialServer/checker.hs Sat Feb 16 23:28:16 2013 +0400 @@ -109,7 +109,8 @@ main :: IO () main = withSocketsDo $ do #if !defined(mingw32_HOST_OS) - installHandler sigPIPE Ignore Nothing; + installHandler sigPIPE Ignore Nothing + installHandler sigCHLD Ignore Nothing #endif updateGlobalLogger "Core" (setLevel DEBUG)