]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_watch.cpp
Add comments
[user/henk/code/inspircd.git] / src / modules / m_watch.cpp
index 6cc96d0f9c241a022cfa993c2a87fcff61486300..669f76b538d8f2d5a0e993128c99c72097af214f 100644 (file)
@@ -2,7 +2,7 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
+ *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
  * See: http://www.inspircd.org/wiki/index.php/Credits
  *
  * This program is free but copyrighted software; see
@@ -62,7 +62,7 @@
  * Yes, it's horrid. Blame cl for being different. -- w00t
  */
 #ifdef WINDOWS
-typedef nspace::hash_map<irc::string, std::deque<User*>, nspace::hash_compare<irc::string, less<irc::string> > > watchentries;
+typedef nspace::hash_map<irc::string, std::deque<User*>, nspace::hash_compare<irc::string, std::less<irc::string> > > watchentries;
 #else
 typedef nspace::hash_map<irc::string, std::deque<User*>, nspace::hash<irc::string> > watchentries;
 #endif
@@ -76,7 +76,7 @@ watchentries* whos_watching_me;
 
 /** Handle /WATCH
  */
-class cmd_watch : public Command
+class CommandWatch : public Command
 {
        unsigned int& MAX_WATCH;
  public:
@@ -94,6 +94,10 @@ class cmd_watch : public Command
                {
                        /* Yup, is on my list */
                        watchlist::iterator n = wl->find(nick);
+
+                       if (!wl)
+                               return CMD_FAILURE;
+
                        if (n != wl->end())
                        {
                                if (!n->second.empty())
@@ -192,7 +196,7 @@ class cmd_watch : public Command
                return CMD_FAILURE;
        }
 
-       cmd_watch (InspIRCd* Instance, unsigned int &maxwatch) : Command(Instance,"WATCH",0,0), MAX_WATCH(maxwatch)
+       CommandWatch (InspIRCd* Instance, unsigned int &maxwatch) : Command(Instance,"WATCH",0,0), MAX_WATCH(maxwatch)
        {
                this->source = "m_watch.so";
                syntax = "[C|L|S]|[+|-<nick>]";
@@ -301,7 +305,7 @@ class cmd_watch : public Command
 
 class Modulewatch : public Module
 {
-       cmd_watch* mycommand;
+       CommandWatch* mycommand;
        unsigned int maxwatch;
  public:
 
@@ -310,8 +314,10 @@ class Modulewatch : public Module
        {
                OnRehash(NULL, "");
                whos_watching_me = new watchentries();
-               mycommand = new cmd_watch(ServerInstance, maxwatch);
+               mycommand = new CommandWatch(ServerInstance, maxwatch);
                ServerInstance->AddCommand(mycommand);
+               Implementation eventlist[] = { I_OnRehash, I_OnGarbageCollect, I_OnCleanup, I_OnUserQuit, I_OnPostConnect, I_OnUserPostNick, I_On005Numeric };
+               ServerInstance->Modules->Attach(eventlist, this, 7);
        }
 
        virtual void OnRehash(User* user, const std::string &parameter)
@@ -322,10 +328,6 @@ class Modulewatch : public Module
                        maxwatch = 32;
        }
 
-       void Implements(char* List)
-       {
-               List[I_OnRehash] = List[I_OnGarbageCollect] = List[I_OnCleanup] = List[I_OnUserQuit] = List[I_OnPostConnect] = List[I_OnUserPostNick] = List[I_On005Numeric] = 1;
-       }
 
        virtual void OnUserQuit(User* user, const std::string &reason, const std::string &oper_message)
        {
@@ -367,6 +369,7 @@ class Modulewatch : public Module
 
                        /* User's quitting, we're done with this. */
                        delete wl;
+                       user->Shrink("watchlist");
                }
        }