Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions mgz/fast/header.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,8 @@ def parse_de(data, version, save, skip=False):
data.read(8)
if save >= 64.3:
data.read(4)
if save >= 67.2:
_ = de_string(data)

players.append(dict(
number=number,
Expand Down Expand Up @@ -550,6 +552,9 @@ def parse_de(data, version, save, skip=False):
data.read(c * 4)
if not skip:
de_string(data)
if save >= 67.2:
_ = de_string(data)
_ = de_string(data)
data.read(8)
if save >= 37:
timestamp, x = unpack('<II', data)
Expand Down
7 changes: 6 additions & 1 deletion mgz/header/de.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"custom_ai"/Flag,
If(lambda ctx: find_save_version(ctx) >= 25.06, "handicap"/Bytes(8)),
If(lambda ctx: find_save_version(ctx) >= 64.3, "unknown_de_64_3" / Int32ul),
If(lambda ctx: find_save_version(ctx) >= 67.2, "unknown_de_67_2" / de_string),
)

string_block = Struct(
Expand Down Expand Up @@ -167,6 +168,10 @@
If(lambda ctx: find_save_version(ctx) >= 66.3, Bytes(12)),
If(lambda ctx: find_save_version(ctx) >= 66.3, Array(lambda ctx: ctx.unknown_count, Bytes(4))),
de_string,
If(lambda ctx: find_save_version(ctx) >= 67.2, Struct(
de_string,
de_string,
)),
Bytes(5),
If(lambda ctx: find_save_version(ctx) >= 13.13, Byte),
If(lambda ctx: find_save_version(ctx) < 13.17, Struct(
Expand All @@ -178,5 +183,5 @@
"ver37"/If(lambda ctx: find_save_version(ctx) >= 37, Struct(
Int32ul,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a timestamp. Value seems to be always the same as at the one declared above in the struct.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this is a timestamp, I didn't change it here. I have it as a timestamp in my own Rust parser.

Int32ul
))
)),
)
2 changes: 2 additions & 0 deletions mgz/header/initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
Int32ul, Padding, Struct, Tell, this, Bytes, Const, IfThenElse)

from mgz.enums import MyDiplomacyEnum, TheirDiplomacyEnum
from mgz.header.de import de_string
from mgz.header.objects import existing_object
from mgz.header.playerstats import player_stats
from mgz.util import Find, GotoObjectsEnd, RepeatUpTo, Version, find_save_version, find_version
Expand Down Expand Up @@ -42,6 +43,7 @@
"y"/Int16ul
),
"culture"/Byte,
"name"/If(lambda ctx: find_save_version(ctx) >= 67.2, de_string),
"civilization"/Byte,
"game_status"/Byte,
"resigned"/Flag,
Expand Down
2 changes: 1 addition & 1 deletion mgz/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def parse_match(handle):
player['name'].decode(encoding),
consts['player_colors'][str(player['color_id'])],
player['color_id'],
dataset['civilizations'][str(player['civilization_id'])]['name'],
dataset['civilizations'].get(str(player['civilization_id']), {'name': f"<Unknown civ: {player['civilization_id']}>"})['name'],
player['civilization_id'],
Position(pos_x, pos_y),
[
Expand Down
Loading