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.

This commit is contained in:
Griatch 2011-08-06 19:39:06 +00:00
parent 2059fd9701
commit 16affc284b
5 changed files with 9 additions and 7 deletions

View file

@ -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)

View file

@ -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

View file

@ -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:

View file

@ -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)

View file

@ -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