diff options
author | rubidium <rubidium@openttd.org> | 2008-08-02 22:55:08 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2008-08-02 22:55:08 +0000 |
commit | 753da05bc612002b3ea5eca8d17c883479016189 (patch) | |
tree | 9de1c30da5558dcc2ee3cbb3175aecf553951635 /src/waypoint.cpp | |
parent | bce6f7b41cda862b6405e506dacd9e57c3189d7e (diff) | |
download | openttd-753da05bc612002b3ea5eca8d17c883479016189.tar.xz |
(svn r13957) -Codechange [YAPP]: Free the old path reservation on removing some tracks and reroute trains afterwards. (michi_cc)
Diffstat (limited to 'src/waypoint.cpp')
-rw-r--r-- | src/waypoint.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
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); |