Skip to content

Commit 2b480d4

Browse files
committed
Fix replay.gateway, add a test for china, and fix the china gateway.
1 parent bb34412 commit 2b480d4

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

sc2reader/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
1:'us',
8181
2:'eu',
8282
3:'kr',
83-
5:'ch',
83+
5:'cn',
8484
6:'sea',
8585
98:'xx',
8686
}

sc2reader/resources.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -279,14 +279,6 @@ def __init__(self, replay_file, filename=None, load_level=4, **options):
279279
def load_details(self):
280280
if 'replay.initData' in self.raw_data:
281281
initData = self.raw_data['replay.initData']
282-
if initData.map_data:
283-
self.gateway = initData.map_data[0].server.lower()
284-
self.map_hash = initData.map_data[-1].hash
285-
self.map_file = initData.map_data[-1]
286-
287-
#Expand this special case mapping
288-
if self.gateway == 'sg':
289-
self.gateway = 'sea'
290282

291283
if 'replay.attributes.events' in self.raw_data:
292284
# Organize the attribute data to be useful
@@ -307,6 +299,14 @@ def load_details(self):
307299

308300
self.map_name = details.map
309301

302+
self.gateway = details.dependencies[0].server.lower()
303+
self.map_hash = details.dependencies[-1].hash
304+
self.map_file = details.dependencies[-1]
305+
306+
#Expand this special case mapping
307+
if self.gateway == 'sg':
308+
self.gateway = 'sea'
309+
310310
dependency_hashes = [d.hash for d in details.dependencies]
311311
if hashlib.sha256('Standard Data: Swarm.SC2Mod').hexdigest() in dependency_hashes:
312312
self.expansion = 'HotS'
88.2 KB
Binary file not shown.

test_replays/test_all.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,3 +247,8 @@ def test_WoL_204():
247247
def test_send_resources():
248248
replay = sc2reader.load_replay("test_replays/2.0.4.24944/Backwater Complex (15).SC2Replay")
249249

250+
def test_cn_replays():
251+
replay = sc2reader.load_replay("test_replays/2.0.5.25092/cn1.SC2Replay")
252+
assert replay.gateway == 'cn'
253+
assert replay.expansion == 'WoL'
254+

0 commit comments

Comments
 (0)