gameServer/OfficialServer/GameReplayStore.hs
changeset 8495 f1223400b473
parent 8482 5656a73fe3c3
child 8502 fb8d914e76d8
equal deleted inserted replaced
8494:53b91a602955 8495:f1223400b473
    32 
    32 
    33 loadReplay :: Int -> IO [B.ByteString]
    33 loadReplay :: Int -> IO [B.ByteString]
    34 loadReplay p = E.handle (\(e :: SomeException) -> warningM "REPLAYS" "Problems reading replay" >> return []) $ do
    34 loadReplay p = E.handle (\(e :: SomeException) -> warningM "REPLAYS" "Problems reading replay" >> return []) $ do
    35     files <- liftM (filter (isSuffixOf ('.' : show p))) $ getDirectoryContents "replays"
    35     files <- liftM (filter (isSuffixOf ('.' : show p))) $ getDirectoryContents "replays"
    36     if (not $ null files) then
    36     if (not $ null files) then
    37         loadFile $ head files
    37         loadFile $ "replays/" ++ head files
    38         else
    38         else
    39         return []
    39         return []
    40     where
    40     where
    41         loadFile :: String -> IO [B.ByteString]
    41         loadFile :: String -> IO [B.ByteString]
    42         loadFile fileName = E.handle (\(e :: SomeException) -> warningM "REPLAYS" ("Problems reading " ++ fileName) >> return []) $ do
    42         loadFile fileName = E.handle (\(e :: SomeException) -> warningM "REPLAYS" ("Problems reading " ++ fileName ++ ": " ++ show e) >> return []) $ do
    43             (teams, params1, params2, roundMsgs) <- liftM read $ readFile fileName
    43             (teams, params1, params2, roundMsgs) <- liftM read $ readFile fileName
    44             return $ replayToDemo teams (Map.fromList params1) (Map.fromList params2) roundMsgs
    44             return $ replayToDemo teams (Map.fromList params1) (Map.fromList params2) roundMsgs