1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-24 20:54:08 +01:00

Add: Show height difference in bridge is too low error message. (#14614)

This commit is contained in:
Rito12
2025-10-24 22:27:11 +02:00
committed by GitHub
parent 6ebe64703f
commit 70bf84175f
3 changed files with 15 additions and 10 deletions

View File

@@ -5271,13 +5271,13 @@ STR_ERROR_START_AND_END_MUST_BE_IN :{WHITE}Start an
STR_ERROR_ENDS_OF_BRIDGE_MUST_BOTH :{WHITE}... ends of bridge must both be on land
STR_ERROR_BRIDGE_TOO_LONG :{WHITE}... bridge too long
STR_ERROR_BRIDGE_THROUGH_MAP_BORDER :{WHITE}Bridge would end out of the map
STR_ERROR_BRIDGE_TOO_LOW_FOR_STATION :{WHITE}Bridge is too low for station
STR_ERROR_BRIDGE_TOO_LOW_FOR_ROADSTOP :{WHITE}Bridge is too low for road stop
STR_ERROR_BRIDGE_TOO_LOW_FOR_DOCK :{WHITE}Bridge is too low for dock
STR_ERROR_BRIDGE_TOO_LOW_FOR_BUOY :{WHITE}Bridge is too low for buoy
STR_ERROR_BRIDGE_TOO_LOW_FOR_RAIL_WAYPOINT :{WHITE}Bridge is too low for rail waypoint
STR_ERROR_BRIDGE_TOO_LOW_FOR_ROAD_WAYPOINT :{WHITE}Bridge is too low for road waypoint
STR_ERROR_BRIDGE_TOO_LOW_FOR_LOCK :{WHITE}Bridge is too low for lock
STR_ERROR_BRIDGE_TOO_LOW_FOR_STATION :{WHITE}Bridge is {HEIGHT} too low for station
STR_ERROR_BRIDGE_TOO_LOW_FOR_ROADSTOP :{WHITE}Bridge is {HEIGHT} too low for road stop
STR_ERROR_BRIDGE_TOO_LOW_FOR_DOCK :{WHITE}Bridge is {HEIGHT} too low for dock
STR_ERROR_BRIDGE_TOO_LOW_FOR_BUOY :{WHITE}Bridge is {HEIGHT} too low for buoy
STR_ERROR_BRIDGE_TOO_LOW_FOR_RAIL_WAYPOINT :{WHITE}Bridge is {HEIGHT} too low for rail waypoint
STR_ERROR_BRIDGE_TOO_LOW_FOR_ROAD_WAYPOINT :{WHITE}Bridge is {HEIGHT} too low for road waypoint
STR_ERROR_BRIDGE_TOO_LOW_FOR_LOCK :{WHITE}Bridge is {HEIGHT} too low for lock
# Tunnel related errors
STR_ERROR_CAN_T_BUILD_TUNNEL_HERE :{WHITE}Can't build tunnel here...

View File

@@ -891,7 +891,10 @@ static CommandCost IsStationBridgeAboveOk(TileIndex tile, std::span<const Bridge
/* Get normal error message associated with clearing the tile. */
return Command<CMD_LANDSCAPE_CLEAR>::Do(DoCommandFlag::Auto, tile);
}
if (GetTileMaxZ(tile) + height > bridge_height) return CommandCost{GetBridgeTooLowMessageForStationType(type)};
if (GetTileMaxZ(tile) + height > bridge_height) {
int height_diff = (GetTileMaxZ(tile) + height - bridge_height) * TILE_HEIGHT_STEP;
return CommandCostWithParam(GetBridgeTooLowMessageForStationType(type), height_diff);
}
return CommandCost{};
}

View File

@@ -365,7 +365,8 @@ static CommandCost DoBuildLock(TileIndex tile, DiagDirection dir, DoCommandFlags
for (LockPart lock_part = LOCK_PART_MIDDLE; TileIndex t : {tile, tile - delta, tile + delta}) {
if (IsBridgeAbove(t) && GetBridgeHeight(GetSouthernBridgeEnd(t)) < GetTileMaxZ(t) + GetLockPartMinimalBridgeHeight(lock_part)) {
return CommandCost(STR_ERROR_BRIDGE_TOO_LOW_FOR_LOCK);
int height_diff = (GetTileMaxZ(tile) + GetLockPartMinimalBridgeHeight(lock_part) - GetBridgeHeight(GetSouthernBridgeEnd(t))) * TILE_HEIGHT_STEP;
return CommandCostWithParam(STR_ERROR_BRIDGE_TOO_LOW_FOR_LOCK, height_diff);
}
++lock_part;
}
@@ -1445,7 +1446,8 @@ static CommandCost CheckBuildAbove_Water(TileIndex tile, DoCommandFlags flags, A
if (IsWater(tile) || IsCoast(tile)) return CommandCost();
if (IsLock(tile)) {
if (GetTileMaxZ(tile) + GetLockPartMinimalBridgeHeight(GetLockPart(tile)) <= height) return CommandCost();
return CommandCost(STR_ERROR_BRIDGE_TOO_LOW_FOR_LOCK);
int height_diff = (GetTileMaxZ(tile) + GetLockPartMinimalBridgeHeight(GetLockPart(tile)) - height) * TILE_HEIGHT_STEP;
return CommandCostWithParam(STR_ERROR_BRIDGE_TOO_LOW_FOR_LOCK, height_diff);
}
return Command<CMD_LANDSCAPE_CLEAR>::Do(flags, tile);
}