Skip to content
Merged
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
1 change: 1 addition & 0 deletions sc2reader/data/attributes.json
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,7 @@
"Horn": "Horner",
"Kara": "Karax",
"Kerr": "Kerrigan",
"Meng": "Mengsk",
"Nova": "Nova",
"Rayn": "Raynor",
"Stet": "Stetmann",
Expand Down
22 changes: 21 additions & 1 deletion sc2reader/readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,13 @@ def __call__(self, data, replay):
licenses=[
data.read_uint32()
for i in range(
data.read_bits(13 if replay.base_build >= 70154 else 9)
data.read_bits(
16
if replay.base_build >= 77379
else 13
if replay.base_build >= 70154
else 9
Copy link
Collaborator

Choose a reason for hiding this comment

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

A double ternary if is not really Pythonic. What about:

if replay.base_build >= 77379:
    read_bits = 16
elif replay.base_build >= 70154:
    read_bits = 13
else:
    read_bits = 9
data.read_bits(read_bits)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It might not be Pythonic, but it's consistent with rest of the code. So I'd rather keep it as is.

Unfortunately decoding functions are already hardly readable. And if there's something to be done with it, it should be tackled in separate PR IMO.

)
)
]
if replay.base_build >= 19132
Expand Down Expand Up @@ -250,6 +256,20 @@ def __call__(self, data, replay):
]
if replay.base_build >= 47185
else None,
brutal_plus_difficulty=data.read_uint32()
if replay.base_build >= 77379
else None,
retry_mutation_indexes=[
data.read_uint32() for i in range(data.read_bits(3))
]
if replay.base_build >= 77379
else None,
ac_enemy_race=data.read_uint32()
if replay.base_build >= 77379
else None,
ac_enemy_wave_type=data.read_uint32()
if replay.base_build >= 77379
else None,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same.

)
for i in range(data.read_bits(5))
],
Expand Down
Binary file not shown.
7 changes: 7 additions & 0 deletions test_replays/test_replays.py
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,13 @@ def test_75689(self):
replay = factory.load_replay(replayfilename)
self.assertEqual(replay.players[0].trophy_id, 13)

def test_77379(self):
replay = sc2reader.load_replay(
"test_replays/4.11.0.77379/Oblivion Express.SC2Replay"
)
self.assertEqual(replay.players[0].commander, "Mengsk")
self.assertEqual(replay.players[1].commander, "Stetmann")

def test_anonymous_replay(self):
replayfilename = "test_replays/4.1.2.60604/1.SC2Replay"
factory = sc2reader.factories.SC2Factory()
Expand Down