# HG changeset patch # User rubidium # Date 2013-06-04 15:04:59 # Node ID 1193be4a351bbab121ec92ae9517e6c63560b747 # Parent 7cc954e96245c7966d0335d8d81536e1e9673bc4 (svn r25319) -Fix [FS#5570]: crash when train with reserved cargo vanishes diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -460,9 +460,11 @@ inline int RoadVehicle::GetCurrentMaxSpe */ 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 --- 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 --- 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; } /**