Permalink
Browse files

Fixes #104, introducing China as a gateway.

Thanks David.
  • Loading branch information...
1 parent 1b656fc commit bb344121bc99a3d4503c494894c243c1a215255d @GraylinKim committed Mar 8, 2013
Showing with 15 additions and 5 deletions.
  1. +10 −0 sc2reader/constants.py
  2. +2 −2 sc2reader/decoders.py
  3. +1 −1 sc2reader/objects.py
  4. +2 −2 sc2reader/resources.py
@@ -75,6 +75,16 @@
'XX': 'Public Test',
}
+GATEWAY_LOOKUP = {
+ 0:'',
+ 1:'us',
+ 2:'eu',
+ 3:'kr',
+ 5:'ch',
+ 6:'sea',
+ 98:'xx',
+}
+
COLOR_CODES = {
'B4141E': 'Red',
'0042FF': 'Blue',
@@ -52,7 +52,7 @@ def __init__(self, contents, endian):
def done(self):
""" Returns true when all bytes have been decoded """
return self.tell() == self.length
-
+
def read_range(self, start, end):
""" Returns the raw byte string from the indicated address range """
return self._contents[start:end]
@@ -330,4 +330,4 @@ def read_struct(self, datatype=None):
if debug: print prefix
raise TypeError("Unknown Data Structure: '%s'" % datatype)
- return data
+ return data
@@ -10,7 +10,7 @@
Location = namedtuple('Location',('x','y'))
MapData = namedtuple('MapData',['gateway','map_hash'])
ColorData = namedtuple('ColorData',['a','r','g','b'])
-BnetData = namedtuple('BnetData',['unknown1','unknown2','subregion','uid'])
+BnetData = namedtuple('BnetData',['gateway','unknown2','subregion','uid'])
class DepotFile(object):
url_template = 'http://{0}.depot.battle.net:1119/{1}.{2}'
@@ -26,7 +26,7 @@
from sc2reader.events import AbilityEvent, CameraEvent, HotkeyEvent, SelectionEvent
from sc2reader.exceptions import SC2ReaderLocalizationError
from sc2reader.objects import Player, Observer, Team, PlayerSummary, Graph, DepotFile, BuildEntry
-from sc2reader.constants import REGIONS, LOCALIZED_RACES, GAME_SPEED_FACTOR, LOBBY_PROPERTIES
+from sc2reader.constants import REGIONS, LOCALIZED_RACES, GAME_SPEED_FACTOR, LOBBY_PROPERTIES, GATEWAY_LOOKUP
def real_type(teams):
@@ -385,7 +385,7 @@ def createPlayer(pid, pdata, attributes):
player.is_human = (attributes.get('Controller','Computer') == 'User')
player.uid = pdata.bnet.uid
player.subregion = pdata.bnet.subregion
- player.gateway = {0:'', 1:'us',2:'eu',3:'kr',6:'sea', 98:'xx'}[pdata.bnet.unknown1] # actually is gateway!!!
+ player.gateway = GATEWAY_LOOKUP[pdata.bnet.gateway]
player.handicap = pdata.handicap
player.color = utils.Color(**pdata.color._asdict())
return player

0 comments on commit bb34412

Please sign in to comment.