mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r19130) -Codechange: Use references and inlining in CommandCost.
This commit is contained in:
parent
8641f08df3
commit
7dcc414000
|
@ -687,7 +687,7 @@ CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd,
|
|||
* Also takes a possible error message when it is set.
|
||||
* @param ret The command to add the cost of.
|
||||
*/
|
||||
void CommandCost::AddCost(CommandCost ret)
|
||||
void CommandCost::AddCost(const CommandCost &ret)
|
||||
{
|
||||
this->AddCost(ret.cost);
|
||||
if (this->success && !ret.success) {
|
||||
|
|
|
@ -48,25 +48,25 @@ public:
|
|||
* @param ex_t the expense type
|
||||
* @param cst the initial cost of this command
|
||||
*/
|
||||
CommandCost(ExpensesType ex_t, Money cst) : expense_type(ex_t), cost(cst), message(INVALID_STRING_ID), success(true) {}
|
||||
CommandCost(ExpensesType ex_t, const Money &cst) : expense_type(ex_t), cost(cst), message(INVALID_STRING_ID), success(true) {}
|
||||
|
||||
|
||||
/**
|
||||
* Adds the given cost to the cost of the command.
|
||||
* @param cost the cost to add
|
||||
*/
|
||||
void AddCost(Money cost)
|
||||
FORCEINLINE void AddCost(const Money &cost)
|
||||
{
|
||||
this->cost += cost;
|
||||
}
|
||||
|
||||
void AddCost(CommandCost ret);
|
||||
void AddCost(const CommandCost &cmd_cost);
|
||||
|
||||
/**
|
||||
* Multiplies the cost of the command by the given factor.
|
||||
* @param factor factor to multiply the costs with
|
||||
*/
|
||||
void MultiplyCost(int factor)
|
||||
FORCEINLINE void MultiplyCost(int factor)
|
||||
{
|
||||
this->cost *= factor;
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ public:
|
|||
* The costs as made up to this moment
|
||||
* @return the costs
|
||||
*/
|
||||
Money GetCost() const
|
||||
FORCEINLINE Money GetCost() const
|
||||
{
|
||||
return this->cost;
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ public:
|
|||
* The expense type of the cost
|
||||
* @return the expense type
|
||||
*/
|
||||
ExpensesType GetExpensesType() const
|
||||
FORCEINLINE ExpensesType GetExpensesType() const
|
||||
{
|
||||
return this->expense_type;
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ public:
|
|||
/**
|
||||
* Sets the global error message *if* this class has one.
|
||||
*/
|
||||
void SetGlobalErrorMessage() const
|
||||
FORCEINLINE void SetGlobalErrorMessage() const
|
||||
{
|
||||
extern StringID _error_message;
|
||||
if (this->message != INVALID_STRING_ID) _error_message = this->message;
|
||||
|
@ -126,7 +126,7 @@ public:
|
|||
* Did this command succeed?
|
||||
* @return true if and only if it succeeded
|
||||
*/
|
||||
bool Succeeded() const
|
||||
FORCEINLINE bool Succeeded() const
|
||||
{
|
||||
return this->success;
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ public:
|
|||
* Did this command fail?
|
||||
* @return true if and only if it failed
|
||||
*/
|
||||
bool Failed() const
|
||||
FORCEINLINE bool Failed() const
|
||||
{
|
||||
return !this->success;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue