]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/commands/cmd_kick.cpp
Merge pull request #16 from Adam-/insp20
[user/henk/code/inspircd.git] / src / commands / cmd_kick.cpp
index d07d5383636a6d4a6c9ee79fd07e084ba8b051e9..ab346d395e35b593bf1ca7c00873f2f8177d3acc 100644 (file)
@@ -2,7 +2,7 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
+ *  InspIRCd: (C) 2002-2010 InspIRCd Development Team
  * See: http://wiki.inspircd.org/Credits
  *
  * This program is free but copyrighted software; see
 
 #include "inspircd.h"
 
-#ifndef __CMD_KICK_H__
-#define __CMD_KICK_H__
-
-// include the common header files
-
-#include "users.h"
-#include "channels.h"
-
 /** Handle /KICK. These command handlers can be reloaded by the core,
  * and handle basic RFC1459 commands. Commands within modules work
  * the same way, however, they can be fully unloaded, where these
@@ -41,8 +33,6 @@ class CommandKick : public Command
        CmdResult Handle(const std::vector<std::string>& parameters, User *user);
 };
 
-#endif
-
 
 /** Handle /KICK
  */
@@ -50,11 +40,16 @@ CmdResult CommandKick::Handle (const std::vector<std::string>& parameters, User
 {
        std::string reason;
        Channel* c = ServerInstance->FindChan(parameters[0]);
-       User* u = ServerInstance->FindNick(parameters[1]);
+       User* u;
 
        if (ServerInstance->Parser->LoopCall(user, this, parameters, 1))
                return CMD_SUCCESS;
 
+       if (IS_LOCAL(user))
+               u = ServerInstance->FindNickOnly(parameters[1]);
+       else
+               u = ServerInstance->FindNick(parameters[1]);
+
        if (!u || !c)
        {
                user->WriteServ( "401 %s %s :No such nick/channel", user->nick.c_str(), u ? parameters[0].c_str() : parameters[1].c_str());
@@ -76,9 +71,7 @@ CmdResult CommandKick::Handle (const std::vector<std::string>& parameters, User
                reason.assign(user->nick, 0, ServerInstance->Config->Limits.MaxKick);
        }
 
-       if (!c->KickUser(user, u, reason.c_str()))
-               /* Nobody left here, delete the Channel */
-               delete c;
+       c->KickUser(user, u, reason.c_str());
 
        return CMD_SUCCESS;
 }