summaryrefslogtreecommitdiff
path: root/src/water_cmd.cpp
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2008-02-09 17:30:13 +0000
committersmatz <smatz@openttd.org>2008-02-09 17:30:13 +0000
commit98e81e95a535f7d940057e79ab46902498d0d067 (patch)
treee6417e0b62166f7f70376d52251478b4877f5d00 /src/water_cmd.cpp
parentd00bf03012ec14e42e96002be248b2365e44f872 (diff)
downloadopenttd-98e81e95a535f7d940057e79ab46902498d0d067.tar.xz
(svn r12095) -Fix [FS#1703]: when a company bankrupts, remove drive-through road stops, ship depots and buoys too. Update owners of water and road.
Diffstat (limited to 'src/water_cmd.cpp')
-rw-r--r--src/water_cmd.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp
index 5f316dac2..99141d795 100644
--- a/src/water_cmd.cpp
+++ b/src/water_cmd.cpp
@@ -220,15 +220,15 @@ void MakeWaterKeepingClass(TileIndex tile, Owner o)
static CommandCost RemoveShipDepot(TileIndex tile, uint32 flags)
{
- TileIndex tile2;
-
if (!IsShipDepot(tile)) return CMD_ERROR;
if (!CheckTileOwnership(tile)) return CMD_ERROR;
- if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
- tile2 = GetOtherShipDepotTile(tile);
+ TileIndex tile2 = GetOtherShipDepotTile(tile);
- if (!EnsureNoVehicleOnGround(tile2)) return CMD_ERROR;
+ /* do not check for ship on tile when company goes bankrupt */
+ if (!(flags & DC_BANKRUPT)) {
+ if (!EnsureNoVehicleOnGround(tile) || !EnsureNoVehicleOnGround(tile2)) return CMD_ERROR;
+ }
if (flags & DC_EXEC) {
/* Kill the depot, which is registered at the northernmost tile. Use that one */
@@ -1139,11 +1139,15 @@ static void ChangeTileOwner_Water(TileIndex tile, PlayerID old_player, PlayerID
if (new_player != PLAYER_SPECTATOR) {
SetTileOwner(tile, new_player);
- } else if (IsShipDepot(tile)) {
- DoCommand(tile, 0, 0, DC_EXEC | DC_BANKRUPT, CMD_LANDSCAPE_CLEAR);
- } else {
- SetTileOwner(tile, OWNER_NONE);
+ return;
}
+
+ /* Remove depot */
+ if (IsShipDepot(tile)) DoCommand(tile, 0, 0, DC_EXEC | DC_BANKRUPT, CMD_LANDSCAPE_CLEAR);
+
+ /* Set owner of canals and locks ... and also canal under dock there was before.
+ * Check if the new owner after removing depot isn't OWNER_WATER. */
+ if (IsTileOwner(tile, old_player)) SetTileOwner(tile, OWNER_NONE);
}
static VehicleEnterTileStatus VehicleEnter_Water(Vehicle *v, TileIndex tile, int x, int y)