diff --git a/evennia/settings_default.py b/evennia/settings_default.py index b1e2a7a79e..7948868ed9 100644 --- a/evennia/settings_default.py +++ b/evennia/settings_default.py @@ -490,8 +490,13 @@ TIME_FACTOR = 2.0 # The starting point of your game time (the epoch), in seconds. # In Python a value of 0 means Jan 1 1970 (use negatives for earlier # start date). This will affect the returns from the utils.gametime -# module. +# module. If None, the server's first start-time is used as the epoch. TIME_GAME_EPOCH = None +# Normally, game time will only increase when the server runs. If this is True, +# game time will not pause when the server reloads or goes offline. This setting +# together with a time factor of 1 should keep the game in sync with +# the real time (add a different epoch to shift time) +TIME_IGNORE_DOWNTIMES = False ###################################################################### # Inlinefunc diff --git a/evennia/utils/gametime.py b/evennia/utils/gametime.py index 793e348143..3736128819 100644 --- a/evennia/utils/gametime.py +++ b/evennia/utils/gametime.py @@ -19,6 +19,8 @@ from evennia.utils.create import create_script # to real time. TIMEFACTOR = settings.TIME_FACTOR +IGNORE_DOWNTIMES = settings.TIME_IGNORE_DOWNTIMES + # Only set if gametime_reset was called at some point. GAME_TIME_OFFSET = ServerConfig.objects.conf("gametime_offset", default=0) @@ -133,7 +135,10 @@ def gametime(absolute=False): """ epoch = game_epoch() if absolute else 0 - gtime = epoch + (runtime() - GAME_TIME_OFFSET) * TIMEFACTOR + if IGNORE_DOWNTIMES: + gtime = epoch + (time.time() - server_epoch()) * TIMEFACTOR + else: + gtime = epoch + (runtime() - GAME_TIME_OFFSET) * TIMEFACTOR return gtime