static Command *AddCommand(Module *module, char *msg, char *token, iFP func) { Command *cmd; if (CommandExists(msg)) { config_error("Command %s already exists", msg); return NULL; } if (CommandExists(token)) { config_error("Token %s already exists", token); return NULL; } cmd = CommandAdd(module, msg, token, func, MAXPARA, 0); #ifndef STATIC_LINKING if (ModuleGetError(module) != MODERR_NOERROR || !cmd) #else if (!cmd) #endif { #ifndef STATIC_LINKING config_error("Error adding command %s: %s", msg, ModuleGetErrorStr(module)); #else config_error("Error adding command %s", msg); #endif return NULL; } return cmd; }
BOOL Commandable::AddCommand(Command* com) { if (CommandExists(com->GetName())) { return false;; } _commands.push_back(com); return true; }
BOOL Commandable::RemoveCommand(const std::string &name) { std::vector<Command*>::iterator it, itEnd; if (!CommandExists(name)) { return false; } itEnd = _commands.end(); for (it = _commands.begin(); it != itEnd; ++it) { if ((*it)->GetName() == name) { _commands.erase(it); return true; } } return false; }