|
@@ -21,12 +21,13 @@
|
|
|
#include "vehiclelist.h"
|
|
|
#include "core/pool_func.hpp"
|
|
|
#include "station_base.h"
|
|
|
#include "roadstop_base.h"
|
|
|
#include "industry.h"
|
|
|
#include "core/random_func.hpp"
|
|
|
#include "linkgraph/linkgraph.h"
|
|
|
|
|
|
#include "table/strings.h"
|
|
|
|
|
|
/** The pool of stations. */
|
|
|
StationPool _station_pool("Station");
|
|
|
INSTANTIATE_POOL_METHODS(Station)
|
|
@@ -60,13 +61,14 @@ Station::Station(TileIndex tile) :
|
|
|
last_vehicle_type(VEH_INVALID)
|
|
|
{
|
|
|
/* this->random_bits is set in Station::AddFacility() */
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Clean up a station by clearing vehicle orders and invalidating windows.
|
|
|
* Clean up a station by clearing vehicle orders, invalidating windows and
|
|
|
* removing link stats.
|
|
|
* Aircraft-Hangar orders need special treatment here, as the hangars are
|
|
|
* actually part of a station (tiletype is STATION), but the order type
|
|
|
* is OT_GOTO_DEPOT.
|
|
|
*/
|
|
|
Station::~Station()
|
|
|
{
|
|
@@ -84,18 +86,31 @@ Station::~Station()
|
|
|
Aircraft *a;
|
|
|
FOR_ALL_AIRCRAFT(a) {
|
|
|
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 != NULL) {
|
|
|
lg->RemoveNode(this->goods[c].node);
|
|
|
if (lg->Size() == 0) {
|
|
|
delete lg;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Vehicle *v;
|
|
|
FOR_ALL_VEHICLES(v) {
|
|
|
/* 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;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/* Clear the persistent storage. */
|
|
|
delete this->airport.psa;
|
|
|
|
|
|
if (this->owner == OWNER_NONE) {
|