diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/modes/cmode_b.cpp | 157 |
1 files changed, 77 insertions, 80 deletions
diff --git a/src/modes/cmode_b.cpp b/src/modes/cmode_b.cpp index 66889364d..57e13159d 100644 --- a/src/modes/cmode_b.cpp +++ b/src/modes/cmode_b.cpp @@ -34,112 +34,109 @@ ModeAction ModeChannelBan::OnModeChange(userrec* source, userrec* dest, chanrec* std::string& ModeChannelBan::AddBan(userrec *user,std::string &dest,chanrec *chan,int status) { - BanItem b; - int toomanyexclamation = 0; - int toomanyat = 0; + BanItem b; + int toomanyexclamation = 0; + int toomanyat = 0; - if ((!user) || (!chan)) - { - log(DEFAULT,"*** BUG *** AddBan was given an invalid parameter"); + if ((!user) || (!chan)) + { + log(DEFAULT,"*** BUG *** AddBan was given an invalid parameter"); dest = ""; - return dest; - } + return dest; + } - for (std::string::iterator i = dest.begin(); i != dest.end(); i++) - { - if ((*i < 32) || (*i > 126)) - { + for (std::string::iterator i = dest.begin(); i != dest.end(); i++) + { + if ((*i < 32) || (*i > 126)) + { dest = ""; - return dest; - } - else if (*i == '!') - { - toomanyexclamation++; - } - else if (*i == '@') - { - toomanyat++; - } - } + return dest; + } + else if (*i == '!') + { + toomanyexclamation++; + } + else if (*i == '@') + { + toomanyat++; + } + } - if (toomanyexclamation != 1 || toomanyat != 1) + if (toomanyexclamation != 1 || toomanyat != 1) { - /* - * this stops sillyness like n!u!u!u@h, though note that most - * ircds don't actually verify banmask validity. --w00t - */ + /* + * this stops sillyness like n!u!u!u@h, though note that most + * ircds don't actually verify banmask validity. --w00t + */ dest = ""; - return dest; + return dest; } - long maxbans = GetMaxBans(chan->name); - if ((unsigned)chan->bans.size() > (unsigned)maxbans) - { - WriteServ(user->fd,"478 %s %s :Channel ban list for %s is full (maximum entries for this channel is %d)",user->nick, chan->name,chan->name,maxbans); + long maxbans = GetMaxBans(chan->name); + if ((unsigned)chan->bans.size() > (unsigned)maxbans) + { + WriteServ(user->fd,"478 %s %s :Channel ban list for %s is full (maximum entries for this channel is %d)",user->nick, chan->name,chan->name,maxbans); dest = ""; - return dest; - } - - log(DEBUG,"AddBan: %s %s",chan->name,user->nick); + return dest; + } - int MOD_RESULT = 0; - FOREACH_RESULT(I_OnAddBan,OnAddBan(user,chan,dest)); - if (MOD_RESULT) + int MOD_RESULT = 0; + FOREACH_RESULT(I_OnAddBan,OnAddBan(user,chan,dest)); + if (MOD_RESULT) { dest = ""; - return dest; + return dest; } - //TidyBan(dest); - for (BanList::iterator i = chan->bans.begin(); i != chan->bans.end(); i++) - { - if (!strcasecmp(i->data,dest.c_str())) - { - // dont allow a user to set the same ban twice + for (BanList::iterator i = chan->bans.begin(); i != chan->bans.end(); i++) + { + if (!strcasecmp(i->data,dest.c_str())) + { + /* dont allow a user to set the same ban twice */ dest = ""; - return dest; - } - } + return dest; + } + } - b.set_time = TIME; - strlcpy(b.data,dest.c_str(),MAXBUF); - if (*user->nick) - { - strlcpy(b.set_by,user->nick,NICKMAX-1); - } - else - { - strlcpy(b.set_by,Config->ServerName,NICKMAX-1); - } - chan->bans.push_back(b); - return dest; + b.set_time = TIME; + strlcpy(b.data,dest.c_str(),MAXBUF); + if (*user->nick) + { + strlcpy(b.set_by,user->nick,NICKMAX-1); + } + else + { + strlcpy(b.set_by,Config->ServerName,NICKMAX-1); + } + chan->bans.push_back(b); + return dest; } std::string& ModeChannelBan::DelBan(userrec *user,std::string& dest,chanrec *chan,int status) { - if ((!user) || (!chan)) { - log(DEFAULT,"*** BUG *** TakeBan was given an invalid parameter"); + if ((!user) || (!chan)) + { + log(DEFAULT,"*** BUG *** TakeBan was given an invalid parameter"); dest = ""; - return dest; - } + return dest; + } - log(DEBUG,"del_ban: %s %s",chan->name,user->nick); - for (BanList::iterator i = chan->bans.begin(); i != chan->bans.end(); i++) - { - if (!strcasecmp(i->data,dest.c_str())) - { - int MOD_RESULT = 0; - FOREACH_RESULT(I_OnDelBan,OnDelBan(user,chan,dest)); - if (MOD_RESULT) + for (BanList::iterator i = chan->bans.begin(); i != chan->bans.end(); i++) + { + if (!strcasecmp(i->data,dest.c_str())) + { + int MOD_RESULT = 0; + FOREACH_RESULT(I_OnDelBan,OnDelBan(user,chan,dest)); + if (MOD_RESULT) { dest = ""; - return dest; + return dest; } - chan->bans.erase(i); - return dest; - } - } + chan->bans.erase(i); + return dest; + } + } dest = ""; - return dest; + return dest; } |