From f0fdbf9644502541531112c6b10f63d9f68313d4 Mon Sep 17 00:00:00 2001 From: rubidium Date: Sat, 2 Aug 2008 22:55:08 +0000 Subject: (svn r13957) -Codechange [YAPP]: Free the old path reservation on removing some tracks and reroute trains afterwards. (michi_cc) --- src/waypoint.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/waypoint.cpp') diff --git a/src/waypoint.cpp b/src/waypoint.cpp index ad86a6690..ac81cc45d 100644 --- a/src/waypoint.cpp +++ b/src/waypoint.cpp @@ -33,6 +33,8 @@ #include "newgrf_station.h" #include "oldpool_func.h" #include "viewport_func.h" +#include "pbs.h" +#include "train.h" #include "table/strings.h" @@ -320,6 +322,7 @@ CommandCost RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove) wp->deleted = 30; // let it live for this many days before we do the actual deletion. RedrawWaypointSign(wp); + Vehicle *v = NULL; if (justremove) { TrackBits tracks = GetRailWaypointBits(tile); bool reserved = GetDepotWaypointReservation(tile); @@ -327,10 +330,15 @@ CommandCost RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove) if (reserved) SetTrackReservation(tile, tracks); MarkTileDirtyByTile(tile); } else { + if (GetDepotWaypointReservation(tile)) { + v = GetTrainForReservation(tile, track); + if (v != NULL) FreeTrainTrackReservation(v); + } DoClearSquare(tile); AddTrackToSignalBuffer(tile, track, owner); } YapfNotifyTrackLayoutChange(tile, track); + if (v != NULL) TryPathReserve(v, true); } return CommandCost(EXPENSES_CONSTRUCTION, _price.remove_train_depot); -- cgit v1.2.3-54-g00ecf