From c770c47e18121e93bcdd06b1ab5f161440ffcfe2 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 31 Jul 2010 21:37:45 -0400 Subject: 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. --- modules/core/cs_modes.cpp | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) (limited to 'modules/core/cs_modes.cpp') 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); } }; -- cgit