Changeset - r14549:56c5f10f6f93
[Not reviewed]
master
0 2 0
alberth - 14 years ago 2010-02-14 15:44:21
alberth@openttd.org
(svn r19130) -Codechange: Use references and inlining in CommandCost.
2 files changed with 10 insertions and 10 deletions:
0 comments (0 inline, 0 general)
src/command.cpp
Show inline comments
 
@@ -687,7 +687,7 @@ CommandCost DoCommandPInternal(TileIndex
 
 * 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) {
src/command_type.h
Show inline comments
 
@@ -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;
 
	}
0 comments (0 inline, 0 general)