File diff r27883:ddbd33508a8a → r27884:803962be0328
src/station.cpp
Show inline comments
 
@@ -84,49 +84,49 @@ Station::~Station()
 
{
 
	if (CleaningPool()) {
 
		for (CargoID c = 0; c < NUM_CARGO; c++) {
 
			this->goods[c].cargo.OnCleanPool();
 
		}
 
		return;
 
	}
 

	
 
	while (!this->loading_vehicles.empty()) {
 
		this->loading_vehicles.front()->LeaveStation();
 
	}
 

	
 
	for (Aircraft *a : Aircraft::Iterate()) {
 
		if (!a->IsNormalAircraft()) continue;
 
		if (a->targetairport == this->index) a->targetairport = INVALID_STATION;
 
	}
 

	
 
	for (CargoID c = 0; c < NUM_CARGO; ++c) {
 
		LinkGraph *lg = LinkGraph::GetIfValid(this->goods[c].link_graph);
 
		if (lg == nullptr) continue;
 

	
 
		for (NodeID node = 0; node < lg->Size(); ++node) {
 
			Station *st = Station::Get((*lg)[node].station);
 
			st->goods[c].flows.erase(this->index);
 
			if ((*lg)[node].HasEdgeTo(this->goods[c].node) && (*lg)[node][this->goods[c].node].LastUpdate() != INVALID_DATE) {
 
			if ((*lg)[node].HasEdgeTo(this->goods[c].node) && (*lg)[node][this->goods[c].node].LastUpdate() != CalendarTime::INVALID_DATE) {
 
				st->goods[c].flows.DeleteFlows(this->index);
 
				RerouteCargo(st, c, this->index, st->index);
 
			}
 
		}
 
		lg->RemoveNode(this->goods[c].node);
 
		if (lg->Size() == 0) {
 
			LinkGraphSchedule::instance.Unqueue(lg);
 
			delete lg;
 
		}
 
	}
 

	
 
	for (Vehicle *v : Vehicle::Iterate()) {
 
		/* Forget about this station if this station is removed */
 
		if (v->last_station_visited == this->index) {
 
			v->last_station_visited = INVALID_STATION;
 
		}
 
		if (v->last_loading_station == this->index) {
 
			v->last_loading_station = INVALID_STATION;
 
		}
 
	}
 

	
 
	/* Remove station from industries and towns that reference it. */
 
	this->RemoveFromAllNearbyLists();