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] |
103 -> ([B.ByteString], [B.ByteString]) |
104 replayToDemo ti mParams prms msgs = if not sane then [] else concat [ |
104 replayToDemo ti mParams prms msgs = if not sane then ([], []) else ([scriptName], 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"]] |
115 , [eml ["e$mapgen ", mapgen]] |
115 , [eml ["e$mapgen ", mapgen]] |
116 , mapgenSpecific |
116 , mapgenSpecific |
117 , concatMap teamSetup ti |
117 , concatMap teamSetup ti |
118 , msgs |
118 , msgs |
119 , [em "!"] |
119 , [em "!"] |
120 ] |
120 ]) |
121 where |
121 where |
122 keys1, keys2 :: Set.Set B.ByteString |
122 keys1, keys2 :: Set.Set B.ByteString |
123 keys1 = Set.fromList ["FEATURE_SIZE", "MAP", "MAPGEN", "MAZE_SIZE", "SEED", "TEMPLATE"] |
123 keys1 = Set.fromList ["FEATURE_SIZE", "MAP", "MAPGEN", "MAZE_SIZE", "SEED", "TEMPLATE"] |
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 mapGenTypes = ["+rnd+", "+maze+", "+drawn+", "+perlin+"] |
129 mapGenTypes = ["+rnd+", "+maze+", "+drawn+", "+perlin+"] |
130 maybeScript = let s = head . fromMaybe ["Normal"] $ Map.lookup "SCRIPT" prms in if s == "Normal" then [] else [eml ["escript Scripts/Multiplayer/", s, ".lua"]] |
130 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"]] |
131 maybeMap = let m = mParams Map.! "MAP" in if m `elem` mapGenTypes then [] else [eml ["emap ", m]] |
132 maybeMap = let m = mParams Map.! "MAP" in if m `elem` mapGenTypes then [] else [eml ["emap ", m]] |
132 scheme = tail $ prms Map.! "SCHEME" |
133 scheme = tail $ prms Map.! "SCHEME" |
133 mapgen = mParams Map.! "MAPGEN" |
134 mapgen = mParams Map.! "MAPGEN" |
134 mazeSizeMsg = eml ["e$maze_size ", mParams Map.! "MAZE_SIZE"] |
135 mazeSizeMsg = eml ["e$maze_size ", mParams Map.! "MAZE_SIZE"] |
135 mapgenSpecific = case mapgen of |
136 mapgenSpecific = case mapgen of |