diff options
-rw-r--r-- | include/ctables.h | 43 | ||||
-rw-r--r-- | src/command_parse.cpp | 10 |
2 files changed, 20 insertions, 33 deletions
diff --git a/include/ctables.h b/include/ctables.h index 938deac15..4e3d196e6 100644 --- a/include/ctables.h +++ b/include/ctables.h @@ -148,10 +148,6 @@ class CoreExport CommandBase : public ServiceProvider const ClientProtocol::TagMap& GetTags() const { return tags; } }; - /** User flags needed to execute the command or 0 - */ - unsigned char flags_needed; - /** Minimum number of parameters command takes */ const unsigned int min_params; @@ -162,14 +158,6 @@ class CoreExport CommandBase : public ServiceProvider */ const unsigned int max_params; - /** used by /stats m - */ - unsigned long use_count; - - /** True if the command can be issued before registering - */ - bool works_before_reg; - /** True if the command allows an empty last parameter. * When false and the last parameter is empty, it's popped BEFORE * checking there are enough params, etc. (i.e. the handler won't @@ -179,20 +167,11 @@ class CoreExport CommandBase : public ServiceProvider */ bool allow_empty_last_param; - /** Syntax string for the command, displayed if non-empty string. - * This takes place of the text in the 'not enough parameters' numeric. - */ - std::string syntax; - /** Translation type list for possible parameters, used to tokenize * parameters into UIDs and SIDs etc. */ std::vector<TranslateType> translation; - /** How many seconds worth of penalty does this command have? - */ - unsigned int Penalty; - /** Create a new command. * @param me The module which created this command. * @param cmd Command name. This must be UPPER CASE. @@ -211,24 +190,32 @@ class CoreExport CommandBase : public ServiceProvider */ virtual void EncodeParameter(std::string& parameter, unsigned int index); - /** @return true if the command works before registration. - */ - bool WorksBeforeReg() - { - return works_before_reg; - } - virtual ~CommandBase(); }; class CoreExport Command : public CommandBase { public: + /** The user modes required to be able to execute this command. */ + unsigned char flags_needed; + /** If true, the command will not be forwarded by the linking module even if it comes via ENCAP. * Can be used to forward commands before their effects. */ bool force_manual_route; + /** The number of seconds worth of penalty that executing this command gives. */ + unsigned int Penalty; + + /** The number of times this command has been executed. */ + unsigned long use_count; + + /** If non-empty then the syntax of the parameter for this command. */ + std::string syntax; + + /** Whether the command can be issued before registering. */ + bool works_before_reg; + Command(Module* me, const std::string& cmd, unsigned int minpara = 0, unsigned int maxpara = 0); /** Handle the command from a user. diff --git a/src/command_parse.cpp b/src/command_parse.cpp index 0405a5659..f8c88a9f0 100644 --- a/src/command_parse.cpp +++ b/src/command_parse.cpp @@ -290,7 +290,7 @@ void CommandParser::ProcessCommand(LocalUser* user, std::string& command, Comman return; } - if ((user->registered != REG_ALL) && (!handler->WorksBeforeReg())) + if ((user->registered != REG_ALL) && (!handler->works_before_reg)) { user->CommandFloodPenalty += failpenalty; user->WriteNumeric(ERR_NOTREGISTERED, command, "You have not registered"); @@ -327,13 +327,9 @@ void CommandParser::RemoveCommand(Command* x) CommandBase::CommandBase(Module* mod, const std::string& cmd, unsigned int minpara, unsigned int maxpara) : ServiceProvider(mod, cmd, SERVICE_COMMAND) - , flags_needed(0) , min_params(minpara) , max_params(maxpara) - , use_count(0) - , works_before_reg(false) , allow_empty_last_param(true) - , Penalty(1) { } @@ -352,7 +348,11 @@ RouteDescriptor CommandBase::GetRouting(User* user, const Params& parameters) Command::Command(Module* mod, const std::string& cmd, unsigned int minpara, unsigned int maxpara) : CommandBase(mod, cmd, minpara, maxpara) + , flags_needed(0) , force_manual_route(false) + , Penalty(1) + , use_count(0) + , works_before_reg(false) { } |