Fixed a bug that had global scripts think they were already running. Resolves issue 176. Made the @time command a tad more useful by having it report uptime also in seconds.
This commit is contained in:
parent
d466d8325f
commit
2059fd9701
4 changed files with 39 additions and 9 deletions
|
|
@ -5,7 +5,7 @@ System commands
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import traceback
|
import traceback
|
||||||
import os, datetime
|
import os, datetime, time
|
||||||
import django, twisted
|
import django, twisted
|
||||||
|
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
|
|
@ -476,13 +476,13 @@ class CmdTime(MuxCommand):
|
||||||
|
|
||||||
def func(self):
|
def func(self):
|
||||||
"Show times."
|
"Show times."
|
||||||
|
|
||||||
table = [["Current server uptime:",
|
table = [["Current server uptime:",
|
||||||
"Total server running time:",
|
"Total server running time:",
|
||||||
"Total in-game time (realtime x %g):" % (gametime.TIMEFACTOR),
|
"Total in-game time (realtime x %g):" % (gametime.TIMEFACTOR),
|
||||||
"Server time stamp:"
|
"Server time stamp:"
|
||||||
],
|
],
|
||||||
[utils.time_format(gametime.uptime(format=False), 2),
|
[utils.time_format(time.time() - SESSIONS.server.start_time, 3),
|
||||||
utils.time_format(gametime.runtime(format=False), 2),
|
utils.time_format(gametime.runtime(format=False), 2),
|
||||||
utils.time_format(gametime.gametime(format=False), 2),
|
utils.time_format(gametime.gametime(format=False), 2),
|
||||||
datetime.datetime.now()
|
datetime.datetime.now()
|
||||||
|
|
|
||||||
|
|
@ -114,8 +114,11 @@ class ScriptManager(TypedObjectManager):
|
||||||
|
|
||||||
if init_mode:
|
if init_mode:
|
||||||
# special mode when server starts or object logs in.
|
# special mode when server starts or object logs in.
|
||||||
# This deletes all non-persistent scripts from database
|
# This deletes all non-persistent scripts from database
|
||||||
nr_stopped += self.remove_non_persistent(obj=obj)
|
nr_stopped += self.remove_non_persistent(obj=obj)
|
||||||
|
# turn off the activity flag for all remaining scripts
|
||||||
|
for script in self.all():
|
||||||
|
script.is_active = False
|
||||||
|
|
||||||
if dbref and self.dbref(dbref):
|
if dbref and self.dbref(dbref):
|
||||||
scripts = self.get_id(dbref)
|
scripts = self.get_id(dbref)
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,7 @@ class GameTime(Script):
|
||||||
self.desc = "Keeps track of the game time"
|
self.desc = "Keeps track of the game time"
|
||||||
self.interval = REAL_MIN # update every minute
|
self.interval = REAL_MIN # update every minute
|
||||||
self.persistent = True
|
self.persistent = True
|
||||||
|
self.start_delay = True
|
||||||
self.attr("game_time", 0.0) #IC time
|
self.attr("game_time", 0.0) #IC time
|
||||||
self.attr("run_time", 0.0) #OOC time
|
self.attr("run_time", 0.0) #OOC time
|
||||||
self.attr("up_time", 0.0) #OOC time
|
self.attr("up_time", 0.0) #OOC time
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,6 @@ def time_format(seconds, style=0):
|
||||||
return '%im' % (minutes,)
|
return '%im' % (minutes,)
|
||||||
else:
|
else:
|
||||||
return '%is' % (seconds,)
|
return '%is' % (seconds,)
|
||||||
|
|
||||||
elif style is 2:
|
elif style is 2:
|
||||||
"""
|
"""
|
||||||
Full-detailed, long-winded format. We ignore seconds.
|
Full-detailed, long-winded format. We ignore seconds.
|
||||||
|
|
@ -158,10 +157,37 @@ def time_format(seconds, style=0):
|
||||||
if minutes == 1:
|
if minutes == 1:
|
||||||
minutes_str = '%i minute ' % minutes
|
minutes_str = '%i minute ' % minutes
|
||||||
else:
|
else:
|
||||||
minutes_str = '%i minutes ' % minutes
|
minutes_str = '%i minutes ' % minutes
|
||||||
retval = '%s%s%s' % (days_str, hours_str, minutes_str)
|
retval = '%s%s%s' % (days_str, hours_str, minutes_str)
|
||||||
return retval
|
elif style is 3:
|
||||||
|
"""
|
||||||
|
Full-detailed, long-winded format. Includes seconds.
|
||||||
|
"""
|
||||||
|
days_str = hours_str = minutes_str = seconds_str = ''
|
||||||
|
if days > 0:
|
||||||
|
if days == 1:
|
||||||
|
days_str = '%i day, ' % days
|
||||||
|
else:
|
||||||
|
days_str = '%i days, ' % days
|
||||||
|
if days or hours > 0:
|
||||||
|
if hours == 1:
|
||||||
|
hours_str = '%i hour, ' % hours
|
||||||
|
else:
|
||||||
|
hours_str = '%i hours, ' % hours
|
||||||
|
if hours or minutes > 0:
|
||||||
|
if minutes == 1:
|
||||||
|
minutes_str = '%i minute ' % minutes
|
||||||
|
else:
|
||||||
|
minutes_str = '%i minutes ' % minutes
|
||||||
|
if minutes or seconds > 0:
|
||||||
|
if seconds == 1:
|
||||||
|
seconds_str = '%i second ' % seconds
|
||||||
|
else:
|
||||||
|
seconds_str = '%i seconds ' % seconds
|
||||||
|
retval = '%s%s%s%s' % (days_str, hours_str, minutes_str, seconds_str)
|
||||||
|
|
||||||
|
return retval
|
||||||
|
|
||||||
def datetime_format(dtobj):
|
def datetime_format(dtobj):
|
||||||
"""
|
"""
|
||||||
Takes a datetime object instance (e.g. from django's DateTimeField)
|
Takes a datetime object instance (e.g. from django's DateTimeField)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue