Stop #dbref searches for unprivileged. Other minor fixes. Resolves #1251.

This commit is contained in:
Griatch 2017-10-01 16:51:41 +02:00
parent 3938dd45f7
commit d2e8badf18
4 changed files with 25 additions and 16 deletions

View file

@ -824,7 +824,7 @@ class CmdQuell(COMMAND_DEFAULT_CLASS):
"""Perform the command"""
account = self.account
permstr = account.is_superuser and " (superuser)" or "(%s)" % (", ".join(account.permissions.all()))
if self.cmdstring == '@unquell':
if self.cmdstring in ('unquell', '@unquell'):
if not account.attributes.get('_quell'):
self.msg("Already using normal Account permissions %s." % permstr)
else:

View file

@ -67,7 +67,7 @@ class CmdLook(COMMAND_DEFAULT_CLASS):
caller.msg("You have no location to look at!")
return
else:
target = caller.search(self.args, use_dbref=caller.check_permstring("Builders"))
target = caller.search(self.args)
if not target:
return
self.msg(caller.at_look(target))
@ -266,7 +266,7 @@ class CmdGet(COMMAND_DEFAULT_CLASS):
else:
caller.msg("You can't get that.")
return
# calling at_before_get hook method
if not obj.at_before_get(caller):
return
@ -311,7 +311,7 @@ class CmdDrop(COMMAND_DEFAULT_CLASS):
multimatch_string="You carry more than one %s:" % self.args)
if not obj:
return
# Call the object script's at_before_drop() method.
if not obj.at_before_drop(caller):
return
@ -358,11 +358,11 @@ class CmdGive(COMMAND_DEFAULT_CLASS):
if not to_give.location == caller:
caller.msg("You are not holding %s." % to_give.key)
return
# calling at_before_give hook method
if not to_give.at_before_give(caller, target):
return
# give object
caller.msg("You give %s to %s." % (to_give.key, target.key))
to_give.move_to(target, quiet=True)

View file

@ -292,7 +292,7 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
candidates=None,
nofound_string=None,
multimatch_string=None,
use_dbref=True):
use_dbref=None):
"""
Returns an Object matching a search string/condition
@ -343,8 +343,9 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
caller's contents (inventory).
nofound_string (str): optional custom string for not-found error message.
multimatch_string (str): optional custom string for multimatch error header.
use_dbref (bool, optional): if False, treat a given #dbref strings as a
normal string rather than database ids.
use_dbref (bool or None, optional): if True/False, active/deactivate the use of
#dbref as valid global search arguments. If None, check against a permission
('Builder' by default).
Returns:
match (Object, None or list): will return an Object/None if `quiet=False`,
@ -360,6 +361,7 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
"""
is_string = isinstance(searchdata, basestring)
if is_string:
# searchdata is a string; wrap some common self-references
if searchdata.lower() in ("here", ):
@ -367,6 +369,9 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
if searchdata.lower() in ("me", "self",):
return [self] if quiet else self
if use_dbref is None:
use_dbref = self.locks.check_lockstring(self, "_dummy:perm(Builder)")
if use_nicks:
# do nick-replacement on search
searchdata = self.nicks.nickreplace(searchdata, categories=("object", "account"), include_account=True)
@ -1495,7 +1500,7 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
def at_before_get(self, getter, **kwargs):
"""
Called by the default `get` command before this object has been
picked up.
picked up.
Args:
getter (Object): The object about to get this object.
@ -1509,8 +1514,8 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
If this method returns False/None, the getting is cancelled
before it is even started.
"""
return True
return True
def at_get(self, getter, **kwargs):
"""
Called by the default `get` command when this object has been
@ -1545,10 +1550,10 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
Notes:
If this method returns False/None, the giving is cancelled
before it is even started.
"""
return True
return True
def at_give(self, giver, getter, **kwargs):
"""
Called by the default `give` command when this object has been
@ -1586,7 +1591,7 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
"""
return True
def at_drop(self, dropper, **kwargs):
"""
Called by the default `drop` command when this object has been

View file

@ -575,6 +575,10 @@ class TypedObject(SharedMemoryModel):
ppos = _PERMISSION_HIERARCHY.index(perm)
return any(True for hpos, hperm in enumerate(_PERMISSION_HIERARCHY)
if hperm in perms and hpos > ppos)
# we ignore pluralization (english only)
if perm.endswith("s"):
return self.check_permstring(perm[:-1])
return False
#