diff options
| author | 2021-06-13 14:46:41 +0100 | |
|---|---|---|
| committer | 2021-06-13 14:46:41 +0100 | |
| commit | 7fa0672ebde614218a18600686370ac234e67bf0 (patch) | |
| tree | fd8933975ec00af7373b890d0171f7350fab6f83 /src/command_parse.cpp | |
| parent | Fix undefined behaviour with converting a path to a string. (diff) | |
| parent | Point to the license on the docs site not to the GNU website. (diff) | |
Merge branch 'insp3' into master.
Diffstat (limited to 'src/command_parse.cpp')
| -rw-r--r-- | src/command_parse.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/command_parse.cpp b/src/command_parse.cpp index ae543a0a8..c6072447f 100644 --- a/src/command_parse.cpp +++ b/src/command_parse.cpp @@ -122,20 +122,19 @@ Command* CommandParser::GetHandler(const std::string &commandname) CmdResult CommandParser::CallHandler(const std::string& commandname, const CommandBase::Params& parameters, User* user, Command** cmd) { - CommandMap::iterator n = cmdlist.find(commandname); - - if (n != cmdlist.end()) + /* find the command, check it exists */ + Command* handler = GetHandler(commandname); + if (handler) { - if ((!parameters.empty()) && (parameters.back().empty()) && (!n->second->allow_empty_last_param)) + if ((!parameters.empty()) && (parameters.back().empty()) && (!handler->allow_empty_last_param)) return CmdResult::INVALID; - if (parameters.size() >= n->second->min_params) + if (parameters.size() >= handler->min_params) { bool bOkay = false; - if (IS_LOCAL(user)) { - switch (n->second->access_needed) + switch (handler->access_needed) { case CmdAccess::NORMAL: // Anyone can execute. bOkay = true; @@ -159,10 +158,10 @@ CmdResult CommandParser::CallHandler(const std::string& commandname, const Comma if (bOkay) { if (cmd) - *cmd = n->second; + *cmd = handler; ClientProtocol::TagMap tags; - return n->second->Handle(user, CommandBase::Params(parameters, tags)); + return handler->Handle(user, CommandBase::Params(parameters, tags)); } } } |
