Skip to content

Commit cc2aacd

Browse files
committed
Make replays load their maps via their parent factory.
1 parent d35ef33 commit cc2aacd

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

sc2reader/readers.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,8 @@ def __call__(self, data, replay):
4949
#
5050
# TODO: Figure out how we could be missing a maps section.
5151
map_data = list()
52-
while data.read(4) == 's2ma':
53-
gateway = data.read(4).strip('\00 ').lower()
54-
map_hash = data.read(32)
55-
map_data.append(MapData(gateway,map_hash))
52+
while data.peek(4) == 's2ma':
53+
map_data.append(DepotFile(data.read(40)))
5654

5755
# Return the extracted information inside an AttributeDict.
5856
return AttributeDict(

sc2reader/resources.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,9 @@ def load_details(self):
260260
if 'replay.initData' in self.raw_data:
261261
initData = self.raw_data['replay.initData']
262262
if initData.map_data:
263-
self.gateway = initData.map_data[0].gateway
264-
self.map_hash = initData.map_data[-1].map_hash.encode('hex')
263+
self.gateway = initData.map_data[0].server.lower()
264+
self.map_hash = initData.map_data[-1].hash
265+
self.map_file = initData.map_data[-1]
265266

266267
#Expand this special case mapping
267268
if self.gateway == 'sg':
@@ -313,9 +314,7 @@ def load_details(self):
313314
self.date = self.end_time #backwards compatibility
314315

315316
def load_map(self):
316-
map_url = Map.get_url(self.gateway, self.map_hash)
317-
map_file = StringIO(urllib2.urlopen(map_url).read())
318-
self.map = Map(map_file, filename=self.map, gateway=self.gateway, map_hash=self.map_hash)
317+
self.map = self.factory.load_map(self.map_file, **self.opt)
319318

320319
def load_players(self):
321320
#If we don't at least have details and attributes_events we can go no further

0 commit comments

Comments
 (0)