]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/command_parse.cpp
Split up spanningtree some more, the filenames should be more intuitive so that devel...
[user/henk/code/inspircd.git] / src / command_parse.cpp
index a155a6207d21d51ff4b82ebf2ac4941c03ee2c17..c273e0859cef1cb4dfcc7ca3871279613f8a72ef 100644 (file)
@@ -217,12 +217,15 @@ bool CommandParser::IsValidCommand(const std::string &commandname, int pcnt, use
        {
                if ((pcnt>=n->second->min_params) && (n->second->source != "<core>"))
                {
-                       if ((!n->second->flags_needed) || (user->IsModeSet(n->second->flags_needed)))
+                       if (IS_LOCAL(user) && n->second->flags_needed)
                        {
-                               if (n->second->flags_needed)
+                               if (user->IsModeSet(n->second->flags_needed))
                                {
-                                       return ((user->HasPermission(commandname)) || (ServerInstance->ULine(user->server)));
+                                       return (user->HasPermission(commandname));
                                }
+                       }
+                       else
+                       {
                                return true;
                        }
                }
@@ -249,20 +252,29 @@ CmdResult CommandParser::CallHandler(const std::string &commandname,const char**
        {
                if (pcnt >= n->second->min_params)
                {
-                       if ((!n->second->flags_needed) || (user->IsModeSet(n->second->flags_needed)))
+                       bool bOkay = false;
+
+                       if (IS_LOCAL(user) && n->second->flags_needed)
                        {
-                               if (n->second->flags_needed)
-                               {
-                                       if ((user->HasPermission(commandname)) || (!IS_LOCAL(user)))
-                                       {
-                                               return n->second->Handle(parameters,pcnt,user);
-                                       }
-                               }
-                               else
+                               /* if user is local, and flags are needed .. */
+
+                               if (user->IsModeSet(n->second->flags_needed))
                                {
-                                       return n->second->Handle(parameters,pcnt,user);
+                                       /* 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;
@@ -346,8 +358,7 @@ void CommandParser::ProcessCommand(userrec *user, std::string &cmd)
                                        return;
 
                                /*
-                                * WARNING: nothing should come after this, as the user may be on a cull list to
-                                * be nuked next loop iteration. be sensible.
+                                * WARNING: be careful, the user may be deleted soon
                                 */
                                CmdResult result = cm->second->Handle(command_p,items,user);
 
@@ -414,7 +425,7 @@ void CommandParser::ProcessBuffer(std::string &buffer,userrec *user)
        {
                if (!user->muted)
                {
-                       ServerInstance->Log(DEBUG,"C[%d] -> :%s %s",user->GetFd(), user->nick, buffer.c_str());
+                       ServerInstance->Log(DEBUG,"C[%d] I :%s %s",user->GetFd(), user->nick, buffer.c_str());
                        this->ProcessCommand(user,buffer);
                }
        }