diff options
author | Adam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864> | 2009-11-18 02:51:46 +0000 |
---|---|---|
committer | Adam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864> | 2009-11-18 02:51:46 +0000 |
commit | 5179a0a40f7edcf510fd3b296962c4d90c0840f9 (patch) | |
tree | 56a479f11b2c6f72ea80cbbdc6d7976203b4c3ec /src | |
parent | da8a1c7b6068dcc079d6f710a877ed53fabff86f (diff) |
Delete the correct entries from akick and badwords list when given a numlist
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2657 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src')
-rw-r--r-- | src/chanserv.c | 8 | ||||
-rw-r--r-- | src/core/bs_badwords.c | 7 | ||||
-rw-r--r-- | src/core/cs_akick.c | 20 | ||||
-rw-r--r-- | src/regchannel.cpp | 23 |
4 files changed, 40 insertions, 18 deletions
diff --git a/src/chanserv.c b/src/chanserv.c index d7b2a3bfa..6413e468b 100644 --- a/src/chanserv.c +++ b/src/chanserv.c @@ -1200,7 +1200,7 @@ int check_kick(User * user, const char *chan, time_t chants) { akick = ci->GetAkick(j); - if (!akick->HasFlag(AK_USED)) + if (!akick->InUse) continue; if ((akick->HasFlag(AK_ISNICK) && akick->nc == nc) @@ -1510,7 +1510,7 @@ void cs_remove_nick(const NickCore * nc) for (j = ci->GetAkickCount(); j > 0; --j) { akick = ci->GetAkick(j - 1); - if (akick->HasFlag(AK_USED) && akick->HasFlag(AK_ISNICK) && akick->nc == nc) + if (akick->InUse && akick->HasFlag(AK_ISNICK) && akick->nc == nc) ci->EraseAkick(akick); } } @@ -1852,7 +1852,7 @@ AutoKick *is_stuck(ChannelInfo * ci, const char *mask) { AutoKick *akick = ci->GetAkick(i); - if (!akick->HasFlag(AK_USED) || akick->HasFlag(AK_ISNICK) || !akick->HasFlag(AK_STUCK)) + if (!akick->InUse || akick->HasFlag(AK_ISNICK) || !akick->HasFlag(AK_STUCK)) continue; if (Anope::Match(akick->mask, mask, false)) @@ -1913,7 +1913,7 @@ void stick_all(ChannelInfo * ci) { AutoKick *akick = ci->GetAkick(i); - if (!akick->HasFlag(AK_USED) || (akick->HasFlag(AK_ISNICK) || !akick->HasFlag(AK_STUCK))) + if (!akick->InUse || (akick->HasFlag(AK_ISNICK) || !akick->HasFlag(AK_STUCK))) continue; av[0] = "+b"; diff --git a/src/core/bs_badwords.c b/src/core/bs_badwords.c index f8f98be09..6709dab0e 100644 --- a/src/core/bs_badwords.c +++ b/src/core/bs_badwords.c @@ -126,6 +126,9 @@ class CommandBSBadwords : public Command { notice_lang(s_BotServ, u, BOT_BADWORDS_DELETED_SEVERAL, deleted, ci->name); } + + if (deleted) + ci->CleanBadWords(); } else { @@ -239,7 +242,6 @@ class BSBadwords : public Module int badwords_del_callback(User * u, int num, va_list args) { - BadWord *bw; ChannelInfo *ci = va_arg(args, ChannelInfo *); int *last = va_arg(args, int *); @@ -248,8 +250,7 @@ int badwords_del_callback(User * u, int num, va_list args) if (num < 1 || num > ci->GetBadWordCount()) return 0; - bw = ci->GetBadWord(num - 1); - ci->EraseBadWord(bw); + ci->GetBadWord(num - 1)->InUse = false; return 1; } diff --git a/src/core/cs_akick.c b/src/core/cs_akick.c index 2753b947f..13bbad0a2 100644 --- a/src/core/cs_akick.c +++ b/src/core/cs_akick.c @@ -56,7 +56,7 @@ int akick_del_callback(User * u, int num, va_list args) if (num < 1 || num > ci->GetAkickCount()) return 0; - ci->EraseAkick(ci->GetAkick(num - 1)); + ci->GetAkick(num - 1)->InUse = false; return 1; } @@ -65,7 +65,7 @@ int akick_list(User * u, int index, ChannelInfo * ci, int *sent_header) { AutoKick *akick = ci->GetAkick(index); - if (!(akick->HasFlag(AK_USED))) + if (!akick->InUse) return 0; if (!*sent_header) { notice_lang(s_ChanServ, u, CHAN_AKICK_LIST_HEADER, ci->name); @@ -95,7 +95,7 @@ int akick_view(User * u, int index, ChannelInfo * ci, int *sent_header) char timebuf[64]; struct tm tm; - if (!(akick->HasFlag(AK_USED))) + if (!akick->InUse) return 0; if (!*sent_header) { notice_lang(s_ChanServ, u, CHAN_AKICK_LIST_HEADER, ci->name); @@ -235,7 +235,7 @@ class CommandCSAKick : public Command for (unsigned j = 0; j < ci->GetAkickCount(); ++j) { akick = ci->GetAkick(j); - if (!(akick->HasFlag(AK_USED))) + if (!akick->InUse) continue; if ((akick->HasFlag(AK_ISNICK)) ? akick->nc == nc : akick->mask == mask) { @@ -284,7 +284,7 @@ class CommandCSAKick : public Command { akick = ci->GetAkick(i); - if (!akick->HasFlag(AK_USED) || akick->HasFlag(AK_ISNICK)) + if (!akick->InUse || akick->HasFlag(AK_ISNICK)) continue; if (akick->mask == mask) break; @@ -324,7 +324,7 @@ class CommandCSAKick : public Command { akick = ci->GetAkick(i); - if (!akick->HasFlag(AK_USED) || akick->HasFlag(AK_ISNICK)) + if (!akick->InUse || akick->HasFlag(AK_ISNICK)) continue; if (akick->mask == mask) break; @@ -370,6 +370,8 @@ class CommandCSAKick : public Command notice_lang(s_ChanServ, u, CHAN_AKICK_DELETED_ONE, ci->name); else notice_lang(s_ChanServ, u, CHAN_AKICK_DELETED_SEVERAL, deleted, ci->name); + if (deleted) + ci->CleanAkick(); } else { @@ -380,7 +382,7 @@ class CommandCSAKick : public Command { akick = ci->GetAkick(i); - if (!(akick->HasFlag(AK_USED))) + if (!akick->InUse) continue; if (((akick->HasFlag(AK_ISNICK)) && akick->nc == nc) || (!(akick->HasFlag(AK_ISNICK)) @@ -421,7 +423,7 @@ class CommandCSAKick : public Command { akick = ci->GetAkick(i); - if (!(akick->HasFlag(AK_USED))) + if (!akick->InUse) continue; if (!mask.empty()) { @@ -460,7 +462,7 @@ class CommandCSAKick : public Command { akick = ci->GetAkick(i); - if (!(akick->HasFlag(AK_USED))) + if (!akick->InUse) continue; if (!mask.empty()) { diff --git a/src/regchannel.cpp b/src/regchannel.cpp index 1ecb97697..6bf2c64fe 100644 --- a/src/regchannel.cpp +++ b/src/regchannel.cpp @@ -247,7 +247,7 @@ AutoKick *ChannelInfo::AddAkick(const std::string &user, NickCore *akicknc, cons return NULL; AutoKick *autokick = new AutoKick(); - autokick->SetFlag(AK_USED); + autokick->InUse = true; autokick->SetFlag(AK_ISNICK); autokick->nc = akicknc; autokick->reason = reason; @@ -269,7 +269,7 @@ AutoKick *ChannelInfo::AddAkick(const std::string &user, const std::string &mask { AutoKick *autokick = new AutoKick(); autokick->mask = mask; - autokick->SetFlag(AK_USED); + autokick->InUse = true; autokick->reason = reason; autokick->creator = user; autokick->addtime = t; @@ -322,6 +322,15 @@ void ChannelInfo::ClearAkick() } } +/** Clean all of the nonused entries from the akick list + */ +void ChannelInfo::CleanAkick() +{ + for (unsigned i = akick.size(); i > 0; --i) + if (!akick[i - 1]->InUse) + EraseAkick(akick[i - 1]); +} + /** Add a badword to the badword list * @param word The badword * @param type The type (SINGLE START END) @@ -330,6 +339,7 @@ void ChannelInfo::ClearAkick() BadWord *ChannelInfo::AddBadWord(const std::string &word, BadWordType type) { BadWord *bw = new BadWord; + bw->InUse = true; bw->word = word; bw->type = type; @@ -381,6 +391,15 @@ void ChannelInfo::ClearBadWords() } } +/** Clean all of the nonused entries from the badwords list + */ +void ChannelInfo::CleanBadWords() +{ + for (unsigned i = badwords.size(); i > 0; --i) + if (!badwords[i - 1]->InUse) + EraseBadWord(badwords[i - 1]); +} + /** Check if a mode is mlocked * @param Name The mode * @param status True to check mlock on, false for mlock off |