]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_close.cpp
Remove InspIRCd* parameters and fields
[user/henk/code/inspircd.git] / src / modules / m_close.cpp
index e8e176296f82b499c2dfb39cd9a404064fa3073c..1cddc5012805d94fb88508cc68152db80dce422e 100644 (file)
@@ -2,8 +2,8 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
- * See: http://www.inspircd.org/wiki/index.php/Credits
+ *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
+ * See: http://wiki.inspircd.org/Credits
  *
  * This program is free but copyrighted software; see
  *            the file COPYING for details.
@@ -29,21 +29,22 @@ class CommandClose : public Command
 {
  public:
        /* Command 'close', needs operator */
-       CommandClose (InspIRCd* Instance) : Command(Instance,"CLOSE", "o", 0)
+       CommandClose(Module* Creator) : Command(Creator,"CLOSE", 0)
        {
-               this->source = "m_close.so";
-       }
+       flags_needed = 'o'; }
 
        CmdResult Handle (const std::vector<std::string> &parameters, User *user)
        {
                std::map<std::string,int> closed;
 
-               for (std::vector<User*>::iterator u = ServerInstance->Users->local_users.begin(); u != ServerInstance->Users->local_users.end(); u++)
+               std::vector<User*>::reverse_iterator u = ServerInstance->Users->local_users.rbegin();
+               while (u != ServerInstance->Users->local_users.rend())
                {
-                       if ((*u)->registered != REG_ALL)
+                       User* user = *u++;
+                       if (user->registered != REG_ALL)
                        {
-                               ServerInstance->Users->QuitUser(*u, "Closing all unknown connections per request");
-                               std::string key = ConvToStr((*u)->GetIPString())+"."+ConvToStr((*u)->GetPort());
+                               ServerInstance->Users->QuitUser(user, "Closing all unknown connections per request");
+                               std::string key = ConvToStr(user->GetIPString())+"."+ConvToStr(user->GetServerPort());
                                closed[key]++;
                        }
                }
@@ -59,21 +60,18 @@ class CommandClose : public Command
                else
                        user->WriteServ("NOTICE %s :*** No unknown connections found",user->nick.c_str());
 
-               return CMD_LOCALONLY;
+               return CMD_SUCCESS;
        }
 };
 
 class ModuleClose : public Module
 {
-       CommandClose* newcommand;
+       CommandClose cmd;
  public:
-       ModuleClose(InspIRCd* Me)
-               : Module(Me)
+       ModuleClose()
+               : cmd(this)
        {
-               // Create a new command
-               newcommand = new CommandClose(ServerInstance);
-               ServerInstance->AddCommand(newcommand);
-
+               ServerInstance->AddCommand(&cmd);
        }
 
        virtual ~ModuleClose()
@@ -82,7 +80,7 @@ class ModuleClose : public Module
 
        virtual Version GetVersion()
        {
-               return Version("$Id$", VF_VENDOR, API_VERSION);
+               return Version("Provides /CLOSE functionality", VF_VENDOR, API_VERSION);
        }
 };