Fix issue #77, dealing with clearing objects out of a room being @dest'd.

This commit is contained in:
Greg Taylor 2009-10-24 03:49:14 +00:00
parent 4125c93c8b
commit 239af1593d
2 changed files with 8 additions and 17 deletions

View file

@ -534,12 +534,12 @@ class Object(models.Model):
string = 'Destroying object %s but no matching player.' % (self,) string = 'Destroying object %s but no matching player.' % (self,)
functions_general.log_errmsg(string) functions_general.log_errmsg(string)
# Clear out any objects located within the object
self.clear_objects()
# Set the object type to GOING # Set the object type to GOING
self.type = defines_global.OTYPE_GOING self.type = defines_global.OTYPE_GOING
# Destroy any exits to and from this room, do this first # Destroy any exits to and from this room, do this first
self.clear_exits() self.clear_exits()
# Clear out any objects located within the object
self.clear_objects()
self.save() self.save()
def delete(self): def delete(self):
@ -613,9 +613,6 @@ class Object(models.Model):
# If home is still None, it goes to a null location. # If home is still None, it goes to a null location.
obj.move_to(home) obj.move_to(home)
obj.save()
def set_attribute(self, attribute, new_value=None): def set_attribute(self, attribute, new_value=None):
""" """
@ -977,8 +974,7 @@ class Object(models.Model):
quiet: (bool) If true, don't emit left/arrived messages. quiet: (bool) If true, don't emit left/arrived messages.
force_look: (bool) If true and self is a player, make them 'look'. force_look: (bool) If true and self is a player, make them 'look'.
""" """
# First, check if we can enter that location at all.
#first, check if we can enter that location at all.
if not target.scriptlink.enter_lock(self): if not target.scriptlink.enter_lock(self):
lock_desc = self.get_attribute_value("enter_lock_msg") lock_desc = self.get_attribute_value("enter_lock_msg")
if lock_desc: if lock_desc:
@ -987,7 +983,7 @@ class Object(models.Model):
self.emit_to("That destination is blocked from you.") self.emit_to("That destination is blocked from you.")
return return
#before the move, call eventual pre-commands. # Before the move, call eventual pre-commands.
if self.scriptlink.at_before_move(target) != None: if self.scriptlink.at_before_move(target) != None:
return return
@ -996,20 +992,19 @@ class Object(models.Model):
self.scriptlink.announce_move_from(target) self.scriptlink.announce_move_from(target)
source_location = self.location source_location = self.location
#perform move # Perform move
self.location = target self.location = target
self.save() self.save()
if not quiet: if not quiet:
#tell the new room we are there. # Tell the new room we are there.
self.scriptlink.announce_move_to(source_location) self.scriptlink.announce_move_to(source_location)
#execute eventual extra commands on this object after moving it # Execute eventual extra commands on this object after moving it
self.scriptlink.at_after_move() self.scriptlink.at_after_move()
if force_look and self.is_player(): if force_look and self.is_player():
self.execute_cmd('look') self.execute_cmd('look')
def dbref_match(self, oname): def dbref_match(self, oname):
""" """

View file

@ -134,11 +134,7 @@ class SessionProtocol(StatefulTelnetProtocol):
def get_pobject(self): def get_pobject(self):
""" """
Returns the object associated with a session. Returns the object associated with a session.
""" """
# If the pobject is already cached, return it and skip the lookup.
if self.pobject:
return self.pobject
try: try:
# Cache the result in the session object for quick retrieval. # Cache the result in the session object for quick retrieval.
result = Object.objects.get(id=self.uid) result = Object.objects.get(id=self.uid)