From ce5d79565405e19606f4eb16cd0b2395d325012a Mon Sep 17 00:00:00 2001 From: Griatch Date: Fri, 28 Jul 2023 16:18:54 +0200 Subject: [PATCH] Fix error in at_pre_puppet when neither last-location, nor home is set --- evennia/objects/objects.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/evennia/objects/objects.py b/evennia/objects/objects.py index fdab9aa26c..a2a6200162 100644 --- a/evennia/objects/objects.py +++ b/evennia/objects/objects.py @@ -2661,20 +2661,20 @@ class DefaultCharacter(DefaultObject): session (Session): Session controlling the connection. """ - if ( - self.location is None - ): # Make sure character's location is never None before being puppeted. - # Return to last location (or home, which should always exist), - self.location = self.db.prelogout_location if self.db.prelogout_location else self.home - self.location.at_object_receive( - self, None - ) # and trigger the location's reception hook. - if self.location: # If the character is verified to be somewhere, + if self.location is None: + # Make sure character's location is never None before being puppeted. + # Return to last location (or home, which should always exist) + location = self.db.prelogout_location if self.db.prelogout_location else self.home + if location: + self.location = location + self.location.at_object_receive(self, None) + + if self.location: self.db.prelogout_location = self.location # save location again to be sure. else: account.msg( _("|r{obj} has no location and no home is set.|n").format(obj=self), session=session - ) # Note to set home. + ) def at_post_puppet(self, **kwargs): """