Skip to content

Commit

Permalink
2 of 2 changes to support bot replays in ggtracker#149 (#2)
Browse files Browse the repository at this point in the history
* 2 of 2 changes to support bot replays in ggtracker#149

Fixes the issue when defaulting to LoTV for GAME_SPEED_FACTOR for bot replays

* Update sc2reader/resources.py

Co-authored-by: Christian Clauss <[email protected]>

* Update sc2reader/resources.py

Co-authored-by: Christian Clauss <[email protected]>

* Update sc2reader/resources.py

Co-authored-by: Christian Clauss <[email protected]>

* Update sc2reader/resources.py

Co-authored-by: Christian Clauss <[email protected]>

---------

Co-authored-by: Christian Clauss <[email protected]>
  • Loading branch information
craigdods and cclauss authored Jul 16, 2023
1 parent 12634e1 commit d693b08
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions sc2reader/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,10 @@ def load_details(self):
)

self.game_length = self.length
expansion = self.expansion or 'LotV' # Using @brean's logic to fix bot replays
self.real_length = utils.Length(
seconds=self.length.seconds
// GAME_SPEED_FACTOR[self.expansion].get(self.speed, 1.0)
// GAME_SPEED_FACTOR[expansion].get(self.speed, 1.0)
)
self.start_time = datetime.utcfromtimestamp(
self.unix_timestamp - self.real_length.seconds
Expand Down Expand Up @@ -1096,9 +1097,11 @@ def __init__(self, summary_file, filename=None, lang="enUS", **options):
self.end_time = datetime.utcfromtimestamp(self.parts[0][8])
self.game_speed = LOBBY_PROPERTIES[0xBB8][1][self.parts[0][0][1].decode("utf8")]
self.game_length = utils.Length(seconds=self.parts[0][7])
expansion = self.expansion or 'LotV'
self.real_length = utils.Length(
# Use @brean's logic to fix bot replays
seconds=int(
self.parts[0][7] / GAME_SPEED_FACTOR[self.expansion][self.game_speed]
self.parts[0][7] / GAME_SPEED_FACTOR[expansion][self.game_speed]
)
)
self.start_time = datetime.utcfromtimestamp(
Expand Down

0 comments on commit d693b08

Please sign in to comment.