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:
Griatch 2011-08-06 18:56:05 +00:00
parent d466d8325f
commit 2059fd9701
4 changed files with 39 additions and 9 deletions

View file

@ -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
@ -482,7 +482,7 @@ class CmdTime(MuxCommand):
"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()

View file

@ -116,6 +116,9 @@ class ScriptManager(TypedObjectManager):
# 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)

View file

@ -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

View file

@ -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.
@ -160,7 +159,34 @@ def time_format(seconds, style=0):
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):
""" """