Skip to content

Commit

Permalink
string block version support
Browse files Browse the repository at this point in the history
  • Loading branch information
happyleavesaoc committed Oct 2, 2022
1 parent b344420 commit 9b8e716
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion mgz/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ async def extract_rec(playback, path, select=None):
def print_info(path):
"""Print basic info."""
with open(path, 'rb') as handle:
summary = Summary(handle, fallback=True)
summary = Summary(handle)
dataset = summary.get_dataset()
print('-------------')
print(tabulate([
Expand Down
2 changes: 1 addition & 1 deletion mgz/fast/header.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def string_block(data):
strings = []
while True:
crc = unpack("<I", data)
if crc == 47:
if 255 > crc > 0:
break
strings.append(de_string(data).decode('utf-8').split(':'))
return strings
Expand Down
6 changes: 3 additions & 3 deletions mgz/header/de.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
)

string_block = Struct(
"strings"/RepeatUntil(lambda x, lst, ctx: lst[-1].crc == 47, Struct(
"strings"/RepeatUntil(lambda x, lst, ctx: 255 > lst[-1].crc > 0, Struct(
"crc"/Int32ul,
"string"/If(lambda ctx: ctx.crc != 47, de_string)
"string"/If(lambda ctx: ctx.crc == 0 or ctx.crc > 255, de_string)
))
)

Expand Down Expand Up @@ -112,7 +112,7 @@
"lobby_visibility"/Int32ul,
"hidden_civs"/Flag,
"matchmaking"/Flag,
"spec_delay"/Int32ul,
"spec_delay"/If(lambda ctx: find_save_version(ctx) >= 13.13, Int32ul),
"scenario_civ"/If(lambda ctx: find_save_version(ctx) >= 13.13, Byte),
"rms_strings"/string_block,
Bytes(8),
Expand Down

0 comments on commit 9b8e716

Please sign in to comment.