Skip to content

Commit

Permalink
Merge branch 'master+cmdcleanup'
Browse files Browse the repository at this point in the history
  • Loading branch information
attilamolnar committed Jan 25, 2015
2 parents bdc7089 + b127d36 commit 1ea821e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 28 deletions.
32 changes: 4 additions & 28 deletions include/ctables.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,36 +163,16 @@ class CoreExport CommandBase : public ServiceProvider
* @param maxpara Maximum number of parameters this command may have - extra parameters
* will be tossed into one last space-seperated param.
*/
CommandBase(Module* me, const std::string &cmd, int minpara = 0, int maxpara = 0) :
ServiceProvider(me, cmd, SERVICE_COMMAND), flags_needed(0), min_params(minpara), max_params(maxpara),
use_count(0), disabled(false), works_before_reg(false), allow_empty_last_param(true),
Penalty(1)
{
}
CommandBase(Module* me, const std::string& cmd, unsigned int minpara = 0, unsigned int maxpara = 0);

virtual RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
{
return ROUTE_LOCALONLY;
}
virtual RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);

/** Encode a parameter for server->server transmission.
* Used for parameters for which the translation type is TR_CUSTOM.
* @param parameter The parameter to encode. Can be modified in place.
* @param index The parameter index (0 == first parameter).
*/
virtual void EncodeParameter(std::string& parameter, int index)
{
}

/** Decode a parameter from server->server transmission.
* Not currently used in this version of InspIRCd.
* Used for parameters for which the translation type is TR_CUSTOM.
* @param parameter The parameter to decode. Can be modified in place.
* @param index The parameter index (0 == first parameter).
*/
virtual void DecodeParameter(std::string& parameter, int index)
{
}
virtual void EncodeParameter(std::string& parameter, int index);

/** Disable or enable this command.
* @param setting True to disable the command.
Expand Down Expand Up @@ -229,11 +209,7 @@ class CoreExport Command : public CommandBase
*/
bool force_manual_route;

Command(Module* me, const std::string& cmd, unsigned int minpara = 0, unsigned int maxpara = 0)
: CommandBase(me, cmd, minpara, maxpara)
, force_manual_route(false)
{
}
Command(Module* me, const std::string& cmd, unsigned int minpara = 0, unsigned int maxpara = 0);

/** Handle the command from a user.
* @param parameters The parameters for the command.
Expand Down
28 changes: 28 additions & 0 deletions src/command_parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,38 @@ void CommandParser::RemoveCommand(Command* x)
cmdlist.erase(n);
}

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)
, disabled(false)
, works_before_reg(false)
, allow_empty_last_param(true)
, Penalty(1)
{
}

CommandBase::~CommandBase()
{
}

void CommandBase::EncodeParameter(std::string& parameter, int index)
{
}

RouteDescriptor CommandBase::GetRouting(User* user, const std::vector<std::string>& parameters)
{
return ROUTE_LOCALONLY;
}

Command::Command(Module* mod, const std::string& cmd, unsigned int minpara, unsigned int maxpara)
: CommandBase(mod, cmd, minpara, maxpara)
, force_manual_route(false)
{
}

Command::~Command()
{
ServerInstance->Parser.RemoveCommand(this);
Expand Down

0 comments on commit 1ea821e

Please sign in to comment.