summaryrefslogtreecommitdiff
path: root/src/unmovable_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/unmovable_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/unmovable_cmd.cpp')
-rw-r--r--src/unmovable_cmd.cpp18
1 files changed, 5 insertions, 13 deletions
diff --git a/src/unmovable_cmd.cpp b/src/unmovable_cmd.cpp
index a50c05ace..8a89ae775 100644
--- a/src/unmovable_cmd.cpp
+++ b/src/unmovable_cmd.cpp
@@ -38,8 +38,6 @@ static CommandCost DestroyCompanyHQ(PlayerID pid, uint32 flags)
{
Player* p = GetPlayer(pid);
- SET_EXPENSES_TYPE(EXPENSES_PROPERTY);
-
if (flags & DC_EXEC) {
TileIndex t = p->location_of_house;
@@ -52,7 +50,7 @@ static CommandCost DestroyCompanyHQ(PlayerID pid, uint32 flags)
}
/* cost of relocating company is 1% of company value */
- return CommandCost(CalculateCompanyValue(p) / 100);
+ return CommandCost(EXPENSES_PROPERTY, CalculateCompanyValue(p) / 100);
}
void UpdateCompanyHQ(Player *p, uint score)
@@ -87,9 +85,7 @@ extern CommandCost CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags
CommandCost CmdBuildCompanyHQ(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
Player *p = GetPlayer(_current_player);
- CommandCost cost;
-
- SET_EXPENSES_TYPE(EXPENSES_PROPERTY);
+ CommandCost cost(EXPENSES_PROPERTY);
cost = CheckFlatLandBelow(tile, 2, 2, flags, 0, NULL);
if (CmdFailed(cost)) return cost;
@@ -122,9 +118,7 @@ CommandCost CmdBuildCompanyHQ(TileIndex tile, uint32 flags, uint32 p1, uint32 p2
*/
CommandCost CmdPurchaseLandArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
- CommandCost cost;
-
- SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
+ CommandCost cost(EXPENSES_CONSTRUCTION);
if (IsOwnedLandTile(tile) && IsTileOwner(tile, _current_player)) {
return_cmd_error(STR_5807_YOU_ALREADY_OWN_IT);
@@ -151,8 +145,6 @@ CommandCost CmdPurchaseLandArea(TileIndex tile, uint32 flags, uint32 p1, uint32
*/
CommandCost CmdSellLandArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
- SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
-
if (!IsOwnedLandTile(tile)) return CMD_ERROR;
if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER) return CMD_ERROR;
@@ -161,7 +153,7 @@ CommandCost CmdSellLandArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (flags & DC_EXEC) DoClearSquare(tile);
- return CommandCost(- _price.clear_roughland * 2);
+ return CommandCost(EXPENSES_CONSTRUCTION,- _price.clear_roughland * 2);
}
static Foundation GetFoundation_Unmovable(TileIndex tile, Slope tileh);
@@ -463,7 +455,7 @@ static CommandCost TerraformTile_Unmovable(TileIndex tile, uint32 flags, uint z_
if (IsOwnedLand(tile) && CheckTileOwnership(tile)) return CommandCost();
if (AutoslopeEnabled() && (IsStatue(tile) || IsCompanyHQ(tile))) {
- if (!IsSteepSlope(tileh_new) && (z_new + GetSlopeMaxZ(tileh_new) == GetTileMaxZ(tile))) return _price.terraform;
+ if (!IsSteepSlope(tileh_new) && (z_new + GetSlopeMaxZ(tileh_new) == GetTileMaxZ(tile))) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
}
return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);