diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/command_parse.cpp | 10 | ||||
-rw-r--r-- | src/modules.cpp | 18 | ||||
-rw-r--r-- | src/modules/extra/m_filter_pcre.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_helpop.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_randquote.cpp | 20 |
5 files changed, 38 insertions, 14 deletions
diff --git a/src/command_parse.cpp b/src/command_parse.cpp index 7c9e5aa5c..e735ad828 100644 --- a/src/command_parse.cpp +++ b/src/command_parse.cpp @@ -742,9 +742,13 @@ void CommandParser::ProcessBuffer(const char* cmdbuf,userrec *user) bool CommandParser::CreateCommand(command_t *f) { /* create the command and push it onto the table */ - cmdlist[f->command] = f; - log(DEBUG,"Added command %s (%lu parameters)",f->command.c_str(),(unsigned long)f->min_params); - return true; + if (cmdlist.find(f->command) != cmdlist.end()) + { + cmdlist[f->command] = f; + log(DEBUG,"Added command %s (%lu parameters)",f->command.c_str(),(unsigned long)f->min_params); + return true; + } + else return false } CommandParser::CommandParser() diff --git a/src/modules.cpp b/src/modules.cpp index b1ac75f8f..fa1c9e7bd 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -475,7 +475,11 @@ void Server::Log(int level, std::string s) void Server::AddCommand(command_t *f) { - ServerInstance->Parser->CreateCommand(f); + if (!ServerInstance->Parser->CreateCommand(f)) + { + ModuleException err("Command "+std::string(f->command)+" already exists."); + throw (err); + } } void Server::SendMode(char **parameters, int pcnt, userrec *user) @@ -619,24 +623,28 @@ bool Server::AddExtendedMode(char modechar, int type, bool requires_oper, int pa { if (type == MT_SERVER) { - log(DEBUG,"*** API ERROR *** Modes of type MT_SERVER are reserved for future expansion"); + ModuleException e("Modes of type MT_SERVER are reserved for future expansion"); + throw(e); return false; } if (((params_when_on>0) || (params_when_off>0)) && (type == MT_CLIENT)) { - log(DEBUG,"*** API ERROR *** Parameters on MT_CLIENT modes are not supported"); + ModuleException e("Parameters on MT_CLIENT modes are not supported"); + throw(e); return false; } if ((params_when_on>1) || (params_when_off>1)) { - log(DEBUG,"*** API ERROR *** More than one parameter for an MT_CHANNEL mode is not yet supported"); + ModuleException e("More than one parameter for an MT_CHANNEL mode is not yet supported"); + throw(e); return false; } return DoAddExtendedMode(modechar,type,requires_oper,params_when_on,params_when_off); } else { - log(DEBUG,"*** API ERROR *** Muppet modechar detected."); + ModuleException e("Muppet modechar detected."); + throw(e); } return false; } diff --git a/src/modules/extra/m_filter_pcre.cpp b/src/modules/extra/m_filter_pcre.cpp index fe3d721d4..638c1bd24 100644 --- a/src/modules/extra/m_filter_pcre.cpp +++ b/src/modules/extra/m_filter_pcre.cpp @@ -28,7 +28,7 @@ using namespace std; #include "modules.h" #include "helperfuncs.h" -class FilterPCREException +class FilterPCREException : public ModuleException { public: virtual char* GetReason() diff --git a/src/modules/m_helpop.cpp b/src/modules/m_helpop.cpp index 3272b3580..b3b3d113a 100644 --- a/src/modules/m_helpop.cpp +++ b/src/modules/m_helpop.cpp @@ -160,7 +160,7 @@ void sendtohelpop(userrec *src, int pcnt, char **params) Srv->SendToModeMask("oh",WM_AND,line); } -class HelpopException +class HelpopException : public ModuleException { private: std::string err; diff --git a/src/modules/m_randquote.cpp b/src/modules/m_randquote.cpp index 08de8876d..8ee07f242 100644 --- a/src/modules/m_randquote.cpp +++ b/src/modules/m_randquote.cpp @@ -62,6 +62,18 @@ class cmd_randquote : public command_t } }; +class RandquoteException : public ModuleException +{ + private: + std::string err; + public: + RandquoteException(std::string message) : err(message) { } + + virtual char* GetReason() + { + return (char*)err.c_str(); + } +} class ModuleRandQuote : public Module { @@ -85,15 +97,15 @@ class ModuleRandQuote : public Module if (q_file == "") { - log(DEFAULT,"m_randquote: Quotefile not specified - Please check your config."); - return; + RandquoteException e("m_randquote: Quotefile not specified - Please check your config."); + throw(e); } quotes = new FileReader(q_file); if(!quotes->Exists()) { - log(DEFAULT,"m_randquote: QuoteFile not Found!! Please check your config - module will not function."); - return; + RandquoteException e("m_randquote: QuoteFile not Found!! Please check your config - module will not function."); + throw(e); } else { |