From 254c3834d0ef508e167f1d3b3c000b1db04b578a Mon Sep 17 00:00:00 2001 From: rubidium Date: Tue, 4 Jun 2013 15:04:59 +0000 Subject: (svn r25319) -Fix [FS#5570]: crash when train with reserved cargo vanishes --- src/roadveh_cmd.cpp | 2 ++ src/train_cmd.cpp | 1 + src/vehicle.cpp | 2 ++ 3 files changed, 5 insertions(+) (limited to 'src') 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; } /** -- cgit v1.2.3-54-g00ecf