From a93d318121bf5b97a33403bdef52b658a9eea240 Mon Sep 17 00:00:00 2001 From: Griatch Date: Mon, 22 Dec 2014 21:46:52 +0100 Subject: [PATCH] Starting to remove obj.typeclass references. Server now starts and stops cleanly, but not yet tested with actual gameplay. --- src/scripts/models.py | 3 +-- src/server/server.py | 29 +++++++++++------------------ src/utils/idmapper/base.py | 2 -- 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/src/scripts/models.py b/src/scripts/models.py index c1717fc0b9..99ec793f4b 100644 --- a/src/scripts/models.py +++ b/src/scripts/models.py @@ -124,8 +124,7 @@ class ScriptDB(TypedObject): obj = _GA(self, "db_player") if not obj: obj = _GA(self, "db_obj") - if obj: - return obj.typeclass + return obj def __set_obj(self, value): """ diff --git a/src/server/server.py b/src/server/server.py index a32b0d9803..618fe5e327 100644 --- a/src/server/server.py +++ b/src/server/server.py @@ -232,8 +232,8 @@ class Evennia(object): self.update_defaults() #print "run_init_hooks:", ObjectDB.get_all_cached_instances() - [(o.typeclass, o.at_init()) for o in ObjectDB.get_all_cached_instances()] - [(p.typeclass, p.at_init()) for p in PlayerDB.get_all_cached_instances()] + [o.at_init() for o in ObjectDB.get_all_cached_instances()] + [p.at_init() for p in PlayerDB.get_all_cached_instances()] with open(SERVER_RESTART, 'r') as f: mode = f.read() @@ -305,11 +305,9 @@ class Evennia(object): if mode == 'reload': # call restart hooks - yield [(o.typeclass, o.at_server_reload()) - for o in ObjectDB.get_all_cached_instances()] - yield [(p.typeclass, p.at_server_reload()) - for p in PlayerDB.get_all_cached_instances()] - yield [(s.typeclass, s.pause(), s.at_server_reload()) + yield [o.at_server_reload() for o in ObjectDB.get_all_cached_instances()] + yield [p.at_server_reload() for p in PlayerDB.get_all_cached_instances()] + yield [(s.pause(), s.at_server_reload()) for s in ScriptDB.get_all_cached_instances()] yield self.sessions.all_sessions_portal_sync() ServerConfig.objects.conf("server_restart_mode", "reload") @@ -325,19 +323,14 @@ class Evennia(object): if mode == 'reset': # don't unset the is_connected flag on reset, otherwise # 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()] + yield [o.at_server_shutdown() for o in ObjectDB.get_all_cached_instances()] + yield [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()) + yield [_SA(p, "is_connected", False) for p in PlayerDB.get_all_cached_instances()] + yield [o.at_server_shutdown() for o in ObjectDB.get_all_cached_instances()] + yield [(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 [s.at_server_shutdown() for s in ScriptDB.get_all_cached_instances()] yield ObjectDB.objects.clear_all_sessids() ServerConfig.objects.conf("server_restart_mode", "reset") diff --git a/src/utils/idmapper/base.py b/src/utils/idmapper/base.py index 70e4a8187c..0b6eb82037 100755 --- a/src/utils/idmapper/base.py +++ b/src/utils/idmapper/base.py @@ -266,7 +266,6 @@ class SharedMemoryModel(Model): def get_all_cached_instances(cls): "return the objects so far cached by idmapper for this class." return cls.__instance_cache__.values() - #get_all_cached_instances = classmethod(get_all_cached_instances) @classmethod def _flush_cached_by_key(cls, key, force=True): @@ -276,7 +275,6 @@ class SharedMemoryModel(Model): del cls.__instance_cache__[key] except KeyError: pass - #_flush_cached_by_key = classmethod(_flush_cached_by_key) @classmethod def flush_cached_instance(cls, instance, force=True):