1
0
mirror of https://github.com/anope/anope.git synced 2026-06-29 17:36:37 +02:00

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
This commit is contained in:
Adam-
2009-11-17 03:15:31 +00:00
parent 88c0edc8f8
commit 88330c07ad
6 changed files with 207 additions and 207 deletions
+59 -11
View File
@@ -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