equal
deleted
inserted
replaced
35 import qualified Data.ByteString.Char8 as B |
35 import qualified Data.ByteString.Char8 as B |
36 import qualified Data.ByteString as BW |
36 import qualified Data.ByteString as BW |
37 import qualified Codec.Binary.Base64 as Base64 |
37 import qualified Codec.Binary.Base64 as Base64 |
38 import System.Process |
38 import System.Process |
39 import Data.Maybe |
39 import Data.Maybe |
|
40 import Data.Either |
40 import qualified Data.List as L |
41 import qualified Data.List as L |
41 #if !defined(mingw32_HOST_OS) |
42 #if !defined(mingw32_HOST_OS) |
42 import System.Posix |
43 import System.Posix |
43 #endif |
44 #endif |
44 |
45 |
52 | CheckFailed B.ByteString |
53 | CheckFailed B.ByteString |
53 | CheckSuccess [B.ByteString] |
54 | CheckSuccess [B.ByteString] |
54 deriving Show |
55 deriving Show |
55 |
56 |
56 serverAddress = "netserver.hedgewars.org" |
57 serverAddress = "netserver.hedgewars.org" |
57 protocolNumber = "51" |
58 protocolNumber = "53" |
58 |
59 |
59 getLines :: Handle -> IO [B.ByteString] |
60 getLines :: Handle -> IO [B.ByteString] |
60 getLines h = g |
61 getLines h = g |
61 where |
62 where |
62 g = do |
63 g = do |
90 |
91 |
91 checkReplay :: String -> String -> String -> Chan Message -> [B.ByteString] -> IO () |
92 checkReplay :: String -> String -> String -> Chan Message -> [B.ByteString] -> IO () |
92 checkReplay home exe prefix coreChan msgs = do |
93 checkReplay home exe prefix coreChan msgs = do |
93 tempDir <- getTemporaryDirectory |
94 tempDir <- getTemporaryDirectory |
94 (fileName, h) <- openBinaryTempFile tempDir "checker-demo" |
95 (fileName, h) <- openBinaryTempFile tempDir "checker-demo" |
95 B.hPut h . BW.pack . concat . map (fromMaybe [] . Base64.decode . B.unpack) $ msgs |
96 B.hPut h . B.concat . map (either (const B.empty) id . Base64.decode) $ msgs |
96 hFlush h |
97 hFlush h |
97 hClose h |
98 hClose h |
98 |
99 |
99 (_, _, Just hOut, _) <- createProcess (proc exe |
100 (_, _, Just hOut, _) <- createProcess (proc exe |
100 [fileName |
101 [fileName |