gameServer/OfficialServer/extdbinterface.hs
changeset 11575 db7743e2fad1
parent 11573 8fd1808b12ed
child 11579 d389ea7ca66f
equal deleted inserted replaced
11573:8fd1808b12ed 11575:db7743e2fad1
   138             )
   138             )
   139         modify $ \st@(l, s) -> if result < s then (location, result) else st
   139         modify $ \st@(l, s) -> if result < s then (location, result) else st
   140         ps bs
   140         ps bs
   141     ps ("GHOST_POINTS" : n : bs) = do
   141     ps ("GHOST_POINTS" : n : bs) = do
   142         let pointsNum = readInt_ n
   142         let pointsNum = readInt_ n
   143         (loc, time) <- get
   143         (location, time) <- get
   144         res <- io $ query dbConn dbQueryBestTime $ Only loc
   144         res <- io $ query dbConn dbQueryBestTime $ Only location
   145         let bestTime = case res of
   145         let bestTime = case res of
   146                 [Only a] -> a
   146                 [Only a] -> a
   147                 _ -> maxBound :: Int
   147                 _ -> maxBound :: Int
   148         when (time < bestTime) $ do
   148         when (time < bestTime) $ do
   149             -- store it
   149             io $ writeFile (B.unpack $ "ghosts/" `B.append` sanitizeName location) $ show (map readInt_ $ take (2 * pointsNum) bs)
   150             return ()
   150             return ()
   151         ps (drop (2 * pointsNum) bs)
   151         ps (drop (2 * pointsNum) bs)
   152     ps (b:bs) = ps bs
   152     ps (b:bs) = ps bs
   153 
   153 
   154     drawParams t = (snd t, 0 :: Int)
   154     drawParams t = (snd t, 0 :: Int)