Skip to content

Commit

Permalink
Fix replay.gateway, add a test for china, and fix the china gateway.
Browse files Browse the repository at this point in the history
  • Loading branch information
GraylinKim committed Mar 8, 2013
1 parent bb34412 commit 2b480d4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion sc2reader/constants.py
Expand Up @@ -80,7 +80,7 @@
1:'us',
2:'eu',
3:'kr',
5:'ch',
5:'cn',
6:'sea',
98:'xx',
}
Expand Down
16 changes: 8 additions & 8 deletions sc2reader/resources.py
Expand Up @@ -279,14 +279,6 @@ def __init__(self, replay_file, filename=None, load_level=4, **options):
def load_details(self):
if 'replay.initData' in self.raw_data:
initData = self.raw_data['replay.initData']
if initData.map_data:
self.gateway = initData.map_data[0].server.lower()
self.map_hash = initData.map_data[-1].hash
self.map_file = initData.map_data[-1]

#Expand this special case mapping
if self.gateway == 'sg':
self.gateway = 'sea'

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

self.map_name = details.map

self.gateway = details.dependencies[0].server.lower()
self.map_hash = details.dependencies[-1].hash
self.map_file = details.dependencies[-1]

#Expand this special case mapping
if self.gateway == 'sg':
self.gateway = 'sea'

dependency_hashes = [d.hash for d in details.dependencies]
if hashlib.sha256('Standard Data: Swarm.SC2Mod').hexdigest() in dependency_hashes:
self.expansion = 'HotS'
Expand Down
Binary file added test_replays/2.0.5.25092/cn1.SC2Replay
Binary file not shown.
5 changes: 5 additions & 0 deletions test_replays/test_all.py
Expand Up @@ -247,3 +247,8 @@ def test_WoL_204():
def test_send_resources():
replay = sc2reader.load_replay("test_replays/2.0.4.24944/Backwater Complex (15).SC2Replay")

def test_cn_replays():
replay = sc2reader.load_replay("test_replays/2.0.5.25092/cn1.SC2Replay")
assert replay.gateway == 'cn'
assert replay.expansion == 'WoL'

0 comments on commit 2b480d4

Please sign in to comment.