diff -r 2c27f9be3fb9 -r f82a4facea8b src/water_cmd.cpp --- a/src/water_cmd.cpp Sat Oct 20 10:14:05 2007 +0000 +++ b/src/water_cmd.cpp Sat Oct 20 10:42:28 2007 +0000 @@ -31,20 +31,21 @@ #include "newgrf_canal.h" #include "misc/autoptr.hpp" +/** Array for the shore sprites */ static const SpriteID _water_shore_sprites[] = { 0, - SPR_SHORE_TILEH_1, - SPR_SHORE_TILEH_2, - SPR_SHORE_TILEH_3, - SPR_SHORE_TILEH_4, + SPR_SHORE_TILEH_1, // SLOPE_W + SPR_SHORE_TILEH_2, // SLOPE_S + SPR_SHORE_TILEH_3, // SLOPE_SW + SPR_SHORE_TILEH_4, // SLOPE_E 0, - SPR_SHORE_TILEH_6, + SPR_SHORE_TILEH_6, // SLOPE_SE 0, - SPR_SHORE_TILEH_8, - SPR_SHORE_TILEH_9, + SPR_SHORE_TILEH_8, // SLOPE_N + SPR_SHORE_TILEH_9, // SLOPE_NW 0, 0, - SPR_SHORE_TILEH_12, + SPR_SHORE_TILEH_12, // SLOPE_NE 0, 0 }; @@ -71,7 +72,7 @@ tile2 = tile + (axis == AXIS_X ? TileDiffXY(1, 0) : TileDiffXY(0, 1)); - if (!IsClearWaterTile(tile) || !IsClearWaterTile(tile2)) + if (!IsWaterTile(tile) || !IsWaterTile(tile2)) return_cmd_error(STR_3801_MUST_BE_BUILT_ON_WATER); if (IsBridgeAbove(tile) || IsBridgeAbove(tile2)) return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST); @@ -104,11 +105,11 @@ if (!IsShipDepot(tile)) return CMD_ERROR; if (!CheckTileOwnership(tile)) return CMD_ERROR; - if (!EnsureNoVehicle(tile)) return CMD_ERROR; + if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; tile2 = GetOtherShipDepotTile(tile); - if (!EnsureNoVehicle(tile2)) return CMD_ERROR; + if (!EnsureNoVehicleOnGround(tile2)) return CMD_ERROR; if (flags & DC_EXEC) { /* Kill the depot, which is registered at the northernmost tile. Use that one */ @@ -171,7 +172,7 @@ if (!CheckTileOwnership(tile) && GetTileOwner(tile) != OWNER_NONE) return CMD_ERROR; /* make sure no vehicle is on the tile. */ - if (!EnsureNoVehicle(tile) || !EnsureNoVehicle(tile + delta) || !EnsureNoVehicle(tile - delta)) + if (!EnsureNoVehicleOnGround(tile) || !EnsureNoVehicleOnGround(tile + delta) || !EnsureNoVehicleOnGround(tile - delta)) return CMD_ERROR; if (flags & DC_EXEC) { @@ -302,7 +303,7 @@ } /* Make sure no vehicle is on the tile */ - if (!EnsureNoVehicle(tile)) return CMD_ERROR; + if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; if (GetTileOwner(tile) != OWNER_WATER && GetTileOwner(tile) != OWNER_NONE && !CheckTileOwnership(tile)) return CMD_ERROR; @@ -313,7 +314,7 @@ Slope slope = GetTileSlope(tile, NULL); /* Make sure no vehicle is on the tile */ - if (!EnsureNoVehicle(tile)) return CMD_ERROR; + if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; if (flags & DC_EXEC) DoClearSquare(tile); if (slope == SLOPE_N || slope == SLOPE_E || slope == SLOPE_S || slope == SLOPE_W) { @@ -457,7 +458,7 @@ switch (GetWaterTileType(ti->tile)) { case WATER_TILE_CLEAR: DrawGroundSprite(SPR_FLAT_WATER_TILE, PAL_NONE); - if (ti->z != 0 || !IsTileOwner(ti->tile, OWNER_WATER)) DrawCanalWater(ti->tile); + if (IsCanal(ti->tile)) DrawCanalWater(ti->tile); DrawBridgeMiddle(ti); break; @@ -517,7 +518,7 @@ { switch (GetWaterTileType(tile)) { case WATER_TILE_CLEAR: - if (TilePixelHeight(tile) == 0 || IsTileOwner(tile, OWNER_WATER)) { + if (!IsCanal(tile)) { td->str = STR_3804_WATER; } else { td->str = STR_LANDINFO_CANAL; @@ -708,7 +709,12 @@ } } -/** called from tunnelbridge_cmd, and by TileLoop_Industry() */ +/** + * Let a water tile floods its diagonal adjoining tiles + * called from tunnelbridge_cmd, and by TileLoop_Industry() + * + * @param tile the water/shore tile that floods + */ void TileLoop_Water(TileIndex tile) { static const TileIndexDiffC _tile_loop_offs_array[][5] = { @@ -719,9 +725,12 @@ {{ 0, -1}, {0, 0}, {1, 0}, { 0, -1}, { 1, -1}} }; - /* Ensure sea-level canals and buoys on canal borders do not flood */ - if ((IsTileType(tile, MP_WATER) || IsBuoyTile(tile)) && !IsTileOwner(tile, OWNER_WATER)) return; + /* Ensure buoys on canal borders do not flood */ + if (IsCanalBuoyTile(tile)) return; + /* Ensure only sea and coast floods, not canals or rivers */ + if (IsTileType(tile, MP_WATER) && !(IsSea(tile) || IsCoast(tile))) return; + /* floods in all four diagonal directions with the exception of the edges */ if (IS_INT_INSIDE(TileX(tile), 1, MapSizeX() - 3 + 1) && IS_INT_INSIDE(TileY(tile), 1, MapSizeY() - 3 + 1)) { uint i; @@ -730,6 +739,7 @@ TileLoopWaterHelper(tile, _tile_loop_offs_array[i]); } } + /* _current_player can be changed by TileLoopWaterHelper.. reset it back here */ _current_player = OWNER_NONE; @@ -807,7 +817,7 @@ static CommandCost TerraformTile_Water(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new) { /* Canals can't be terraformed */ - if (IsClearWaterTile(tile) && IsCanal(tile)) return_cmd_error(STR_MUST_DEMOLISH_CANAL_FIRST); + if (IsWaterTile(tile) && IsCanal(tile)) return_cmd_error(STR_MUST_DEMOLISH_CANAL_FIRST); return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); }