mirror of
https://github.com/evennia/evennia.git
synced 2026-03-19 06: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
|
|
@ -88,8 +88,8 @@ class ScriptManager(TypedObjectManager):
|
|||
key = validate only scripts with a particular key
|
||||
dbref = validate only the single script with this particular id.
|
||||
|
||||
init_mode - When this mode is active, non-persistent scripts
|
||||
will be removed and persistent scripts will be
|
||||
init_mode - This is used during server upstart. It causes non-persistent
|
||||
scripts to be removed and persistent scripts to be
|
||||
force-restarted.
|
||||
|
||||
This method also makes sure start any scripts it validates,
|
||||
|
|
@ -117,26 +117,30 @@ class ScriptManager(TypedObjectManager):
|
|||
# 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
|
||||
scripts = self.get_all_scripts()
|
||||
for script in scripts:
|
||||
script.dbobj.is_active = False
|
||||
|
||||
elif not scripts:
|
||||
# normal operation
|
||||
if dbref and self.dbref(dbref):
|
||||
scripts = self.get_id(dbref)
|
||||
elif obj:
|
||||
scripts = self.get_all_scripts_on_obj(obj, key=key)
|
||||
else:
|
||||
scripts = self.get_all_scripts(key=key) #self.model.get_all_cached_instances()
|
||||
|
||||
if dbref and self.dbref(dbref):
|
||||
scripts = self.get_id(dbref)
|
||||
elif scripts:
|
||||
pass
|
||||
elif obj:
|
||||
scripts = self.get_all_scripts_on_obj(obj, key=key)
|
||||
else:
|
||||
scripts = self.model.get_all_cached_instances()#get_all_scripts(key=key)
|
||||
if not scripts:
|
||||
# no scripts available to validate
|
||||
VALIDATE_ITERATION -= 1
|
||||
return None, None
|
||||
|
||||
#print "scripts to validate: [%s]" % (", ".join(script.key for script in scripts))
|
||||
for script in scripts:
|
||||
if script.is_valid():
|
||||
#print "validating %s (%i)" % (script.key, id(script.dbobj))
|
||||
#print "validating %s (%i) (init_mode=%s)" % (script.key, id(script.dbobj), init_mode)
|
||||
nr_started += script.start(force_restart=init_mode)
|
||||
#print "back from start."
|
||||
#print "back from start. nr_started=", nr_started
|
||||
else:
|
||||
script.stop()
|
||||
nr_stopped += 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue