--- a/gameServer/OfficialServer/checker.hs Fri Jan 02 22:07:31 2015 +0300
+++ b/gameServer/OfficialServer/checker.hs Fri Jan 02 23:54:11 2015 +0300
@@ -54,7 +54,7 @@
deriving Show
serverAddress = "netserver.hedgewars.org"
-protocolNumber = "47"
+protocolNumber = "49"
getLines :: Handle -> IO [B.ByteString]
getLines h = g
@@ -87,18 +87,18 @@
"ACHIEVEMENT" : typ : teamname : location : value : ps bs
ps _ = []
-checkReplay :: Chan Message -> [B.ByteString] -> IO ()
-checkReplay coreChan msgs = do
+checkReplay :: String -> String -> String -> Chan Message -> [B.ByteString] -> IO ()
+checkReplay home exe prefix coreChan msgs = do
tempDir <- getTemporaryDirectory
(fileName, h) <- openBinaryTempFile tempDir "checker-demo"
B.hPut h . BW.pack . concat . map (fromMaybe [] . Base64.decode . B.unpack) $ msgs
hFlush h
hClose h
- (_, _, Just hOut, _) <- createProcess (proc "/usr/home/unC0Rr/Sources/Hedgewars/Releases/0.9.20/bin/hwengine"
+ (_, _, Just hOut, _) <- createProcess (proc exe
[fileName
- , "--user-prefix", "/usr/home/unC0Rr/.hedgewars"
- , "--prefix", "/usr/home/unC0Rr/Sources/Hedgewars/Releases/0.9.20/share/hedgewars/Data"
+ , "--user-prefix", home
+ , "--prefix", prefix
, "--nomusic"
, "--nosound"
, "--stats-only"
@@ -139,8 +139,8 @@
sendPacket packet = writeChan chan $ Packet packet
-session :: B.ByteString -> B.ByteString -> Socket -> IO ()
-session l p s = do
+session :: B.ByteString -> B.ByteString -> String -> String -> String -> Socket -> IO ()
+session l p home exe prefix s = do
noticeM "Core" "Connected"
coreChan <- newChan
forkIO $ recvLoop s coreChan
@@ -169,7 +169,7 @@
onPacket _ ["PING"] = answer ["PONG"]
onPacket _ ["LOGONPASSED"] = answer ["READY"]
onPacket chan ("REPLAY":msgs) = do
- checkReplay chan msgs
+ checkReplay home exe prefix chan msgs
warningM "Check" "Started check"
onPacket _ ("BYE" : xs) = error $ show xs
onPacket _ _ = return ()
@@ -187,18 +187,24 @@
updateGlobalLogger "Check" (setLevel DEBUG)
updateGlobalLogger "Engine" (setLevel DEBUG)
+ d <- getHomeDirectory
Right (login, password) <- runErrorT $ do
- d <- liftIO $ getHomeDirectory
conf <- join . liftIO . CF.readfile CF.emptyCP $ d ++ "/.hedgewars/settings.ini"
l <- CF.get conf "net" "nick"
p <- CF.get conf "net" "passwordhash"
return (B.pack l, B.pack p)
+ Right (exeFullname, dataPrefix) <- runErrorT $ do
+ conf <- join . liftIO . CF.readfile CF.emptyCP $ d ++ "/.hedgewars/checker.ini"
+ l <- CF.get conf "engine" "exe"
+ p <- CF.get conf "engine" "prefix"
+ return (l, p)
+
Exception.bracket
setupConnection
(\s -> noticeM "Core" "Shutting down" >> sClose s)
- (session login password)
+ (session login password d exeFullname dataPrefix)
where
setupConnection = do
noticeM "Core" "Connecting to the server..."