summaryrefslogtreecommitdiff
path: root/src/town_cmd.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/town_cmd.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/town_cmd.cpp')
-rw-r--r--src/town_cmd.cpp11
1 files changed, 3 insertions, 8 deletions
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index bf74d116f..1f9dbfdc4 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -502,7 +502,7 @@ static void ClickTile_Town(TileIndex tile)
static CommandCost ClearTile_Town(TileIndex tile, byte flags)
{
int rating;
- CommandCost cost;
+ CommandCost cost(EXPENSES_CONSTRUCTION);
Town *t;
HouseSpec *hs = GetHouseSpecs(GetHouseType(tile));
@@ -1496,8 +1496,6 @@ CommandCost CmdBuildTown(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (_game_mode != GM_EDITOR) return CMD_ERROR;
if (p2 > TSM_CITY) return CMD_ERROR;
- SET_EXPENSES_TYPE(EXPENSES_OTHER);
-
/* Check if too close to the edge of map */
if (DistanceFromEdge(tile) < 12)
return_cmd_error(STR_0237_TOO_CLOSE_TO_EDGE_OF_MAP);
@@ -2097,7 +2095,6 @@ extern uint GetMaskOfTownActions(int *nump, PlayerID pid, const Town *t);
*/
CommandCost CmdDoTownAction(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
- CommandCost cost;
Town *t;
if (!IsValidTownID(p1) || p2 > lengthof(_town_action_proc)) return CMD_ERROR;
@@ -2106,9 +2103,7 @@ CommandCost CmdDoTownAction(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (!HasBit(GetMaskOfTownActions(NULL, _current_player, t), p2)) return CMD_ERROR;
- SET_EXPENSES_TYPE(EXPENSES_OTHER);
-
- cost.AddCost((_price.build_industry >> 8) * _town_action_costs[p2]);
+ CommandCost cost(EXPENSES_OTHER, (_price.build_industry >> 8) * _town_action_costs[p2]);
if (flags & DC_EXEC) {
_town_action_proc[p2](t);
@@ -2364,7 +2359,7 @@ static CommandCost TerraformTile_Town(TileIndex tile, uint32 flags, uint z_new,
/* Here we differ from TTDP by checking TILE_NOT_SLOPED */
if (((hs->building_flags & TILE_NOT_SLOPED) == 0) && !IsSteepSlope(tileh_new) &&
- (GetTileMaxZ(tile) == z_new + GetSlopeMaxZ(tileh_new))) return _price.terraform;
+ (GetTileMaxZ(tile) == z_new + GetSlopeMaxZ(tileh_new))) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
}
return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);