Patched the batch-processor's interactive mode so it will not abort if it processes an object/script parent that changes the player's state. Also added a variable BATCH_IMPORT_PATH to config so one can keep all batch scripts in one location and don't have to write the full path to get them. Default is the new directory game/gamesrc/world.

Added the permission genperms.admin_nostate so that builders can avoid entering a state when working on a room with a state-changing parent. Superusers have to set the flag ADMIN_NOSTATE on themselves to achieve the same effect (this is necessary since superusers always have all permissions, so they would otherwise never be able to enter states).
/Griatch
This commit is contained in:
Griatch 2009-10-20 22:21:01 +00:00
parent c4114938cc
commit a6ae6e936a
4 changed files with 63 additions and 16 deletions

View file

@ -1090,13 +1090,46 @@ class Object(models.Model):
"""
Only allow setting a state on a player object, otherwise
fail silently.
"""
if self.is_player():
self.state = state_name
This command safeguards the batch processor against dropping
out of interactive mode; it also allows builders to
sidestep room-based states when building (the genperm.admin_nostate
permission is not set on anyone by default, set it temporarily
when building a state-based room).
"""
if not self.is_player():
return False
if self.is_superuser():
# we have to deal with superusers separately since
# they would always appear to have the genperm.admin_nostate
# permission. Instead we expect them to set the flag
# ADMIN_NOSTATE on themselves if they don't want to
# enter states.
nostate = self.has_flag("admin_nostate")
else:
# for other users we request the permission as normal.
nostate = self.has_perm("genperms.admin_nostate")
# we never enter other states if we are in the interactive batch processor.
nostate = nostate or self.state == "_interactive batch processor"
if nostate:
return False
self.state = state_name
return True
def clear_state(self):
"Set to no state (return to normal operation)"
self.state = None
"""
Set to no state (return to normal operation)
This safeguards the batch processor from exiting its
interactive mode when entering a room cancelling states.
(batch processor clears the state directly instead)
"""
if not self.state == "_interactive batch processor":
self.state = None
def purge_object(self):
"Completely clears all aspects of the object."