(svn r19372) -Codechange: CheckTileOwnership() returns a CommandCost.

This commit is contained in:
alberth
2010-03-07 20:44:05 +00:00
parent 8f335d4cbd
commit 40f106ba7c
7 changed files with 74 additions and 26 deletions

View File

@@ -175,7 +175,11 @@ CommandCost CmdPurchaseLandArea(TileIndex tile, DoCommandFlag flags, uint32 p1,
CommandCost CmdSellLandArea(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
{
if (!IsOwnedLandTile(tile)) return CMD_ERROR;
if (!CheckTileOwnership(tile) && _current_company != OWNER_WATER) return CMD_ERROR;
if (_current_company != OWNER_WATER) {
CommandCost ret = CheckTileOwnership(tile);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
}
CommandCost ret = EnsureNoVehicleOnGround(tile);
ret.SetGlobalErrorMessage();
@@ -500,7 +504,11 @@ static void ChangeTileOwner_Unmovable(TileIndex tile, Owner old_owner, Owner new
static CommandCost TerraformTile_Unmovable(TileIndex tile, DoCommandFlag flags, uint z_new, Slope tileh_new)
{
/* Owned land remains unsold */
if (IsOwnedLand(tile) && CheckTileOwnership(tile)) return CommandCost();
if (IsOwnedLand(tile)) {
CommandCost ret = CheckTileOwnership(tile);
ret.SetGlobalErrorMessage();
if (ret.Succeeded()) return CommandCost();
}
if (AutoslopeEnabled() && (IsStatue(tile) || IsCompanyHQ(tile))) {
if (!IsSteepSlope(tileh_new) && (z_new + GetSlopeMaxZ(tileh_new) == GetTileMaxZ(tile))) return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_FOUNDATION]);