diff options
author | Attila Molnar <attilamolnar@hush.com> | 2014-06-10 17:12:00 +0200 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2014-06-10 17:12:00 +0200 |
commit | 854af2945eb6b9b62c19e3c823d3bcc8a84e52ae (patch) | |
tree | 3ccf9b4ae39f4ae7964a0391f6af7ee3045fb8e4 | |
parent | bef2d3f462cacd978898235dc49a0a6c3bac0356 (diff) |
Change Channel::KickUser() to accept an iterator, add overload that accepts a User
Remove srcmemb parameter
-rw-r--r-- | include/channels.h | 17 | ||||
-rw-r--r-- | src/channels.cpp | 6 | ||||
-rw-r--r-- | src/coremods/core_channel/cmd_kick.cpp | 2 |
3 files changed, 18 insertions, 7 deletions
diff --git a/include/channels.h b/include/channels.h index 736ca2e98..cf7285210 100644 --- a/include/channels.h +++ b/include/channels.h @@ -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. diff --git a/src/channels.cpp b/src/channels.cpp index 8b9e38e9c..77b7f81db 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -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); diff --git a/src/coremods/core_channel/cmd_kick.cpp b/src/coremods/core_channel/cmd_kick.cpp index a9e7ee2cd..9039d8551 100644 --- a/src/coremods/core_channel/cmd_kick.cpp +++ b/src/coremods/core_channel/cmd_kick.cpp @@ -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; } |