summaryrefslogtreecommitdiff
path: root/src/water_cmd.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-12-07 21:14:54 +0000
committerrubidium <rubidium@openttd.org>2007-12-07 21:14:54 +0000
commitcbb2d39860a847687019ab47095646e593fb5bc8 (patch)
tree564b72840ffd1f1485b52afdcd03fc9e08aaab24 /src/water_cmd.cpp
parentc21f588a14f30fed3d683b4686975670adaf7ed5 (diff)
downloadopenttd-cbb2d39860a847687019ab47095646e593fb5bc8.tar.xz
(svn r11589) -Fix [FS#1514]: when ship depots got destroyed they always returned to water, even when it should've been canals.
Diffstat (limited to 'src/water_cmd.cpp')
-rw-r--r--src/water_cmd.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp
index 7b388ae3f..e6d1904bb 100644
--- a/src/water_cmd.cpp
+++ b/src/water_cmd.cpp
@@ -81,8 +81,8 @@ void MakeWaterOrCanalDependingOnSurroundings(TileIndex t, Owner o)
for (DiagDirection dir = DIAGDIR_BEGIN; dir < DIAGDIR_END; dir++) {
TileIndex neighbour = TileAddByDiagDir(t, dir);
if (IsTileType(neighbour, MP_WATER)) {
- has_water |= IsSea(neighbour) || IsCoast(neighbour);
- has_canal |= IsCanal(neighbour);
+ has_water |= IsSea(neighbour) || IsCoast(neighbour) || (IsShipDepot(neighbour) && GetShipDepotWaterOwner(neighbour) == OWNER_WATER);
+ has_canal |= IsCanal(neighbour) || (IsShipDepot(neighbour) && GetShipDepotWaterOwner(neighbour) != OWNER_WATER);
}
}
if (has_canal || !has_water) {
@@ -116,6 +116,8 @@ CommandCost CmdBuildShipDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2
if (IsBridgeAbove(tile) || IsBridgeAbove(tile2)) return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST);
+ Owner o1 = GetTileOwner(tile);
+ Owner o2 = GetTileOwner(tile2);
ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
if (CmdFailed(ret)) return CMD_ERROR;
ret = DoCommand(tile2, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
@@ -128,8 +130,8 @@ CommandCost CmdBuildShipDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2
if (flags & DC_EXEC) {
depot->town_index = ClosestTownFromTile(tile, (uint)-1)->index;
- MakeShipDepot(tile, _current_player, DEPOT_NORTH, axis);
- MakeShipDepot(tile2, _current_player, DEPOT_SOUTH, axis);
+ MakeShipDepot(tile, _current_player, DEPOT_NORTH, axis, o1);
+ MakeShipDepot(tile2, _current_player, DEPOT_SOUTH, axis, o2);
MarkTileDirtyByTile(tile);
MarkTileDirtyByTile(tile2);
d_auto_delete.Detach();
@@ -138,6 +140,15 @@ CommandCost CmdBuildShipDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2
return cost.AddCost(_price.build_ship_depot);
}
+static void MakeWaterOrCanalDependingOnOwner(TileIndex tile, Owner o)
+{
+ if (o == OWNER_WATER) {
+ MakeWater(tile);
+ } else {
+ MakeCanal(tile, o);
+ }
+}
+
static CommandCost RemoveShipDepot(TileIndex tile, uint32 flags)
{
TileIndex tile2;
@@ -154,8 +165,8 @@ static CommandCost RemoveShipDepot(TileIndex tile, uint32 flags)
/* Kill the depot, which is registered at the northernmost tile. Use that one */
delete GetDepotByTile(tile2 < tile ? tile2 : tile);
- MakeWater(tile);
- MakeWater(tile2);
+ MakeWaterOrCanalDependingOnOwner(tile, GetShipDepotWaterOwner(tile));
+ MakeWaterOrCanalDependingOnOwner(tile2, GetShipDepotWaterOwner(tile2));
MarkTileDirtyByTile(tile);
MarkTileDirtyByTile(tile2);
}