Changeset - r10138:5b63d0853f23
[Not reviewed]
master
0 1 0
rubidium - 16 years ago 2008-09-14 16:49:21
rubidium@openttd.org
(svn r14324) -Fix [FS#2241]: free any blocks that a helicopter may have on an oilrig when the helicopter gets forcefully removed (bankruptcy). For other airports this isn't needed as they can't be used by multiple companies.
1 file changed with 5 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/vehicle.cpp
Show inline comments
 
@@ -630,48 +630,53 @@ bool IsEngineCountable(const Vehicle *v)
 
		default: return false; // Only count player buildable vehicles
 
	}
 
}
 

	
 
void Vehicle::PreDestructor()
 
{
 
	if (CleaningPool()) return;
 

	
 
	if (IsValidStationID(this->last_station_visited)) {
 
		GetStation(this->last_station_visited)->loading_vehicles.remove(this);
 

	
 
		HideFillingPercent(this->fill_percent_te_id);
 
		this->fill_percent_te_id = INVALID_TE_ID;
 
	}
 

	
 
	if (IsEngineCountable(this)) {
 
		GetPlayer(this->owner)->num_engines[this->engine_type]--;
 
		if (this->owner == _local_player) InvalidateAutoreplaceWindow(this->engine_type, this->group_id);
 

	
 
		if (IsValidGroupID(this->group_id)) GetGroup(this->group_id)->num_engines[this->engine_type]--;
 
		if (this->IsPrimaryVehicle()) DecreaseGroupNumVehicle(this->group_id);
 
	}
 

	
 
	if (this->type == VEH_ROAD) ClearSlot(this);
 
	if (this->type == VEH_AIRCRAFT && this->IsPrimaryVehicle()) {
 
		Station *st = GetStation(this->u.air.targetairport);
 
		const AirportFTA *layout = st->Airport()->layout;
 
		CLRBITS(st->airport_flags, layout[this->u.air.previous_pos].block | layout[this->u.air.pos].block);
 
	}
 

	
 
	if (this->type != VEH_TRAIN || (this->type == VEH_TRAIN && (IsFrontEngine(this) || IsFreeWagon(this)))) {
 
		InvalidateWindowData(WC_VEHICLE_DEPOT, this->tile);
 
	}
 

	
 
	this->cargo.Truncate(0);
 
	DeleteVehicleOrders(this);
 

	
 
	/* Now remove any artic part. This will trigger an other
 
	 *  destroy vehicle, which on his turn can remove any
 
	 *  other artic parts. */
 
	if ((this->type == VEH_TRAIN && EngineHasArticPart(this)) || (this->type == VEH_ROAD && RoadVehHasArticPart(this))) {
 
		delete this->Next();
 
	}
 

	
 
	extern void StopGlobalFollowVehicle(const Vehicle *v);
 
	StopGlobalFollowVehicle(this);
 
}
 

	
 
Vehicle::~Vehicle()
 
{
 
	free(this->name);
 

	
 
	if (CleaningPool()) return;
0 comments (0 inline, 0 general)