From a528adf65ac9d64dc257d7a31cec8179c4088c82 Mon Sep 17 00:00:00 2001 From: Jonathan <30329245+CookStar@users.noreply.github.com> Date: Mon, 11 Nov 2024 06:29:55 +0900 Subject: [PATCH 1/2] Fixed incorrect Repeat.total_time_remaining. --- addons/source-python/packages/source-python/listeners/tick.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/source-python/packages/source-python/listeners/tick.py b/addons/source-python/packages/source-python/listeners/tick.py index 333fef15e..dca71d2ae 100644 --- a/addons/source-python/packages/source-python/listeners/tick.py +++ b/addons/source-python/packages/source-python/listeners/tick.py @@ -315,9 +315,9 @@ def total_time_remaining(self): :rtype: float """ if self.delay_time_remaining is None: - return None + return 0 return ( - self.loops_remaining * self.interval + + (self.loops_remaining - 1) * self.interval + self.delay_time_remaining ) From 2fc87290c64534472ce787d213b219ea371ba030 Mon Sep 17 00:00:00 2001 From: Jonathan <30329245+CookStar@users.noreply.github.com> Date: Wed, 18 Dec 2024 05:46:21 +0900 Subject: [PATCH 2/2] Changed Delay to return 0 instead of None for certain functions. --- .../packages/source-python/listeners/tick.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/addons/source-python/packages/source-python/listeners/tick.py b/addons/source-python/packages/source-python/listeners/tick.py index dca71d2ae..69ad6ce67 100644 --- a/addons/source-python/packages/source-python/listeners/tick.py +++ b/addons/source-python/packages/source-python/listeners/tick.py @@ -181,8 +181,7 @@ def time_remaining(self): :rtype: float """ if not self.running: - # TODO: what should we return here, or should we raise an error? - return None + return 0 return self.exec_time - time.time() @property @@ -192,8 +191,7 @@ def time_elapsed(self): :rtype: float """ if not self.running: - # TODO: what should we return here, or should we raise an error? - return None + return 0 return time.time() - self._start_time def _unload_instance(self): @@ -314,7 +312,7 @@ def total_time_remaining(self): :rtype: float """ - if self.delay_time_remaining is None: + if not self.delay_time_remaining: return 0 return ( (self.loops_remaining - 1) * self.interval +