summaryrefslogtreecommitdiff
path: root/src/command_parse.cpp
diff options
context:
space:
mode:
authorGravatar brain2007-10-06 00:03:00 +0000
committerGravatar brain2007-10-06 00:03:00 +0000
commite5c8a56d0eebc1ed8254aec68cbdf781ab6d0a0c (patch)
tree9691979d4f34091e0e763a7afd7216e7084f3e50 /src/command_parse.cpp
parentAdd -lunwind to libraries on openbsd to fix some compile issues (thanks nenolod) (diff)
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
Diffstat (limited to 'src/command_parse.cpp')
-rw-r--r--src/command_parse.cpp53
1 files changed, 31 insertions, 22 deletions
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);
+ 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;
+ 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)