Skip to content

Commit 86bd9b7

Browse files
authored
Merge pull request #122 from Talv/p80949
Support for protocol 80949 (v5.0.0)
2 parents f088867 + ff0cb87 commit 86bd9b7

File tree

9 files changed

+1570
-3
lines changed

9 files changed

+1570
-3
lines changed

sc2reader/data/LotV/80949_abilities.csv

Lines changed: 409 additions & 0 deletions
Large diffs are not rendered by default.

sc2reader/data/LotV/80949_units.csv

Lines changed: 1058 additions & 0 deletions
Large diffs are not rendered by default.

sc2reader/data/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,7 @@ def load_build(expansion, version):
480480
"70154",
481481
"76114",
482482
"77379",
483+
"80949",
483484
):
484485
lotv_builds[version] = load_build("LotV", version)
485486

sc2reader/data/ability_lookup.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,3 +865,4 @@ BattlecruiserStop,Stop
865865
BattlecruiserAttack,BattlecruiserAttack
866866
BattlecruiserMove,Move,Patrol,HoldPos
867867
AmorphousArmorcloud,AmorphousArmorcloud
868+
BatteryOvercharge,BatteryOvercharge

sc2reader/data/unit_lookup.csv

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,3 +1062,23 @@ ArtilleryMengskACGluescreenDummy,ArtilleryMengskACGluescreenDummy
10621062
AccelerationZoneSmall,AccelerationZoneSmall
10631063
AccelerationZoneMedium,AccelerationZoneMedium
10641064
AccelerationZoneLarge,AccelerationZoneLarge
1065+
LoadOutSpray@1,LoadOutSpray@1
1066+
LoadOutSpray@2,LoadOutSpray@2
1067+
LoadOutSpray@3,LoadOutSpray@3
1068+
LoadOutSpray@4,LoadOutSpray@4
1069+
LoadOutSpray@5,LoadOutSpray@5
1070+
LoadOutSpray@6,LoadOutSpray@6
1071+
LoadOutSpray@7,LoadOutSpray@7
1072+
LoadOutSpray@8,LoadOutSpray@8
1073+
LoadOutSpray@9,LoadOutSpray@9
1074+
LoadOutSpray@10,LoadOutSpray@10
1075+
LoadOutSpray@11,LoadOutSpray@11
1076+
LoadOutSpray@12,LoadOutSpray@12
1077+
LoadOutSpray@13,LoadOutSpray@13
1078+
LoadOutSpray@14,LoadOutSpray@14
1079+
AccelerationZoneFlyingSmall,AccelerationZoneFlyingSmall
1080+
AccelerationZoneFlyingMedium,AccelerationZoneFlyingMedium
1081+
AccelerationZoneFlyingLarge,AccelerationZoneFlyingLarge
1082+
InhibitorZoneFlyingSmall,InhibitorZoneFlyingSmall
1083+
InhibitorZoneFlyingMedium,InhibitorZoneFlyingMedium
1084+
InhibitorZoneFlyingLarge,InhibitorZoneFlyingLarge

sc2reader/readers.py

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,9 @@ def __call__(self, data, replay):
167167
ai_build=data.read_bits(8 if replay.base_build >= 38749 else 7)
168168
if replay.base_build >= 23925
169169
else None,
170-
handicap=data.read_bits(7),
170+
handicap=data.read_bits(
171+
32 if replay.base_build >= 80669 else 7
172+
),
171173
observe=data.read_bits(2),
172174
logo_index=data.read_uint32()
173175
if replay.base_build >= 32283
@@ -270,6 +272,9 @@ def __call__(self, data, replay):
270272
ac_enemy_wave_type=data.read_uint32()
271273
if replay.base_build >= 77379
272274
else None,
275+
selected_commander_prestige=data.read_uint32()
276+
if replay.base_build >= 80871
277+
else None,
273278
)
274279
for i in range(data.read_bits(5))
275280
],
@@ -2196,6 +2201,65 @@ def set_sync_playing(self, data):
21962201
return dict(sync_load=data.read_uint32())
21972202

21982203

