Gave better error messages when a player typeclass has bugs and thus won't load. Also made a better solution for hiding new characters from the start room when first being created (also makes sure that character.location never starts as being None, recovering back to home in that case).

This commit is contained in:
Griatch 2011-10-09 16:32:55 +02:00
parent 8c6b27b5b3
commit aee147102b
3 changed files with 77 additions and 50 deletions

View file

@ -107,10 +107,10 @@ class Character(BaseCharacter):
def at_disconnect(self):
"""
We stove away the character when logging off, otherwise they will remain where
they are, 'headless', so to say.
We stove away the character when logging off, otherwise the character object will
remain in the room also after the player logged off ("headless", so to say).
"""
if self.location: # have to check, in case of multiple connections
if self.location: # have to check, in case of multiple connections closing
self.location.msg_contents("%s has left the game." % self.name)
self.db.prelogout_location = self.location
self.location = None
@ -120,9 +120,14 @@ class Character(BaseCharacter):
This recovers the character again after having been "stoved away" at disconnect.
"""
if self.db.prelogout_location:
self.location = self.db.prelogout_location
else:
self.db.prelogout_location = self.location
# try to recover
self.location = self.db.prelogout_location
if self.location == None:
# make sure location is never None (home should always exist)
self.location = self.home
# save location again to be sure
self.db.prelogout_location = self.location
self.location.msg_contents("%s has entered the game." % self.name)
self.location.at_object_receive(self, self.location)