- implemented @destroy as per the MUX help specifications. As part of this, fixed the object recycling routines to actually properly replace GARBAGE-flagged objects (it crashed before).
- Set up a global cleaner event to clean all @destroyed objects every 30 minutes (makes their dbrefs available). - Added the @recover command for recovering @destroyed objects up until the point that the cleaner runs and actually destroys them. This can recover @destroyed objects, rooms and exits to the same state as before @destroy. It could easily be made to recover player objects too, but I'm thinking this would be a security issue. - Added to @dig in order to allow for creating rooms with a particular parent. Also auto-creates exits in each room if desired. The only things that is not implemented is the aliases of the exits, I don't really know how to do that. - Changed the @create command format to match the @dig (it uses : to mark the parent instead of = now, since MUX' @dig reserve = to the exit list.) - Added extra security in the example event to guard against the bug that causes the whole scheduler to freak out if the event_function() gives a traceback. - Changed many instances of type to point to the defines_global.OTYPE instead of giving the integer explicitly. /Starkiel
This commit is contained in:
parent
8799a0fd55
commit
3eb4cddf42
8 changed files with 274 additions and 77 deletions
|
|
@ -9,6 +9,8 @@ import time
|
|||
from twisted.internet import task
|
||||
import session_mgr
|
||||
from src import scheduler
|
||||
from src import defines_global
|
||||
from src.objects.models import Object
|
||||
|
||||
class IntervalEvent(object):
|
||||
"""
|
||||
|
|
@ -71,6 +73,8 @@ class IntervalEvent(object):
|
|||
self.set_lastfired()
|
||||
self.event_function()
|
||||
|
||||
|
||||
|
||||
class IEvt_Check_Sessions(IntervalEvent):
|
||||
"""
|
||||
Event: Check all of the connected sessions.
|
||||
|
|
@ -87,10 +91,30 @@ class IEvt_Check_Sessions(IntervalEvent):
|
|||
"""
|
||||
session_mgr.check_all_sessions()
|
||||
|
||||
class IEvt_Destroy_Objects(IntervalEvent):
|
||||
"""
|
||||
Event: Clean out all objects marked for destruction.
|
||||
"""
|
||||
def __init__(self):
|
||||
super(IEvt_Destroy_Objects, self).__init__()
|
||||
self.name = 'IEvt_Destroy_Objects'
|
||||
self.interval = 1800
|
||||
self.description = "Destroy objects with the GOING flag set."
|
||||
|
||||
def event_function(self):
|
||||
"""
|
||||
This is the function that is fired every self.interval seconds.
|
||||
"""
|
||||
going_objects = Object.objects.filter(type__exact=defines_global.OTYPE_GOING)
|
||||
for obj in going_objects:
|
||||
obj.delete()
|
||||
|
||||
def add_global_events():
|
||||
"""
|
||||
When the server is started up, this is triggered to add all of the
|
||||
events in this file to the scheduler.
|
||||
"""
|
||||
# Create an instance and add it to the scheduler.
|
||||
scheduler.add_event(IEvt_Check_Sessions())
|
||||
scheduler.add_event(IEvt_Check_Sessions())
|
||||
scheduler.add_event(IEvt_Destroy_Objects())
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue