--- a/gameServer/Actions.hs Thu Oct 31 23:27:06 2013 +0400
+++ b/gameServer/Actions.hs Thu Oct 31 23:27:46 2013 +0400
@@ -684,7 +684,16 @@
processAction CheckRecord = do
p <- client's clientProto
c <- client's sendChan
- (cinfo, l) <- io $ loadReplay (fromIntegral p)
+ ri <- clientRoomA
+ rnc <- gets roomsClients
+
+ blackList <- liftM (map (recordFileName . fromJust . checkInfo) . filter (isJust . checkInfo)) allClientsS
+
+ readyCheckersIds <- io $ do
+ allci <- allClientsM rnc
+ filterM (client'sM rnc (isJust . checkInfo)) allci
+
+ (cinfo, l) <- io $ loadReplay (fromIntegral p) blackList
when (not . null $ l) $
mapM_ processAction [
AnswerClients [c] ("REPLAY" : l)
--- a/gameServer/OfficialServer/GameReplayStore.hs Thu Oct 31 23:27:06 2013 +0400
+++ b/gameServer/OfficialServer/GameReplayStore.hs Thu Oct 31 23:27:46 2013 +0400
@@ -17,13 +17,16 @@
import EngineInteraction
-pickReplayFile :: Int -> IO String
-pickReplayFile p = do
- files <- liftM (filter (isSuffixOf ('.' : show p))) $ getDirectoryContents "replays"
+pickReplayFile :: Int -> [String] -> IO String
+pickReplayFile p blackList = do
+ files <- liftM (filter (\f -> sameProto f && notBlacklisted f)) $ getDirectoryContents "replays"
if (not $ null files) then
return $ "replays/" ++ head files
else
return ""
+ where
+ sameProto = (isSuffixOf ('.' : show p))
+ notBlacklisted = flip notElem blackList
saveReplay :: RoomInfo -> IO ()
saveReplay r = do
@@ -38,9 +41,9 @@
(\(e :: IOException) -> warningM "REPLAYS" $ "Couldn't write to " ++ fileName ++ ": " ++ show e)
-loadReplay :: Int -> IO (Maybe CheckInfo, [B.ByteString])
-loadReplay p = E.handle (\(e :: SomeException) -> warningM "REPLAYS" "Problems reading replay" >> return (Nothing, [])) $ do
- fileName <- pickReplayFile p
+loadReplay :: Int -> [String] -> IO (Maybe CheckInfo, [B.ByteString])
+loadReplay p blackList = E.handle (\(e :: SomeException) -> warningM "REPLAYS" "Problems reading replay" >> return (Nothing, [])) $ do
+ fileName <- pickReplayFile p blackList
if (not $ null fileName) then
loadFile fileName
else