]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_remove.cpp
Improved strhashcomp with no allocations
[user/henk/code/inspircd.git] / src / modules / m_remove.cpp
index 7962d6a1def26cc59714260e55abe948d89de1f4..5cbc384990934d7bca08b0f2a1c68fb58912fba3 100644 (file)
@@ -17,24 +17,33 @@ using namespace std;
  * eg: +h can remove +hv and users with no modes. +a can remove +aohv and users with no modes.
 */
 
-Server *Srv;
+static Server *Srv;
 
 /* This little function just converts a chanmode character (~ & @ & +) into an integer (5 4 3 2 1) */
 /* XXX - this could be handy in the core, so it can be used elsewhere */
-int chartolevel(std::string privs)
+int chartolevel(std::string &privs)
 {
-       /* XXX - if we just passed this a char, we could do a switch. Look nicer, really. */
-
-       if (privs == "~")
-               return 5;
-       else if (privs == "&")
-               return 4;
-       else if (privs == "@")
-               return 3;
-       else if (privs == "%")
-               return 2;
-       else
-               return 1;
+       const char* n = privs.c_str();
+
+       switch (*n)
+       {
+               case '~':
+                       return 5;
+               break;
+               case '&':
+                       return 4;
+               break;
+               case '@':
+                       return 3;
+               break;
+               case '%':
+                       return 2;
+               break;
+               default:
+                       return 1;
+               break;
+       }
+       return 1;
 }
 
 class cmd_remove : public command_t
@@ -101,7 +110,7 @@ class cmd_remove : public command_t
                                /* For now, we'll let everyone remove their level and below, eg ops can remove ops, halfops, voices, and those with no mode (no moders actually are set to 1) */
                                if(ulevel >= tlevel)
                                {
-                                       Srv->PartUserFromChannel(target,std::string(parameters[1]), "Remove by "+std::string(user->nick)+":"+result);
+                                       Srv->PartUserFromChannel(target,std::string(parameters[1]), "Removed by "+std::string(user->nick)+":"+result);
                                        Srv->SendTo(NULL,user,"NOTICE "+std::string(channel->name)+" : "+std::string(user->nick)+" removed "+std::string(target->nick)+ " from the channel");
                                        Srv->SendTo(NULL,target,"NOTICE "+std::string(target->nick)+" :*** "+std::string(user->nick)+" removed you from "+std::string(channel->name)+" with the message:"+std::string(result));
                                }
@@ -130,6 +139,11 @@ class ModuleRemove : public Module
                Srv->AddCommand(mycommand);
        }
 
+       void Implements(char* List)
+       {
+               List[I_On005Numeric] = 1;
+       }
+
         virtual void On005Numeric(std::string &output)
         {
                 output = output + std::string(" REMOVE");