diff --git a/mgz/fast/header.py b/mgz/fast/header.py index 1ecb73e..1f8c03e 100644 --- a/mgz/fast/header.py +++ b/mgz/fast/header.py @@ -206,6 +206,8 @@ def parse_map(data, version, save): tile_format = '= 62.0: + tile_format = '= 61.5 else 9, MyDiplomacyEnum("my_diplomacy"/Int32sl)), "allied_los"/Int32ul, "allied_victory"/Flag, "player_name_length"/Int16ul, @@ -59,10 +58,6 @@ attributes, "end_of_attr"/Tell, "start_of_objects"/Find([b'\x0b\x00.\x00\x00\x00\x02\x00\x00'], None), - "objects"/Array(600, existing_object), - "next"/Bytes(40) -) -x = ( Embedded(IfThenElse(lambda ctx: ctx._.restore_time == 0, Struct( "objects"/RepeatUpTo(b'\x00', existing_object), @@ -101,11 +96,6 @@ "num_particles"/Int32ul, "particles"/Bytes(lambda ctx: ctx.num_particles * 27), "identifier"/Int32ul, - Array(1, player), - "next"/Bytes(40), - #player, -) -x = ( - #Array(lambda ctx: ctx._.replay.num_players, player), - #Padding(21), + Array(lambda ctx: ctx._.replay.num_players, player), + Padding(21), ) diff --git a/mgz/header/map_info.py b/mgz/header/map_info.py index b74f797..76084f7 100644 --- a/mgz/header/map_info.py +++ b/mgz/header/map_info.py @@ -13,6 +13,7 @@ "terrain_type"/Byte, Embedded(IfThenElse(lambda ctx: ctx._._.version == Version.DE, Embedded(Struct( + If(lambda ctx: ctx._._._.save_version >= 62.0, Byte), Padding(1), # copy of previous byte "elevation"/Byte, "unk0"/Int16sl, @@ -35,8 +36,6 @@ "size_x"/Int32ul, "size_y"/Int32ul, "tile_num"/Computed(lambda ctx: ctx.size_x * ctx.size_y), -) -x = ( "zone_num"/Int32ul, Array(lambda ctx: ctx.zone_num, Struct( IfThenElse(lambda ctx: ctx._._.version in (Version.DE, Version.HD), diff --git a/mgz/header/objects.py b/mgz/header/objects.py index 85ba22e..6b21814 100644 --- a/mgz/header/objects.py +++ b/mgz/header/objects.py @@ -113,7 +113,8 @@ If(lambda ctx: find_save_version(ctx) < 25.22 and find_type(ctx) == 10 and ctx.peek[0] == 0 and ctx.peek[0:2] != b"\x00\x0b", Bytes(1)), If(lambda ctx: find_type(ctx) == 20 and ctx.peek[4] == 0 and ctx.peek[4:6] != b"\x00\x0b", Bytes(1)), )), - "x"/Bytes(14) + If(lambda ctx: find_save_version(ctx) >= 61.5, Bytes(14)), + If(lambda ctx: find_save_version(ctx) >= 62.0, Bytes(4)) )), "hd_extension"/If(lambda ctx: find_version(ctx) == Version.HD and find_save_version(ctx) > 12.36, Struct( "flag"/Flag, @@ -398,6 +399,7 @@ "de"/If(lambda ctx: find_version(ctx) == Version.DE, Bytes(14)), "de_2"/If(lambda ctx: find_save_version(ctx) >= 26.16, Bytes(16)), "de_3"/If(lambda ctx: find_save_version(ctx) >= 26.18, Bytes(1)), + "de_4"/If(lambda ctx: find_save_version(ctx) >= 61.5, Bytes(4)), "next_volley"/Byte, "using_special_animation"/Byte, "own_base"/Byte, @@ -430,15 +432,7 @@ "de_unknown3"/If(lambda ctx: 26.18 > find_save_version(ctx) >= 26.16, Bytes(5)), "de_unknown4"/If(lambda ctx: find_save_version(ctx) >= 26.18, Bytes(4)), "de_unknown5"/If(lambda ctx: find_save_version(ctx) >= 50, Bytes(48)), - #"nn"/Find(b'\x46', 1000) - "de_unknown6"/If(lambda ctx: find_save_version(ctx) >= 61.5, Struct( - "a"/Bytes(40), - "b"/Bytes(40), - "c"/Bytes(40), - "d"/Bytes(40), - "e"/Bytes(40), - "f"/Bytes(8) - )) #Bytes(208)), + "de_unknown6"/If(lambda ctx: find_save_version(ctx) >= 61.5, Bytes(44)) ) production_queue = "production_queue"/Struct( @@ -484,6 +478,7 @@ "de_unk_3"/If(lambda ctx: find_save_version(ctx) >= 25.22, Byte), "de_unk_4"/If(lambda ctx: find_save_version(ctx) >= 26.16, Bytes(4)), "de_unk_5"/If(lambda ctx: find_save_version(ctx) >= 50.4, Bytes(4)), + "de_unk_6"/If(lambda ctx: find_save_version(ctx) >= 61.5, Bytes(12)), ) diff --git a/mgz/header/scenario.py b/mgz/header/scenario.py index 6d47975..fd95ed7 100644 --- a/mgz/header/scenario.py +++ b/mgz/header/scenario.py @@ -14,8 +14,10 @@ scenario_header = "scenario_header"/Struct( "next_uid"/Int32ul, "scenario_version"/Float32l, + If(lambda ctx: find_save_version(ctx) >= 61.5, Padding(8)), Array(16, "names"/String(256)), Array(16, "player_ids"/Int32ul), + If(lambda ctx: find_save_version(ctx) >= 61.5, Padding(64)), Array(16, "player_data"/Struct( "active"/Int32ul, "human"/Int32ul, @@ -147,7 +149,8 @@ If(lambda ctx: 26.16 > find_save_version(ctx) >= 25.22, Find(struct.pack(' find_save_version(ctx) >= 26.16, Find(struct.pack(' find_save_version(ctx) >= 26.21, Find(struct.pack('= 37, Find(struct.pack(' find_save_version(ctx) >= 37, Find(struct.pack('= 61.5, Find(struct.pack('= 61.5: + offset = num_players * 4 + backtrack = 7 + num_players + offset # Otherwise, this is the last player else: # Search for the scenario header diff --git a/setup.py b/setup.py index 7ecb8e0..9626821 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name='mgz', - version='1.8.25', + version='1.8.26', description='Parse Age of Empires 2 recorded games.', url='https://github.com/happyleavesaoc/aoc-mgz/', license='MIT', @@ -11,7 +11,7 @@ author_email='happyleaves.tfr@gmail.com', packages=find_packages(), install_requires=[ - 'aocref>=2.0.17', + 'aocref>=2.0.19', 'construct==2.8.16', 'dataclasses==0.8; python_version < "3.7"', 'tabulate>=0.9.0', diff --git a/tests/recs/de-62.0.aoe2record b/tests/recs/de-62.0.aoe2record new file mode 100644 index 0000000..df36d0d Binary files /dev/null and b/tests/recs/de-62.0.aoe2record differ