]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_operchans.cpp
Fix these to use new hook system (u_listmode wasnt fixed yet)
[user/henk/code/inspircd.git] / src / modules / m_operchans.cpp
index 69876cfcf9b8a405592e9514a01d63021f4b564a..e96fbc79a8cd40aecbe6382588efd3dd652b72c4 100644 (file)
@@ -11,9 +11,6 @@
  * ---------------------------------------------------
  */
 
-#include "users.h"
-#include "channels.h"
-#include "modules.h"
 #include "inspircd.h"
 
 /* $ModDesc: Provides support for oper-only chans via the +O channel mode */
@@ -24,7 +21,7 @@ class OperChans : public ModeHandler
        /* This is an oper-only mode */
        OperChans(InspIRCd* Instance) : ModeHandler(Instance, 'O', 0, 0, false, MODETYPE_CHANNEL, true) { }
 
-       ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
+       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
        {
                if (adding)
                {
@@ -53,11 +50,14 @@ class ModuleOperChans : public Module
        OperChans* oc;
  public:
        ModuleOperChans(InspIRCd* Me)
-               : Module::Module(Me)
+               : Module(Me)
        {
                                
                oc = new OperChans(ServerInstance);
-               ServerInstance->AddMode(oc, 'O');
+               if (!ServerInstance->AddMode(oc))
+                       throw ModuleException("Could not add new modes!");
+               Implementation eventlist[] = { I_OnUserPreJoin };
+               ServerInstance->Modules->Attach(eventlist, this, 1);
        }
 
        void Implements(char* List)
@@ -65,9 +65,9 @@ class ModuleOperChans : public Module
                List[I_OnUserPreJoin] = 1;
        }
 
-       virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname, std::string &privs)
+       virtual int OnUserPreJoin(User* user, Channel* chan, const char* cname, std::string &privs)
        {
-               if (!*user->oper)
+               if (!IS_OPER(user))
                {
                        if (chan)
                        {
@@ -81,10 +81,10 @@ class ModuleOperChans : public Module
                return 0;
        }
        
-       virtual ~ModuleOperChans()
+       virtual ~ModuleOperChans()
        {
                ServerInstance->Modes->DelMode(oc);
-               DELETE(oc);
+               delete oc;
        }
        
        virtual Version GetVersion()
@@ -93,28 +93,4 @@ class ModuleOperChans : public Module
        }
 };
 
-
-class ModuleOperChansFactory : public ModuleFactory
-{
- public:
-       ModuleOperChansFactory()
-       {
-       }
-       
-       ~ModuleOperChansFactory()
-       {
-       }
-       
-       virtual Module * CreateModule(InspIRCd* Me)
-       {
-               return new ModuleOperChans(Me);
-       }
-       
-};
-
-
-extern "C" void * init_module( void )
-{
-       return new ModuleOperChansFactory;
-}
-
+MODULE_INIT(ModuleOperChans)