55from datetime import datetime
66from collections import defaultdict
77from sc2reader .constants import REGIONS , LOCALIZED_RACES , GAME_SPEED_FACTOR
8- from sc2reader .objects import Player , Observer , Team
8+ from sc2reader .objects import Player , Observer , Team , Map
99
1010from sc2reader import utils
1111
@@ -42,7 +42,7 @@ class Replay(object):
4242 is_private = bool ()
4343
4444 #: The name of the map the game was played on
45- map = str ()
45+ map = None
4646
4747 #: The gateway the game was played on: us, eu, sea, etc
4848 gateway = str ()
@@ -151,6 +151,7 @@ def load_details(self):
151151 initData = self .raw_data ['replay.initData' ]
152152 if initData .map_data :
153153 self .gateway = initData .map_data [0 ].gateway
154+ self .map = Map (self .gateway , initData .map_data [- 1 ].map_hash )
154155
155156 #Expand this special case mapping
156157 if self .gateway == 'sg' :
@@ -173,7 +174,8 @@ def load_details(self):
173174 if 'replay.details' in self .raw_data :
174175 details = self .raw_data ['replay.details' ]
175176
176- self .map = details .map
177+ if self .map :
178+ self .map .name = details .map
177179
178180 self .windows_timestamp = details .file_time - details .utc_adjustment
179181 self .unix_timestamp = utils .windows_to_unix (self .windows_timestamp )
@@ -185,6 +187,8 @@ def load_details(self):
185187 self .start_time = datetime .utcfromtimestamp (self .unix_timestamp - self .real_length .seconds )
186188 self .date = self .end_time #backwards compatibility
187189
190+ def load_map (self ):
191+ self .map .load ()
188192
189193 def load_players (self ):
190194 #If we don't at least have details and attributes_events we can go no further
0 commit comments