Server timekeeper no longer assume 60s between snapshots
This commit is contained in:
parent
cd5beed8d7
commit
586414247f
1 changed files with 8 additions and 1 deletions
|
|
@ -105,6 +105,7 @@ _IDMAPPER_CACHE_MAXSIZE = settings.IDMAPPER_CACHE_MAXSIZE
|
||||||
_GAMETIME_MODULE = None
|
_GAMETIME_MODULE = None
|
||||||
|
|
||||||
_IDLE_TIMEOUT = settings.IDLE_TIMEOUT
|
_IDLE_TIMEOUT = settings.IDLE_TIMEOUT
|
||||||
|
_LAST_SERVER_TIME_SNAPSHOT = None
|
||||||
|
|
||||||
|
|
||||||
def _server_maintenance():
|
def _server_maintenance():
|
||||||
|
|
@ -113,6 +114,8 @@ def _server_maintenance():
|
||||||
the server needs to do. It is called every minute.
|
the server needs to do. It is called every minute.
|
||||||
"""
|
"""
|
||||||
global EVENNIA, _MAINTENANCE_COUNT, _FLUSH_CACHE, _GAMETIME_MODULE
|
global EVENNIA, _MAINTENANCE_COUNT, _FLUSH_CACHE, _GAMETIME_MODULE
|
||||||
|
global _LAST_SERVER_TIME_SNAPSHOT
|
||||||
|
|
||||||
if not _FLUSH_CACHE:
|
if not _FLUSH_CACHE:
|
||||||
from evennia.utils.idmapper.models import conditional_flush as _FLUSH_CACHE
|
from evennia.utils.idmapper.models import conditional_flush as _FLUSH_CACHE
|
||||||
if not _GAMETIME_MODULE:
|
if not _GAMETIME_MODULE:
|
||||||
|
|
@ -126,7 +129,11 @@ def _server_maintenance():
|
||||||
_GAMETIME_MODULE.SERVER_START_TIME = now
|
_GAMETIME_MODULE.SERVER_START_TIME = now
|
||||||
_GAMETIME_MODULE.SERVER_RUNTIME = ServerConfig.objects.conf("runtime", default=0.0)
|
_GAMETIME_MODULE.SERVER_RUNTIME = ServerConfig.objects.conf("runtime", default=0.0)
|
||||||
else:
|
else:
|
||||||
_GAMETIME_MODULE.SERVER_RUNTIME += 60.0
|
# adjust the runtime not with 60s but with the actual elapsed time
|
||||||
|
# in case this may varies slightly from 60s.
|
||||||
|
_GAMETIME_MODULE.SERVER_RUNTIME += (now - _LAST_SERVER_TIME_SNAPSHOT)
|
||||||
|
_LAST_SERVER_TIME_SNAPSHOT = now
|
||||||
|
|
||||||
# update game time and save it across reloads
|
# update game time and save it across reloads
|
||||||
_GAMETIME_MODULE.SERVER_RUNTIME_LAST_UPDATED = now
|
_GAMETIME_MODULE.SERVER_RUNTIME_LAST_UPDATED = now
|
||||||
ServerConfig.objects.conf("runtime", _GAMETIME_MODULE.SERVER_RUNTIME)
|
ServerConfig.objects.conf("runtime", _GAMETIME_MODULE.SERVER_RUNTIME)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue