Changeset - r22389:1757ebccc162
[Not reviewed]
master
0 2 0
frosch - 8 years ago 2016-05-29 13:33:20
frosch@openttd.org
(svn r27584) -Codechange: Add some assertions about Vehicle::cargo_payment.
2 files changed with 4 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/economy.cpp
Show inline comments
 
@@ -1648,12 +1648,13 @@ static void LoadUnloadVehicle(Vehicle *f
 

	
 
		if (HasBit(v->vehicle_flags, VF_CARGO_UNLOADING) && (front->current_order.GetUnloadType() & OUFB_NO_UNLOAD) == 0) {
 
			uint cargo_count = v->cargo.UnloadCount();
 
			uint amount_unloaded = _settings_game.order.gradual_loading ? min(cargo_count, load_amount) : cargo_count;
 
			bool remaining = false; // Are there cargo entities in this vehicle that can still be unloaded here?
 

	
 
			assert(payment != NULL);
 
			payment->SetCargo(v->cargo_type);
 

	
 
			if (!HasBit(ge->status, GoodsEntry::GES_ACCEPTANCE) && v->cargo.ActionCount(VehicleCargoList::MTA_DELIVER) > 0) {
 
				/* The station does not accept our goods anymore. */
 
				if (front->current_order.GetUnloadType() & (OUFB_TRANSFER | OUFB_UNLOAD)) {
 
					/* Transfer instead of delivering. */
src/vehicle.cpp
Show inline comments
 
@@ -213,13 +213,13 @@ uint Vehicle::Crash(bool flooded)
 
	InvalidateWindowClassesData(GetWindowClassForVehicleType(this->type), 0);
 
	SetWindowWidgetDirty(WC_VEHICLE_VIEW, this->index, WID_VV_START_STOP);
 
	SetWindowDirty(WC_VEHICLE_DETAILS, this->index);
 
	SetWindowDirty(WC_VEHICLE_DEPOT, this->tile);
 

	
 
	delete this->cargo_payment;
 
	this->cargo_payment = NULL;
 
	assert(this->cargo_payment == NULL); // cleared by ~CargoPayment
 

	
 
	return RandomRange(pass + 1); // Randomise deceased passengers.
 
}
 

	
 

	
 
/**
 
@@ -743,12 +743,13 @@ void Vehicle::PreDestructor()
 
		Station *st = Station::Get(this->last_station_visited);
 
		st->loading_vehicles.remove(this);
 

	
 
		HideFillingPercent(&this->fill_percent_te_id);
 
		this->CancelReservation(INVALID_STATION, st);
 
		delete this->cargo_payment;
 
		assert(this->cargo_payment == NULL); // cleared by ~CargoPayment
 
	}
 

	
 
	if (this->IsEngineCountable()) {
 
		GroupStatistics::CountEngine(this, -1);
 
		if (this->IsPrimaryVehicle()) GroupStatistics::CountVehicle(this, -1);
 
		GroupStatistics::UpdateAutoreplace(this->owner);
 
@@ -2082,12 +2083,13 @@ void Vehicle::CancelReservation(StationI
 
 */
 
void Vehicle::LeaveStation()
 
{
 
	assert(this->current_order.IsType(OT_LOADING));
 

	
 
	delete this->cargo_payment;
 
	assert(this->cargo_payment == NULL); // cleared by ~CargoPayment
 

	
 
	/* Only update the timetable if the vehicle was supposed to stop here. */
 
	if (this->current_order.GetNonStopType() != ONSF_STOP_EVERYWHERE) UpdateVehicleTimetable(this, false);
 

	
 
	if ((this->current_order.GetLoadType() & OLFB_NO_LOAD) == 0 ||
 
			(this->current_order.GetUnloadType() & OUFB_NO_UNLOAD) == 0) {
0 comments (0 inline, 0 general)