Skip to content

Commit

Permalink
fixed parsing of scenario matches
Browse files Browse the repository at this point in the history
  • Loading branch information
Void / aoe2insights.com committed Jul 7, 2023
1 parent fe6b020 commit 8561e5b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
8 changes: 6 additions & 2 deletions mgz/fast/header.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,11 @@ def parse_map(data, version):
def parse_scenario(data, num_players, version, save):
"""Parse scenario section."""
data.read(4455)
scenario_filename = None
if version is Version.DE:
data.read(128)
data.read(102)
scenario_filename = aoc_string(data)
data.read(24)
instructions = aoc_string(data)
for _ in range(0, 9):
aoc_string(data)
Expand Down Expand Up @@ -278,7 +281,8 @@ def parse_scenario(data, num_players, version, save):
return dict(
map_id=map_id,
difficulty_id=difficulty_id,
instructions=instructions
instructions=instructions,
scenario_filename=scenario_filename,
)


Expand Down
Binary file added tests/recs/de-50.6-scenario.aoe2record
Binary file not shown.
15 changes: 15 additions & 0 deletions tests/test_fast.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,21 @@ def test_map(self):
self.assertEqual(self.data['lobby']['seed'], -1970180596)


class TestFastDEScenario(unittest.TestCase):

@classmethod
def setUpClass(cls):
with open('tests/recs/de-50.6-scenario.aoe2record', 'rb') as handle:
cls.data = parse(handle)

def test_version(self):
self.assertEqual(self.data['version'], Version.DE)

def test_players(self):
players = self.data.get('players')
self.assertEqual(len(players), 3)


class TestFastHD(unittest.TestCase):

@classmethod
Expand Down

0 comments on commit 8561e5b

Please sign in to comment.