(svn r25319) -Fix [FS#5570]: crash when train with reserved cargo vanishes

This commit is contained in:
rubidium
2013-06-04 15:04:59 +00:00
parent 0d28dc92fc
commit 254c3834d0
3 changed files with 5 additions and 0 deletions

View File

@@ -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);