Skip to content

Commit b3281fe

Browse files
author
Morgan
committed
cleaning up, rewriting comments, de-64.3-campaign.aoe2record is passing tests now
1 parent be78f8a commit b3281fe

2 files changed

Lines changed: 8 additions & 9 deletions

File tree

mgz/header/scenario.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"""Scenario."""
22

33
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)
66

77
from mgz.enums import DifficultyEnum, PlayerTypeEnum, AgeEnum
88
from mgz.header.objects import de_string
@@ -64,7 +64,7 @@
6464
scenario_players = "players"/Struct(
6565
Array(16, "ai_names"/PascalString(lengthfield="ai_name_length"/Int16ul)),
6666
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
6868
Padding(4),
6969
Array(16, "resources"/Struct(
7070
"gold"/Int32ul,
@@ -112,7 +112,7 @@
112112
If(lambda ctx: ctx._._.version == Version.DE,
113113
Struct(
114114
"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
116116
"p1_num_disabled_techs"/Int32ul,
117117
"p2_num_disabled_techs"/Int32ul,
118118
"p3_num_disabled_techs"/Int32ul,
@@ -214,14 +214,14 @@
214214
)
215215
),
216216
If(lambda ctx: ctx._._.version == Version.HD, Bytes(644)),
217-
"padding"/Bytes(12),
217+
"padding"/Bytes(12)
218218
)
219219

220220
# Game settings.
221221
game_settings = "game_settings"/Struct(
222222
Array(16, AgeEnum("starting_ages"/Int32sl)),
223223
"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
225225
Padding(8),
226226
"map_id"/If(lambda ctx: ctx._._.version != Version.AOK, Int32ul),
227227
Peek("difficulty_id"/Int32ul),
@@ -273,7 +273,7 @@
273273
# parse if num > 0
274274
"de"/If(lambda ctx: ctx._._.version == Version.DE,
275275
#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)
277277
"end_of_triggers"/GoToLobbyStart()
278278
)
279279
)

tests/test_files.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,11 @@ def test_files_full(self):
3838

3939
def test_files_fast(self):
4040
# these files aren't supported by full header parser for now:
41-
skip = {"tests/recs/de-13.17.aoe2record","tests/recs/de-50.6-scenario.aoe2record", "tests/recs/de-50.6-scenario-with-triggers.aoe2record", "tests/recs/de-64.3-campaign.aoe2record"}
41+
skip = {"tests/recs/de-13.17.aoe2record","tests/recs/de-50.6-scenario.aoe2record", "tests/recs/de-50.6-scenario-with-triggers.aoe2record"}
4242

4343
for path in glob.glob('tests/recs/*'):
4444
if path.replace("\\", "/") in skip:
4545
continue
46-
print("\n" + path)
4746
parse_file_fast(path)
4847

4948
@unittest.skip("This test is meant to be run manually when debugging issues in a specific rec")

0 commit comments

Comments
 (0)