gameServer/OfficialServer/GameReplayStore.hs
changeset 5996 2c72fe81dd37
parent 5143 649d87819682
child 6040 a740069c21e3
equal deleted inserted replaced
5994:3c578f531cc1 5996:2c72fe81dd37
     5 import Data.Time
     5 import Data.Time
     6 import Control.Exception as E
     6 import Control.Exception as E
     7 import qualified Data.Map as Map
     7 import qualified Data.Map as Map
     8 import Data.Sequence()
     8 import Data.Sequence()
     9 import System.Log.Logger
     9 import System.Log.Logger
       
    10 import Data.Maybe
    10 
    11 
    11 saveReplay :: RoomInfo -> IO ()
    12 saveReplay :: RoomInfo -> IO ()
    12 saveReplay r = do
    13 saveReplay r = do
    13     time <- getCurrentTime
    14     time <- getCurrentTime
    14     let fileName = "replays/" ++ show time
    15     let fileName = "replays/" ++ show time
    15     let replayInfo = (teamsAtStart r, Map.toList $ mapParams r, Map.toList $ params r, roundMsgs r)
    16     let gi = fromJust $ gameInfo r
       
    17     let replayInfo = (teamsAtStart gi, Map.toList $ mapParams r, Map.toList $ params r, roundMsgs gi)
    16     E.catch
    18     E.catch
    17         (writeFile fileName (show replayInfo))
    19         (writeFile fileName (show replayInfo))
    18         (\(e :: IOException) -> warningM "REPLAYS" $ "Couldn't write to " ++ fileName ++ ": " ++ show e)
    20         (\(e :: IOException) -> warningM "REPLAYS" $ "Couldn't write to " ++ fileName ++ ": " ++ show e)
    19                    
    21