1
0
Fork 0

(svn r19130) -Codechange: Use references and inlining in CommandCost.

release/1.0
alberth 2010-02-14 15:44:21 +00:00
parent 8641f08df3
commit 7dcc414000
2 changed files with 10 additions and 10 deletions

View File

@ -687,7 +687,7 @@ CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd,
* Also takes a possible error message when it is set. * Also takes a possible error message when it is set.
* @param ret The command to add the cost of. * @param ret The command to add the cost of.
*/ */
void CommandCost::AddCost(CommandCost ret) void CommandCost::AddCost(const CommandCost &ret)
{ {
this->AddCost(ret.cost); this->AddCost(ret.cost);
if (this->success && !ret.success) { if (this->success && !ret.success) {

View File

@ -48,25 +48,25 @@ public:
* @param ex_t the expense type * @param ex_t the expense type
* @param cst the initial cost of this command * @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. * Adds the given cost to the cost of the command.
* @param cost the cost to add * @param cost the cost to add
*/ */
void AddCost(Money cost) FORCEINLINE void AddCost(const Money &cost)
{ {
this->cost += cost; this->cost += cost;
} }
void AddCost(CommandCost ret); void AddCost(const CommandCost &cmd_cost);
/** /**
* Multiplies the cost of the command by the given factor. * Multiplies the cost of the command by the given factor.
* @param factor factor to multiply the costs with * @param factor factor to multiply the costs with
*/ */
void MultiplyCost(int factor) FORCEINLINE void MultiplyCost(int factor)
{ {
this->cost *= factor; this->cost *= factor;
} }
@ -75,7 +75,7 @@ public:
* The costs as made up to this moment * The costs as made up to this moment
* @return the costs * @return the costs
*/ */
Money GetCost() const FORCEINLINE Money GetCost() const
{ {
return this->cost; return this->cost;
} }
@ -84,7 +84,7 @@ public:
* The expense type of the cost * The expense type of the cost
* @return the expense type * @return the expense type
*/ */
ExpensesType GetExpensesType() const FORCEINLINE ExpensesType GetExpensesType() const
{ {
return this->expense_type; return this->expense_type;
} }
@ -92,7 +92,7 @@ public:
/** /**
* Sets the global error message *if* this class has one. * Sets the global error message *if* this class has one.
*/ */
void SetGlobalErrorMessage() const FORCEINLINE void SetGlobalErrorMessage() const
{ {
extern StringID _error_message; extern StringID _error_message;
if (this->message != INVALID_STRING_ID) _error_message = this->message; if (this->message != INVALID_STRING_ID) _error_message = this->message;
@ -126,7 +126,7 @@ public:
* Did this command succeed? * Did this command succeed?
* @return true if and only if it succeeded * @return true if and only if it succeeded
*/ */
bool Succeeded() const FORCEINLINE bool Succeeded() const
{ {
return this->success; return this->success;
} }
@ -135,7 +135,7 @@ public:
* Did this command fail? * Did this command fail?
* @return true if and only if it failed * @return true if and only if it failed
*/ */
bool Failed() const FORCEINLINE bool Failed() const
{ {
return !this->success; return !this->success;
} }