]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_opermodes.cpp
Fix new millisec /map to compile on windows, by ifndef gettimeofday out reverting...
[user/henk/code/inspircd.git] / src / modules / m_opermodes.cpp
index 30f6fef9cbefdc24d59bf33556e27645818d999d..598f84e4355c2469fb7087dbb07f2f7224881e3e 100644 (file)
  * ---------------------------------------------------
  */
 
-#include <stdio.h>
-#include <vector>
+#include "inspircd.h"
 #include "users.h"
 #include "channels.h"
-#include "inspircd.h"
 #include "modules.h"
 
 /* $ModDesc: Sets (and unsets) modes on opers when they oper up */
@@ -67,14 +65,14 @@ class ModuleModesOnOper : public Module
                        if (!strcmp(typen.c_str(),user->oper))
                        {
                                std::string ThisOpersModes = Conf->ReadValue("type","modes",j);
-                               char first = *(ThisOpersModes.c_str());
-                               if ((first != '+') && (first != '-'))
-                                       ThisOpersModes = "+" + ThisOpersModes;
-                               if (ThisOpersModes != "")
+                               if (!ThisOpersModes.empty())
                                {
+                                       char first = *(ThisOpersModes.c_str());
+                                       if ((first != '+') && (first != '-'))
+                                               ThisOpersModes = "+" + ThisOpersModes;
+
                                        std::string buf;
                                        stringstream ss(ThisOpersModes);
-
                                        vector<string> tokens;
 
                                        // split ThisOperModes into modes and mode params
@@ -82,28 +80,24 @@ class ModuleModesOnOper : public Module
                                                tokens.push_back(buf);
 
                                        int size = tokens.size() + 1;
-                                       char** modes = new char*[size];
+                                       const char** modes = new const char*[size];
                                        modes[0] = user->nick;
-                                       modes[1] = (char*)tokens[0].c_str();
 
-                                       if (tokens.size() > 1)
+                                       // process mode params
+                                       int i = 1;
+                                       for (unsigned int k = 0; k < tokens.size(); k++)
                                        {
-                                               // process mode params
-                                               int i = 2;
-                                               for (unsigned int k = 1; k < tokens.size(); k++)
-                                               {
-                                                       modes[i] = (char*)tokens[k].c_str();
-                                                       i++;
-                                               }
+                                               modes[i] = tokens[k].c_str();
+                                               i++;
                                        }
+
                                        std::deque<std::string> n;
-                                       Event rmode((char *)&n, NULL, "send_mode");
+                                       Event rmode((char *)&n, NULL, "send_mode_explicit");
                                        for (unsigned int j = 0; j < tokens.size(); j++)
-                                       {
                                                n.push_back(modes[j]);
-                                       }
+
                                        rmode.Send(ServerInstance);
-                                       ServerInstance->SendMode((const char**)modes, size, user);
+                                       ServerInstance->SendMode(modes, size, user);
                                        delete [] modes;
                                }
                                break;
@@ -112,29 +106,4 @@ class ModuleModesOnOper : public Module
        }
 };
 
-// stuff down here is the module-factory stuff. For basic modules you can ignore this.
-
-class ModuleModesOnOperFactory : public ModuleFactory
-{
- public:
-       ModuleModesOnOperFactory()
-       {
-       }
-       
-       ~ModuleModesOnOperFactory()
-       {
-       }
-       
-       virtual Module * CreateModule(InspIRCd* Me)
-       {
-               return new ModuleModesOnOper(Me);
-       }
-       
-};
-
-
-extern "C" DllExport void * init_module( void )
-{
-       return new ModuleModesOnOperFactory;
-}
-
+MODULE_INIT(ModuleModesOnOper)