equal
deleted
inserted
replaced
19 {-# LANGUAGE CPP, OverloadedStrings #-} |
19 {-# LANGUAGE CPP, OverloadedStrings #-} |
20 |
20 |
21 #if defined(OFFICIAL_SERVER) |
21 #if defined(OFFICIAL_SERVER) |
22 module EngineInteraction(replayToDemo, checkNetCmd, toEngineMsg, drawnMapData) where |
22 module EngineInteraction(replayToDemo, checkNetCmd, toEngineMsg, drawnMapData) where |
23 #else |
23 #else |
24 module EngineInteraction(checkNetCmd, toEngineMsg, drawnMapData) where |
24 module EngineInteraction(checkNetCmd, toEngineMsg) where |
25 #endif |
25 #endif |
26 |
26 |
27 import qualified Data.Set as Set |
27 import qualified Data.Set as Set |
28 import Control.Monad |
28 import Control.Monad |
29 import qualified Codec.Binary.Base64 as Base64 |
29 import qualified Codec.Binary.Base64 as Base64 |
38 import Data.Maybe |
38 import Data.Maybe |
39 ------------- |
39 ------------- |
40 import CoreTypes |
40 import CoreTypes |
41 import Utils |
41 import Utils |
42 |
42 |
|
43 #if defined(OFFICIAL_SERVER) |
43 {- |
44 {- |
44 this is snippet from http://stackoverflow.com/questions/10043102/how-to-catch-the-decompress-ioerror |
45 this is snippet from http://stackoverflow.com/questions/10043102/how-to-catch-the-decompress-ioerror |
45 because standard 'catch' doesn't seem to catch decompression errors for some reason |
46 because standard 'catch' doesn't seem to catch decompression errors for some reason |
46 -} |
47 -} |
47 import qualified Codec.Compression.Zlib.Internal as Z |
48 import qualified Codec.Compression.Zlib.Internal as Z |
53 where err _ msg = Left msg |
54 where err _ msg = Left msg |
54 nil = Right [] |
55 nil = Right [] |
55 cons chunk = right (chunk :) |
56 cons chunk = right (chunk :) |
56 finalise = right BL.fromChunks |
57 finalise = right BL.fromChunks |
57 {- end snippet -} |
58 {- end snippet -} |
|
59 #endif |
58 |
60 |
59 toEngineMsg :: B.ByteString -> B.ByteString |
61 toEngineMsg :: B.ByteString -> B.ByteString |
60 toEngineMsg msg = B.pack $ Base64.encode (fromIntegral (BW.length msg) : BW.unpack msg) |
62 toEngineMsg msg = B.pack $ Base64.encode (fromIntegral (BW.length msg) : BW.unpack msg) |
61 |
63 |
62 |
64 |
152 eml ["eaddhh ", showB $ difficulty t, " ", initHealth, " ", hname] |
154 eml ["eaddhh ", showB $ difficulty t, " ", initHealth, " ", hname] |
153 , eml ["ehat ", hhat] |
155 , eml ["ehat ", hhat] |
154 ]) |
156 ]) |
155 $ hedgehogs t |
157 $ hedgehogs t |
156 ) |
158 ) |
157 #endif |
|
158 |
159 |
159 drawnMapData :: B.ByteString -> [B.ByteString] |
160 drawnMapData :: B.ByteString -> [B.ByteString] |
160 drawnMapData = |
161 drawnMapData = |
161 L.map (\m -> eml ["edraw ", BW.pack m]) |
162 L.map (\m -> eml ["edraw ", BW.pack m]) |
162 . L.unfoldr by200 |
163 . L.unfoldr by200 |
219 , 0x00800000 |
220 , 0x00800000 |
220 , 0x01000000 |
221 , 0x01000000 |
221 , 0x02000000 |
222 , 0x02000000 |
222 , 0x04000000 |
223 , 0x04000000 |
223 ] |
224 ] |
224 |
225 #endif |
225 |
|
226 |
|