]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Implement Command::RegisterService()
authorAttila Molnar <attilamolnar@hush.com>
Mon, 23 Nov 2015 11:50:35 +0000 (12:50 +0100)
committerAttila Molnar <attilamolnar@hush.com>
Mon, 23 Nov 2015 11:50:35 +0000 (12:50 +0100)
include/ctables.h
src/command_parse.cpp
src/modules.cpp

index abf65f56127122f2e742b76592b3b65fdd8f23fe..bc4226ea93b5c7b73165fc748086c25195fd74ec 100644 (file)
@@ -218,6 +218,10 @@ class CoreExport Command : public CommandBase
         */
        virtual CmdResult Handle(const std::vector<std::string>& parameters, User* user) = 0;
 
+       /** Register this object in the CommandParser
+        */
+       void RegisterService() CXX11_OVERRIDE;
+
        /** Destructor
         * Removes this command from the command parser
         */
index 7998d9cc3a982f0f71732a2f7dfe4af2b831e9f3..c123353b0a96b94da8c6ded03762afdc7c92be3e 100644 (file)
@@ -379,6 +379,12 @@ Command::~Command()
        ServerInstance->Parser.RemoveCommand(this);
 }
 
+void Command::RegisterService()
+{
+       if (!ServerInstance->Parser.AddCommand(this))
+               throw ModuleException("Command already exists: " + name);
+}
+
 void CommandParser::ProcessBuffer(std::string &buffer,LocalUser *user)
 {
        if (buffer.empty())
index 3ff8aad145f3aec69cfb973617e6bd418822f95d..d28657ca8359d1256b9e9224e221080a5a651dc4 100644 (file)
@@ -556,10 +556,6 @@ void ModuleManager::AddService(ServiceProvider& item)
 {
        switch (item.service)
        {
-               case SERVICE_COMMAND:
-                       if (!ServerInstance->Parser.AddCommand(static_cast<Command*>(&item)))
-                               throw ModuleException("Command "+std::string(item.name)+" already exists.");
-                       return;
                case SERVICE_MODE:
                {
                        ModeHandler* mh = static_cast<ModeHandler*>(&item);