Fix error in at_pre_puppet when neither last-location, nor home is set

This commit is contained in:
Griatch 2023-07-28 16:18:54 +02:00
parent b168fbd747
commit ce5d795654

View file

@ -2661,20 +2661,20 @@ class DefaultCharacter(DefaultObject):
session (Session): Session controlling the connection. session (Session): Session controlling the connection.
""" """
if ( if self.location is None:
self.location is None # Make sure character's location is never None before being puppeted.
): # Make sure character's location is never None before being puppeted. # Return to last location (or home, which should always exist)
# Return to last location (or home, which should always exist), location = self.db.prelogout_location if self.db.prelogout_location else self.home
self.location = self.db.prelogout_location if self.db.prelogout_location else self.home if location:
self.location.at_object_receive( self.location = location
self, None 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:
self.db.prelogout_location = self.location # save location again to be sure. self.db.prelogout_location = self.location # save location again to be sure.
else: else:
account.msg( account.msg(
_("|r{obj} has no location and no home is set.|n").format(obj=self), session=session _("|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): def at_post_puppet(self, **kwargs):
""" """