# HG changeset patch # User unc0rr # Date 1388092992 -14400 # Node ID 53d1b92db6ce1f42076e6434ffc38eeabc793042 # Parent 62ffe234127d7b7c1fca229ee707d3c63302ebb0 Store protocol number in database for replays diff -r 62ffe234127d -r 53d1b92db6ce gameServer/Actions.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) diff -r 62ffe234127d -r 53d1b92db6ce gameServer/CoreTypes.hs --- 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) diff -r 62ffe234127d -r 53d1b92db6ce gameServer/OfficialServer/extdbinterface.hs --- 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