Fix eabb9db: Drag building of road stops should not allow mixing z levels.

This commit is contained in:
Michael Lutz 2024-03-24 17:22:39 +01:00
parent 69acc132ca
commit 8fb7d74dfe
1 changed files with 98 additions and 98 deletions

View File

@ -952,7 +952,8 @@ static CommandCost CheckFlatLandRailStation(TileIndex tile_cur, TileIndex north_
/**
* Checks if a road stop can be built at the given tile.
* @param tile_area Area to check.
* @param cur_tile Tile to check.
* @param allowed_z Height allowed for the tile. If allowed_z is negative, it will be set to the height of this tile.
* @param flags Operation to perform.
* @param invalid_dirs Prohibited directions (set of DiagDirections).
* @param is_drive_through True if trying to build a drive-through station.
@ -962,12 +963,10 @@ static CommandCost CheckFlatLandRailStation(TileIndex tile_cur, TileIndex north_
* @param rt Road type to build.
* @return The cost in case of success, or an error code if it failed.
*/
static CommandCost CheckFlatLandRoadStop(TileArea tile_area, DoCommandFlag flags, uint invalid_dirs, bool is_drive_through, bool is_truck_stop, Axis axis, StationID *station, RoadType rt)
static CommandCost CheckFlatLandRoadStop(TileIndex cur_tile, int &allowed_z, DoCommandFlag flags, uint invalid_dirs, bool is_drive_through, bool is_truck_stop, Axis axis, StationID *station, RoadType rt)
{
CommandCost cost(EXPENSES_CONSTRUCTION);
int allowed_z = -1;
for (TileIndex cur_tile : tile_area) {
CommandCost ret = CheckBuildableTile(cur_tile, invalid_dirs, allowed_z, !is_drive_through);
if (ret.Failed()) return ret;
cost.AddCost(ret);
@ -1065,7 +1064,6 @@ static CommandCost CheckFlatLandRoadStop(TileArea tile_area, DoCommandFlag flags
cost.AddCost(RoadBuildCost(rt) * 2);
}
}
}
return cost;
}
@ -1885,9 +1883,6 @@ static CommandCost FindJoiningRoadStop(StationID existing_stop, StationID statio
*/
static CommandCost CalculateRoadStopCost(TileArea tile_area, DoCommandFlag flags, bool is_drive_through, bool is_truck_stop, Axis axis, DiagDirection ddir, StationID *est, RoadType rt, Money unit_cost)
{
CommandCost cost(EXPENSES_CONSTRUCTION);
/* Check every tile in the area. */
for (TileIndex cur_tile : tile_area) {
uint invalid_dirs = 0;
if (is_drive_through) {
SetBit(invalid_dirs, AxisToDiagDir(axis));
@ -1895,7 +1890,12 @@ static CommandCost CalculateRoadStopCost(TileArea tile_area, DoCommandFlag flags
} else {
SetBit(invalid_dirs, ddir);
}
CommandCost ret = CheckFlatLandRoadStop(TileArea(cur_tile, cur_tile), flags, invalid_dirs, is_drive_through, is_truck_stop, axis, est, rt);
/* Check every tile in the area. */
int allowed_z = -1;
CommandCost cost(EXPENSES_CONSTRUCTION);
for (TileIndex cur_tile : tile_area) {
CommandCost ret = CheckFlatLandRoadStop(cur_tile, allowed_z, flags, invalid_dirs, is_drive_through, is_truck_stop, axis, est, rt);
if (ret.Failed()) return ret;
bool is_preexisting_roadstop = IsTileType(cur_tile, MP_STATION) && IsRoadStop(cur_tile);