Skip to content

Commit bb34412

Browse files
committed
Fixes #104, introducing China as a gateway.
Thanks David.
1 parent 1b656fc commit bb34412

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

sc2reader/constants.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,16 @@
7575
'XX': 'Public Test',
7676
}
7777

78+
GATEWAY_LOOKUP = {
79+
0:'',
80+
1:'us',
81+
2:'eu',
82+
3:'kr',
83+
5:'ch',
84+
6:'sea',
85+
98:'xx',
86+
}
87+
7888
COLOR_CODES = {
7989
'B4141E': 'Red',
8090
'0042FF': 'Blue',

sc2reader/decoders.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def __init__(self, contents, endian):
5252
def done(self):
5353
""" Returns true when all bytes have been decoded """
5454
return self.tell() == self.length
55-
55+
5656
def read_range(self, start, end):
5757
""" Returns the raw byte string from the indicated address range """
5858
return self._contents[start:end]
@@ -330,4 +330,4 @@ def read_struct(self, datatype=None):
330330
if debug: print prefix
331331
raise TypeError("Unknown Data Structure: '%s'" % datatype)
332332

333-
return data
333+
return data

sc2reader/objects.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
Location = namedtuple('Location',('x','y'))
1111
MapData = namedtuple('MapData',['gateway','map_hash'])
1212
ColorData = namedtuple('ColorData',['a','r','g','b'])
13-
BnetData = namedtuple('BnetData',['unknown1','unknown2','subregion','uid'])
13+
BnetData = namedtuple('BnetData',['gateway','unknown2','subregion','uid'])
1414

1515
class DepotFile(object):
1616
url_template = 'http://{0}.depot.battle.net:1119/{1}.{2}'

sc2reader/resources.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from sc2reader.events import AbilityEvent, CameraEvent, HotkeyEvent, SelectionEvent
2727
from sc2reader.exceptions import SC2ReaderLocalizationError
2828
from sc2reader.objects import Player, Observer, Team, PlayerSummary, Graph, DepotFile, BuildEntry
29-
from sc2reader.constants import REGIONS, LOCALIZED_RACES, GAME_SPEED_FACTOR, LOBBY_PROPERTIES
29+
from sc2reader.constants import REGIONS, LOCALIZED_RACES, GAME_SPEED_FACTOR, LOBBY_PROPERTIES, GATEWAY_LOOKUP
3030

3131

3232
def real_type(teams):
@@ -385,7 +385,7 @@ def createPlayer(pid, pdata, attributes):
385385
player.is_human = (attributes.get('Controller','Computer') == 'User')
386386
player.uid = pdata.bnet.uid
387387
player.subregion = pdata.bnet.subregion
388-
player.gateway = {0:'', 1:'us',2:'eu',3:'kr',6:'sea', 98:'xx'}[pdata.bnet.unknown1] # actually is gateway!!!
388+
player.gateway = GATEWAY_LOOKUP[pdata.bnet.gateway]
389389
player.handicap = pdata.handicap
390390
player.color = utils.Color(**pdata.color._asdict())
391391
return player

0 commit comments

Comments
 (0)