Skip to content

Commit ac8c220

Browse files
committed
further support for 3.0.
now two replays pass the parsing test.
1 parent c6fdb74 commit ac8c220

File tree

4 files changed

+53
-4
lines changed

4 files changed

+53
-4
lines changed

sc2reader/events/game.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def __init__(self, frame, pid, data):
101101
self.use_ai_beacons = data['use_ai_beacons']
102102

103103
#: Are workers sent to auto-mine on game start
104-
self.starting_rally = data['starting_rally']
104+
self.starting_rally = data['starting_rally'] if 'starting_rally' in data else None
105105

106106
#:
107107
self.debug_pause_enabled = data['debug_pause_enabled']
@@ -427,7 +427,10 @@ def create_control_group_event(frame, pid, data):
427427
elif update_type == 3:
428428
# TODO: What could this be?!?
429429
return HotkeyEvent(frame, pid, data)
430-
430+
elif update_type == 4:
431+
# No idea what this is but we're seeing it now in 3.0
432+
return HotkeyEvent(frame, pid, data)
433+
431434

432435
@loggable
433436
class HotkeyEvent(PlayerActionEvent):

sc2reader/readers.py

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def __call__(self, data, replay):
4747
random_races=data.read_bool(),
4848
battle_net=data.read_bool(),
4949
amm=data.read_bool(),
50-
ranked=data.read_bool() if replay.base_build >= 34784 else None,
50+
ranked=data.read_bool() if replay.base_build >= 34784 and replay.base_build < 38215 else None,
5151
competitive=data.read_bool(),
5252
practice=data.read_bool() if replay.base_build >= 34784 else None,
5353
cooperative=data.read_bool() if replay.base_build >= 34784 else None,
@@ -1726,6 +1726,31 @@ def control_group_update_event(self, data):
17261726

17271727
class GameEventsReader_38215(GameEventsReader_36442):
17281728

1729+
def __init__(self):
1730+
super(GameEventsReader_38215, self).__init__()
1731+
1732+
self.EVENT_DISPATCH.update({
1733+
76: (None, self.trigger_command_error_event),
1734+
92: (None, self.trigger_mousewheel_event), # 172 in protocol38125.py
1735+
})
1736+
1737+
def trigger_command_error_event(self, data):
1738+
return dict(
1739+
error=data.read_uint32() - 2147483648,
1740+
ability=dict(
1741+
ability_link=data.read_uint16(),
1742+
ability_command_index=data.read_bits(5),
1743+
ability_command_data=data.read_uint8() if data.read_bool() else None,
1744+
) if data.read_bool() else None,
1745+
)
1746+
1747+
def trigger_mousewheel_event(self, data):
1748+
# 172 in protocol38125.py
1749+
return dict(
1750+
wheelspin=data.read_uint16()-32768, # 171 in protocol38125.py
1751+
flags=data.read_uint8() - 128, # 112 in protocol38125.py
1752+
)
1753+
17291754
def command_event(self, data):
17301755
# this function is exactly the same as command_event() from GameEventsReader_36442
17311756
# with the only change being that flags now has 25 bits instead of 23.
@@ -1766,7 +1791,27 @@ def command_event(self, data):
17661791
other_unit_tag=data.read_uint32() if data.read_bool() else None,
17671792
unit_group=data.read_uint32() if data.read_bool() else None,
17681793
)
1769-
1794+
1795+
def user_options_event(self, data):
1796+
# only change: removes starting_rally
1797+
return dict(
1798+
game_fully_downloaded=data.read_bool(),
1799+
development_cheats_enabled=data.read_bool(),
1800+
test_cheats_enabled=data.read_bool(),
1801+
multiplayer_cheats_enabled=data.read_bool(),
1802+
sync_checksumming_enabled=data.read_bool(),
1803+
is_map_to_map_transition=data.read_bool(),
1804+
debug_pause_enabled=data.read_bool(),
1805+
use_galaxy_asserts=data.read_bool(),
1806+
platform_mac=data.read_bool(),
1807+
camera_follow=data.read_bool(),
1808+
base_build_num=data.read_uint32(),
1809+
build_num=data.read_uint32(),
1810+
version_flags=data.read_uint32(),
1811+
hotkey_profile=data.read_aligned_string(data.read_bits(9)),
1812+
use_ai_beacons=None,
1813+
)
1814+
17701815

17711816
class TrackerEventsReader(object):
17721817

82.7 KB
Binary file not shown.

test_replays/test_all.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,7 @@ def test_lotv_map(self):
429429

430430
def test_30(self):
431431
replay = sc2reader.load_replay("test_replays/3.0.0.38215/first.SC2Replay")
432+
replay = sc2reader.load_replay("test_replays/3.0.0.38215/second.SC2Replay")
432433

433434

434435
class TestGameEngine(unittest.TestCase):

0 commit comments

Comments
 (0)