Make sure to avoid double multi-matches from rpsystem. Resolve #1757

This commit is contained in:
Griatch 2019-06-08 17:34:30 +02:00
parent c083f767d8
commit 21a5285954
2 changed files with 16 additions and 13 deletions

View file

@ -1268,16 +1268,19 @@ class ContribRPObject(DefaultObject):
is_builder = self.locks.check_lockstring(self, "perm(Builder)")
use_dbref = is_builder if use_dbref is None else use_dbref
def search_obj(string): return ObjectDB.objects.object_search(string,
attribute_name=attribute_name,
typeclass=typeclass,
candidates=candidates,
exact=exact,
use_dbref=use_dbref)
def search_obj(string):
"helper wrapper for searching"
return ObjectDB.objects.object_search(string,
attribute_name=attribute_name,
typeclass=typeclass,
candidates=candidates,
exact=exact,
use_dbref=use_dbref)
if candidates:
candidates = parse_sdescs_and_recogs(self, candidates,
_PREFIX + searchdata, search_mode=True)
_PREFIX + searchdata,
search_mode=True)
results = []
for candidate in candidates:
# we search by candidate keys here; this allows full error
@ -1285,7 +1288,8 @@ class ContribRPObject(DefaultObject):
# in eventual error reporting later (not their keys). Doing
# it like this e.g. allows for use of the typeclass kwarg
# limiter.
results.extend(search_obj(candidate.key))
results.extend([obj for obj in search_obj(candidate.key)
if obj not in results])
if not results and is_builder:
# builders get a chance to search only by key+alias
@ -1299,7 +1303,8 @@ class ContribRPObject(DefaultObject):
if quiet:
return results
return _AT_SEARCH_RESULT(results, self, query=searchdata,
nofound_string=nofound_string, multimatch_string=multimatch_string)
nofound_string=nofound_string,
multimatch_string=multimatch_string)
def get_display_name(self, looker, **kwargs):
"""
@ -1497,5 +1502,3 @@ class ContribRPCharacter(DefaultCharacter, ContribRPObject):
"""
return "%s|w%s|n" % ("|W(%s)" % language if language else "", text)
#from evennia.contrib import rplanguage
# return "|w%s|n" % rplanguage.obfuscate_language(text, level=1.0)

View file

@ -265,9 +265,9 @@ class ObjectDBManager(TypedObjectManager):
type_restriction = typeclasses and Q(db_typeclass_path__in=make_iter(typeclasses)) or Q()
if exact:
# exact match - do direct search
return self.filter(cand_restriction & type_restriction & (
return (self.filter(cand_restriction & type_restriction & (
Q(db_key__iexact=ostring) | Q(db_tags__db_key__iexact=ostring) & Q(
db_tags__db_tagtype__iexact="alias"))).order_by('id').distinct()
db_tags__db_tagtype__iexact="alias")))).distinct().order_by('id')
elif candidates:
# fuzzy with candidates
search_candidates = self.filter(cand_restriction & type_restriction).distinct().order_by('id')