summaryrefslogtreecommitdiff
path: root/src/command.cpp
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.cpp
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.cpp')
-rw-r--r--src/command.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/command.cpp b/src/command.cpp
index fdd595a28..40161688b 100644
--- a/src/command.cpp
+++ b/src/command.cpp
@@ -441,7 +441,7 @@ CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint32
}
/* Execute the command here. All cost-relevant functions set the expenses type
- * themselves with "SET_EXPENSES_TYPE(...);" at the beginning of the function */
+ * themselves to the cost object at some point */
res = proc(tile, flags, p1, p2);
if (CmdFailed(res)) {
res.SetGlobalErrorMessage();
@@ -622,7 +622,6 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
/* Actually try and execute the command. If no cost-type is given
* use the construction one */
- _yearly_expenses_type = EXPENSES_CONSTRUCTION;
res2 = proc(tile, flags | DC_EXEC, p1, p2);
/* If notest is on, it means the result of the test can be different than
@@ -697,6 +696,11 @@ Money CommandCost::GetCost() const
return this->cost;
}
+ExpensesType CommandCost::GetExpensesType() const
+{
+ return this->expense_type;
+}
+
void CommandCost::SetGlobalErrorMessage() const
{
extern StringID _error_message;