]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Change Channel::KickUser() to accept an iterator, add overload that accepts a User
authorAttila Molnar <attilamolnar@hush.com>
Tue, 10 Jun 2014 15:12:00 +0000 (17:12 +0200)
committerAttila Molnar <attilamolnar@hush.com>
Tue, 10 Jun 2014 15:12:00 +0000 (17:12 +0200)
Remove srcmemb parameter

include/channels.h
src/channels.cpp
src/coremods/core_channel/cmd_kick.cpp

index 736ca2e98f602e36370712900e9f52970eee621b..cf7285210ea7801b69d6c868e4155dbbb6a99f1d 100644 (file)
@@ -178,11 +178,22 @@ class CoreExport Channel : public Extensible, public InviteBase<Channel>
 
        /** Make src kick user from this channel with the given reason.
         * @param src The source of the kick
-        * @param user The user being kicked (must be on this channel)
+        * @param victimiter Iterator to the user being kicked, must be valid
         * @param reason The reason for the kick
-        * @param srcmemb The membership of the user who does the kick, can be NULL
         */
-       void KickUser(User* src, User* user, const std::string& reason, Membership* srcmemb = NULL);
+       void KickUser(User* src, const UserMembIter& victimiter, const std::string& reason);
+
+       /** Make src kick user from this channel with the given reason.
+        * @param src The source of the kick
+        * @param user The user being kicked
+        * @param reason The reason for the kick
+        */
+       void KickUser(User* src, User* user, const std::string& reason)
+       {
+               UserMembIter it = userlist.find(user);
+               if (it != userlist.end())
+                       KickUser(src, it, reason);
+       }
 
        /** Part a user from this channel with the given reason.
         * If the reason field is NULL, no reason will be sent.
index 8b9e38e9c6ce4bb143bb48ec6884e8db5e96ae55..77b7f81db21281f835f104fce93bcfec68e1a230 100644 (file)
@@ -444,13 +444,13 @@ void Channel::PartUser(User *user, std::string &reason)
        }
 }
 
-void Channel::KickUser(User* src, User* victim, const std::string& reason, Membership* srcmemb)
+void Channel::KickUser(User* src, const UserMembIter& victimiter, const std::string& reason)
 {
-       UserMembIter victimiter = userlist.find(victim);
-       Membership* memb = ((victimiter != userlist.end()) ? victimiter->second : NULL);
+       Membership* memb = victimiter->second;
        CUList except_list;
        FOREACH_MOD(OnUserKick, (src, memb, reason, except_list));
 
+       User* victim = memb->user;
        WriteAllExcept(src, false, 0, except_list, "KICK %s %s :%s", name.c_str(), victim->nick.c_str(), reason.c_str());
 
        victim->chans.erase(memb);
index a9e7ee2cd57c8daf7c283297dca693f47fccce12..9039d8551a737ca62f36fa83a951f1ed66a336f2 100644 (file)
@@ -112,7 +112,7 @@ CmdResult CommandKick::Handle (const std::vector<std::string>& parameters, User
                }
        }
 
-       c->KickUser(user, u, reason, srcmemb);
+       c->KickUser(user, u, reason);
 
        return CMD_SUCCESS;
 }