gameServer/EngineInteraction.hs
branchios-revival
changeset 11353 62af5c67662d
parent 11321 71a46315c2d4
child 11323 2400c9496288
equal deleted inserted replaced
11352:d98070707214 11353:62af5c67662d
    98 #if defined(OFFICIAL_SERVER)
    98 #if defined(OFFICIAL_SERVER)
    99 replayToDemo :: [TeamInfo]
    99 replayToDemo :: [TeamInfo]
   100         -> Map.Map B.ByteString B.ByteString
   100         -> Map.Map B.ByteString B.ByteString
   101         -> Map.Map B.ByteString [B.ByteString]
   101         -> Map.Map B.ByteString [B.ByteString]
   102         -> [B.ByteString]
   102         -> [B.ByteString]
   103         -> ([B.ByteString], [B.ByteString])
   103         -> (Maybe GameDetails, [B.ByteString])
   104 replayToDemo ti mParams prms msgs = if not sane then ([], []) else ([scriptName], concat [
   104 replayToDemo ti mParams prms msgs = if not sane then (Nothing, []) else (Just $ GameDetails scriptName infRopes vamp infattacks, concat [
   105         [em "TD"]
   105         [em "TD"]
   106         , maybeScript
   106         , maybeScript
   107         , maybeMap
   107         , maybeMap
   108         , [eml ["etheme ", head $ prms Map.! "THEME"]]
   108         , [eml ["etheme ", head $ prms Map.! "THEME"]]
   109         , [eml ["eseed ", mParams Map.! "SEED"]]
   109         , [eml ["eseed ", mParams Map.! "SEED"]]
   124         keys2 = Set.fromList ["AMMO", "SCHEME", "SCRIPT", "THEME"]
   124         keys2 = Set.fromList ["AMMO", "SCHEME", "SCRIPT", "THEME"]
   125         sane = Set.null (keys1 Set.\\ Map.keysSet mParams)
   125         sane = Set.null (keys1 Set.\\ Map.keysSet mParams)
   126             && Set.null (keys2 Set.\\ Map.keysSet prms)
   126             && Set.null (keys2 Set.\\ Map.keysSet prms)
   127             && (not . null . drop 41 $ scheme)
   127             && (not . null . drop 41 $ scheme)
   128             && (not . null . tail $ prms Map.! "AMMO")
   128             && (not . null . tail $ prms Map.! "AMMO")
       
   129             && ((B.length . head $ prms Map.! "AMMO") > 200)
   129         mapGenTypes = ["+rnd+", "+maze+", "+drawn+", "+perlin+"]
   130         mapGenTypes = ["+rnd+", "+maze+", "+drawn+", "+perlin+"]
   130         scriptName = head . fromMaybe ["Normal"] $ Map.lookup "SCRIPT" prms
   131         scriptName = head . fromMaybe ["Normal"] $ Map.lookup "SCRIPT" prms
   131         maybeScript = let s = scriptName in if s == "Normal" then [] else [eml ["escript Scripts/Multiplayer/", s, ".lua"]]
   132         maybeScript = let s = scriptName in if s == "Normal" then [] else [eml ["escript Scripts/Multiplayer/", s, ".lua"]]
   132         maybeMap = let m = mParams Map.! "MAP" in if m `elem` mapGenTypes then [] else [eml ["emap ", m]]
   133         maybeMap = let m = mParams Map.! "MAP" in if m `elem` mapGenTypes then [] else [eml ["emap ", m]]
   133         scheme = tail $ prms Map.! "SCHEME"
   134         scheme = tail $ prms Map.! "SCHEME"
   160                             eml ["eaddhh ", showB $ difficulty t, " ", initHealth, " ", hname]
   161                             eml ["eaddhh ", showB $ difficulty t, " ", initHealth, " ", hname]
   161                             , eml ["ehat ", hhat]
   162                             , eml ["ehat ", hhat]
   162                             ])
   163                             ])
   163                         $ hedgehogs t
   164                         $ hedgehogs t
   164                         )
   165                         )
       
   166         infRopes = ammoStr `B.index` 7  == '9'
       
   167         vamp = gameFlags .&. 0x00000200 /= 0
       
   168         infattacks = gameFlags .&. 0x00100000 /= 0
   165 
   169 
   166 drawnMapData :: B.ByteString -> [B.ByteString]
   170 drawnMapData :: B.ByteString -> [B.ByteString]
   167 drawnMapData =
   171 drawnMapData =
   168           L.map (\m -> eml ["edraw ", BW.pack m])
   172           L.map (\m -> eml ["edraw ", BW.pack m])
   169         . L.unfoldr by200
   173         . L.unfoldr by200