From 9e3285a791a7e63b5f4e9b72a02ba5e25e5cea5d Mon Sep 17 00:00:00 2001 From: Griatch Date: Sun, 8 Sep 2019 20:17:04 +0200 Subject: [PATCH] Handle drop with drop:holds() lock. Default to pass for backwards-compatibilty while on Evennia 0.9. See #1868 --- CHANGELOG.md | 3 +++ evennia/objects/objects.py | 18 +++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1305c857c8..2a9bc3ed65 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## Evennia 1.0 (2019-) (WIP) +- new `drop:holds()` lock default to limit dropping nonsensical things. Access check + defaults to True for backwards-compatibility in 0.9, will be False in 1.0 + ### Already in master - `py` command now reroutes stdout to output results in-game client. `py` diff --git a/evennia/objects/objects.py b/evennia/objects/objects.py index 9fe152513e..bb6f6b5c64 100644 --- a/evennia/objects/objects.py +++ b/evennia/objects/objects.py @@ -194,7 +194,8 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)): """ # lockstring of newly created objects, for easy overloading. # Will be formatted with the appropriate attributes. - lockstring = "control:id({account_id}) or perm(Admin);delete:id({account_id}) or perm(Admin)" + lockstring = ("control:id({account_id}) or perm(Admin);" + "delete:id({account_id}) or perm(Admin)") objects = ObjectManager() @@ -1132,13 +1133,14 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)): self.locks.add(";".join([ "control:perm(Developer)", # edit locks/permissions, delete - "examine:perm(Builder)", # examine properties + "examine:perm(Builder)", # examine properties "view:all()", # look at object (visibility) - "edit:perm(Admin)", # edit properties/attributes - "delete:perm(Admin)", # delete object + "edit:perm(Admin)", # edit properties/attributes + "delete:perm(Admin)", # delete object "get:all()", # pick up object + "drop:holds()" # drop only that which you hold "call:true()", # allow to call commands on this object - "tell:perm(Admin)", # allow emits to this object + "tell:perm(Admin)", # allow emits to this object "puppet:pperm(Developer)"])) # lock down puppeting only to staff by default def basetype_posthook_setup(self): @@ -1752,6 +1754,12 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)): before it is even started. """ + if not self.locks.get("drop"): + # TODO: This if-statment will be removed in Evennia 1.0 + return True + if not self.access(dropper, 'drop', default=False): + dropper.msg(f"You cannot drop {self.get_display_name(dropper)}") + return False return True def at_drop(self, dropper, **kwargs):