Fix: Rail depot overbuild did not handle associated reservation (#15860)

This commit is contained in:
Jonathan G Rennison
2026-07-15 12:40:37 +01:00
committed by GitHub
parent 659208ab57
commit 7126fcafcc
+12 -1
View File
@@ -990,15 +990,21 @@ CommandCost CmdBuildTrainDepot(DoCommandFlags flags, TileIndex tile, RailType ra
/* Allow the user to rotate the depot instead of having to destroy it and build it again */
bool rotate_existing_depot = false;
Train *v = nullptr;
if (IsRailDepotTile(tile) && railtype == GetRailType(tile)) {
CommandCost ret = CheckTileOwnership(tile);
if (ret.Failed()) return ret;
if (dir == GetRailDepotDirection(tile)) return CommandCost();
DiagDirection old_dir = GetRailDepotDirection(tile);
if (dir == old_dir) return CommandCost();
ret = EnsureNoVehicleOnGround(tile);
if (ret.Failed()) return ret;
if (HasDepotReservation(tile)) {
v = GetTrainForReservation(tile, DiagDirToDiagTrack(old_dir));
}
rotate_existing_depot = true;
}
@@ -1015,7 +1021,10 @@ CommandCost CmdBuildTrainDepot(DoCommandFlags flags, TileIndex tile, RailType ra
}
if (flags.Test(DoCommandFlag::Execute)) {
if (v != nullptr) FreeTrainTrackReservation(v);
if (rotate_existing_depot) {
SetDepotReservation(tile, false);
SetRailDepotExitDirection(tile, dir);
} else {
Depot *d = Depot::Create(tile);
@@ -1030,6 +1039,8 @@ CommandCost CmdBuildTrainDepot(DoCommandFlags flags, TileIndex tile, RailType ra
MarkTileDirtyByTile(tile);
AddSideToSignalBuffer(tile, DiagDirection::Invalid, _current_company);
YapfNotifyTrackLayoutChange(tile, DiagDirToDiagTrack(dir));
if (v != nullptr) TryPathReserve(v, true);
}
cost.AddCost(_price[Price::BuildDepotTrain]);