Chunnel: Adjust arguments of IsTunnelInWay
This commit is contained in:
@@ -270,7 +270,7 @@ CommandCost CmdTerraformLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
|
||||
}
|
||||
}
|
||||
/* 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
|
||||
return_cmd_error(STR_ERROR_EXCAVATION_WOULD_DAMAGE);
|
||||
}
|
||||
|
@@ -44,10 +44,10 @@ TileIndex GetOtherTunnelEnd(TileIndex tile)
|
||||
* Is there a tunnel in the way in any direction?
|
||||
* @param tile the tile to search from.
|
||||
* @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.
|
||||
*/
|
||||
bool IsTunnelInWay(TileIndex tile, int z, bool not_allowed)
|
||||
bool IsTunnelInWay(TileIndex tile, int z, bool chunnel_allowed)
|
||||
{
|
||||
uint x = TileX(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 (t->is_chunnel > not_allowed) {
|
||||
if (t->is_chunnel && chunnel_allowed) {
|
||||
/* 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.
|
||||
if (tile < t->tile_n + delta || t->tile_s - delta < tile) return true;
|
||||
|
@@ -51,7 +51,7 @@ static inline TunnelID GetTunnelIndex(TileIndex t)
|
||||
}
|
||||
|
||||
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
|
||||
|
@@ -740,7 +740,7 @@ CommandCost CmdBuildTunnel(TileIndex start_tile, DoCommandFlag flags, uint32 p1,
|
||||
head_tiles = 0;
|
||||
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.
|
||||
found_tunnel_tile = end_tile;
|
||||
head_tiles = 0;
|
||||
|
Reference in New Issue
Block a user