diff --git a/evennia/commands/default/tests.py b/evennia/commands/default/tests.py index 9b6ac7d1ab..c1166939c8 100644 --- a/evennia/commands/default/tests.py +++ b/evennia/commands/default/tests.py @@ -1405,6 +1405,7 @@ class TestBuilding(EvenniaCommandTest): "Could not find 'Obj'.| (Objects to destroy " "must either be local or specified with a unique #dbref.)", ) + settings.DEFAULT_HOME = f"#{self.room1.dbid}" self.call( building.CmdDestroy(), settings.DEFAULT_HOME, "You are trying to delete" ) # DEFAULT_HOME should not be deleted diff --git a/evennia/contrib/game_systems/crafting/tests.py b/evennia/contrib/game_systems/crafting/tests.py index 32ac22c7c2..7386f190f0 100644 --- a/evennia/contrib/game_systems/crafting/tests.py +++ b/evennia/contrib/game_systems/crafting/tests.py @@ -654,7 +654,7 @@ class TestCraftSword(BaseEvenniaTestCase): @mock.patch("evennia.contrib.game_systems.crafting.crafting._load_recipes", new=mock.MagicMock()) @mock.patch("evennia.contrib.game_systems.crafting.crafting._RECIPE_CLASSES", new={"testrecipe": _MockRecipe}) -@override_settings(CRAFT_RECIPE_MODULES=[], DEFAULT_HOME="#999999") +@override_settings(CRAFT_RECIPE_MODULES=[]) class TestCraftCommand(EvenniaCommandTest): """Test the crafting command""" diff --git a/evennia/objects/manager.py b/evennia/objects/manager.py index 724a8588a9..851a3da1d9 100644 --- a/evennia/objects/manager.py +++ b/evennia/objects/manager.py @@ -676,15 +676,19 @@ class ObjectDBManager(TypedObjectManager): location = dbid_to_obj(location, self.model) destination = dbid_to_obj(destination, self.model) - home = dbid_to_obj(home, self.model) - if not home: + if home: + home = dbid_to_obj(home, self.model) + + if not nohome and not home: try: - home = dbid_to_obj(settings.DEFAULT_HOME, self.model) if not nohome else None - except self.model_ObjectDB.DoesNotExist: + home = dbid_to_obj(settings.DEFAULT_HOME, self.model) + except self.model.DoesNotExist: raise self.model.DoesNotExist( "settings.DEFAULT_HOME (= '%s') does not exist, or the setting is malformed." % settings.DEFAULT_HOME ) + elif nohome and not home: + home = None # create new instance new_object = typeclass( diff --git a/evennia/prototypes/prototypes.py b/evennia/prototypes/prototypes.py index 2e83d698a2..1f666d931a 100644 --- a/evennia/prototypes/prototypes.py +++ b/evennia/prototypes/prototypes.py @@ -31,7 +31,6 @@ from evennia.utils.funcparser import FuncParser from evennia.utils import dbserialize from evennia.utils.evtable import EvTable - _MODULE_PROTOTYPE_MODULES = {} _MODULE_PROTOTYPES = {} _PROTOTYPE_META_NAMES = ( @@ -516,6 +515,10 @@ def search_prototype(key=None, tags=None, require_single=False, return_iterators be found as a match. """ + # This will load the prototypes the first time they are searched + if not _MODULE_PROTOTYPE_MODULES: + load_module_prototypes() + # prototype keys are always in lowecase if key: key = key.lower() diff --git a/evennia/utils/test_resources.py b/evennia/utils/test_resources.py index 2f3967086e..edf66e6668 100644 --- a/evennia/utils/test_resources.py +++ b/evennia/utils/test_resources.py @@ -152,13 +152,12 @@ class EvenniaTestMixin: if hasattr(self, "account2"): self.account2.delete() + # Set up fake prototype module for allowing tests to use named prototypes. + @override_settings(PROTOTYPE_MODULES=["evennia.utils.tests.data.prototypes_example"], DEFAULT_HOME="#1") def create_rooms(self): self.room1 = create.create_object(self.room_typeclass, key="Room", nohome=True) self.room1.db.desc = "room_desc" - settings.DEFAULT_HOME = "#%i" % self.room1.id # we must have a default home - # Set up fake prototype module for allowing tests to use named prototypes. - settings.PROTOTYPE_MODULES = "evennia.utils.tests.data.prototypes_example" self.room2 = create.create_object(self.room_typeclass, key="Room2") self.exit = create.create_object( self.exit_typeclass, key="out", location=self.room1, destination=self.room2