]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_watch.cpp
Dynamically determine the size of the eventlist[] passed to Attach()
[user/henk/code/inspircd.git] / src / modules / m_watch.cpp
index 3750fceac0bf2b0427a32ef0d6cb24ed6aa51040..28ae052866cbb1d0ccbf2f813425ab68bc95f0d6 100644 (file)
@@ -249,7 +249,7 @@ class CommandWatch : public Command
                        }
                        else
                        {
-                               (*wl)[nick] = "";
+                               (*wl)[nick].clear();
                                user->WriteNumeric(605, "%s %s * * 0 :is offline",user->nick.c_str(), nick);
                        }
                }
@@ -377,15 +377,19 @@ class Modulewatch : public Module
 
  public:
        Modulewatch()
-               : maxwatch(32), cmdw(this, maxwatch), sw(this) 
+               : maxwatch(32), cmdw(this, maxwatch), sw(this)
        {
-               OnRehash(NULL);
                whos_watching_me = new watchentries();
+       }
+
+       void init()
+       {
+               OnRehash(NULL);
                ServerInstance->AddCommand(&cmdw);
                ServerInstance->AddCommand(&sw);
                ServerInstance->Extensions.Register(&cmdw.ext);
                Implementation eventlist[] = { I_OnRehash, I_OnGarbageCollect, I_OnUserQuit, I_OnPostConnect, I_OnUserPostNick, I_On005Numeric, I_OnSetAway };
-               ServerInstance->Modules->Attach(eventlist, this, 7);
+               ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
        }
 
        virtual void OnRehash(User* user)
@@ -435,7 +439,7 @@ class Modulewatch : public Module
                                watchlist* wl = cmdw.ext.get(*n);
                                if (wl)
                                        /* We were on somebody's notify list, set ourselves offline */
-                                       (*wl)[user->nick.c_str()] = "";
+                                       (*wl)[user->nick.c_str()].clear();
                        }
                }
 
@@ -504,7 +508,7 @@ class Modulewatch : public Module
                                if (wl)
                                {
                                        (*n)->WriteNumeric(601, "%s %s %s %s %lu :went offline", (*n)->nick.c_str(), oldnick.c_str(), user->ident.c_str(), user->dhost.c_str(), (unsigned long) user->age);
-                                       (*wl)[oldnick.c_str()] = "";
+                                       (*wl)[oldnick.c_str()].clear();
                                }
                        }
                }