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)
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)
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)
{