diff options
author | rubidium <rubidium@openttd.org> | 2008-01-09 16:55:48 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2008-01-09 16:55:48 +0000 |
commit | 46650c54b6a13ef5980eadb24995481f1fd83712 (patch) | |
tree | a0181571819fca45c3cc170c7ce718009cb12535 /src/misc_cmd.cpp | |
parent | b4337eba83e34ddaac29684d78202ae9623e9240 (diff) | |
download | openttd-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/misc_cmd.cpp')
-rw-r--r-- | src/misc_cmd.cpp | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/misc_cmd.cpp b/src/misc_cmd.cpp index 645455aae..1f05f5fd1 100644 --- a/src/misc_cmd.cpp +++ b/src/misc_cmd.cpp @@ -157,7 +157,7 @@ CommandCost CmdIncreaseLoan(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) InvalidatePlayerWindows(p); } - return CommandCost(); + return CommandCost(EXPENSES_OTHER); } /** Decrease the loan of your company. @@ -357,8 +357,7 @@ CommandCost CmdMoneyCheat(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) #ifndef _DEBUG if (_networking) return CMD_ERROR; #endif - SET_EXPENSES_TYPE(EXPENSES_OTHER); - return CommandCost(-(Money)p1); + return CommandCost(EXPENSES_OTHER, -(Money)p1); } /** Transfer funds (money) from one player to another. @@ -375,9 +374,7 @@ CommandCost CmdGiveMoney(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) if (!_patches.give_money) return CMD_ERROR; const Player *p = GetPlayer(_current_player); - CommandCost amount(min((Money)p1, (Money)20000000LL)); - - SET_EXPENSES_TYPE(EXPENSES_OTHER); + CommandCost amount(EXPENSES_OTHER, min((Money)p1, (Money)20000000LL)); /* You can only transfer funds that is in excess of your loan */ if (p->player_money - p->current_loan < amount.GetCost() || amount.GetCost() <= 0) return CMD_ERROR; @@ -387,7 +384,7 @@ CommandCost CmdGiveMoney(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) /* Add money to player */ PlayerID old_cp = _current_player; _current_player = (PlayerID)p2; - SubtractMoneyFromPlayer(CommandCost(-amount.GetCost())); + SubtractMoneyFromPlayer(CommandCost(EXPENSES_OTHER, -amount.GetCost())); _current_player = old_cp; } |