|
@@ -49,54 +49,54 @@ public:
|
|
|
/**
|
|
|
* Creates a command return value with the given start cost and expense type
|
|
|
* @param ex_t the expense type
|
|
|
* @param cst the initial cost of this command
|
|
|
*/
|
|
|
CommandCost(ExpensesType ex_t, const Money &cst) : expense_type(ex_t), cost(cst), message(INVALID_STRING_ID), success(true), textref_stack_size(0) {}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* Adds the given cost to the cost of the command.
|
|
|
* @param cost the cost to add
|
|
|
*/
|
|
|
FORCEINLINE void AddCost(const Money &cost)
|
|
|
inline void AddCost(const Money &cost)
|
|
|
{
|
|
|
this->cost += cost;
|
|
|
}
|
|
|
|
|
|
void AddCost(const CommandCost &cmd_cost);
|
|
|
|
|
|
/**
|
|
|
* Multiplies the cost of the command by the given factor.
|
|
|
* @param factor factor to multiply the costs with
|
|
|
*/
|
|
|
FORCEINLINE void MultiplyCost(int factor)
|
|
|
inline void MultiplyCost(int factor)
|
|
|
{
|
|
|
this->cost *= factor;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* The costs as made up to this moment
|
|
|
* @return the costs
|
|
|
*/
|
|
|
FORCEINLINE Money GetCost() const
|
|
|
inline Money GetCost() const
|
|
|
{
|
|
|
return this->cost;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* The expense type of the cost
|
|
|
* @return the expense type
|
|
|
*/
|
|
|
FORCEINLINE ExpensesType GetExpensesType() const
|
|
|
inline ExpensesType GetExpensesType() const
|
|
|
{
|
|
|
return this->expense_type;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Makes this #CommandCost behave like an error command.
|
|
|
* @param message The error message.
|
|
|
*/
|
|
|
void MakeError(StringID message)
|
|
|
{
|
|
|
assert(message != INVALID_STRING_ID);
|
|
|
this->success = false;
|
|
@@ -128,34 +128,34 @@ public:
|
|
|
* @return the error message, if succeeded #INVALID_STRING_ID
|
|
|
*/
|
|
|
StringID GetErrorMessage() const
|
|
|
{
|
|
|
if (this->success) return INVALID_STRING_ID;
|
|
|
return this->message;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Did this command succeed?
|
|
|
* @return true if and only if it succeeded
|
|
|
*/
|
|
|
FORCEINLINE bool Succeeded() const
|
|
|
inline bool Succeeded() const
|
|
|
{
|
|
|
return this->success;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Did this command fail?
|
|
|
* @return true if and only if it failed
|
|
|
*/
|
|
|
FORCEINLINE bool Failed() const
|
|
|
inline bool Failed() const
|
|
|
{
|
|
|
return !this->success;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* List of commands.
|
|
|
*
|
|
|
* This enum defines all possible commands which can be executed to the game
|
|
|
* engine. Observing the game like the query-tool or checking the profit of a
|
|
|
* vehicle don't result in a command which should be executed in the engine
|
|
|
* nor send to the server in a network game.
|