diff --git a/sc2reader/engine/plugins/__init__.py b/sc2reader/engine/plugins/__init__.py index ca62c70c..0d4dff9e 100644 --- a/sc2reader/engine/plugins/__init__.py +++ b/sc2reader/engine/plugins/__init__.py @@ -4,3 +4,5 @@ from sc2reader.engine.plugins.supply import SupplyTracker from sc2reader.engine.plugins.creeptracker import CreepTracker from sc2reader.engine.plugins.gameheart import GameHeartNormalizer + +from sc2reader.engine.plugins.lotv import EventSecondCorrector diff --git a/sc2reader/engine/plugins/lotv/__init__.py b/sc2reader/engine/plugins/lotv/__init__.py new file mode 100644 index 00000000..48dc1fb8 --- /dev/null +++ b/sc2reader/engine/plugins/lotv/__init__.py @@ -0,0 +1 @@ +from sc2reader.engine.plugins.lotv.event_second import EventSecondCorrector diff --git a/sc2reader/engine/plugins/lotv/event_second.py b/sc2reader/engine/plugins/lotv/event_second.py new file mode 100644 index 00000000..202a537e --- /dev/null +++ b/sc2reader/engine/plugins/lotv/event_second.py @@ -0,0 +1,20 @@ +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from sc2reader.events import Event + from sc2reader.resources import Replay + + +class EventSecondCorrector: + """ + In Lotv, the game fps is 22.4, which means that the game time is not + accurate to the second. But the event.seconds is hardcoded as the fps + is 16. Since currently the replay build is not passed into the event, + the safest way to correct the event.seconds is use plugin. + """ + + name = "EventSecondCorrector" + + def handleEvent(self, e: "Event", replay: "Replay"): + if 34784 <= replay.build: # lotv replay, adjust time + e.second = int(e.second * 16 / 22.4) diff --git a/sc2reader/objects.py b/sc2reader/objects.py index d6c9491d..1922ccb8 100644 --- a/sc2reader/objects.py +++ b/sc2reader/objects.py @@ -135,6 +135,9 @@ def __init__(self, sid, slot_data): toon_handle = self.toon_handle or "0-S2-0-0" parts = toon_handle.split("-") + #: The Battle.net region id the entity is registered to + self.region_id = int(parts[0]) + #: The Battle.net region the entity is registered to self.region = GATEWAY_LOOKUP[int(parts[0])]