|
@@ -1298,50 +1298,58 @@ CommandCost CmdBuildRailStation(TileInde
|
|
|
YapfNotifyTrackLayoutChange(tile_track, track);
|
|
|
tile_track += tile_delta ^ TileDiffXY(1, 1); // perpendicular to tile_delta
|
|
|
} while (--numtracks);
|
|
|
|
|
|
for (uint i = 0; i < affected_vehicles.Length(); ++i) {
|
|
|
/* Restore reservations of trains. */
|
|
|
Train *v = affected_vehicles[i];
|
|
|
if (IsRailStationTile(v->tile)) SetRailStationPlatformReservation(v->tile, TrackdirToExitdir(v->GetVehicleTrackdir()), true);
|
|
|
TryPathReserve(v, true, true);
|
|
|
for (; v->Next() != NULL; v = v->Next()) { }
|
|
|
if (IsRailStationTile(v->tile)) SetRailStationPlatformReservation(v->tile, TrackdirToExitdir(ReverseTrackdir(v->GetVehicleTrackdir())), true);
|
|
|
}
|
|
|
|
|
|
/* Check whether we need to expand the reservation of trains already on the station. */
|
|
|
TileArea update_reservation_area;
|
|
|
if (axis == AXIS_X) {
|
|
|
update_reservation_area = TileArea(tile_org, 1, numtracks_orig);
|
|
|
} else {
|
|
|
update_reservation_area = TileArea(tile_org, numtracks_orig, 1);
|
|
|
}
|
|
|
|
|
|
TILE_AREA_LOOP(tile, update_reservation_area) {
|
|
|
DiagDirection dir = AxisToDiagDir(axis);
|
|
|
TileIndexDiff tile_offset = TileOffsByDiagDir(dir);
|
|
|
TileIndex platform_begin = tile - tile_offset * (st->GetPlatformLength(tile, ReverseDiagDir(dir)) - 1);
|
|
|
TileIndex platform_end = tile + tile_offset * (st->GetPlatformLength(tile, dir) - 1);
|
|
|
TileIndex platform_begin = tile;
|
|
|
TileIndex platform_end = tile;
|
|
|
|
|
|
/* We can only account for tiles that are reachable from this tile, so ignore primarily blocked tiles while finding the platform begin and end. */
|
|
|
for (TileIndex next_tile = platform_begin - tile_offset; IsCompatibleTrainStationTile(next_tile, platform_begin); next_tile -= tile_offset) {
|
|
|
platform_begin = next_tile;
|
|
|
}
|
|
|
for (TileIndex next_tile = platform_end + tile_offset; IsCompatibleTrainStationTile(next_tile, platform_end); next_tile += tile_offset) {
|
|
|
platform_end = next_tile;
|
|
|
}
|
|
|
|
|
|
/* If there is at least on reservation on the platform, we reserve the whole platform. */
|
|
|
bool reservation = false;
|
|
|
for (TileIndex t = platform_begin; !reservation && t <= platform_end; t += tile_offset) {
|
|
|
reservation = HasStationReservation(t);
|
|
|
}
|
|
|
|
|
|
if (reservation) {
|
|
|
SetRailStationPlatformReservation(platform_begin, dir, true);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
st->MarkTilesDirty(false);
|
|
|
st->UpdateVirtCoord();
|
|
|
UpdateStationAcceptance(st, false);
|
|
|
st->RecomputeIndustriesNear();
|
|
|
InvalidateWindowData(WC_SELECT_STATION, 0, 0);
|
|
|
InvalidateWindowData(WC_STATION_LIST, st->owner, 0);
|
|
|
SetWindowWidgetDirty(WC_STATION_VIEW, st->index, WID_SV_TRAINS);
|
|
|
DirtyCompanyInfrastructureWindows(st->owner);
|
|
|
}
|
|
|
|
|
|
return cost;
|
|
|
}
|