Fixed a bug that prevented objects inside the room designated as "default home" from escaping when deleting that room. Objects will now be dumped to a null location (and warnings be given) instead of being deleted with the room.

Also noticed that large parts of the server is not covered by i18n.
This commit is contained in:
Griatch 2011-11-05 21:19:57 +01:00
parent ce00d7c920
commit 0ed692c19c

View file

@ -310,8 +310,7 @@ class ObjectDB(TypedObject):
hom = home.dbobj hom = home.dbobj
else: else:
hom = home.dbobj hom = home.dbobj
if home: self.db_home = hom
self.db_home = hom
except Exception: except Exception:
string = "Cannot set home: " string = "Cannot set home: "
string += "%s is not a valid home." string += "%s is not a valid home."
@ -746,6 +745,9 @@ class ObjectDB(TypedObject):
default_home_id = int(settings.CHARACTER_DEFAULT_HOME) default_home_id = int(settings.CHARACTER_DEFAULT_HOME)
try: try:
default_home = ObjectDB.objects.get(id=default_home_id) default_home = ObjectDB.objects.get(id=default_home_id)
if default_home.id == self.id:
# we are deleting default home!
default_home = None
except Exception: except Exception:
string = "Could not find default home '(#%d)'." string = "Could not find default home '(#%d)'."
logger.log_errmsg(string % default_home_id) logger.log_errmsg(string % default_home_id)
@ -754,17 +756,19 @@ class ObjectDB(TypedObject):
for obj in objs: for obj in objs:
home = obj.home home = obj.home
# Obviously, we can't send it back to here. # Obviously, we can't send it back to here.
if home and home.id == self.id: if not home or (home and home.id == self.id):
home = default_home obj.home = default_home
# If for some reason it's still None... # If for some reason it's still None...
if not home: if not obj.home:
string = "Missing default home, '%s(#%d)' " string = "Missing default home, '%s(#%d)' "
string += "now has a null location." string += "now has a null location."
obj.location = None
obj.msg("Something went wrong! You are dumped into nowhere. Contact an admin.")
logger.log_errmsg(string % (obj.name, obj.id)) logger.log_errmsg(string % (obj.name, obj.id))
return return
if self.has_player: if obj.has_player:
if home: if home:
string = "Your current location has ceased to exist," string = "Your current location has ceased to exist,"
string += " moving you to %s(#%d)." string += " moving you to %s(#%d)."
@ -812,8 +816,7 @@ class ObjectDB(TypedObject):
for session in self.sessions: for session in self.sessions:
session.msg("Your character %s has been destroyed." % self.name) session.msg("Your character %s has been destroyed." % self.name)
#session.session_disconnect() # no need to disconnect, Player just jumps to OOC mode.
# sever the connection (important!) # sever the connection (important!)
if object.__getattribute__(self, 'player') and self.player: if object.__getattribute__(self, 'player') and self.player:
self.player.character = None self.player.character = None
@ -824,7 +827,7 @@ class ObjectDB(TypedObject):
# if self.player: # if self.player:
# self.player.user.is_active = False # self.player.user.is_active = False
# self.player.user.save() # self.player.user.save(
# Destroy any exits to and from this room, if any # Destroy any exits to and from this room, if any
self.clear_exits() self.clear_exits()