gameServer/EngineInteraction.hs
changeset 10066 1a6e1aad58d6
parent 10065 35bd559c1973
child 10067 8df84ec62600
equal deleted inserted replaced
10065:35bd559c1973 10066:1a6e1aad58d6
    92         , [em "!"]
    92         , [em "!"]
    93         ]
    93         ]
    94     where
    94     where
    95         keys1, keys2 :: Set.Set B.ByteString
    95         keys1, keys2 :: Set.Set B.ByteString
    96         keys1 = Set.fromList ["MAP", "MAPGEN", "MAZE_SIZE", "SEED", "TEMPLATE"]
    96         keys1 = Set.fromList ["MAP", "MAPGEN", "MAZE_SIZE", "SEED", "TEMPLATE"]
    97         keys2 = Set.fromList ["AMMO", "SCHEME", "SCRIPT", "THEME", "MAZE_SIZE", "DRAWNMAP"]
    97         keys2 = Set.fromList ["AMMO", "SCHEME", "SCRIPT", "THEME"]
    98         sane = Set.null (Map.keysSet mParams Set.\\ keys1)
    98         sane = Set.null (Map.keysSet mParams Set.\\ keys1)
    99             && Set.null (Map.keysSet prms Set.\\ keys2)
    99             && Set.null (Map.keysSet prms Set.\\ keys2)
   100             && (not . null . drop 27 $ scheme)
   100             && (not . null . drop 27 $ scheme)
   101             && (not . null . tail $ prms Map.! "AMMO")
   101             && (not . null . tail $ prms Map.! "AMMO")
   102         mapGenTypes = ["+rnd+", "+maze+", "+drawn+"]
   102         mapGenTypes = ["+rnd+", "+maze+", "+drawn+"]
   103         maybeScript = let s = head . fromMaybe ["Normal"] $ Map.lookup "SCRIPT" prms in if s == "Normal" then [] else [eml ["escript Scripts/Multiplayer/", s, ".lua"]]
   103         maybeScript = let s = head . fromMaybe ["Normal"] $ Map.lookup "SCRIPT" prms in if s == "Normal" then [] else [eml ["escript Scripts/Multiplayer/", s, ".lua"]]
   104         maybeMap = let m = mParams Map.! "MAP" in if m `elem` mapGenTypes then [] else [eml ["emap ", m]]
   104         maybeMap = let m = mParams Map.! "MAP" in if m `elem` mapGenTypes then [] else [eml ["emap ", m]]
   105         scheme = tail $ prms Map.! "SCHEME"
   105         scheme = tail $ prms Map.! "SCHEME"
   106         mapgen = mParams Map.! "MAPGEN"
   106         mapgen = mParams Map.! "MAPGEN"
   107         mapgenSpecific = case mapgen of
   107         mapgenSpecific = case mapgen of
   108             "1" -> [eml ["e$maze_size ", head $ prms Map.! "MAZE_SIZE"]]
   108             "1" -> [eml ["e$maze_size ", mParams Map.! "MAZE_SIZE"]]
   109             "2" -> let d = head $ prms Map.! "DRAWNMAP" in if BW.length d <= 1 then [] else drawnMapData d
   109             "2" -> let d = head . fromMaybe [""] $ Map.lookup "DRAWNMAP" prms in if BW.length d <= 4 then [] else drawnMapData d
   110             _ -> []
   110             _ -> []
   111         gameFlags :: Word32
   111         gameFlags :: Word32
   112         gameFlags = foldl (\r (b, f) -> if b == "false" then r else r .|. f) 0 $ zip scheme gameFlagConsts
   112         gameFlags = foldl (\r (b, f) -> if b == "false" then r else r .|. f) 0 $ zip scheme gameFlagConsts
   113         schemeFlags = map (\(v, (n, m)) -> eml [n, " ", showB $ (readInt_ v) * m])
   113         schemeFlags = map (\(v, (n, m)) -> eml [n, " ", showB $ (readInt_ v) * m])
   114             $ filter (\(_, (n, _)) -> not $ B.null n)
   114             $ filter (\(_, (n, _)) -> not $ B.null n)