summaryrefslogtreecommitdiff
path: root/src/waypoint.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-08-02 22:55:08 +0000
committerrubidium <rubidium@openttd.org>2008-08-02 22:55:08 +0000
commitf0fdbf9644502541531112c6b10f63d9f68313d4 (patch)
tree9de1c30da5558dcc2ee3cbb3175aecf553951635 /src/waypoint.cpp
parentbcfc5a78ed603aec55ce8d930b86ddd622b2d51b (diff)
downloadopenttd-f0fdbf9644502541531112c6b10f63d9f68313d4.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.cpp8
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);