From 16affc284b93bd4a80923ed895f160083f80da3b Mon Sep 17 00:00:00 2001 From: Griatch Date: Sat, 6 Aug 2011 19:39:06 +0000 Subject: [PATCH] Allow for changing the home location of new characters by changing a setting. The given location must exist and is given as a dbref. If one wants more advanced control over start locations, one needs to customize the unloggedin/create command to match the particular game. Resolves issue 178. --- src/commands/default/tests.py | 2 +- src/commands/default/unloggedin.py | 3 +-- src/objects/models.py | 5 ++--- src/server/initial_setup.py | 1 - src/settings_default.py | 5 +++++ 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/commands/default/tests.py b/src/commands/default/tests.py index b9dc34aee8..9bff1d0cd8 100644 --- a/src/commands/default/tests.py +++ b/src/commands/default/tests.py @@ -94,7 +94,7 @@ class CommandTest(TestCase): def setUp(self): "sets up the testing environment" - ServerConfig.objects.conf("default_home", 2) + #ServerConfig.objects.conf("default_home", 2) self.addCleanup(cleanup) diff --git a/src/commands/default/unloggedin.py b/src/commands/default/unloggedin.py index a6caadbe64..8156524a6c 100644 --- a/src/commands/default/unloggedin.py +++ b/src/commands/default/unloggedin.py @@ -154,8 +154,7 @@ class CmdCreate(MuxCommand): # everything's ok. Create the new player account. try: - default_home_id = ServerConfig.objects.conf("default_home") - default_home = ObjectDB.objects.get_id(default_home_id) + default_home = ObjectDB.objects.get_id(settings.CHARACTER_DEFAULT_HOME) typeclass = settings.BASE_CHARACTER_TYPECLASS permissions = settings.PERMISSION_PLAYER_DEFAULT diff --git a/src/objects/models.py b/src/objects/models.py index fa520321b6..c49f62cfc3 100644 --- a/src/objects/models.py +++ b/src/objects/models.py @@ -655,8 +655,7 @@ class ObjectDB(TypedObject): if self.home: source_location = self.home else: - default_home_id = ServerConfig.objects.conf("default_home") - default_home = ObjectDB.objects.get_id(default_home_id) + default_home = ObjectDB.objects.get_id(settings.CHARACTER_DEFAULT_HOME) source_location = default_home # Call hook on source location @@ -738,7 +737,7 @@ class ObjectDB(TypedObject): """ # Gather up everything that thinks this is its location. objs = ObjectDB.objects.filter(db_location=self) - default_home_id = int(ServerConfig.objects.conf('default_home')) + default_home_id = int(settings.CHARACTER_DEFAULT_HOME) try: default_home = ObjectDB.objects.get(id=default_home_id) except Exception: diff --git a/src/server/initial_setup.py b/src/server/initial_setup.py index 79041ca0e3..e89aaaf90b 100644 --- a/src/server/initial_setup.py +++ b/src/server/initial_setup.py @@ -17,7 +17,6 @@ def create_config_values(): """ Creates the initial config values. """ - ServerConfig.objects.conf("default_home", '2') ServerConfig.objects.conf("site_name", settings.SERVERNAME) ServerConfig.objects.conf("idle_timeout", settings.IDLE_TIMEOUT) diff --git a/src/settings_default.py b/src/settings_default.py index 317bcb78ad..8d4625b280 100644 --- a/src/settings_default.py +++ b/src/settings_default.py @@ -197,6 +197,11 @@ BASE_CHARACTER_TYPECLASS = "game.gamesrc.objects.baseobjects.Character" BASE_ROOM_TYPECLASS = "game.gamesrc.objects.baseobjects.Room" # Typeclass for Exit objects (fallback) BASE_EXIT_TYPECLASS = "game.gamesrc.objects.baseobjects.Exit" +# The home location for new characters. This must be a unique +# dbref (default is Limbo #2). If you want more advanced control over +# start locations, copy the "create" command from +# src/commands/default/unloggedin.py and customize. +CHARACTER_DEFAULT_HOME = "2" ################################################### # Batch processors