Changeset - r20309:1193be4a351b
[Not reviewed]
master
0 3 0
rubidium - 11 years ago 2013-06-04 15:04:59
rubidium@openttd.org
(svn r25319) -Fix [FS#5570]: crash when train with reserved cargo vanishes
3 files changed with 5 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/roadveh_cmd.cpp
Show inline comments
 
@@ -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);
src/train_cmd.cpp
Show inline comments
 
@@ -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 */
src/vehicle.cpp
Show inline comments
 
@@ -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;
 
}
 

	
 
/**
0 comments (0 inline, 0 general)