- Add unique id to replay file name
authorunc0rr
Mon, 26 Sep 2011 21:45:33 +0400
changeset 6040 a740069c21e3
parent 6038 58d9badf3e7f
child 6042 8b5345758f62
- Add unique id to replay file name - INSERT instead of UPDATE for stats
gameServer/OfficialServer/GameReplayStore.hs
gameServer/OfficialServer/extdbinterface.hs
--- a/gameServer/OfficialServer/GameReplayStore.hs	Mon Sep 26 03:12:09 2011 +0200
+++ b/gameServer/OfficialServer/GameReplayStore.hs	Mon Sep 26 21:45:33 2011 +0400
@@ -1,18 +1,23 @@
 {-# LANGUAGE ScopedTypeVariables #-}
 module OfficialServer.GameReplayStore where
 
-import CoreTypes
 import Data.Time
 import Control.Exception as E
 import qualified Data.Map as Map
 import Data.Sequence()
 import System.Log.Logger
 import Data.Maybe
+import Data.Unique
+import Control.Monad
+---------------
+import CoreTypes
+
 
 saveReplay :: RoomInfo -> IO ()
 saveReplay r = do
     time <- getCurrentTime
-    let fileName = "replays/" ++ show time
+    u <- liftM hashUnique newUnique
+    let fileName = "replays/" ++ show time ++ "-" ++ show u
     let gi = fromJust $ gameInfo r
     let replayInfo = (teamsAtStart gi, Map.toList $ mapParams r, Map.toList $ params r, roundMsgs gi)
     E.catch
--- a/gameServer/OfficialServer/extdbinterface.hs	Mon Sep 26 03:12:09 2011 +0200
+++ b/gameServer/OfficialServer/extdbinterface.hs	Mon Sep 26 21:45:33 2011 +0400
@@ -17,7 +17,7 @@
     "SELECT users.pass, users_roles.rid FROM users LEFT JOIN users_roles ON users.uid = users_roles.uid WHERE users.name = ?"
 
 dbQueryStats =
-    "UPDATE gameserver_stats SET players = ?, rooms = ?, last_update = UNIX_TIMESTAMP()"
+    "INSERT INTO gameserver_stats (players, rooms, last_update) VALUES (?, ?, UNIX_TIMESTAMP())"
 
 dbInteractionLoop dbConn = forever $ do
     q <- liftM read getLine