2204+
class GameEventsReader_80669(GameEventsReader_65895):
2205+
# this is almost the same as `command_event` from previous build
2206+
# the only addition is introduction of extra command flag:
2207+
# > https://news.blizzard.com/en-us/starcraft2/23471116/starcraft-ii-4-13-0-ptr-patch-notes
2208+
# > New order command flag: Attack Once
2209+
# > When issuing an attack order, it is now allowed to issue an “attack once” order with order command flags.
2210+
# > const int c_cmdAttackOnce = 26;
2211+
# ideally this part of the code should be more generic so it doesn't have to copy-pasted as a whole
2212+
# every time there's a tiny change in one of the sub-structs
2213+
def command_event(self, data):
2214+
return dict(
2215+
flags=data.read_bits(27),
2216+
ability=dict(
2217+
ability_link=data.read_uint16(),
2218+
ability_command_index=data.read_bits(5),
2219+
ability_command_data=data.read_uint8() if data.read_bool() else None,
2220+
)
2221+
if data.read_bool()
2222+
else None,
2223+
data={ # Choice
2224+
0: lambda: ("None", None),
2225+
1: lambda: (
2226+
"TargetPoint",
2227+
dict(
2228+
point=dict(
2229+
x=data.read_bits(20),
2230+
y=data.read_bits(20),
2231+
z=data.read_uint32() - 2147483648,
2232+
)
2233+
),
2234+
),
2235+
2: lambda: (
2236+
"TargetUnit",
2237+
dict(
2238+
flags=data.read_uint16(),
2239+
timer=data.read_uint8(),
2240+
unit_tag=data.read_uint32(),
2241+
unit_link=data.read_uint16(),
2242+
control_player_id=data.read_bits(4)
2243+
if data.read_bool()
2244+
else None,
2245+
upkeep_player_id=data.read_bits(4)
2246+
if data.read_bool()
2247+
else None,
2248+
point=dict(
2249+
x=data.read_bits(20),
2250+
y=data.read_bits(20),
2251+
z=data.read_uint32() - 2147483648,
2252+
),
2253+
),
2254+
),
2255+
3: lambda: ("Data", dict(data=data.read_uint32())),
2256+
}[data.read_bits(2)](),
2257+
sequence=data.read_uint32() + 1,
2258+
other_unit_tag=data.read_uint32() if data.read_bool() else None,
2259+
unit_group=data.read_uint32() if data.read_bool() else None,
2260+
)
2261+
2262+
21992263
class TrackerEventsReader(object):
22002264
def __init__(self):
22012265
self.EVENT_DISPATCH = {

sc2reader/resources.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,12 @@ def register_default_readers(self):
773773
self.register_reader(
774774
"replay.game.events",
775775
readers.GameEventsReader_65895(),
776-
lambda r: 65895 <= r.base_build,
776+
lambda r: 65895 <= r.base_build < 80669,
777+
)
778+
self.register_reader(
779+
"replay.game.events",
780+
readers.GameEventsReader_80669(),
781+
lambda r: 80669 <= r.base_build,
777782
)
778783
self.register_reader(
779784
"replay.game.events",
@@ -865,7 +870,11 @@ def register_default_datapacks(self):
865870
)
866871
self.register_datapack(
867872
datapacks["LotV"]["77379"],
868-
lambda r: r.expansion == "LotV" and 77379 <= r.build,
873+
lambda r: r.expansion == "LotV" and 77379 <= r.build < 80949,
874+
)
875+
self.register_datapack(
876+
datapacks["LotV"]["80949"],
877+
lambda r: r.expansion == "LotV" and 80949 <= r.build,
869878
)
870879

871880
# Internal Methods
Binary file not shown.

test_replays/test_replays.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,11 @@ def test_77379(self):
708708
self.assertEqual(replay.players[0].commander, "Mengsk")
709709
self.assertEqual(replay.players[1].commander, "Stetmann")
710710

711+
def test_80949(self):
712+
replay = sc2reader.load_replay(
713+
"test_replays/5.0.0.80949/2020-07-28 - (T)Ocrucius VS (Z)Rairden.SC2Replay"
714+
)
715+
711716
def test_anonymous_replay(self):
712717
replayfilename = "test_replays/4.1.2.60604/1.SC2Replay"
713718
factory = sc2reader.factories.SC2Factory()

0 commit comments

Comments
 (0)