mirror of
https://github.com/anope/anope.git
synced 2026-07-08 01:23:14 +02:00
Fix deleting badwords/modes/logs etc
This commit is contained in:
@@ -32,6 +32,7 @@ struct BadWord
|
||||
Anope::string word;
|
||||
BadWordType type;
|
||||
|
||||
virtual ~BadWord() { }
|
||||
protected:
|
||||
BadWord() { }
|
||||
};
|
||||
|
||||
@@ -35,6 +35,8 @@ struct BadWordsImpl : BadWords
|
||||
|
||||
BadWordsImpl(Extensible *obj) : ci(anope_dynamic_static_cast<ChannelInfo *>(obj)), badwords("BadWord") { }
|
||||
|
||||
~BadWordsImpl();
|
||||
|
||||
BadWord* AddBadWord(const Anope::string &word, BadWordType type) anope_override
|
||||
{
|
||||
BadWordImpl *bw = new BadWordImpl();
|
||||
@@ -87,6 +89,16 @@ struct BadWordsImpl : BadWords
|
||||
}
|
||||
};
|
||||
|
||||
BadWordsImpl::~BadWordsImpl()
|
||||
{
|
||||
for (list::iterator it = badwords->begin(); it != badwords->end();)
|
||||
{
|
||||
BadWord *bw = *it;
|
||||
++it;
|
||||
delete bw;
|
||||
}
|
||||
}
|
||||
|
||||
BadWordImpl::~BadWordImpl()
|
||||
{
|
||||
ChannelInfo *ci = ChannelInfo::Find(chan);
|
||||
|
||||
@@ -26,6 +26,8 @@ struct EntryMsg : Serializable
|
||||
this->when = ct;
|
||||
}
|
||||
|
||||
~EntryMsg();
|
||||
|
||||
void Serialize(Serialize::Data &data) const anope_override
|
||||
{
|
||||
data["ci"] << this->ci->name;
|
||||
@@ -43,11 +45,23 @@ struct EntryMessageList : Serialize::Checker<std::vector<EntryMsg *> >
|
||||
|
||||
~EntryMessageList()
|
||||
{
|
||||
for (unsigned i = 0; i < (*this)->size(); ++i)
|
||||
delete (*this)->at(i);
|
||||
for (unsigned i = (*this)->size(); i > 0; --i)
|
||||
delete (*this)->at(i - 1);
|
||||
}
|
||||
};
|
||||
|
||||
EntryMsg::~EntryMsg()
|
||||
{
|
||||
EntryMessageList *messages = ci->GetExt<EntryMessageList>("entrymsg");
|
||||
if (messages)
|
||||
{
|
||||
std::vector<EntryMsg *>::iterator it = std::find((*messages)->begin(), (*messages)->end(), this);
|
||||
if (it != (*messages)->end())
|
||||
(*messages)->erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Serializable* EntryMsg::Unserialize(Serializable *obj, Serialize::Data &data)
|
||||
{
|
||||
Anope::string sci, screator, smessage;
|
||||
@@ -71,9 +85,7 @@ Serializable* EntryMsg::Unserialize(Serializable *obj, Serialize::Data &data)
|
||||
return msg;
|
||||
}
|
||||
|
||||
EntryMessageList *messages = ci->GetExt<EntryMessageList>("entrymsg");
|
||||
if (messages == NULL)
|
||||
messages = ci->Extend<EntryMessageList>("entrymsg");
|
||||
EntryMessageList *messages = ci->Require<EntryMessageList>("entrymsg");
|
||||
|
||||
data["when"] >> swhen;
|
||||
|
||||
@@ -87,9 +99,7 @@ class CommandEntryMessage : public Command
|
||||
private:
|
||||
void DoList(CommandSource &source, ChannelInfo *ci)
|
||||
{
|
||||
EntryMessageList *messages = ci->GetExt<EntryMessageList>("entrymsg");
|
||||
if (messages == NULL)
|
||||
messages = ci->Extend<EntryMessageList>("entrymsg");
|
||||
EntryMessageList *messages = ci->Require<EntryMessageList>("entrymsg");
|
||||
|
||||
if ((*messages)->empty())
|
||||
{
|
||||
@@ -123,9 +133,7 @@ class CommandEntryMessage : public Command
|
||||
|
||||
void DoAdd(CommandSource &source, ChannelInfo *ci, const Anope::string &message)
|
||||
{
|
||||
EntryMessageList *messages = ci->GetExt<EntryMessageList>("entrymsg");
|
||||
if (messages == NULL)
|
||||
messages = ci->Extend<EntryMessageList>("entrymsg");
|
||||
EntryMessageList *messages = ci->Require<EntryMessageList>("entrymsg");
|
||||
|
||||
if ((*messages)->size() >= Config->GetModule(this->owner)->Get<unsigned>("maxentries"))
|
||||
source.Reply(_("The entry message list for \002%s\002 is full."), ci->name.c_str());
|
||||
@@ -139,9 +147,7 @@ class CommandEntryMessage : public Command
|
||||
|
||||
void DoDel(CommandSource &source, ChannelInfo *ci, const Anope::string &message)
|
||||
{
|
||||
EntryMessageList *messages = ci->GetExt<EntryMessageList>("entrymsg");
|
||||
if (messages == NULL)
|
||||
messages = ci->Extend<EntryMessageList>("entrymsg");
|
||||
EntryMessageList *messages = ci->Require<EntryMessageList>("entrymsg");
|
||||
|
||||
if (!message.is_pos_number_only())
|
||||
source.Reply(("Entry message \002%s\002 not found on channel \002%s\002."), message.c_str(), ci->name.c_str());
|
||||
@@ -155,7 +161,6 @@ class CommandEntryMessage : public Command
|
||||
if (i > 0 && i <= (*messages)->size())
|
||||
{
|
||||
delete (*messages)->at(i - 1);
|
||||
(*messages)->erase((*messages)->begin() + i - 1);
|
||||
if ((*messages)->empty())
|
||||
ci->Shrink<EntryMessageList>("entrymsg");
|
||||
Log(source.IsFounder(ci) ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to remove a message";
|
||||
@@ -246,14 +251,15 @@ class CommandEntryMessage : public Command
|
||||
|
||||
class CSEntryMessage : public Module
|
||||
{
|
||||
Serialize::Type entrymsg_type;
|
||||
CommandEntryMessage commandentrymsg;
|
||||
Serialize::Type entrymsg_type;
|
||||
ExtensibleItem<EntryMessageList> eml;
|
||||
|
||||
public:
|
||||
CSEntryMessage(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), entrymsg_type("EntryMsg", EntryMsg::Unserialize), commandentrymsg(this), eml(this, "entrymsg")
|
||||
CSEntryMessage(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
|
||||
commandentrymsg(this), eml(this, "entrymsg"),
|
||||
entrymsg_type("EntryMsg", EntryMsg::Unserialize)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void OnJoinChannel(User *u, Channel *c) anope_override
|
||||
|
||||
@@ -277,8 +277,8 @@ class CSLog : public Module
|
||||
{
|
||||
ServiceReference<MemoServService> MSService;
|
||||
CommandCSLog commandcslog;
|
||||
ExtensibleItem<LogSettingsImpl> logsettings;
|
||||
Serialize::Type logsetting_type;
|
||||
ExtensibleItem<LogSettingsImpl> logsettings;
|
||||
|
||||
struct LogDefault
|
||||
{
|
||||
@@ -289,8 +289,9 @@ class CSLog : public Module
|
||||
|
||||
public:
|
||||
CSLog(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
|
||||
MSService("MemoServService", "MemoServ"), commandcslog(this), logsettings(this, "logsettings"),
|
||||
logsetting_type("LogSetting", LogSettingImpl::Unserialize)
|
||||
MSService("MemoServService", "MemoServ"), commandcslog(this),
|
||||
logsetting_type("LogSetting", LogSettingImpl::Unserialize),
|
||||
logsettings(this, "logsettings")
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -42,6 +42,16 @@ struct ModeLocksImpl : ModeLocks
|
||||
{
|
||||
}
|
||||
|
||||
~ModeLocksImpl()
|
||||
{
|
||||
for (ModeList::iterator it = this->mlocks->begin(); it != this->mlocks->end();)
|
||||
{
|
||||
ModeLock *ml = *it;
|
||||
++it;
|
||||
delete ml;
|
||||
}
|
||||
}
|
||||
|
||||
bool HasMLock(ChannelMode *mode, const Anope::string ¶m, bool status) const anope_override
|
||||
{
|
||||
if (!mode)
|
||||
@@ -818,13 +828,14 @@ class CSMode : public Module
|
||||
{
|
||||
CommandCSMode commandcsmode;
|
||||
CommandCSModes commandcsmodes;
|
||||
ExtensibleItem<ModeLocksImpl> modelocks;
|
||||
Serialize::Type modelocks_type;
|
||||
ExtensibleItem<ModeLocksImpl> modelocks;
|
||||
|
||||
public:
|
||||
CSMode(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
|
||||
commandcsmode(this), commandcsmodes(this),
|
||||
modelocks(this, "modelocks"), modelocks_type("ModeLock", ModeLockImpl::Unserialize)
|
||||
modelocks_type("ModeLock", ModeLockImpl::Unserialize),
|
||||
modelocks(this, "modelocks")
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -27,6 +27,17 @@ struct AJoinEntry : Serializable
|
||||
|
||||
AJoinEntry(Extensible *) : Serializable("AJoinEntry") { }
|
||||
|
||||
~AJoinEntry()
|
||||
{
|
||||
AJoinList *channels = owner->GetExt<AJoinList>("ajoinlist");
|
||||
if (channels)
|
||||
{
|
||||
std::vector<AJoinEntry *>::iterator it = std::find((*channels)->begin(), (*channels)->end(), this);
|
||||
if (it != (*channels)->end())
|
||||
(*channels)->erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
void Serialize(Serialize::Data &sd) const anope_override
|
||||
{
|
||||
if (!this->owner)
|
||||
@@ -147,7 +158,6 @@ class CommandNSAJoin : public Command
|
||||
else
|
||||
{
|
||||
delete (*channels)->at(i);
|
||||
(*channels)->erase((*channels)->begin() + i);
|
||||
source.Reply(_("%s was removed from %s's auto join list."), chan.c_str(), nc->display.c_str());
|
||||
}
|
||||
|
||||
@@ -214,13 +224,14 @@ class CommandNSAJoin : public Command
|
||||
|
||||
class NSAJoin : public Module
|
||||
{
|
||||
Serialize::Type ajoinentry_type;
|
||||
CommandNSAJoin commandnsajoin;
|
||||
Serialize::Type ajoinentry_type;
|
||||
ExtensibleItem<AJoinList> ajoinlist;
|
||||
|
||||
public:
|
||||
NSAJoin(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
|
||||
ajoinentry_type("AJoinEntry", AJoinEntry::Unserialize), commandnsajoin(this), ajoinlist(this, "ajoinlist")
|
||||
commandnsajoin(this),
|
||||
ajoinentry_type("AJoinEntry", AJoinEntry::Unserialize), ajoinlist(this, "ajoinlist")
|
||||
{
|
||||
|
||||
if (!IRCD->CanSVSJoin)
|
||||
|
||||
Reference in New Issue
Block a user