gameServer/EngineInteraction.hs
changeset 10065 35bd559c1973
parent 10060 bcf2e1ca2971
child 10066 1a6e1aad58d6
--- a/gameServer/EngineInteraction.hs	Thu Jan 23 23:28:16 2014 +0400
+++ b/gameServer/EngineInteraction.hs	Fri Jan 24 00:05:19 2014 +0400
@@ -28,7 +28,7 @@
 decompressWithoutExceptions = finalise
                             . Z.foldDecompressStream cons nil err
                             . Z.decompressWithErrors Z.zlibFormat Z.defaultDecompressParams
-  where err errorCode msg = Left msg
+  where err _ msg = Left msg
         nil = Right []
         cons chunk = right (chunk :)
         finalise = right BL.fromChunks
@@ -76,7 +76,7 @@
         -> Map.Map B.ByteString [B.ByteString]
         -> [B.ByteString]
         -> [B.ByteString]
-replayToDemo ti mParams prms msgs = concat [
+replayToDemo ti mParams prms msgs = if not sane then [] else concat [
         [em "TD"]
         , maybeScript
         , maybeMap
@@ -92,6 +92,13 @@
         , [em "!"]
         ]
     where
+        keys1, keys2 :: Set.Set B.ByteString
+        keys1 = Set.fromList ["MAP", "MAPGEN", "MAZE_SIZE", "SEED", "TEMPLATE"]
+        keys2 = Set.fromList ["AMMO", "SCHEME", "SCRIPT", "THEME", "MAZE_SIZE", "DRAWNMAP"]
+        sane = Set.null (Map.keysSet mParams Set.\\ keys1)
+            && Set.null (Map.keysSet prms Set.\\ keys2)
+            && (not . null . drop 27 $ scheme)
+            && (not . null . tail $ prms Map.! "AMMO")
         mapGenTypes = ["+rnd+", "+maze+", "+drawn+"]
         maybeScript = let s = head . fromMaybe ["Normal"] $ Map.lookup "SCRIPT" prms in if s == "Normal" then [] else [eml ["escript Scripts/Multiplayer/", s, ".lua"]]
         maybeMap = let m = mParams Map.! "MAP" in if m `elem` mapGenTypes then [] else [eml ["emap ", m]]