summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2013-06-04 15:04:59 +0000
committerrubidium <rubidium@openttd.org>2013-06-04 15:04:59 +0000
commit254c3834d0ef508e167f1d3b3c000b1db04b578a (patch)
tree55f7a0f060d3d362b98d96e1c09cb0da23f84673
parent0d28dc92fc71c55fe0249937af5e98ebfadb2151 (diff)
downloadopenttd-254c3834d0ef508e167f1d3b3c000b1db04b578a.tar.xz
(svn r25319) -Fix [FS#5570]: crash when train with reserved cargo vanishes
-rw-r--r--src/roadveh_cmd.cpp2
-rw-r--r--src/train_cmd.cpp1
-rw-r--r--src/vehicle.cpp2
3 files changed, 5 insertions, 0 deletions
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index 77b82a420..a204c391c 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -460,9 +460,11 @@ inline int RoadVehicle::GetCurrentMaxSpeed() const
*/
static void DeleteLastRoadVeh(RoadVehicle *v)
{
+ RoadVehicle *first = v->First();
Vehicle *u = v;
for (; v->Next() != NULL; v = v->Next()) u = v;
u->SetNext(NULL);
+ v->last_station_visited = first->last_station_visited; // for PreDestructor
/* Only leave the road stop when we're really gone. */
if (IsInsideMM(v->state, RVSB_IN_ROAD_STOP, RVSB_IN_ROAD_STOP_END)) RoadStop::GetByTile(v->tile, GetRoadStopType(v->tile))->Leave(v);
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index b8ed5596b..ddbc5cdf6 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -3432,6 +3432,7 @@ static void DeleteLastWagon(Train *v)
if (first->track == TRACK_BIT_DEPOT) {
SetWindowDirty(WC_VEHICLE_DEPOT, first->tile);
}
+ v->last_station_visited = first->last_station_visited; // for PreDestructor
}
/* 'v' shouldn't be accessed after it has been deleted */
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 1a50a0241..49e8eed01 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -270,6 +270,8 @@ Vehicle::Vehicle(VehicleType type)
this->first = this;
this->colourmap = PAL_NONE;
this->cargo_age_counter = 1;
+ this->last_station_visited = INVALID_STATION;
+ this->last_loading_station = INVALID_STATION;
}
/**