From 08b0f3fbf819185eb005d018ad3e953fd49774de Mon Sep 17 00:00:00 2001 From: Griatch Date: Mon, 3 Jun 2019 07:01:03 +0200 Subject: [PATCH] Fix bug in multi-object alias targeting. Resolves #1823 --- evennia/__init__.py | 2 +- evennia/objects/manager.py | 9 +++++---- evennia/objects/objects.py | 1 + 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/evennia/__init__.py b/evennia/__init__.py index 3aabc97c50..3b8ecf425e 100644 --- a/evennia/__init__.py +++ b/evennia/__init__.py @@ -170,7 +170,7 @@ def _init(): global create_message, create_help_entry global settings, lockfuncs, logger, utils, gametime, ansi, spawn, managers global contrib, TICKER_HANDLER, MONITOR_HANDLER, SESSION_HANDLER - global CHANNEL_HANDLER, TASK_HANDLER + global CHANNEL_HANDLER, TASK_HANDLER global GLOBAL_SCRIPTS, OPTION_CLASSES global EvMenu, EvTable, EvForm, EvMore, EvEditor global ANSIString diff --git a/evennia/objects/manager.py b/evennia/objects/manager.py index 45bca49d9d..4562e0ffb5 100644 --- a/evennia/objects/manager.py +++ b/evennia/objects/manager.py @@ -281,11 +281,11 @@ class ObjectDBManager(TypedObjectManager): index_matches = string_partial_matching(key_strings, ostring, ret_index=True) if index_matches: # a match by key - return [obj for ind, obj in enumerate(search_candidates) if ind in index_matches] + return list({obj for ind, obj in enumerate(search_candidates) if ind in index_matches}) else: # match by alias rather than by key search_candidates = search_candidates.filter(db_tags__db_tagtype__iexact="alias", - db_tags__db_key__icontains=ostring) + db_tags__db_key__icontains=ostring).distinct() alias_strings = [] alias_candidates = [] # TODO create the alias_strings and alias_candidates lists more efficiently? @@ -295,7 +295,8 @@ class ObjectDBManager(TypedObjectManager): alias_candidates.append(candidate) index_matches = string_partial_matching(alias_strings, ostring, ret_index=True) if index_matches: - return [alias_candidates[ind] for ind in index_matches] + # it's possible to have multiple matches to the same Object, we must weed those out + return list({alias_candidates[ind] for ind in index_matches}) return [] # main search methods and helper functions @@ -507,7 +508,7 @@ class ObjectDBManager(TypedObjectManager): # copy over all tags, if any for tag in original_object.tags.get(return_tagobj=True, return_list=True): new_object.tags.add(tag=tag.key, category=tag.category, data=tag.data) - + return new_object def clear_all_sessids(self): diff --git a/evennia/objects/objects.py b/evennia/objects/objects.py index 671342889a..d908cc0b66 100644 --- a/evennia/objects/objects.py +++ b/evennia/objects/objects.py @@ -466,6 +466,7 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)): candidates=candidates, exact=exact, use_dbref=use_dbref) + if quiet: return results return _AT_SEARCH_RESULT(results, self, query=searchdata,