diff options
author | Adam <Adam@anope.org> | 2010-07-31 21:37:45 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2010-07-31 21:37:45 -0400 |
commit | c770c47e18121e93bcdd06b1ab5f161440ffcfe2 (patch) | |
tree | 8e80d54507ab705e2dc51278c533c6000c8af1da /modules/core/cs_modes.cpp | |
parent | 9d0d44d738705a457ce08599ba50c97033a43c71 (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/core/cs_modes.cpp')
-rw-r--r-- | modules/core/cs_modes.cpp | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/modules/core/cs_modes.cpp b/modules/core/cs_modes.cpp index 5825b7a97..66f882147 100644 --- a/modules/core/cs_modes.cpp +++ b/modules/core/cs_modes.cpp @@ -399,16 +399,27 @@ class CommandCSDeOwner : public Command class CSModes : public Module { + CommandCSOwner commandcsowner; + CommandCSDeOwner commandcsdeowner; + CommandCSProtect commandcsprotect; + CommandCSDeProtect commandcsdeprotect; + CommandCSOp commandcsop; + CommandCSDeOp commandcsdeop; + CommandCSHalfOp commandcshalfop; + CommandCSDeHalfOp commandcsdehalfop; + CommandCSVoice commandcsvoice; + CommandCSDeVoice commandcsdevoice; + public: CSModes(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) { this->SetAuthor("Anope"); this->SetType(CORE); - this->AddCommand(ChanServ, new CommandCSOp()); - this->AddCommand(ChanServ, new CommandCSDeOp()); - this->AddCommand(ChanServ, new CommandCSVoice()); - this->AddCommand(ChanServ, new CommandCSDeVoice()); + this->AddCommand(ChanServ, &commandcsop); + this->AddCommand(ChanServ, &commandcsdeop); + this->AddCommand(ChanServ, &commandcsvoice); + this->AddCommand(ChanServ, &commandcsdevoice); if (Me && Me->IsSynced()) OnUplinkSync(NULL); @@ -421,31 +432,31 @@ class CSModes : public Module { if (ModeManager::FindChannelModeByName(CMODE_OWNER)) { - this->AddCommand(ChanServ, new CommandCSOwner()); - this->AddCommand(ChanServ, new CommandCSDeOwner()); + this->AddCommand(ChanServ, &commandcsowner); + this->AddCommand(ChanServ, &commandcsdeowner); } if (ModeManager::FindChannelModeByName(CMODE_PROTECT)) { - this->AddCommand(ChanServ, new CommandCSProtect()); - this->AddCommand(ChanServ, new CommandCSDeProtect()); + this->AddCommand(ChanServ, &commandcsprotect); + this->AddCommand(ChanServ, &commandcsdeprotect); } if (ModeManager::FindChannelModeByName(CMODE_HALFOP)) { - this->AddCommand(ChanServ, new CommandCSHalfOp()); - this->AddCommand(ChanServ, new CommandCSDeHalfOp()); + this->AddCommand(ChanServ, &commandcshalfop); + this->AddCommand(ChanServ, &commandcsdehalfop); } } void OnServerDisconnect() { - this->DelCommand(ChanServ, FindCommand(ChanServ, "OWNER")); - this->DelCommand(ChanServ, FindCommand(ChanServ, "DEOWNER")); - this->DelCommand(ChanServ, FindCommand(ChanServ, "PROTECT")); - this->DelCommand(ChanServ, FindCommand(ChanServ, "DEPROTECT")); - this->DelCommand(ChanServ, FindCommand(ChanServ, "HALFOP")); - this->DelCommand(ChanServ, FindCommand(ChanServ, "DEHALFOP")); + this->DelCommand(ChanServ, &commandcsowner); + this->DelCommand(ChanServ, &commandcsdeowner); + this->DelCommand(ChanServ, &commandcsprotect); + this->DelCommand(ChanServ, &commandcsdeprotect); + this->DelCommand(ChanServ, &commandcshalfop); + this->DelCommand(ChanServ, &commandcsdehalfop); } }; |