Skip to content

Commit c51af6d

Browse files
correct save version
1 parent 485e8b2 commit c51af6d

13 files changed

Lines changed: 16 additions & 15 deletions

mgz/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"game_version"/CString(encoding='latin1'),
2020
"checker"/Peek(Float32l),
2121
"old_save_version"/VersionAdapter(Float32l),
22-
"new_save_version"/If(lambda ctx: ctx.old_save_version == -1, Int32ub),
22+
"new_save_version"/If(lambda ctx: ctx.old_save_version == -1, Int32ul),
2323
"save_version"/Computed(lambda ctx: get_save_version(ctx.old_save_version, ctx.new_save_version)),
2424
"version"/Computed(lambda ctx: get_version(ctx.game_version, ctx.save_version, None)),
2525
"hd"/If(lambda ctx: ctx.version == Version.HD and ctx.save_version > 12.34, hd),

mgz/fast/enums.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ class Action(Enum):
7272
DE_UNKNOWN_130 = 130
7373
DE_UNKNOWN_131 = 131
7474
DE_UNKNOWN_135 = 135
75+
DE_UNKNOWN_136 = 136
7576
DE_UNKNOWN_138 = 138
7677
DE_TRIBUTE = 196
7778
POSTGAME = 255

mgz/fast/header.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ def parse_de(data, version, save, skip=False):
311311
data.read(20)
312312
if save >= 25.06:
313313
data.read(1)
314-
if save > 51:
314+
if save > 50:
315315
data.read(1)
316316
players = []
317317
for _ in range(num_players if save >= 37 else 8):
@@ -395,7 +395,7 @@ def parse_de(data, version, save, skip=False):
395395
data.read(8)
396396
if save >= 37:
397397
data.read(3)
398-
if save > 51:
398+
if save > 50:
399399
data.read(8)
400400
if not skip:
401401
de_string(data)
@@ -499,11 +499,11 @@ def parse_version(header, data):
499499
log = unpack('<I', data)
500500
game, save = unpack('<7sxf', header)
501501
if save == -1:
502-
save = unpack('>I', header)
503-
if save == 9472:
502+
save = unpack('<I', header)
503+
if save == 37:
504504
save = 37.0
505505
else:
506-
save /= (1<<24)
506+
save /= (1<<16)
507507
version = get_version(game.decode('ascii'), round(save, 2), log)
508508
return version, game.decode('ascii'), round(save, 2), log
509509

mgz/header/de.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
"sub_game_mode"/If(lambda ctx: find_save_version(ctx) >= 13.34, Int32ul),
101101
"battle_royale_time"/If(lambda ctx: find_save_version(ctx) >= 13.34, Int32ul),
102102
"handicap"/If(lambda ctx: find_save_version(ctx) >= 25.06, Flag),
103-
"unk"/If(lambda ctx: find_save_version(ctx) >= 51, Flag),
103+
"unk"/If(lambda ctx: find_save_version(ctx) >= 50, Flag),
104104
separator,
105105
"players"/Array(lambda ctx: ctx.num_players if find_save_version(ctx) >= 37 else 8, player),
106106
Bytes(9),
@@ -153,7 +153,7 @@
153153
If(lambda ctx: find_save_version(ctx) >= 25.22, Bytes(4)),
154154
If(lambda ctx: find_save_version(ctx) >= 26.16, Bytes(8)),
155155
If(lambda ctx: find_save_version(ctx) >= 37, Bytes(3)),
156-
If(lambda ctx: find_save_version(ctx) >= 51, Bytes(8)),
156+
If(lambda ctx: find_save_version(ctx) >= 50, Bytes(8)),
157157
de_string,
158158
Bytes(5),
159159
If(lambda ctx: find_save_version(ctx) >= 13.13, Byte),

mgz/header/lobby.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
Bytes(10),
5959
If(lambda ctx: find_save_version(ctx) >= 26.16, Bytes(4)),
6060
If(lambda ctx: find_save_version(ctx) >= 37, Bytes(4)),
61-
If(lambda ctx: find_save_version(ctx) >= 51, Bytes(1)),
61+
If(lambda ctx: find_save_version(ctx) >= 50, Bytes(1)),
6262
)
6363
)
6464
)

mgz/header/objects.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@
428428
"de_unknown2"/If(lambda ctx: find_save_version(ctx) >= 25.01, Int32ul),
429429
"de_unknown3"/If(lambda ctx: 26.18 > find_save_version(ctx) >= 26.16, Bytes(5)),
430430
"de_unknown4"/If(lambda ctx: find_save_version(ctx) >= 26.18, Bytes(4)),
431-
"de_unknown5"/If(lambda ctx: find_save_version(ctx) >= 51, Bytes(48)),
431+
"de_unknown5"/If(lambda ctx: find_save_version(ctx) >= 50, Bytes(48)),
432432
)
433433

434434
production_queue = "production_queue"/Struct(
@@ -473,7 +473,7 @@
473473
"de_unk_2"/If(lambda ctx: find_save_version(ctx) >= 20.16, Int16ul),
474474
"de_unk_3"/If(lambda ctx: find_save_version(ctx) >= 25.22, Byte),
475475
"de_unk_4"/If(lambda ctx: find_save_version(ctx) >= 26.16, Bytes(4)),
476-
"de_unk_5"/If(lambda ctx: find_save_version(ctx) >= 102, Bytes(4)),
476+
"de_unk_5"/If(lambda ctx: find_save_version(ctx) >= 50.4, Bytes(4)),
477477
)
478478

479479

mgz/util.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
POSTGAME_LENGTH = 2096
2121
LOOKAHEAD = 9
2222
DE_MARKERS = {
23-
38: b"\xa4\x70\xbd\x3f",
23+
50: b"\xa4\x70\xbd\x3f",
2424
37: b"\xf6\x28\xbc\x3f",
2525
26.21: b"\xf6\x28\xbc\x3f",
2626
26.16: b"\x48\xe1\xba\x3f",
@@ -86,9 +86,9 @@ def _decode(self, data, context):
8686
def get_save_version(old_version, new_version):
8787
"""Get the save version."""
8888
if old_version == -1:
89-
if new_version == 9472:
89+
if new_version == 37:
9090
return 37.0
91-
return new_version/(1<<24)
91+
return round(new_version / (1<<16), 2)
9292
return old_version
9393

9494

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
setup(
55
name='mgz',
6-
version='1.8.13',
6+
version='1.8.14',
77
description='Parse Age of Empires 2 recorded games.',
88
url='https://github.com/happyleavesaoc/aoc-mgz/',
99
license='MIT',

0 commit comments

Comments
 (0)