From f950cd8b94c448d1f74bbca04f250cce8dfbc623 Mon Sep 17 00:00:00 2001 From: Griatch Date: Wed, 9 Nov 2011 09:53:57 +0100 Subject: [PATCH] Red button commands lacked proper locks, causing non-privileged chars to not have access. Fixed. --- game/gamesrc/commands/examples/cmdset_red_button.py | 9 +++++++++ src/commands/cmdhandler.py | 11 +++++------ src/commands/cmdparser.py | 1 - 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/game/gamesrc/commands/examples/cmdset_red_button.py b/game/gamesrc/commands/examples/cmdset_red_button.py index f9402ad9f9..111437f290 100644 --- a/game/gamesrc/commands/examples/cmdset_red_button.py +++ b/game/gamesrc/commands/examples/cmdset_red_button.py @@ -30,6 +30,7 @@ class CmdNudge(Command): key = "nudge lid" # two-word command name! aliases = ["nudge"] + locks = "cmd:all()" def func(self): """ @@ -54,6 +55,7 @@ class CmdPush(Command): """ key = "push button" aliases = ["push", "press button", "press"] + locks = "cmd:all()" def func(self): """ @@ -94,6 +96,7 @@ class CmdSmashGlass(Command): key = "smash glass" aliases = ["smash lid", "break lid", "smash"] + locks = "cmd:all()" def func(self): """ @@ -129,6 +132,7 @@ class CmdOpenLid(Command): key = "open lid" aliases = ["open button", 'open'] + locks = "cmd:all()" def func(self): "simply call the right function." @@ -159,6 +163,7 @@ class CmdCloseLid(Command): key = "close lid" aliases = ["close"] + locks = "cmd:all()" def func(self): "Close the lid" @@ -183,6 +188,8 @@ class CmdBlindLook(Command): key = "look" aliases = ["l", "get", "examine", "ex", "feel", "listen"] + locks = "cmd:all()" + def func(self): "This replaces all the senses when blinded." @@ -215,6 +222,8 @@ class CmdBlindHelp(Command): """ key = "help" aliases = "h" + locks = "cmd:all()" + def func(self): "Give a message." self.caller.msg("You are beyond help ... until you can see again.") diff --git a/src/commands/cmdhandler.py b/src/commands/cmdhandler.py index ba802c1e3b..c5cb40bf5b 100644 --- a/src/commands/cmdhandler.py +++ b/src/commands/cmdhandler.py @@ -119,13 +119,14 @@ def get_and_merge_cmdsets(caller): try: player_cmdset = caller.player.cmdset.current except AttributeError: - player_cmdset = None + player_cmdset = None cmdsets = [caller_cmdset] + [player_cmdset] + [channel_cmdset] + local_objects_cmdsets # weed out all non-found sets cmdsets = [cmdset for cmdset in cmdsets if cmdset] # sort cmdsets after reverse priority (highest prio are merged in last) cmdsets = sorted(cmdsets, key=lambda x: x.priority) + if cmdsets: # Merge all command sets into one, beginning with the lowest-prio one cmdset = cmdsets.pop(0) @@ -135,7 +136,7 @@ def get_and_merge_cmdsets(caller): cmdset = merging_cmdset + cmdset else: cmdset = None - + for cset in (cset for cset in local_objects_cmdsets if cset): cset.duplicates = cset.old_duplicates @@ -157,8 +158,8 @@ def cmdhandler(caller, raw_string, testing=False): try: # catch special-type commands cmdset = get_and_merge_cmdsets(caller) - - #print cmdset + + # print cmdset if not cmdset: # this is bad and shouldn't happen. raise NoCmdSets @@ -169,12 +170,10 @@ def cmdhandler(caller, raw_string, testing=False): syscmd = cmdset.get(CMD_NOINPUT) sysarg = "" raise ExecSystemCommand(syscmd, sysarg) - # Parse the input string and match to available cmdset. # This also checks for permissions, so all commands in match # are commands the caller is allowed to call. matches = COMMAND_PARSER(raw_string, cmdset, caller) - # Deal with matches if not matches: # No commands match our entered command diff --git a/src/commands/cmdparser.py b/src/commands/cmdparser.py index 4b4985f968..a71157954c 100644 --- a/src/commands/cmdparser.py +++ b/src/commands/cmdparser.py @@ -49,7 +49,6 @@ def cmdparser(raw_string, cmdset, caller, match_index=None): matches.extend([create_match(cmdname, raw_string, cmd) for cmdname in [cmd.key] + cmd.aliases if cmdname and l_raw_string.startswith(cmdname.lower())]) - if not matches: # no matches found. if '-' in raw_string: