gameServer/OfficialServer/GameReplayStore.hs
changeset 8371 0551b5c3de9a
parent 6040 a740069c21e3
child 8423 8aa450f6cf2c
equal deleted inserted replaced
8370:0c79946e96f8 8371:0551b5c3de9a
    12 ---------------
    12 ---------------
    13 import CoreTypes
    13 import CoreTypes
    14 
    14 
    15 
    15 
    16 saveReplay :: RoomInfo -> IO ()
    16 saveReplay :: RoomInfo -> IO ()
    17 saveReplay r = do
    17 saveReplay r = when allPlayersHaveRegisteredAccounts $ do
    18     time <- getCurrentTime
    18     time <- getCurrentTime
    19     u <- liftM hashUnique newUnique
    19     u <- liftM hashUnique newUnique
    20     let fileName = "replays/" ++ show time ++ "-" ++ show u
    20     let fileName = "replays/" ++ show time ++ "-" ++ show u
    21     let gi = fromJust $ gameInfo r
    21     let gi = fromJust $ gameInfo r
    22     let replayInfo = (teamsAtStart gi, Map.toList $ mapParams r, Map.toList $ params r, roundMsgs gi)
    22     let replayInfo = (teamsAtStart gi, Map.toList $ mapParams r, Map.toList $ params r, roundMsgs gi)
    23     E.catch
    23     E.catch
    24         (writeFile fileName (show replayInfo))
    24         (writeFile fileName (show replayInfo))
    25         (\(e :: IOException) -> warningM "REPLAYS" $ "Couldn't write to " ++ fileName ++ ": " ++ show e)
    25         (\(e :: IOException) -> warningM "REPLAYS" $ "Couldn't write to " ++ fileName ++ ": " ++ show e)
    26