# HG changeset patch # User unc0rr # Date 1482523920 -10800 # Node ID 72f5d670bbee7132ffbad7cd66ffb913b4a5a755 # Parent 2c21bca6cbfad99f747e2a0314521710714eaba0 Fix official server build diff -r 2c21bca6cbfa -r 72f5d670bbee cmake_modules/CheckHaskellModuleExists.cmake --- a/cmake_modules/CheckHaskellModuleExists.cmake Mon Dec 19 12:34:09 2016 -0500 +++ b/cmake_modules/CheckHaskellModuleExists.cmake Fri Dec 23 23:12:00 2016 +0300 @@ -22,7 +22,7 @@ endforeach() endif() - set(PARAMETERS "") + #set(PARAMETERS "") execute_process(COMMAND ${GHC_EXECUTABLE} "-DMODULE=${MODULE}" diff -r 2c21bca6cbfa -r 72f5d670bbee gameServer/EngineInteraction.hs --- a/gameServer/EngineInteraction.hs Mon Dec 19 12:34:09 2016 -0500 +++ b/gameServer/EngineInteraction.hs Fri Dec 23 23:12:00 2016 +0300 @@ -44,22 +44,16 @@ import Utils #if defined(OFFICIAL_SERVER) -{- - this is snippet from http://stackoverflow.com/questions/10043102/how-to-catch-the-decompress-ioerror - because standard 'catch' doesn't seem to catch decompression errors for some reason --} import qualified Codec.Compression.Zlib.Internal as ZI import qualified Codec.Compression.Zlib as Z -decompressWithoutExceptions :: BL.ByteString -> Either String BL.ByteString -decompressWithoutExceptions = finalise - . ZI.foldDecompressStream cons nil err - . ZI.decompressWithErrors ZI.zlibFormat ZI.defaultDecompressParams - where err _ msg = Left msg - nil = Right [] - cons chunk = right (chunk :) - finalise = right BL.fromChunks -{- end snippet -} +decompressWithoutExceptions :: BL.ByteString -> BL.ByteString +decompressWithoutExceptions = BL.fromChunks . ZI.foldDecompressStreamWithInput chunk end err decomp + where + decomp = ZI.decompressST ZI.zlibFormat ZI.defaultDecompressParams + chunk = (:) + end _ = [] + err = const $ [BW.empty] #endif toEngineMsg :: B.ByteString -> B.ByteString @@ -187,13 +181,10 @@ by200 m = Just $ L.splitAt 200 m unpackDrawnMap :: B.ByteString -> BL.ByteString -unpackDrawnMap = either (const BL.empty) id - . decompressWithoutExceptions - . BL.pack - . L.drop 4 - . fromMaybe [] +unpackDrawnMap = either + (const BL.empty) + (decompressWithoutExceptions . BL.pack . drop 4 . BW.unpack) . Base64.decode - . B.unpack compressWithLength :: BL.ByteString -> BL.ByteString compressWithLength b = BL.drop 8 . encode . runPut $ do @@ -201,9 +192,8 @@ mapM_ putWord8 $ BW.unpack $ BL.toStrict $ Z.compress b packDrawnMap :: BL.ByteString -> B.ByteString -packDrawnMap = B.pack - . Base64.encode - . BW.unpack +packDrawnMap = + Base64.encode . BL.toStrict . compressWithLength