From 1652b4566759177953885ff105b5241013bcded7 Mon Sep 17 00:00:00 2001 From: DegenerateTriangle Date: Fri, 25 Dec 2020 17:22:18 -0500 Subject: [PATCH 1/7] Honor START_LOCATION in default account creation. Currently START_LOCATION is only honored by the "charcreate" command, which is unintuitive. --- evennia/accounts/accounts.py | 1 + 1 file changed, 1 insertion(+) diff --git a/evennia/accounts/accounts.py b/evennia/accounts/accounts.py index 79631881db..d8c7ccd735 100644 --- a/evennia/accounts/accounts.py +++ b/evennia/accounts/accounts.py @@ -687,6 +687,7 @@ class DefaultAccount(AccountDB, metaclass=TypeclassBase): ip=character_ip, typeclass=character_typeclass, permissions=character_permissions, + location=ObjectDB.objects.get_id(settings.START_LOCATION), **kwargs, ) if character: From 6d70182d53208a67500d58e43ea0ad048e897954 Mon Sep 17 00:00:00 2001 From: DegenerateTriangle Date: Fri, 25 Dec 2020 17:22:23 -0500 Subject: [PATCH 2/7] Update .gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 6641f347d9..682ebb5dac 100644 --- a/.gitignore +++ b/.gitignore @@ -50,3 +50,6 @@ twistd.bat # never commit docs/build docs/build +pip-wheel-metadata/evennia.dist-info/LICENSE.txt +pip-wheel-metadata/evennia.dist-info/METADATA +pip-wheel-metadata/evennia.dist-info/top_level.txt From bd868f9a13ba43878490732ed6ec91482c7282eb Mon Sep 17 00:00:00 2001 From: DegenerateTriangle Date: Fri, 25 Dec 2020 17:25:30 -0500 Subject: [PATCH 3/7] Revert "Update .gitignore" This reverts commit 6d70182d53208a67500d58e43ea0ad048e897954. --- .gitignore | 3 --- 1 file changed, 3 deletions(-) diff --git a/.gitignore b/.gitignore index 682ebb5dac..6641f347d9 100644 --- a/.gitignore +++ b/.gitignore @@ -50,6 +50,3 @@ twistd.bat # never commit docs/build docs/build -pip-wheel-metadata/evennia.dist-info/LICENSE.txt -pip-wheel-metadata/evennia.dist-info/METADATA -pip-wheel-metadata/evennia.dist-info/top_level.txt From 171694487501aa5eded17093cf0ada1eebed3761 Mon Sep 17 00:00:00 2001 From: Tim Chaplin Date: Wed, 30 Dec 2020 15:30:52 -0500 Subject: [PATCH 4/7] Make gametime use timezone-aware datetimes This fixes evennia.utils.tests.test_gametime; datetime.fromtimestamp assumes the current system's timezone, so some of the unit tests currently fail if the system's timezone is set to EST (on Windows). --- evennia/utils/gametime.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/evennia/utils/gametime.py b/evennia/utils/gametime.py index b280a83999..d9b5a9b0e0 100644 --- a/evennia/utils/gametime.py +++ b/evennia/utils/gametime.py @@ -8,7 +8,7 @@ total runtime of the server and the current uptime. import time from calendar import monthrange -from datetime import datetime, timedelta +from datetime import datetime, timedelta, timezone from django.conf import settings from evennia import DefaultScript @@ -180,14 +180,14 @@ def real_seconds_until(sec=None, min=None, hour=None, day=None, month=None, year """ - current = datetime.fromtimestamp(gametime(absolute=True)) + current = datetime.fromtimestamp(gametime(absolute=True), timezone.utc) s_sec = sec if sec is not None else current.second s_min = min if min is not None else current.minute s_hour = hour if hour is not None else current.hour s_day = day if day is not None else current.day s_month = month if month is not None else current.month s_year = year if year is not None else current.year - projected = datetime(s_year, s_month, s_day, s_hour, s_min, s_sec) + projected = datetime(s_year, s_month, s_day, s_hour, s_min, s_sec, tzinfo=timezone.utc) if projected <= current: # We increase one unit of time depending on parameters From 5cfdfe95a6b6d9a6ba6dfa58482aeef9a3ff8c4f Mon Sep 17 00:00:00 2001 From: Tim Chaplin Date: Mon, 18 Jan 2021 15:53:50 -0500 Subject: [PATCH 5/7] Revert "Make gametime use timezone-aware datetimes" This reverts commit 171694487501aa5eded17093cf0ada1eebed3761. --- evennia/utils/gametime.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/evennia/utils/gametime.py b/evennia/utils/gametime.py index d9b5a9b0e0..b280a83999 100644 --- a/evennia/utils/gametime.py +++ b/evennia/utils/gametime.py @@ -8,7 +8,7 @@ total runtime of the server and the current uptime. import time from calendar import monthrange -from datetime import datetime, timedelta, timezone +from datetime import datetime, timedelta from django.conf import settings from evennia import DefaultScript @@ -180,14 +180,14 @@ def real_seconds_until(sec=None, min=None, hour=None, day=None, month=None, year """ - current = datetime.fromtimestamp(gametime(absolute=True), timezone.utc) + current = datetime.fromtimestamp(gametime(absolute=True)) s_sec = sec if sec is not None else current.second s_min = min if min is not None else current.minute s_hour = hour if hour is not None else current.hour s_day = day if day is not None else current.day s_month = month if month is not None else current.month s_year = year if year is not None else current.year - projected = datetime(s_year, s_month, s_day, s_hour, s_min, s_sec, tzinfo=timezone.utc) + projected = datetime(s_year, s_month, s_day, s_hour, s_min, s_sec) if projected <= current: # We increase one unit of time depending on parameters From 152e86a7f35911712419cb95f399bcf588e426e7 Mon Sep 17 00:00:00 2001 From: Tim Chaplin Date: Mon, 18 Jan 2021 16:37:20 -0500 Subject: [PATCH 6/7] Don't override location passed through kwargs --- evennia/accounts/accounts.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/evennia/accounts/accounts.py b/evennia/accounts/accounts.py index d8c7ccd735..9bb5acbf29 100644 --- a/evennia/accounts/accounts.py +++ b/evennia/accounts/accounts.py @@ -184,7 +184,7 @@ class DefaultAccount(AccountDB, metaclass=TypeclassBase): - at_server_reload() - at_server_shutdown() - """ + """ objects = AccountManager() @@ -680,6 +680,9 @@ class DefaultAccount(AccountDB, metaclass=TypeclassBase): ) Character = class_from_module(character_typeclass) + if "location" not in kwargs: + kwargs["location"] = ObjectDB.objects.get_id(settings.START_LOCATION) + # Create the character character, errs = Character.create( character_key, @@ -687,7 +690,6 @@ class DefaultAccount(AccountDB, metaclass=TypeclassBase): ip=character_ip, typeclass=character_typeclass, permissions=character_permissions, - location=ObjectDB.objects.get_id(settings.START_LOCATION), **kwargs, ) if character: From e848b9162bd314a941289b2fca8456352bf000e0 Mon Sep 17 00:00:00 2001 From: Tim Chaplin Date: Mon, 18 Jan 2021 17:00:23 -0500 Subject: [PATCH 7/7] Replace absolute timestamps in test_gametime with local datetimes --- evennia/utils/tests/test_gametime.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/evennia/utils/tests/test_gametime.py b/evennia/utils/tests/test_gametime.py index 28291d01a7..9060546cbf 100644 --- a/evennia/utils/tests/test_gametime.py +++ b/evennia/utils/tests/test_gametime.py @@ -2,6 +2,7 @@ Unit tests for the utilities of the evennia.utils.gametime module. """ +from datetime import datetime import time import unittest from unittest.mock import Mock @@ -16,7 +17,7 @@ class TestGametime(TestCase): def setUp(self) -> None: self.time = time.time self._SERVER_EPOCH = gametime._SERVER_EPOCH - time.time = Mock(return_value=1555595378.0) + time.time = Mock(return_value=datetime(2019, 4, 18, 13, 49, 38).timestamp()) gametime._SERVER_EPOCH = None gametime.SERVER_RUNTIME = 600.0 gametime.SERVER_START_TIME = time.time() - 300 @@ -54,7 +55,9 @@ class TestGametime(TestCase): self.assertAlmostEqual(gametime.gametime(), 630.0 * 5) def test_gametime_absolute(self): - self.assertAlmostEqual(gametime.gametime(absolute=True), 1555597898.0) + self.assertAlmostEqual( + gametime.gametime(absolute=True), datetime(2019, 4, 18, 14, 31, 38).timestamp() + ) def test_gametime_downtimes(self): gametime.IGNORE_DOWNTIMES = True