diff options
| author | Adam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864> | 2009-11-17 03:15:31 +0000 |
|---|---|---|
| committer | Adam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864> | 2009-11-17 03:15:31 +0000 |
| commit | 88330c07adc5bb3b085cf6ede1d30c0c48afcfb6 (patch) | |
| tree | 3effa4cdbc3c0be79bd812580d77c3884636b6ec /src/regchannel.cpp | |
| parent | 88c0edc8f8f2f3aad67e69593b107b7bd0a56a35 (diff) | |
Cleand up alot of the code in bs_badwords, made it much more C++-ish
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2654 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/regchannel.cpp')
| -rw-r--r-- | src/regchannel.cpp | 70 |
1 files changed, 59 insertions, 11 deletions
diff --git a/src/regchannel.cpp b/src/regchannel.cpp index db3850d6c..2b1dee411 100644 --- a/src/regchannel.cpp +++ b/src/regchannel.cpp @@ -31,8 +31,6 @@ ChannelInfo::ChannelInfo(const std::string &chname) levels = NULL; entry_message = NULL; c = NULL; - bwcount = 0; - badwords = NULL; capsmin = capspercent = 0; floodlines = floodsecs = 0; repeattimes = 0; @@ -126,15 +124,6 @@ ChannelInfo::~ChannelInfo() if (this->ttb) delete [] this->ttb; - for (i = 0; i < this->bwcount; i++) - { - if (this->badwords[i].word) - delete [] this->badwords[i].word; - } - - if (this->badwords) - free(this->badwords); - if (this->founder) this->founder->channelcount--; } @@ -333,6 +322,65 @@ void ChannelInfo::ClearAkick() } } +/** Add a badword to the badword list + * @param word The badword + * @param type The type (SINGLE START END) + * @return The badword + */ +BadWord *ChannelInfo::AddBadWord(const std::string &word, BadWordType type) +{ + BadWord *bw = new BadWord; + bw->word = word; + bw->type = type; + + badwords.push_back(bw); + return bw; +} + +/** Get a badword structure by index + * @param index The index + * @return The badword + */ +BadWord *ChannelInfo::GetBadWord(unsigned index) +{ + if (badwords.empty() || index >= badwords.size()) + return NULL; + + return badwords[index]; +} + +/** Get how many badwords are on this channel + * @return The number of badwords in the vector + */ +const unsigned ChannelInfo::GetBadWordCount() const +{ + return badwords.empty() ? 0 : badwords.size(); +} + +/** Remove a badword + * @param badword The badword + */ +void ChannelInfo::EraseBadWord(BadWord *badword) +{ + std::vector<BadWord *>::iterator it = std::find(badwords.begin(), badwords.end(), badword); + + if (it != badwords.end()) + { + delete *it; + badwords.erase(it); + } +} + +/** Clear all badwords from the channel + */ +void ChannelInfo::ClearBadWords() +{ + for (unsigned i = badwords.size(); i > 0; --i) + { + 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 |
