X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fcommand_parse.cpp;h=3373f714f6330e566f52081f439388a89c44caa6;hb=de184f9d627d26efebd2da1756b8d1d20656b6ad;hp=fd103908829c1e481abe73d24605bea743c7878e;hpb=813c8981600b440a7cf762607fa6518b9e9b3d56;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/command_parse.cpp b/src/command_parse.cpp index fd1039088..3373f714f 100644 --- a/src/command_parse.cpp +++ b/src/command_parse.cpp @@ -287,10 +287,21 @@ bool CommandParser::ProcessCommand(User *user, std::string &cmd) if (MOD_RESULT == 1) return true; - if (user->registered == REG_ALL) - user->WriteNumeric(ERR_UNKNOWNCOMMAND, "%s %s :Unknown command",user->nick.c_str(),command.c_str()); - ServerInstance->stats->statsUnknown++; - return true; + /* + * This double lookup is in case a module (abbreviation) wishes to change a command. + * Sure, the double lookup is a bit painful, but bear in mind this only happens for unknowns anyway. + * + * Thanks dz for making me actually understand why this is necessary! + * -- w00t + */ + cm = cmdlist.find(command); + if (cm == cmdlist.end()) + { + if (user->registered == REG_ALL) + user->WriteNumeric(ERR_UNKNOWNCOMMAND, "%s %s :Unknown command",user->nick.c_str(),command.c_str()); + ServerInstance->stats->statsUnknown++; + return true; + } } if (cm->second->max_params && command_p.size() > cm->second->max_params) @@ -330,6 +341,10 @@ bool CommandParser::ProcessCommand(User *user, std::string &cmd) command_p.push_back(lparam); } + /* + * We call OnPreCommand here seperately if the command exists, so the magic above can + * truncate to max_params if necessary. -- w00t + */ int MOD_RESULT = 0; FOREACH_RESULT(I_OnPreCommand,OnPreCommand(command, command_p, user, false, cmd)); if (MOD_RESULT == 1) @@ -578,7 +593,13 @@ const char* CommandParser::LoadCommand(const char* name) void CommandParser::SetupCommandTable(User* user) { - RFCCommands.clear(); + for (SharedObjectList::iterator command = RFCCommands.begin(); command != RFCCommands.end(); command++) + { + Command *cmdptr = cmdlist.find(command->first)->second; + cmdlist.erase(cmdlist.find(command->first)); + RFCCommands.erase(command); + delete cmdptr; + } if (!user) {