gameServer/OfficialServer/extdbinterface.hs
changeset 9446 4fd5df03deb8
parent 9437 8d1e9a9dda8e
child 9450 2084b1b7839c
--- a/gameServer/OfficialServer/extdbinterface.hs	Thu Aug 29 12:12:19 2013 +0400
+++ b/gameServer/OfficialServer/extdbinterface.hs	Tue Sep 03 00:05:38 2013 +0400
@@ -30,6 +30,9 @@
     \ VALUES (?, (SELECT id FROM achievement_types WHERE name = ?), (SELECT uid FROM users WHERE name = ?), \
     \ ?, ?, ?)"
 
+dbQueryReplayFilename = "SELECT filename FROM achievements WHERE id = ?"
+
+
 dbInteractionLoop dbConn = forever $ do
     q <- liftM read getLine
     hPutStrLn stderr $ show q
@@ -55,14 +58,25 @@
                 print response
                 hFlush stdout
 
+        GetReplayName clId clUid fileId -> do
+                statement <- prepare dbConn dbQueryReplayFilename
+                execute statement [SqlByteString fileId]
+                result <- fetchRow statement
+                finish statement
+                let fn = if (isJust result) then fromJust . fromSql . head $ result else ""
+                print (clId, clUid, ReplayName fn)
+                hFlush stdout
+
         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
 
+
 readTime = read . B.unpack . B.take 19 . B.drop 8
 
+
 parseStats :: B.ByteString -> [(B.ByteString, B.ByteString)] -> [B.ByteString] -> [[SqlValue]]
 parseStats fileName teams = ps
     where