Chunnel: Adjust arguments of IsTunnelInWay

This commit is contained in:
Jonathan G Rennison
2017-03-04 12:21:24 +00:00
parent 13a716980a
commit 21bbb42d7e
4 changed files with 6 additions and 6 deletions

View File

@@ -270,7 +270,7 @@ CommandCost CmdTerraformLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
} }
} }
/* Check if tunnel would take damage */ /* Check if tunnel would take damage */
if (direction == -1 && IsTunnelInWay(tile, z_min, false)) { if (direction == -1 && IsTunnelInWay(tile, z_min, true)) {
_terraform_err_tile = tile; // highlight the tile above the tunnel _terraform_err_tile = tile; // highlight the tile above the tunnel
return_cmd_error(STR_ERROR_EXCAVATION_WOULD_DAMAGE); return_cmd_error(STR_ERROR_EXCAVATION_WOULD_DAMAGE);
} }

View File

@@ -44,10 +44,10 @@ TileIndex GetOtherTunnelEnd(TileIndex tile)
* Is there a tunnel in the way in any direction? * Is there a tunnel in the way in any direction?
* @param tile the tile to search from. * @param tile the tile to search from.
* @param z the 'z' to search on. * @param z the 'z' to search on.
* @param not_allowed Only terra forming does not search between tunnel portals. * @param chunnel_allowed True if chunnel mid-parts are allowed, used when terraforming.
* @return true if and only if there is a tunnel. * @return true if and only if there is a tunnel.
*/ */
bool IsTunnelInWay(TileIndex tile, int z, bool not_allowed) bool IsTunnelInWay(TileIndex tile, int z, bool chunnel_allowed)
{ {
uint x = TileX(tile); uint x = TileX(tile);
uint y = TileY(tile); uint y = TileY(tile);
@@ -62,7 +62,7 @@ bool IsTunnelInWay(TileIndex tile, int z, bool not_allowed)
if (TileY(t->tile_n) != y || (int)TileHeight(t->tile_n) != z) continue; // dir DIAGDIR_SW if (TileY(t->tile_n) != y || (int)TileHeight(t->tile_n) != z) continue; // dir DIAGDIR_SW
} }
if (t->is_chunnel > not_allowed) { if (t->is_chunnel && chunnel_allowed) {
/* Only if tunnel was build over water terraforming is allowed between portals. */ /* Only if tunnel was build over water terraforming is allowed between portals. */
TileIndexDiff delta = GetTunnelBridgeDirection(t->tile_n) == DIAGDIR_SE ? TileOffsByDiagDir(DIAGDIR_SE) * 4 : 4; // 4 tiles ramp. TileIndexDiff delta = GetTunnelBridgeDirection(t->tile_n) == DIAGDIR_SE ? TileOffsByDiagDir(DIAGDIR_SE) * 4 : 4; // 4 tiles ramp.
if (tile < t->tile_n + delta || t->tile_s - delta < tile) return true; if (tile < t->tile_n + delta || t->tile_s - delta < tile) return true;

View File

@@ -51,7 +51,7 @@ static inline TunnelID GetTunnelIndex(TileIndex t)
} }
TileIndex GetOtherTunnelEnd(TileIndex); TileIndex GetOtherTunnelEnd(TileIndex);
bool IsTunnelInWay(TileIndex, int z, bool not_allowed = true); bool IsTunnelInWay(TileIndex, int z, bool chunnel_allowed = false);
/** /**
* Makes a road tunnel entrance * Makes a road tunnel entrance

View File

@@ -740,7 +740,7 @@ CommandCost CmdBuildTunnel(TileIndex start_tile, DoCommandFlag flags, uint32 p1,
head_tiles = 0; head_tiles = 0;
found_tunnel_tile = INVALID_TILE; found_tunnel_tile = INVALID_TILE;
} }
if (!_cheats.crossing_tunnels.value && IsTunnelInWay(end_tile, start_z, false)) { if (!_cheats.crossing_tunnels.value && IsTunnelInWay(end_tile, start_z, true)) {
if (found_tunnel_tile == INVALID_TILE || is_chunnel) { // Remember the first or the last when we pass a tunnel. if (found_tunnel_tile == INVALID_TILE || is_chunnel) { // Remember the first or the last when we pass a tunnel.
found_tunnel_tile = end_tile; found_tunnel_tile = end_tile;
head_tiles = 0; head_tiles = 0;