|
@@ -15,24 +15,25 @@
|
|
|
#include "roadveh.h"
|
|
|
#include "viewport_func.h"
|
|
|
#include "date_func.h"
|
|
|
#include "command_func.h"
|
|
|
#include "news_func.h"
|
|
|
#include "aircraft.h"
|
|
|
#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)
|
|
|
|
|
|
BaseStation::~BaseStation()
|
|
|
{
|
|
|
free(this->name);
|
|
|
free(this->speclist);
|
|
|
|
|
@@ -54,54 +55,68 @@ Station::Station(TileIndex tile) :
|
|
|
bus_station(INVALID_TILE, 0, 0),
|
|
|
truck_station(INVALID_TILE, 0, 0),
|
|
|
dock_tile(INVALID_TILE),
|
|
|
indtype(IT_INVALID),
|
|
|
time_since_load(255),
|
|
|
time_since_unload(255),
|
|
|
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()
|
|
|
{
|
|
|
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();
|
|
|
}
|
|
|
|
|
|
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) {
|
|
|
/* Invalidate all in case of oil rigs. */
|
|
|
InvalidateWindowClassesData(WC_STATION_LIST, 0);
|
|
|
} else {
|
|
|
InvalidateWindowData(WC_STATION_LIST, this->owner, 0);
|
|
|
}
|
|
|
|