summaryrefslogtreecommitdiff
path: root/src/command_type.h
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-01-09 16:55:48 +0000
committerrubidium <rubidium@openttd.org>2008-01-09 16:55:48 +0000
commit46650c54b6a13ef5980eadb24995481f1fd83712 (patch)
treea0181571819fca45c3cc170c7ce718009cb12535 /src/command_type.h
parentb4337eba83e34ddaac29684d78202ae9623e9240 (diff)
downloadopenttd-46650c54b6a13ef5980eadb24995481f1fd83712.tar.xz
(svn r11793) -Codechange: pass the expense type via the CommandCost instead of a global variable. Patch by Noldo (FS#1114).
Diffstat (limited to 'src/command_type.h')
-rw-r--r--src/command_type.h22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/command_type.h b/src/command_type.h
index 6a2aad3d0..22f9c2014 100644
--- a/src/command_type.h
+++ b/src/command_type.h
@@ -14,6 +14,7 @@
* a possible error message/state together.
*/
class CommandCost {
+ ExpensesType expense_type; ///< the type of expence as shown on the finances view
Money cost; ///< The cost of this action
StringID message; ///< Warning message for when success is unset
bool success; ///< Whether the comment went fine up to this moment
@@ -22,18 +23,25 @@ public:
/**
* Creates a command cost return with no cost and no error
*/
- CommandCost() : cost(0), message(INVALID_STRING_ID), success(true) {}
+ CommandCost() : expense_type(INVALID_EXPENSES), cost(0), message(INVALID_STRING_ID), success(true) {}
/**
* Creates a command return value the is failed with the given message
*/
- CommandCost(StringID msg) : cost(0), message(msg), success(false) {}
+ CommandCost(StringID msg) : expense_type(INVALID_EXPENSES), cost(0), message(msg), success(false) {}
/**
- * Creates a command return value with the given start cost
+ * Creates a command cost with given expense type and start cost of 0
+ * @param ex_t the expense type
+ */
+ CommandCost(ExpensesType ex_t) : expense_type(ex_t), cost(0), message(INVALID_STRING_ID), success(true) {}
+
+ /**
+ * 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(Money cst) : cost(cst), message(INVALID_STRING_ID), success(true) {}
+ CommandCost(ExpensesType ex_t, Money cst) : expense_type(ex_t), cost(cst), message(INVALID_STRING_ID), success(true) {}
/**
* Adds the cost of the given command return value to this cost.
@@ -64,6 +72,12 @@ public:
Money GetCost() const;
/**
+ * The expense type of the cost
+ * @return the expense type
+ */
+ ExpensesType GetExpensesType() const;
+
+ /**
* Sets the global error message *if* this class has one.
*/
void SetGlobalErrorMessage() const;