summaryrefslogtreecommitdiff
path: root/modules/extra
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2010-07-31 21:37:45 -0400
committerAdam <Adam@anope.org>2010-07-31 21:37:45 -0400
commitc770c47e18121e93bcdd06b1ab5f161440ffcfe2 (patch)
tree8e80d54507ab705e2dc51278c533c6000c8af1da /modules/extra
parent9d0d44d738705a457ce08599ba50c97033a43c71 (diff)
Don't dynamically allocate commands in modules anymore, instead made them members of modules. This means the commands are automatically destructed when the module is unloaded. Cleans up some old ugly code.
Diffstat (limited to 'modules/extra')
-rw-r--r--modules/extra/cs_appendtopic.cpp4
-rw-r--r--modules/extra/cs_enforce.cpp4
-rw-r--r--modules/extra/cs_set_misc.cpp20
-rw-r--r--modules/extra/cs_tban.cpp4
-rw-r--r--modules/extra/hs_request.cpp13
-rw-r--r--modules/extra/ns_set_misc.cpp19
6 files changed, 51 insertions, 13 deletions
diff --git a/modules/extra/cs_appendtopic.cpp b/modules/extra/cs_appendtopic.cpp
index 8d376e661..42ccb8187 100644
--- a/modules/extra/cs_appendtopic.cpp
+++ b/modules/extra/cs_appendtopic.cpp
@@ -130,6 +130,8 @@ class CommandCSAppendTopic : public Command
class CSAppendTopic : public Module
{
+ CommandCSAppendTopic commandcsappendtopic;
+
public:
CSAppendTopic(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator)
{
@@ -138,7 +140,7 @@ class CSAppendTopic : public Module
this->SetAuthor(AUTHOR);
this->SetType(SUPPORTED);
- this->AddCommand(ChanServ, new CommandCSAppendTopic());
+ this->AddCommand(ChanServ, &commandcsappendtopic);
/* English (US) */
const char *langtable_en_us[] = {
diff --git a/modules/extra/cs_enforce.cpp b/modules/extra/cs_enforce.cpp
index a32d5a8f5..cba949e1d 100644
--- a/modules/extra/cs_enforce.cpp
+++ b/modules/extra/cs_enforce.cpp
@@ -220,6 +220,8 @@ class CommandCSEnforce : public Command
class CSEnforce : public Module
{
+ CommandCSEnforce commandcsenforce;
+
public:
CSEnforce(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator)
{
@@ -228,7 +230,7 @@ class CSEnforce : public Module
this->SetAuthor(AUTHOR);
this->SetType(SUPPORTED);
- this->AddCommand(ChanServ, new CommandCSEnforce());
+ this->AddCommand(ChanServ, &commandcsenforce);
/* English (US) */
const char *langtable_en_us[] = {
diff --git a/modules/extra/cs_set_misc.cpp b/modules/extra/cs_set_misc.cpp
index d287a24c1..48cd636e7 100644
--- a/modules/extra/cs_set_misc.cpp
+++ b/modules/extra/cs_set_misc.cpp
@@ -69,6 +69,7 @@ class CSSetMisc : public Module
Anope::string Name;
Anope::string Desc;
bool ShowHidden;
+ Command *c;
CommandInfo(const Anope::string &name, const Anope::string &desc, bool showhidden) : Name(name), Desc(desc), ShowHidden(showhidden) { }
};
@@ -89,10 +90,23 @@ class CSSetMisc : public Module
for (std::map<Anope::string, CommandInfo *>::const_iterator it = this->Commands.begin(), it_end = this->Commands.end(); it != it_end; ++it)
{
if (set)
- set->DelSubcommand(it->first);
+ {
+ Command *c = set->FindSubcommand(it->second->Name);
+ if (c)
+ {
+ set->DelSubcommand(c);
+ delete c;
+ }
+ }
if (saset)
- saset->DelSubcommand(it->first);
- delete it->second;
+ {
+ Command *c = saset->FindSubcommand(it->second->Name);
+ if (c)
+ {
+ saset->DelSubcommand(c);
+ delete c;
+ }
+ }
}
this->Commands.clear();
diff --git a/modules/extra/cs_tban.cpp b/modules/extra/cs_tban.cpp
index d09677df6..d01c96ee5 100644
--- a/modules/extra/cs_tban.cpp
+++ b/modules/extra/cs_tban.cpp
@@ -91,12 +91,14 @@ class CommandCSTBan : public Command
class CSTBan : public Module
{
+ CommandCSTBan commandcstban;
+
public:
CSTBan(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator)
{
me = this;
- this->AddCommand(ChanServ, new CommandCSTBan());
+ this->AddCommand(ChanServ, &commandcstban);
this->SetAuthor(AUTHOR);
this->SetType(SUPPORTED);
diff --git a/modules/extra/hs_request.cpp b/modules/extra/hs_request.cpp
index 5c5a649f0..6fd48a3ef 100644
--- a/modules/extra/hs_request.cpp
+++ b/modules/extra/hs_request.cpp
@@ -342,15 +342,20 @@ class CommandHSWaiting : public HSListBase
class HSRequest : public Module
{
+ CommandHSRequest commandhsrequest;
+ CommandHSActivate commandhsactive;
+ CommandHSReject commandhsreject;
+ CommandHSWaiting commandhswaiting;
+
public:
HSRequest(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator)
{
me = this;
- this->AddCommand(HostServ, new CommandHSRequest());
- this->AddCommand(HostServ, new CommandHSActivate());
- this->AddCommand(HostServ, new CommandHSReject());
- this->AddCommand(HostServ, new CommandHSWaiting());
+ this->AddCommand(HostServ, &commandhsrequest);
+ this->AddCommand(HostServ, &commandhsactive);
+ this->AddCommand(HostServ, &commandhsreject);
+ this->AddCommand(HostServ, &commandhswaiting);
this->SetAuthor(AUTHOR);
this->SetType(SUPPORTED);
diff --git a/modules/extra/ns_set_misc.cpp b/modules/extra/ns_set_misc.cpp
index 8ab54fd05..87113fb67 100644
--- a/modules/extra/ns_set_misc.cpp
+++ b/modules/extra/ns_set_misc.cpp
@@ -107,10 +107,23 @@ class NSSetMisc : public Module
for (std::map<Anope::string, CommandInfo *>::const_iterator it = this->Commands.begin(), it_end = this->Commands.end(); it != it_end; ++it)
{
if (set)
- set->DelSubcommand(it->first);
+ {
+ Command *c = set->FindSubcommand(it->second->Name);
+ if (c)
+ {
+ set->DelSubcommand(c);
+ delete c;
+ }
+ }
if (saset)
- saset->DelSubcommand(it->first);
- delete it->second;
+ {
+ Command *c = saset->FindSubcommand(it->second->Name);
+ if (c)
+ {
+ saset->DelSubcommand(c);
+ delete c;
+ }
+ }
}
this->Commands.clear();