author | unc0rr |
Sat, 17 Sep 2011 16:20:09 +0400 | |
branch | 0.9.16 |
changeset 5949 | 7e12141c5e10 |
parent 5143 | 649d87819682 |
child 5996 | 2c72fe81dd37 |
permissions | -rw-r--r-- |
5143
649d87819682
Start implementation of archivements/ratings on server side: replay saving routine
unc0rr
parents:
diff
changeset
|
1 |
{-# LANGUAGE ScopedTypeVariables #-} |
649d87819682
Start implementation of archivements/ratings on server side: replay saving routine
unc0rr
parents:
diff
changeset
|
2 |
module OfficialServer.GameReplayStore where |
649d87819682
Start implementation of archivements/ratings on server side: replay saving routine
unc0rr
parents:
diff
changeset
|
3 |
|
649d87819682
Start implementation of archivements/ratings on server side: replay saving routine
unc0rr
parents:
diff
changeset
|
4 |
import CoreTypes |
649d87819682
Start implementation of archivements/ratings on server side: replay saving routine
unc0rr
parents:
diff
changeset
|
5 |
import Data.Time |
649d87819682
Start implementation of archivements/ratings on server side: replay saving routine
unc0rr
parents:
diff
changeset
|
6 |
import Control.Exception as E |
649d87819682
Start implementation of archivements/ratings on server side: replay saving routine
unc0rr
parents:
diff
changeset
|
7 |
import qualified Data.Map as Map |
649d87819682
Start implementation of archivements/ratings on server side: replay saving routine
unc0rr
parents:
diff
changeset
|
8 |
import Data.Sequence() |
649d87819682
Start implementation of archivements/ratings on server side: replay saving routine
unc0rr
parents:
diff
changeset
|
9 |
import System.Log.Logger |
649d87819682
Start implementation of archivements/ratings on server side: replay saving routine
unc0rr
parents:
diff
changeset
|
10 |
|
649d87819682
Start implementation of archivements/ratings on server side: replay saving routine
unc0rr
parents:
diff
changeset
|
11 |
saveReplay :: RoomInfo -> IO () |
649d87819682
Start implementation of archivements/ratings on server side: replay saving routine
unc0rr
parents:
diff
changeset
|
12 |
saveReplay r = do |
649d87819682
Start implementation of archivements/ratings on server side: replay saving routine
unc0rr
parents:
diff
changeset
|
13 |
time <- getCurrentTime |
649d87819682
Start implementation of archivements/ratings on server side: replay saving routine
unc0rr
parents:
diff
changeset
|
14 |
let fileName = "replays/" ++ show time |
649d87819682
Start implementation of archivements/ratings on server side: replay saving routine
unc0rr
parents:
diff
changeset
|
15 |
let replayInfo = (teamsAtStart r, Map.toList $ mapParams r, Map.toList $ params r, roundMsgs r) |
649d87819682
Start implementation of archivements/ratings on server side: replay saving routine
unc0rr
parents:
diff
changeset
|
16 |
E.catch |
649d87819682
Start implementation of archivements/ratings on server side: replay saving routine
unc0rr
parents:
diff
changeset
|
17 |
(writeFile fileName (show replayInfo)) |
649d87819682
Start implementation of archivements/ratings on server side: replay saving routine
unc0rr
parents:
diff
changeset
|
18 |
(\(e :: IOException) -> warningM "REPLAYS" $ "Couldn't write to " ++ fileName ++ ": " ++ show e) |
649d87819682
Start implementation of archivements/ratings on server side: replay saving routine
unc0rr
parents:
diff
changeset
|
19 |