]> 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 bb1843a958e20b6eae05c41f65b387ee7e760e8a..05b07c44fd00b442e6b2765ea5586267be748f4b 100644 (file)
  */
 
 #include "inspircd.h"
-#include "users.h"
-#include "channels.h"
-#include "modules.h"
-#include "hashcomp.h"
-#include "configreader.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)
                {
@@ -57,7 +52,9 @@ class ModuleNoNickChange : public Module
        {
                
                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'))
                                {