diff options
author | Adam <Adam@anope.org> | 2010-12-06 17:06:57 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2010-12-12 19:37:03 -0500 |
commit | aed53dbb47822a79eb9a6b61095ad04ec3d67818 (patch) | |
tree | 72d3210b5609ea2163854d14ec7fb2f48d8b4d12 /src/actions.cpp | |
parent | a507816701d136a1c22d2f6779d811840d61577c (diff) |
Cleaned up some things, made the protocol modules use some basic inheritance to cut back on their code duplication. More work can be done in the future to remove even more of it.
Diffstat (limited to 'src/actions.cpp')
-rw-r--r-- | src/actions.cpp | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/src/actions.cpp b/src/actions.cpp index 6b3a96a24..b583cafae 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -30,7 +30,7 @@ bool bad_password(User *u) u->invalid_pw_time = Anope::CurTime; if (u->invalid_pw_count >= Config->BadPassLimit) { - kill_user("", u->nick, "Too many invalid passwords"); + kill_user("", u, "Too many invalid passwords"); return true; } @@ -41,48 +41,41 @@ bool bad_password(User *u) /** * Remove a user from the IRC network. - * @param source is the nick which should generate the kill, or NULL for a server-generated kill. + * @param source is the nick which should generate the kill, or empty for a server-generated kill. * @param user to remove * @param reason for the kill * @return void */ -void kill_user(const Anope::string &source, const Anope::string &user, const Anope::string &reason) +void kill_user(const Anope::string &source, User *user, const Anope::string &reason) { - if (user.empty()) + if (!user) return; Anope::string real_source = source.empty() ? Config->ServerName : source; Anope::string buf = real_source + " (" + reason + ")"; - ircdproto->SendSVSKill(findbot(source), finduser(user), "%s", buf.c_str()); + ircdproto->SendSVSKill(findbot(source), user, "%s", buf.c_str()); - if (!ircd->quitonkill && finduser(user)) + if (!ircd->quitonkill) do_kill(user, buf); } /*************************************************************************/ /** - * Unban the nick from a channel + * Unban the user from a channel * @param ci channel info for the channel - * @param nick to remove the ban for + * @param u The user to unban * @return void */ -void common_unban(ChannelInfo *ci, const Anope::string &nick) +void common_unban(ChannelInfo *ci, User *u) { - if (!ci || !ci->c || nick.empty()) - return; - - User *u = finduser(nick); - if (!u) - return; - - if (!ci->c->HasMode(CMODE_BAN)) + if (!u || !ci || !ci->c || !ci->c->HasMode(CMODE_BAN)) return; if (ircd->svsmode_unban) - ircdproto->SendBanDel(ci->c, nick); + ircdproto->SendBanDel(ci->c, u->nick); else { std::pair<Channel::ModeList::iterator, Channel::ModeList::iterator> bans = ci->c->GetModeList(CMODE_BAN); |