mirror of https://github.com/OpenTTD/OpenTTD
(svn r25319) -Fix [FS#5570]: crash when train with reserved cargo vanishes
parent
0d28dc92fc
commit
254c3834d0
|
@ -460,9 +460,11 @@ inline int RoadVehicle::GetCurrentMaxSpeed() const
|
||||||
*/
|
*/
|
||||||
static void DeleteLastRoadVeh(RoadVehicle *v)
|
static void DeleteLastRoadVeh(RoadVehicle *v)
|
||||||
{
|
{
|
||||||
|
RoadVehicle *first = v->First();
|
||||||
Vehicle *u = v;
|
Vehicle *u = v;
|
||||||
for (; v->Next() != NULL; v = v->Next()) u = v;
|
for (; v->Next() != NULL; v = v->Next()) u = v;
|
||||||
u->SetNext(NULL);
|
u->SetNext(NULL);
|
||||||
|
v->last_station_visited = first->last_station_visited; // for PreDestructor
|
||||||
|
|
||||||
/* Only leave the road stop when we're really gone. */
|
/* 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);
|
if (IsInsideMM(v->state, RVSB_IN_ROAD_STOP, RVSB_IN_ROAD_STOP_END)) RoadStop::GetByTile(v->tile, GetRoadStopType(v->tile))->Leave(v);
|
||||||
|
|
|
@ -3432,6 +3432,7 @@ static void DeleteLastWagon(Train *v)
|
||||||
if (first->track == TRACK_BIT_DEPOT) {
|
if (first->track == TRACK_BIT_DEPOT) {
|
||||||
SetWindowDirty(WC_VEHICLE_DEPOT, first->tile);
|
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 */
|
/* 'v' shouldn't be accessed after it has been deleted */
|
||||||
|
|
|
@ -270,6 +270,8 @@ Vehicle::Vehicle(VehicleType type)
|
||||||
this->first = this;
|
this->first = this;
|
||||||
this->colourmap = PAL_NONE;
|
this->colourmap = PAL_NONE;
|
||||||
this->cargo_age_counter = 1;
|
this->cargo_age_counter = 1;
|
||||||
|
this->last_station_visited = INVALID_STATION;
|
||||||
|
this->last_loading_station = INVALID_STATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue