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 os, datetime
import os, datetime, time
import django, twisted
from django.contrib.auth.models import User
@ -476,13 +476,13 @@ class CmdTime(MuxCommand):
def func(self):
"Show times."
table = [["Current server uptime:",
"Total server running time:",
"Total in-game time (realtime x %g):" % (gametime.TIMEFACTOR),
"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.gametime(format=False), 2),
datetime.datetime.now()

View file

@ -114,8 +114,11 @@ class ScriptManager(TypedObjectManager):
if init_mode:
# 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)
# turn off the activity flag for all remaining scripts
for script in self.all():
script.is_active = False
if dbref and self.dbref(dbref):
scripts = self.get_id(dbref)

View file

@ -53,6 +53,7 @@ class GameTime(Script):
self.desc = "Keeps track of the game time"
self.interval = REAL_MIN # update every minute
self.persistent = True
self.start_delay = True
self.attr("game_time", 0.0) #IC time
self.attr("run_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,)
else:
return '%is' % (seconds,)
elif style is 2:
"""
Full-detailed, long-winded format. We ignore seconds.
@ -158,10 +157,37 @@ def time_format(seconds, style=0):
if minutes == 1:
minutes_str = '%i minute ' % minutes
else:
minutes_str = '%i minutes ' % minutes
retval = '%s%s%s' % (days_str, hours_str, minutes_str)
return retval
minutes_str = '%i minutes ' % minutes
retval = '%s%s%s' % (days_str, hours_str, minutes_str)
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):
"""
Takes a datetime object instance (e.g. from django's DateTimeField)