From 0c2648edaa4662226d68faa3675032f57f2b5ce3 Mon Sep 17 00:00:00 2001 From: Michael King Date: Tue, 7 Aug 2007 16:52:47 +0000 Subject: [PATCH] Removed DEFAULT_HOME from settings.py into a server configuration directive via the confg app. Changed clear_objects to reflect default home changes. --- apps/config/sql/configvalue.sql | 1 + apps/objects/models.py | 16 +++++++++++----- settings.py.dist | 5 ----- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/apps/config/sql/configvalue.sql b/apps/config/sql/configvalue.sql index a3989eec59..e32dc3b859 100644 --- a/apps/config/sql/configvalue.sql +++ b/apps/config/sql/configvalue.sql @@ -4,3 +4,4 @@ INSERT INTO config_configvalue VALUES(3,'money_name_plural','Credits'); INSERT INTO config_configvalue VALUES(4,'money_name_singular','Credit'); INSERT INTO config_configvalue VALUES(5,'game_firstrun','1'); INSERT INTO config_configvalue VALUES(6,'idle_timeout','1800'); +INSERT INTO config_configvalue VALUES(7,'default_home','2'); diff --git a/apps/objects/models.py b/apps/objects/models.py index 59057e7089..49cd3ae8e3 100755 --- a/apps/objects/models.py +++ b/apps/objects/models.py @@ -5,6 +5,7 @@ from django.contrib.auth.models import User, Group import scripthandler import defines_global +import gameconf import ansi class Attribute(models.Model): @@ -427,6 +428,11 @@ class Object(models.Model): # Gather up everything, other than exits and going/garbage, that is under # the belief this is its location. objs = self.obj_location.filter(type__in=[1,2,3]) + default_home_id = gameconf.get_configvalue('default_home') + try: + default_home = Object.objects.get(id=default_home_id) + except: + functions_general.log_errmsg("Could not find default home '(#%d)'." % (default_home_id)) for obj in objs: home = obj.get_home() @@ -437,13 +443,13 @@ class Object(models.Model): # Obviously, we can't send it back to here. if home is self: - home = None + obj.home = default_home + obj.save() + home = default_home + # If for some reason it's still None... if not home: - try: - home = Object.objects.get(id=defines_global.DEFAULT_HOME) - except: - functions_general.log_errmsg("Could not find default home '(#%d)' for %s '%s(#%d)'." % (defines_global.DEFAULT_HOME, text, obj.name, obj.id)) + functions_general.log_errmsg("Missing default home, %s '%s(#%d)' now has a null location." % (text, obj.name, obj.id)) if obj.is_player(): if obj.is_connected(): diff --git a/settings.py.dist b/settings.py.dist index cfe08e2037..c7115f7ef9 100755 --- a/settings.py.dist +++ b/settings.py.dist @@ -1,11 +1,6 @@ # A list of ports to listen on. Can be one or many. GAMEPORTS = [4000] -# The integer dbref of a home for objects that become homeless. This is the room -# where new players start. NOTE: This is based on the default data. If you delete -# #2, you will want to change this. -DEFAULT_HOME = 2 - # While DEBUG is False, show a regular server error page on the web stuff, # email the traceback to the people in the ADMINS tuple below. By default (True), # show a detailed traceback for the web browser to display.