diff options
author | alberth <alberth@openttd.org> | 2010-03-07 20:44:05 +0000 |
---|---|---|
committer | alberth <alberth@openttd.org> | 2010-03-07 20:44:05 +0000 |
commit | 40f106ba7c2b0055f61e652674701bce53fb06a6 (patch) | |
tree | 4762f0523de8c1b7c40f469f9cee3ea8cb1b5a1e /src/water_cmd.cpp | |
parent | 8f335d4cbd46ef88fabd476a747cf0d4dc18add2 (diff) | |
download | openttd-40f106ba7c2b0055f61e652674701bce53fb06a6.tar.xz |
(svn r19372) -Codechange: CheckTileOwnership() returns a CommandCost.
Diffstat (limited to 'src/water_cmd.cpp')
-rw-r--r-- | src/water_cmd.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp index 01c25157f..6b881352e 100644 --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -168,7 +168,10 @@ void MakeWaterKeepingClass(TileIndex tile, Owner o) static CommandCost RemoveShipDepot(TileIndex tile, DoCommandFlag flags) { if (!IsShipDepot(tile)) return CMD_ERROR; - if (!CheckTileOwnership(tile)) return CMD_ERROR; + + CommandCost ret = CheckTileOwnership(tile); + ret.SetGlobalErrorMessage(); + if (ret.Failed()) return ret; TileIndex tile2 = GetOtherShipDepotTile(tile); @@ -244,10 +247,14 @@ static CommandCost RemoveShiplift(TileIndex tile, DoCommandFlag flags) { TileIndexDiff delta = TileOffsByDiagDir(GetLockDirection(tile)); - if (!CheckTileOwnership(tile) && GetTileOwner(tile) != OWNER_NONE) return CMD_ERROR; + if (GetTileOwner(tile) != OWNER_NONE) { + CommandCost ret = CheckTileOwnership(tile); + ret.SetGlobalErrorMessage(); + if (ret.Failed()) return ret; + } /* make sure no vehicle is on the tile. */ - CommandCost ret = EnsureNoVehicleOnGround(tile); + ret = EnsureNoVehicleOnGround(tile); if (ret.Succeeded()) ret = EnsureNoVehicleOnGround(tile + delta); if (ret.Succeeded()) ret = EnsureNoVehicleOnGround(tile - delta); ret.SetGlobalErrorMessage(); @@ -361,7 +368,11 @@ static CommandCost ClearTile_Water(TileIndex tile, DoCommandFlag flags) ret.SetGlobalErrorMessage(); if (ret.Failed()) return ret; - if (GetTileOwner(tile) != OWNER_WATER && GetTileOwner(tile) != OWNER_NONE && !CheckTileOwnership(tile)) return CMD_ERROR; + if (GetTileOwner(tile) != OWNER_WATER && GetTileOwner(tile) != OWNER_NONE) { + CommandCost ret = CheckTileOwnership(tile); + ret.SetGlobalErrorMessage(); + if (ret.Failed()) return ret; + } if (flags & DC_EXEC) { DoClearSquare(tile); |