gameServer/OfficialServer/extdbinterface.hs
branchwebgl
changeset 9950 2759212a27de
parent 9884 6e09ca662fa3
child 10017 de822cd3df3a
--- a/gameServer/OfficialServer/extdbinterface.hs	Fri Oct 11 17:43:13 2013 +0200
+++ b/gameServer/OfficialServer/extdbinterface.hs	Sat Jan 04 23:55:54 2014 +0400
@@ -11,6 +11,7 @@
 import Database.HDBC.MySQL
 import Data.List (lookup)
 import qualified Data.ByteString.Char8 as B
+import Data.Word
 --------------------------
 import CoreTypes
 import Utils
@@ -26,9 +27,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 +71,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 +92,7 @@
         , SqlInt32 (readInt_ value)
         , SqlByteString fileName
         , SqlByteString location
+        , SqlInt32 $ fromIntegral p
         ] : ps bs
     ps (b:bs) = ps bs