]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_nonicks.cpp
Some more to fix still, modules probably wont load correctly atm
[user/henk/code/inspircd.git] / src / modules / m_nonicks.cpp
index 103d07c2a5eb46eca8774c5eff9f6a8cd56f285b..05b07c44fd00b442e6b2765ea5586267be748f4b 100644 (file)
  * ---------------------------------------------------
  */
 
-#include "users.h"
-#include "channels.h"
-#include "modules.h"
-#include "hashcomp.h"
-#include "configreader.h"
 #include "inspircd.h"
 
 /* $ModDesc: Provides support for channel mode +N which prevents nick changes on channel */
@@ -25,7 +20,7 @@ class NoNicks : public ModeHandler
  public:
        NoNicks(InspIRCd* Instance) : ModeHandler(Instance, 'N', 0, 0, false, MODETYPE_CHANNEL, false) { }
 
-       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 +48,13 @@ class ModuleNoNickChange : public Module
        NoNicks* nn;
  public:
        ModuleNoNickChange(InspIRCd* Me)
-               : Module::Module(Me)
+               : Module(Me)
        {
                
                nn = new NoNicks(ServerInstance);
-               ServerInstance->AddMode(nn, 'N');
+               ServerInstance->AddMode(nn);
+               Implementation eventlist[] = { I_OnUserPreNick };
+               ServerInstance->Modules->Attach(eventlist, this, 1);
        }
        
        virtual ~ModuleNoNickChange()
@@ -76,13 +73,16 @@ class ModuleNoNickChange : public Module
                List[I_OnUserPreNick] = 1;
        }
 
-       virtual int OnUserPreNick(userrec* user, const std::string &newnick)
+       virtual int OnUserPreNick(User* user, const std::string &newnick)
        {
                if (IS_LOCAL(user))
                {
+                       if (isdigit(newnick[0])) /* don't even think about touching a switch to uid! */
+                               return 0;
+
                        for (UCListIter i = user->chans.begin(); i != user->chans.end(); i++)
                        {
-                               chanrec* curr = i->first;
+                               Channel* curr = i->first;
 
                                if (curr->IsModeSet('N'))
                                {
@@ -99,29 +99,4 @@ class ModuleNoNickChange : public Module
        }
 };
 
-// stuff down here is the module-factory stuff. For basic modules you can ignore this.
-
-class ModuleNoNickChangeFactory : public ModuleFactory
-{
- public:
-       ModuleNoNickChangeFactory()
-       {
-       }
-       
-       ~ModuleNoNickChangeFactory()
-       {
-       }
-       
-       virtual Module * CreateModule(InspIRCd* Me)
-       {
-               return new ModuleNoNickChange(Me);
-       }
-       
-};
-
-
-extern "C" void * init_module( void )
-{
-       return new ModuleNoNickChangeFactory;
-}
-
+MODULE_INIT(ModuleNoNickChange)