Store protocol number in database for replays
authorunc0rr
Fri, 27 Dec 2013 01:23:12 +0400
changeset 9868 53d1b92db6ce
parent 9866 62ffe234127d
child 9871 a220ae2097d8
Store protocol number in database for replays
gameServer/Actions.hs
gameServer/CoreTypes.hs
gameServer/OfficialServer/extdbinterface.hs
--- a/gameServer/Actions.hs	Fri Dec 27 01:22:42 2013 +0400
+++ b/gameServer/Actions.hs	Fri Dec 27 01:23:12 2013 +0400
@@ -717,8 +717,9 @@
 
 processAction (CheckSuccess info) = do
     Just (CheckInfo fileName teams) <- client's checkInfo
+    p <- client's clientProto
     si <- gets serverInfo
-    io $ writeChan (dbQueries si) $ StoreAchievements (B.pack fileName) (map toPair teams) info
+    io $ writeChan (dbQueries si) $ StoreAchievements p (B.pack fileName) (map toPair teams) info
     io $ moveCheckedRecord fileName
     where
         toPair t = (teamname t, teamowner t)
--- a/gameServer/CoreTypes.hs	Fri Dec 27 01:22:42 2013 +0400
+++ b/gameServer/CoreTypes.hs	Fri Dec 27 01:23:12 2013 +0400
@@ -275,7 +275,7 @@
     CheckAccount ClientIndex Int B.ByteString B.ByteString
     | ClearCache
     | SendStats Int Int
-    | StoreAchievements B.ByteString [(B.ByteString, B.ByteString)] [B.ByteString]
+    | StoreAchievements Word16 B.ByteString [(B.ByteString, B.ByteString)] [B.ByteString]
     | GetReplayName ClientIndex Int B.ByteString
     deriving (Show, Read)
 
--- a/gameServer/OfficialServer/extdbinterface.hs	Fri Dec 27 01:22:42 2013 +0400
+++ b/gameServer/OfficialServer/extdbinterface.hs	Fri Dec 27 01:23:12 2013 +0400
@@ -26,9 +26,9 @@
     "INSERT INTO gameserver_stats (players, rooms, last_update) VALUES (?, ?, UNIX_TIMESTAMP())"
 
 dbQueryAchievement =
-    "INSERT INTO achievements (time, typeid, userid, value, filename, location) \
+    "INSERT INTO achievements (time, typeid, userid, value, filename, location, protocol) \
     \ VALUES (?, (SELECT id FROM achievement_types WHERE name = ?), (SELECT uid FROM users WHERE name = ?), \
-    \ ?, ?, ?)"
+    \ ?, ?, ?, ?)"
 
 dbQueryReplayFilename = "SELECT filename FROM achievements WHERE id = ?"
 
@@ -70,15 +70,15 @@
         SendStats clients rooms ->
                 run dbConn dbQueryStats [SqlInt32 $ fromIntegral clients, SqlInt32 $ fromIntegral rooms] >> return ()
 --StoreAchievements (B.pack fileName) (map toPair teams) info
-        StoreAchievements fileName teams info -> 
-            mapM_ (run dbConn dbQueryAchievement) $ (parseStats fileName teams) info
+        StoreAchievements p fileName teams info -> 
+            mapM_ (run dbConn dbQueryAchievement) $ (parseStats p fileName teams) info
 
 
 readTime = read . B.unpack . B.take 19 . B.drop 8
 
 
-parseStats :: B.ByteString -> [(B.ByteString, B.ByteString)] -> [B.ByteString] -> [[SqlValue]]
-parseStats fileName teams = ps
+parseStats :: Word16 -> B.ByteString -> [(B.ByteString, B.ByteString)] -> [B.ByteString] -> [[SqlValue]]
+parseStats p fileName teams = ps
     where
     time = readTime fileName
     ps [] = []
@@ -91,6 +91,7 @@
         , SqlInt32 (readInt_ value)
         , SqlByteString fileName
         , SqlByteString location
+        , SqlInt32 p
         ] : ps bs
     ps (b:bs) = ps bs