Skip to content

Commit d936ac3

Browse files
committed
Started to work on MapInfo (.s2mi)
1 parent 9906968 commit d936ac3

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

sc2reader/factories.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from sc2reader import exceptions
1515
from sc2reader import utils
1616
from sc2reader import log_utils
17-
from sc2reader.resources import Replay, Map, GameSummary, MatchInfo, MatchHistory
17+
from sc2reader.resources import Replay, Map, GameSummary, MapInfo, MatchHistory
1818

1919
class SC2Factory(object):
2020
"""
@@ -509,4 +509,4 @@ def load_replay(self, replay_file, options=None, **new_options):
509509
else:
510510
replay = super(SC2Cache, self).load_replay(replay_file, options=options)
511511
self.cache.set(replay_file, replay)
512-
return replay
512+
return replay

sc2reader/resources.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -422,15 +422,28 @@ def __init__(self, summary_file, filename=None, **options):
422422
for player in [0, 1]:
423423
print "Player", player, name, self.parts[3][0][index][1][player][0][0]
424424

425-
class MatchInfo(Resource):
426-
url_template = 'http://{0}.depot.battle.net:1119/{1}.s2ma'
425+
class MapInfo(Resource):
426+
url_template = 'http://{0}.depot.battle.net:1119/{1}.s2mi'
427+
428+
#: Name of the Map
429+
map_name = str()
430+
431+
#: Hash of referenced s2mh file
432+
s2mh_hash = str()
433+
434+
#: URL of referenced s2mh file
435+
s2mh_url = str()
436+
427437
def __init__(self, info_file, filename=None, **options):
428-
super(MatchInfo, self).__init__(info_file, filename,**options)
438+
super(MapInfo, self).__init__(info_file, filename,**options)
429439
self.data = utils.ReplayBuffer(info_file).read_data_struct()
430-
440+
self.map_name = self.data[0][7]
441+
self.language = self.data[0][13]
442+
self.s2mh_hash = ''.join([hex(ord(x))[2:] for x in self.data[0][1][8:]])
443+
self.s2mh_url = MatchHistory.url_template.format(self.data[0][1][6:8], self.s2mh_hash)
431444

432445
class MatchHistory(Resource):
433-
url_template = 'http://{0}.depot.battle.net:1119/{1}.s2ma'
446+
url_template = 'http://{0}.depot.battle.net:1119/{1}.s2mh'
434447
def __init__(self, history_file, filename=None, **options):
435448
super(MatchHistory, self).__init__(history_file, filename,**options)
436449
self.data = utils.ReplayBuffer(history_file).read_data_struct()

0 commit comments

Comments
 (0)