diff --git a/evennia/commands/cmdparser.py b/evennia/commands/cmdparser.py index 56b702d8c1..72040472e4 100644 --- a/evennia/commands/cmdparser.py +++ b/evennia/commands/cmdparser.py @@ -209,10 +209,15 @@ def cmdparser(raw_string, cmdset, caller, match_index=None): quality = [mat[4] for mat in matches] matches = matches[-quality.count(quality[-1]) :] - if len(matches) > 1 and match_index is not None and 0 < match_index <= len(matches): + if len(matches) > 1 and match_index is not None: # We couldn't separate match by quality, but we have an # index argument to tell us which match to use. - matches = [matches[match_index - 1]] + if 0 < match_index <= len(matches): + matches = [matches[match_index - 1]] + else: + # we tried to give an index outside of the range - this means + # a no-match + matches = [] # no matter what we have at this point, we have to return it. return matches diff --git a/evennia/objects/manager.py b/evennia/objects/manager.py index d29ca9a739..0a3dbc90fa 100644 --- a/evennia/objects/manager.py +++ b/evennia/objects/manager.py @@ -466,7 +466,6 @@ class ObjectDBManager(TypedObjectManager): # strips the number match_number, searchdata = match.group("number"), match.group("name") match_number = int(match_number) - 1 - match_number = match_number if match_number >= 0 else None if match_number is not None or not exact: # run search again, with the exactness set by call matches = _searcher(searchdata, candidates, typeclass, exact=exact) @@ -474,11 +473,13 @@ class ObjectDBManager(TypedObjectManager): # deal with result if len(matches) > 1 and match_number is not None: # multiple matches, but a number was given to separate them - try: + if 0 <= match_number < len(matches): + # limit to one match matches = [matches[match_number]] - except IndexError: - # match number not matching anything - pass + else: + # a number was given outside of range. This means a no-match. + matches = [] + # return a list (possibly empty) return matches diff --git a/evennia/objects/objects.py b/evennia/objects/objects.py index 542a89997b..8b66bce8f8 100644 --- a/evennia/objects/objects.py +++ b/evennia/objects/objects.py @@ -389,7 +389,8 @@ class DefaultObject(ObjectDB, metaclass=TypeclassBase): a global search. - `me,self`: self-reference to this object - `-` - can be used to differentiate - between multiple same-named matches + between multiple same-named matches. The exact form of this input + is given by `settings.SEARCH_MULTIMATCH_REGEX`. global_search (bool): Search all objects globally. This overrules 'location' data. use_nicks (bool): Use nickname-replace (nicktype "object") on `searchdata`. typeclass (str or Typeclass, or list of either): Limit search only diff --git a/evennia/server/portal/telnet.py b/evennia/server/portal/telnet.py index 70a3b815ef..821e96aa24 100644 --- a/evennia/server/portal/telnet.py +++ b/evennia/server/portal/telnet.py @@ -85,7 +85,6 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session): super().dataReceived(data) except ValueError as err: from evennia.utils import logger - logger.log_err(f"Malformed telnet input: {err}") def connectionMade(self):