From e5c8a56d0eebc1ed8254aec68cbdf781ab6d0a0c Mon Sep 17 00:00:00 2001 From: brain Date: Sat, 6 Oct 2007 00:03:00 +0000 Subject: Backport the changes to CallHandler to fix an issue Andy Church and Casey are having. The code here is such a mess and a clusterfuck its probably easier to backport this nicer code from trunk. git-svn-id: http://svn.inspircd.org/repository/branches/1_1_stable@8128 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/command_parse.cpp | 55 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 23 deletions(-) (limited to 'src/command_parse.cpp') diff --git a/src/command_parse.cpp b/src/command_parse.cpp index 13d033330..183d0f763 100644 --- a/src/command_parse.cpp +++ b/src/command_parse.cpp @@ -247,29 +247,38 @@ command_t* CommandParser::GetHandler(const std::string &commandname) CmdResult CommandParser::CallHandler(const std::string &commandname,const char** parameters, int pcnt, userrec *user) { - command_table::iterator n = cmdlist.find(commandname); - - if (n != cmdlist.end()) - { - if (pcnt >= n->second->min_params) - { - if ((!n->second->flags_needed) || (user->IsModeSet(n->second->flags_needed))) - { - if (n->second->flags_needed) - { - if ((user->HasPermission(commandname)) || (!IS_LOCAL(user))) - { - return n->second->Handle(parameters,pcnt,user); - } - } - else - { - return n->second->Handle(parameters,pcnt,user); - } - } - } - } - return CMD_INVALID; + command_table::iterator n = cmdlist.find(commandname); + + if (n != cmdlist.end()) + { + if (pcnt >= n->second->min_params) + { + bool bOkay = false; + + if (IS_LOCAL(user) && n->second->flags_needed) + { + /* if user is local, and flags are needed .. */ + + if (user->IsModeSet(n->second->flags_needed)) + { + /* if user has the flags, and now has the permissions, go ahead */ + if (user->HasPermission(commandname)) + bOkay = true; + } + } + else + { + /* remote or no flags required anyway */ + bOkay = true; + } + + if (bOkay) + { + return n->second->Handle(parameters,pcnt,user); + } + } + } + return CMD_INVALID; } void CommandParser::ProcessCommand(userrec *user, std::string &cmd) -- cgit v1.3.1-10-gc9f91