diff --git a/evennia/prototypes/prototypes.py b/evennia/prototypes/prototypes.py index c369e4fa89..a413a5f57b 100644 --- a/evennia/prototypes/prototypes.py +++ b/evennia/prototypes/prototypes.py @@ -187,7 +187,7 @@ def homogenize_prototype(prototype, custom_keys=None): "prototype-{}".format(hashlib.md5(bytes(str(time.time()), "utf-8")).hexdigest()[:7]), ) homogenized["prototype_tags"] = homogenized.get("prototype_tags", []) - homogenized["prototype_locks"] = homogenized.get("prototype_lock", _PROTOTYPE_FALLBACK_LOCK) + homogenized["prototype_locks"] = homogenized.get("prototype_locks", _PROTOTYPE_FALLBACK_LOCK) homogenized["prototype_desc"] = homogenized.get("prototype_desc", "") if "typeclass" not in prototype and "prototype_parent" not in prototype: homogenized["typeclass"] = settings.BASE_OBJECT_TYPECLASS diff --git a/evennia/prototypes/tests.py b/evennia/prototypes/tests.py index 4a0b1d1a1b..c2c8d223e3 100644 --- a/evennia/prototypes/tests.py +++ b/evennia/prototypes/tests.py @@ -402,6 +402,39 @@ class TestProtLib(BaseEvenniaTest): match = protlib.search_prototype(self.prot["prototype_key"].upper()) self.assertEqual(match, [self.prot]) + def test_homogenize_prototype_locks_preserved(self): + """Test that homogenize_prototype preserves custom prototype_locks. (Bug 3828)""" + from evennia.prototypes.prototypes import _PROTOTYPE_FALLBACK_LOCK + + prot_with_locks = { + "prototype_key": "test_prot_with_locks", + "typeclass": "evennia.objects.objects.DefaultObject", + "prototype_locks": "spawn:perm(Builder);edit:perm(Admin)", + } + homogenized = protlib.homogenize_prototype(prot_with_locks) + self.assertEqual( + homogenized["prototype_locks"], + "spawn:perm(Builder);edit:perm(Admin)", + ) + self.assertNotEqual( + homogenized["prototype_locks"], + _PROTOTYPE_FALLBACK_LOCK, + ) + + def test_homogenize_prototype_locks_default_fallback(self): + """Test that homogenize_prototype uses default when prototype_locks not provided.""" + from evennia.prototypes.prototypes import _PROTOTYPE_FALLBACK_LOCK + + prot_without_locks = { + "prototype_key": "test_prot_without_locks", + "typeclass": "evennia.objects.objects.DefaultObject", + } + homogenized = protlib.homogenize_prototype(prot_without_locks) + self.assertEqual( + homogenized["prototype_locks"], + _PROTOTYPE_FALLBACK_LOCK, + ) + class TestProtFuncs(BaseEvenniaTest): @override_settings(PROT_FUNC_MODULES=["evennia.prototypes.protfuncs"])