|
1 | 1 | """Scenario.""" |
2 | 2 |
|
3 | 3 | import struct |
4 | | -from construct import (Array, Computed, Float32l, Int16ul, Int32sl, Int32ul, Padding, |
5 | | - PascalString, Peek, RepeatUntil, String, Struct, Bytes, If, IfThenElse) |
| 4 | +from construct import (Array, Float32l, Int16ul, Int32sl, Int32ul, Padding, |
| 5 | + PascalString, Peek, String, Struct, Bytes, If, IfThenElse) |
6 | 6 |
|
7 | 7 | from mgz.enums import DifficultyEnum, PlayerTypeEnum, AgeEnum |
8 | 8 | from mgz.header.objects import de_string |
|
64 | 64 | scenario_players = "players"/Struct( |
65 | 65 | Array(16, "ai_names"/PascalString(lengthfield="ai_name_length"/Int16ul)), |
66 | 66 | Array(16, "ai"/Struct(Padding(8), "file"/PascalString(lengthfield="ai_file_length"/Int32ul))), |
67 | | - If(lambda ctx: ctx._._.version == Version.DE, Array(16, Padding(1))), # 16 byte 0x00 or 0x01 I think checking with a coop campaign could help understand those value |
| 67 | + If(lambda ctx: ctx._._.version == Version.DE, Array(16, Padding(1))), # 16 byte 0x00 or 0x01 I think checking with a coop campaign could help understand those value, they could be opened slots |
68 | 68 | Padding(4), |
69 | 69 | Array(16, "resources"/Struct( |
70 | 70 | "gold"/Int32ul, |
|
112 | 112 | If(lambda ctx: ctx._._.version == Version.DE, |
113 | 113 | Struct( |
114 | 114 | "unk_bytes"/Bytes(4), |
115 | | - # I can't find a nice way to do this with construct feel free to edit it |
| 115 | + # I can't find a nice way to do this with construct feel free to edit it, make it nicer |
116 | 116 | "p1_num_disabled_techs"/Int32ul, |
117 | 117 | "p2_num_disabled_techs"/Int32ul, |
118 | 118 | "p3_num_disabled_techs"/Int32ul, |
|
214 | 214 | ) |
215 | 215 | ), |
216 | 216 | If(lambda ctx: ctx._._.version == Version.HD, Bytes(644)), |
217 | | - "padding"/Bytes(12), |
| 217 | + "padding"/Bytes(12) |
218 | 218 | ) |
219 | 219 |
|
220 | 220 | # Game settings. |
221 | 221 | game_settings = "game_settings"/Struct( |
222 | 222 | Array(16, AgeEnum("starting_ages"/Int32sl)), |
223 | 223 | "hd"/If(lambda ctx: find_version(ctx) == Version.HD, Bytes(16)), |
224 | | - Padding(4), # 0x9d 0xff 0xff 0xff very helpfull const |
| 224 | + Padding(4), # 0x9d 0xff 0xff 0xff const |
225 | 225 | Padding(8), |
226 | 226 | "map_id"/If(lambda ctx: ctx._._.version != Version.AOK, Int32ul), |
227 | 227 | Peek("difficulty_id"/Int32ul), |
|
273 | 273 | # parse if num > 0 |
274 | 274 | "de"/If(lambda ctx: ctx._._.version == Version.DE, |
275 | 275 | #Padding(1032) |
276 | | - # We are going to ignore trigger and jump to lobby, we know lobby contains the map size followed by the population limit |
| 276 | + # We ignore trigger and jump to lobby, we know lobby contains repeated data we already have (revealed map, fog of war, map size and population limit) |
277 | 277 | "end_of_triggers"/GoToLobbyStart() |
278 | 278 | ) |
279 | 279 | ) |
|
0 commit comments