From e76061ee4c66bbac52a395d18aeb5e29e25e9b0a Mon Sep 17 00:00:00 2001 From: Griatch Date: Sat, 12 Apr 2014 16:25:19 +0200 Subject: [PATCH] Fixed some issues with which hooks the reset command calls. Resolves #499. --- src/commands/default/player.py | 2 +- src/commands/default/system.py | 2 +- src/players/bots.py | 6 ++++++ src/server/server.py | 7 ++++--- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/commands/default/player.py b/src/commands/default/player.py index ac065f151e..021e639446 100644 --- a/src/commands/default/player.py +++ b/src/commands/default/player.py @@ -393,7 +393,7 @@ class CmdWho(MuxPlayerCommand): table.add_row([utils.crop(plr_pobject.name, width=25), utils.time_format(delta_conn, 0), utils.time_format(delta_cmd, 1), - hasattr(plr_pobject, "location") and plr_pobject.location.key or "None", + hasattr(plr_pobject, "location") and plr_pobject.location and plr_pobject.location.key or "None", session.cmd_total, session.protocol_key, isinstance(session.address, tuple) and session.address[0] or session.address]) diff --git a/src/commands/default/system.py b/src/commands/default/system.py index 639718789b..bf7c62bc32 100644 --- a/src/commands/default/system.py +++ b/src/commands/default/system.py @@ -81,7 +81,7 @@ class CmdReset(MuxCommand): """ Reload the system. """ - SESSIONS.announce_all(" Server restarting ...") + SESSIONS.announce_all(" Server resetting/restarting ...") SESSIONS.server.shutdown(mode='reset') diff --git a/src/players/bots.py b/src/players/bots.py index 205edb208a..6a32b19261 100644 --- a/src/players/bots.py +++ b/src/players/bots.py @@ -128,6 +128,12 @@ class Bot(Player): """ pass + def at_server_shutdown(self): + "We need to handle this case manually since the shutdown may be a reset" + print "bots at_server_shutdown called" + for session in self.get_all_sessions(): + session.sessionhandler.disconnect(session) + # Bot implementations diff --git a/src/server/server.py b/src/server/server.py index 0078022cf2..31982d5786 100644 --- a/src/server/server.py +++ b/src/server/server.py @@ -325,14 +325,15 @@ class Evennia(object): # same as shutdown yield [(o.typeclass, o.at_server_shutdown()) for o in ObjectDB.get_all_cached_instances()] + yield [(p.typeclass, p.at_server_shutdown()) + for p in PlayerDB.get_all_cached_instances()] else: # shutdown yield [_SA(p, "is_connected", False) for p in PlayerDB.get_all_cached_instances()] yield [(o.typeclass, o.at_server_shutdown()) for o in ObjectDB.get_all_cached_instances()] - - yield [(p.typeclass, p.unpuppet_all(), p.at_server_shutdown()) - for p in PlayerDB.get_all_cached_instances()] + yield [(p.typeclass, p.unpuppet_all(), p.at_server_shutdown()) + for p in PlayerDB.get_all_cached_instances()] yield [(s.typeclass, s.at_server_shutdown()) for s in ScriptDB.get_all_cached_instances()] yield ObjectDB.objects.clear_all_sessids()