mirror of
https://github.com/evennia/evennia.git
synced 2026-03-21 07:16:31 +01:00
Scripts and Exits updated. Fixed some deep issues with Scripts that caused object-based scripts to not properly shut down in some situations, as well as spawn multiple instances of themselves. I think this should resolve all "at_repeat doubling" issues reported. Due to optimizations in the typeclass cache loader in a previous update, the Exit cmdsets were not properly loaded (they were loaded at cache time, which now doesn't happen as often). So Exits instead rely on the new "at_cmdset_get" hook called by the cmdhandler. It allows dynamic modification of cmdsets just before they are accessed. Resolves issue173 (I hope). Resolves issue180. Resolves issue 181.
This commit is contained in:
parent
16affc284b
commit
2b4e008d18
13 changed files with 135 additions and 68 deletions
|
|
@ -91,20 +91,20 @@ def create_object(typeclass, key=None, location=None,
|
|||
player.obj = new_object
|
||||
|
||||
new_object.destination = destination
|
||||
|
||||
|
||||
# call the hook method. This is where all at_creation
|
||||
# customization happens as the typeclass stores custom
|
||||
# things on its database object.
|
||||
# things on its database object.
|
||||
new_object.basetype_setup() # setup the basics of Exits, Characters etc.
|
||||
new_object.at_object_creation()
|
||||
|
||||
# custom-given variables override the hook
|
||||
|
||||
# custom-given perms/locks overwrite hooks
|
||||
if permissions:
|
||||
new_object.permissions = permissions
|
||||
if aliases:
|
||||
new_object.aliases = aliases
|
||||
if locks:
|
||||
new_object.locks.add(locks)
|
||||
if aliases:
|
||||
new_object.aliases = aliases
|
||||
|
||||
# perform a move_to in order to display eventual messages.
|
||||
if home:
|
||||
|
|
@ -114,6 +114,10 @@ def create_object(typeclass, key=None, location=None,
|
|||
else:
|
||||
# rooms would have location=None.
|
||||
new_object.location = None
|
||||
|
||||
# post-hook setup (mainly used by Exits)
|
||||
new_object.basetype_posthook_setup()
|
||||
|
||||
new_object.save()
|
||||
return new_object
|
||||
|
||||
|
|
|
|||
|
|
@ -102,8 +102,9 @@ class SharedMemoryModel(Model):
|
|||
if instance._get_pk_val() is not None:
|
||||
cls.__instance_cache__[instance._get_pk_val()] = instance
|
||||
try:
|
||||
object.__getattribute__(instance, "at_cache")()
|
||||
except (TypeError, AttributeError):
|
||||
object.__getattribute__(instance, "at_cache")()
|
||||
except (TypeError, AttributeError), e:
|
||||
#print e, instance._get_pk_val()
|
||||
pass
|
||||
|
||||
#key = "%s-%s" % (cls, instance.pk)
|
||||
|
|
@ -118,7 +119,7 @@ class SharedMemoryModel(Model):
|
|||
|
||||
|
||||
def _flush_cached_by_key(cls, key):
|
||||
del cls.__instance_cache__[key]
|
||||
del cls.__instance_cache__[key]
|
||||
_flush_cached_by_key = classmethod(_flush_cached_by_key)
|
||||
|
||||
def flush_cached_instance(cls, instance):
|
||||
|
|
|
|||
|
|
@ -128,23 +128,20 @@ def reload_modules():
|
|||
# run through all objects in database, forcing re-caching.
|
||||
|
||||
|
||||
def reload_scripts(scripts=None, obj=None, key=None,
|
||||
dbref=None, init_mode=False):
|
||||
def reload_scripts(scripts=None, obj=None, key=None, dbref=None):
|
||||
"""
|
||||
Run a validation of the script database.
|
||||
obj - only validate scripts on this object
|
||||
key - only validate scripts with this key
|
||||
dbref - only validate the script with this unique idref
|
||||
emit_to_obj - which object to receive error message
|
||||
init_mode - during init-mode, non-persistent scripts are
|
||||
cleaned out. All persistent scripts are force-started.
|
||||
|
||||
"""
|
||||
|
||||
nr_started, nr_stopped = ScriptDB.objects.validate(scripts=scripts,
|
||||
obj=obj, key=key,
|
||||
dbref=dbref,
|
||||
init_mode=init_mode)
|
||||
init_mode=False)
|
||||
if nr_started or nr_stopped:
|
||||
string = " Started %s script(s). Stopped %s invalid script(s)." % \
|
||||
(nr_started, nr_stopped)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue