File diff r10527:adb65148b086 → r10528:99ad5205b347
src/station.cpp
Show inline comments
 
@@ -12,48 +12,49 @@
 
#include "saveload.h"
 
#include "company_func.h"
 
#include "airport.h"
 
#include "sprite.h"
 
#include "train.h"
 
#include "water_map.h"
 
#include "industry_map.h"
 
#include "newgrf_callbacks.h"
 
#include "newgrf_station.h"
 
#include "yapf/yapf.h"
 
#include "cargotype.h"
 
#include "roadveh.h"
 
#include "window_type.h"
 
#include "station_gui.h"
 
#include "zoom_func.h"
 
#include "functions.h"
 
#include "window_func.h"
 
#include "date_func.h"
 
#include "variables.h"
 
#include "settings_type.h"
 
#include "command_func.h"
 
#include "order_func.h"
 
#include "news_func.h"
 
#include "aircraft.h"
 
#include "vehicle_gui.h"
 

	
 
#include "table/sprites.h"
 
#include "table/strings.h"
 

	
 
Station::Station(TileIndex tile)
 
{
 
	DEBUG(station, cDebugCtorLevel, "I+%3d", index);
 

	
 
	xy = tile;
 
	airport_tile = dock_tile = train_tile = INVALID_TILE;
 
	bus_stops = truck_stops = NULL;
 
	had_vehicle_of_type = 0;
 
	time_since_load = 255;
 
	time_since_unload = 255;
 
	delete_ctr = 0;
 
	facilities = 0;
 

	
 
	last_vehicle_type = VEH_INVALID;
 
	indtype = IT_INVALID;
 

	
 
	random_bits = 0; // Random() must be called when station is really built (DC_EXEC)
 
	waiting_triggers = 0;
 
}
 

	
 
@@ -66,48 +67,53 @@ Station::Station(TileIndex tile)
 
Station::~Station()
 
{
 
	DEBUG(station, cDebugCtorLevel, "I-%3d", index);
 

	
 
	free(this->name);
 
	free(this->speclist);
 

	
 
	if (CleaningPool()) return;
 

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

	
 
	Vehicle *v;
 
	FOR_ALL_VEHICLES(v) {
 
		if (v->type == VEH_AIRCRAFT && IsNormalAircraft(v) && v->u.air.targetairport == this->index) {
 
			v->u.air.targetairport = INVALID_STATION;
 
		}
 
	}
 

	
 
	MarkDirty();
 
	InvalidateWindowData(WC_STATION_LIST, this->owner, 0);
 

	
 
	DeleteWindowById(WC_STATION_VIEW, index);
 
	WindowNumber wno = (index << 16) | VLW_STATION_LIST | this->owner;
 
	DeleteWindowById(WC_TRAINS_LIST, wno | (VEH_TRAIN << 11));
 
	DeleteWindowById(WC_ROADVEH_LIST, wno | (VEH_ROAD << 11));
 
	DeleteWindowById(WC_SHIPS_LIST, wno | (VEH_SHIP << 11));
 
	DeleteWindowById(WC_AIRCRAFT_LIST, wno | (VEH_AIRCRAFT << 11));
 

	
 
	/* Now delete all orders that go to the station */
 
	RemoveOrderFromAllVehicles(OT_GOTO_STATION, index);
 

	
 
	/* Subsidies need removal as well */
 
	DeleteSubsidyWithStation(index);
 

	
 
	/* Remove all news items */
 
	DeleteStationNews(this->index);
 

	
 
	xy = INVALID_TILE;
 

	
 
	for (CargoID c = 0; c < NUM_CARGO; c++) {
 
		goods[c].cargo.Truncate(0);
 
	}
 
}
 

	
 

	
 
/**
 
 * Get the primary road stop (the first road stop) that the given vehicle can load/unload.
 
 * @param v the vehicle to get the first road stop for
 
 * @return the first roadstop that this vehicle can load at
 
 */
 
RoadStop *Station::GetPrimaryRoadStop(const Vehicle *v) const