Changeset - r14849:27386629fac1
[Not reviewed]
master
0 23 0
yexo - 14 years ago 2010-03-18 21:02:20
yexo@openttd.org
(svn r19455) -Codechange: split all airport information in Station to a seperate class
23 files changed with 100 insertions and 97 deletions:
0 comments (0 inline, 0 general)
src/ai/api/ai_airport.cpp
Show inline comments
 
@@ -93,13 +93,13 @@
 
	if (!::IsTileType(tile, MP_STATION)) return -1;
 

	
 
	const Station *st = ::Station::GetByTile(tile);
 
	if (st->owner != _current_company) return -1;
 
	if ((st->facilities & FACIL_AIRPORT) == 0) return -1;
 

	
 
	return st->GetAirportSpec()->nof_depots;
 
	return st->airport.GetSpec()->nof_depots;
 
}
 

	
 
/* static */ TileIndex AIAirport::GetHangarOfAirport(TileIndex tile)
 
{
 
	if (!::IsValidTile(tile)) return INVALID_TILE;
 
	if (!::IsTileType(tile, MP_STATION)) return INVALID_TILE;
 
@@ -117,13 +117,13 @@
 
	if (!AITile::IsStationTile(tile)) return AT_INVALID;
 

	
 
	StationID station_id = ::GetStationIndex(tile);
 

	
 
	if (!AIStation::HasStationType(station_id, AIStation::STATION_AIRPORT)) return AT_INVALID;
 

	
 
	return (AirportType)::Station::Get(station_id)->airport_type;
 
	return (AirportType)::Station::Get(station_id)->airport.type;
 
}
 

	
 

	
 
/* static */ int AIAirport::GetNoiseLevelIncrease(TileIndex tile, AirportType type)
 
{
 
	extern Town *AirportGetNearestTown(const AirportSpec *as, TileIndex airport_tile);
src/ai/api/ai_depotlist.cpp
Show inline comments
 
@@ -26,13 +26,13 @@ AIDepotList::AIDepotList(AITile::Transpo
 

	
 
		case AITile::TRANSPORT_AIR: {
 
			/* Hangars are not seen as real depots by the depot code. */
 
			const Station *st;
 
			FOR_ALL_STATIONS(st) {
 
				if (st->owner == ::_current_company) {
 
					const AirportSpec *as = st->GetAirportSpec();
 
					const AirportSpec *as = st->airport.GetSpec();
 
					for (uint i = 0; i < as->nof_depots; i++) {
 
						this->AddItem(st->GetHangarTile(i));
 
					}
 
				}
 
			}
 
			return;
src/ai/api/ai_order.cpp
Show inline comments
 
@@ -178,13 +178,13 @@ static const Order *ResolveOrder(Vehicle
 
			/* We don't know where the nearest depot is... (yet) */
 
			if (order->GetDepotActionType() & ODATFB_NEAREST_DEPOT) return INVALID_TILE;
 

	
 
			if (v->type != VEH_AIRCRAFT) return ::Depot::Get(order->GetDestination())->xy;
 
			/* Aircraft's hangars are referenced by StationID, not DepotID */
 
			const Station *st = ::Station::Get(order->GetDestination());
 
			if (st->GetAirportSpec()->nof_depots == 0) return INVALID_TILE;
 
			if (st->airport.GetSpec()->nof_depots == 0) return INVALID_TILE;
 
			return st->GetHangarTile(0);
 
		}
 

	
 
		case OT_GOTO_STATION: {
 
			const Station *st = ::Station::Get(order->GetDestination());
 
			if (st->train_station.tile != INVALID_TILE) {
src/ai/api/ai_town.cpp
Show inline comments
 
@@ -185,13 +185,13 @@
 
		return t->MaxTownNoise() - t->noise_reached;
 
	}
 

	
 
	int num = 0;
 
	const Station *st;
 
	FOR_ALL_STATIONS(st) {
 
		if (st->town == t && (st->facilities & FACIL_AIRPORT) && st->airport_type != AT_OILRIG) num++;
 
		if (st->town == t && (st->facilities & FACIL_AIRPORT) && st->airport.type != AT_OILRIG) num++;
 
	}
 
	return max(0, 2 - num);
 
}
 

	
 
/* static */ AITown::RoadLayout AITown::GetRoadLayout(TownID town_id)
 
{
src/aircraft_cmd.cpp
Show inline comments
 
@@ -113,14 +113,14 @@ static StationID FindNearestHangar(const
 
	TileIndex vtile = TileVirtXY(v->x_pos, v->y_pos);
 
	const AircraftVehicleInfo *avi = AircraftVehInfo(v->engine_type);
 

	
 
	FOR_ALL_STATIONS(st) {
 
		if (st->owner != v->owner || !(st->facilities & FACIL_AIRPORT)) continue;
 

	
 
		const AirportFTAClass *afc = st->Airport();
 
		const AirportSpec *as = st->GetAirportSpec();
 
		const AirportFTAClass *afc = st->airport.GetFTA();
 
		const AirportSpec *as = st->airport.GetSpec();
 
		if (as->nof_depots == 0 || (
 
					/* don't crash the plane if we know it can't land at the airport */
 
					(afc->flags & AirportFTAClass::SHORT_STRIP) &&
 
					(avi->subtype & AIR_FAST) &&
 
					!_cheats.no_jetcrash.value)) {
 
			continue;
 
@@ -412,13 +412,13 @@ CommandCost CmdSellAircraft(TileIndex ti
 
}
 

	
 
bool Aircraft::FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse)
 
{
 
	const Station *st = GetTargetAirportIfValid(this);
 
	/* If the station is not a valid airport or if it has no hangars */
 
	if (st == NULL || st->GetAirportSpec()->nof_depots == 0) {
 
	if (st == NULL || st->airport.GetSpec()->nof_depots == 0) {
 
		/* the aircraft has to search for a hangar on its own */
 
		StationID station = FindNearestHangar(this);
 

	
 
		if (station == INVALID_STATION) return false;
 

	
 
		st = Station::Get(station);
 
@@ -512,13 +512,13 @@ static void CheckIfAircraftNeedsService(
 

	
 
	const Station *st = Station::Get(v->current_order.GetDestination());
 

	
 
	assert(st != NULL);
 

	
 
	/* only goto depot if the target airport has a depot */
 
	if (st->GetAirportSpec()->nof_depots > 0 && CanVehicleUseStation(v, st)) {
 
	if (st->airport.GetSpec()->nof_depots > 0 && CanVehicleUseStation(v, st)) {
 
		v->current_order.MakeGoToDepot(st->index, ODTFB_SERVICE);
 
		SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
	} else if (v->current_order.IsType(OT_GOTO_DEPOT)) {
 
		v->current_order.MakeDummy();
 
		SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
	}
 
@@ -838,13 +838,13 @@ static bool AircraftController(Aircraft 
 
	/* INVALID_TILE if there is no station */
 
	TileIndex tile = INVALID_TILE;
 
	if (st != NULL) {
 
		tile = (st->airport.tile != INVALID_TILE) ? st->airport.tile : st->xy;
 
	}
 
	/* DUMMY if there is no station or no airport */
 
	const AirportFTAClass *afc = tile == INVALID_TILE ? GetAirport(AT_DUMMY) : st->Airport();
 
	const AirportFTAClass *afc = tile == INVALID_TILE ? GetAirport(AT_DUMMY) : st->airport.GetFTA();
 

	
 
	/* prevent going to INVALID_TILE if airport is deleted. */
 
	if (st == NULL || st->airport.tile == INVALID_TILE) {
 
		/* Jump into our "holding pattern" state machine if possible */
 
		if (v->pos >= afc->nofelements) {
 
			v->pos = v->previous_pos = AircraftGetEntryPoint(v, afc);
 
@@ -986,13 +986,13 @@ static bool AircraftController(Aircraft 
 
					v->x_pos;
 
			gp.y = (v->y_pos != (y + amd->y)) ?
 
					v->y_pos + ((y + amd->y > v->y_pos) ? 1 : -1) :
 
					v->y_pos;
 

	
 
			/* Oilrigs must keep v->tile as st->airport.tile, since the landing pad is in a non-airport tile */
 
			gp.new_tile = (st->airport_type == AT_OILRIG) ? st->airport.tile : TileVirtXY(gp.x, gp.y);
 
			gp.new_tile = (st->airport.type == AT_OILRIG) ? st->airport.tile : TileVirtXY(gp.x, gp.y);
 

	
 
		} else {
 

	
 
			/* Turn. Do it slowly if in the air. */
 
			Direction newdir = GetDirectionTowards(v, x + amd->x, y + amd->y);
 
			if (newdir != v->direction) {
 
@@ -1122,15 +1122,15 @@ static bool HandleCrashedAircraft(Aircra
 
		/*  remove rubble of crashed airplane */
 

	
 
		/* clear runway-in on all airports, set by crashing plane
 
		 * small airports use AIRPORT_BUSY, city airports use RUNWAY_IN_OUT_block, etc.
 
		 * but they all share the same number */
 
		if (st != NULL) {
 
			CLRBITS(st->airport_flags, RUNWAY_IN_block);
 
			CLRBITS(st->airport_flags, RUNWAY_IN_OUT_block); // commuter airport
 
			CLRBITS(st->airport_flags, RUNWAY_IN2_block);    // intercontinental
 
			CLRBITS(st->airport.flags, RUNWAY_IN_block);
 
			CLRBITS(st->airport.flags, RUNWAY_IN_OUT_block); // commuter airport
 
			CLRBITS(st->airport.flags, RUNWAY_IN2_block);    // intercontinental
 
		}
 

	
 
		delete v;
 

	
 
		return false;
 
	}
 
@@ -1278,13 +1278,13 @@ static void MaybeCrashAirplane(Aircraft 
 
	if (_settings_game.vehicle.plane_crashes == 0) return;
 

	
 
	Station *st = Station::Get(v->targetairport);
 

	
 
	/* FIXME -- MaybeCrashAirplane -> increase crashing chances of very modern airplanes on smaller than AT_METROPOLITAN airports */
 
	uint32 prob = (0x4000 << _settings_game.vehicle.plane_crashes);
 
	if ((st->Airport()->flags & AirportFTAClass::SHORT_STRIP) &&
 
	if ((st->airport.GetFTA()->flags & AirportFTAClass::SHORT_STRIP) &&
 
			(AircraftVehInfo(v->engine_type)->subtype & AIR_FAST) &&
 
			!_cheats.no_jetcrash.value) {
 
		prob /= 20;
 
	} else {
 
		prob /= 1500;
 
	}
 
@@ -1340,13 +1340,13 @@ void AircraftNextAirportPos_and_Order(Ai
 
{
 
	if (v->current_order.IsType(OT_GOTO_STATION) || v->current_order.IsType(OT_GOTO_DEPOT)) {
 
		v->targetairport = v->current_order.GetDestination();
 
	}
 

	
 
	const Station *st = GetTargetAirportIfValid(v);
 
	const AirportFTAClass *apc = st == NULL ? GetAirport(AT_DUMMY) : st->Airport();
 
	const AirportFTAClass *apc = st == NULL ? GetAirport(AT_DUMMY) : st->airport.GetFTA();
 
	v->pos = v->previous_pos = AircraftGetEntryPoint(v, apc);
 
}
 

	
 
void AircraftLeaveHangar(Aircraft *v)
 
{
 
	v->cur_speed = 0;
 
@@ -1465,13 +1465,13 @@ static void AircraftEventHandler_AtTermi
 
			/* In case of a conditional order we just have to wait a tick
 
			 * longer, so the conditional order can actually be processed;
 
			 * we should not clear the order as that makes us go nowhere. */
 
			return;
 
		default:  // orders have been deleted (no orders), goto depot and don't bother us
 
			v->current_order.Free();
 
			go_to_hangar = Station::Get(v->targetairport)->GetAirportSpec()->nof_depots != 0;
 
			go_to_hangar = Station::Get(v->targetairport)->airport.GetSpec()->nof_depots != 0;
 
	}
 

	
 
	if (go_to_hangar) {
 
		v->state = HANGAR;
 
	} else {
 
		/* airplane goto state takeoff, helicopter to helitakeoff */
 
@@ -1543,13 +1543,13 @@ static void AircraftEventHandler_Flying(
 
				if (!AirportHasBlock(v, current, apc)) {
 
					v->state = landingtype; // LANDING / HELILANDING
 
					/* it's a bit dirty, but I need to set position to next position, otherwise
 
					 * if there are multiple runways, plane won't know which one it took (because
 
					 * they all have heading LANDING). And also occupy that block! */
 
					v->pos = current->next_position;
 
					SETBITS(st->airport_flags, apc->layout[v->pos].block);
 
					SETBITS(st->airport.flags, apc->layout[v->pos].block);
 
					return;
 
				}
 
				v->cur_speed = tcur_speed;
 
				v->subspeed = tsubspeed;
 
			}
 
			current = current->next;
 
@@ -1606,13 +1606,13 @@ static void AircraftEventHandler_HeliEnd
 
	 * --> else TAKEOFF
 
	 * the reason behind this is that if an airport has a terminal, it also has a hangar. Airplanes
 
	 * must go to a hangar. */
 
	if (v->current_order.IsType(OT_GOTO_STATION)) {
 
		if (AirportFindFreeHelipad(v, apc)) return;
 
	}
 
	const AirportSpec *as = Station::Get(v->targetairport)->GetAirportSpec();
 
	const AirportSpec *as = Station::Get(v->targetairport)->airport.GetSpec();
 
	v->state = (as->nof_depots != 0) ? HANGAR : HELITAKEOFF;
 
}
 

	
 
typedef void AircraftStateHandler(Aircraft *v, const AirportFTAClass *apc);
 
static AircraftStateHandler * const _aircraft_state_handlers[] = {
 
	AircraftEventHandler_General,        // TO_ALL         =  0
 
@@ -1643,22 +1643,22 @@ static AircraftStateHandler * const _air
 
static void AirportClearBlock(const Aircraft *v, const AirportFTAClass *apc)
 
{
 
	/* we have left the previous block, and entered the new one. Free the previous block */
 
	if (apc->layout[v->previous_pos].block != apc->layout[v->pos].block) {
 
		Station *st = Station::Get(v->targetairport);
 

	
 
		CLRBITS(st->airport_flags, apc->layout[v->previous_pos].block);
 
		CLRBITS(st->airport.flags, apc->layout[v->previous_pos].block);
 
	}
 
}
 

	
 
static void AirportGoToNextPosition(Aircraft *v)
 
{
 
	/* if aircraft is not in position, wait until it is */
 
	if (!AircraftController(v)) return;
 

	
 
	const AirportFTAClass *apc = Station::Get(v->targetairport)->Airport();
 
	const AirportFTAClass *apc = Station::Get(v->targetairport)->airport.GetFTA();
 

	
 
	AirportClearBlock(v, apc);
 
	AirportMove(v, apc); // move aircraft to next position
 
}
 

	
 
/* gets pos from vehicle and next orders */
 
@@ -1722,13 +1722,13 @@ static bool AirportHasBlock(Aircraft *v,
 

	
 
		/* check additional possible extra blocks */
 
		if (current_pos != reference && current_pos->block != NOTHING_block) {
 
			airport_flags |= current_pos->block;
 
		}
 

	
 
		if (st->airport_flags & airport_flags) {
 
		if (st->airport.flags & airport_flags) {
 
			v->cur_speed = 0;
 
			v->subspeed = 0;
 
			return true;
 
		}
 
	}
 
	return false;
 
@@ -1763,33 +1763,33 @@ static bool AirportSetBlocks(Aircraft *v
 

	
 
		/* if the block to be checked is in the next position, then exclude that from
 
		 * checking, because it has been set by the airplane before */
 
		if (current_pos->block == next->block) airport_flags ^= next->block;
 

	
 
		Station *st = Station::Get(v->targetairport);
 
		if (st->airport_flags & airport_flags) {
 
		if (st->airport.flags & airport_flags) {
 
			v->cur_speed = 0;
 
			v->subspeed = 0;
 
			return false;
 
		}
 

	
 
		if (next->block != NOTHING_block) {
 
			SETBITS(st->airport_flags, airport_flags); // occupy next block
 
			SETBITS(st->airport.flags, airport_flags); // occupy next block
 
		}
 
	}
 
	return true;
 
}
 

	
 
static bool FreeTerminal(Aircraft *v, byte i, byte last_terminal)
 
{
 
	Station *st = Station::Get(v->targetairport);
 
	for (; i < last_terminal; i++) {
 
		if (!HasBit(st->airport_flags, _airport_terminal_flag[i])) {
 
		if (!HasBit(st->airport.flags, _airport_terminal_flag[i])) {
 
			/* TERMINAL# HELIPAD# */
 
			v->state = _airport_terminal_state[i]; // start moving to that terminal/helipad
 
			SetBit(st->airport_flags, _airport_terminal_flag[i]); // occupy terminal/helipad
 
			SetBit(st->airport.flags, _airport_terminal_flag[i]); // occupy terminal/helipad
 
			return true;
 
		}
 
	}
 
	return false;
 
}
 

	
 
@@ -1817,13 +1817,13 @@ static bool AirportFindFreeTerminal(Airc
 
	if (apc->terminals[0] > 1) {
 
		const Station *st = Station::Get(v->targetairport);
 
		const AirportFTA *temp = apc->layout[v->pos].next;
 

	
 
		while (temp != NULL) {
 
			if (temp->heading == 255) {
 
				if (!(st->airport_flags & temp->block)) {
 
				if (!(st->airport.flags & temp->block)) {
 
					/* read which group do we want to go to?
 
					 * (the first free group) */
 
					uint target_group = temp->next_position + 1;
 

	
 
					/* at what terminal does the group start?
 
					 * that means, sum up all terminals of
 
@@ -1868,13 +1868,13 @@ static bool AirportFindFreeHelipad(Aircr
 
	if (apc->helipads[0] > 1) {
 
		const Station *st = Station::Get(v->targetairport);
 
		const AirportFTA *temp = apc->layout[v->pos].next;
 

	
 
		while (temp != NULL) {
 
			if (temp->heading == 255) {
 
				if (!(st->airport_flags & temp->block)) {
 
				if (!(st->airport.flags & temp->block)) {
 

	
 
					/* read which group do we want to go to?
 
					 * (the first free group) */
 
					uint target_group = temp->next_position + 1;
 

	
 
					/* at what terminal does the group start?
 
@@ -1971,13 +1971,13 @@ Station *GetTargetAirportIfValid(const A
 
 * Updates the status of the Aircraft heading or in the station
 
 * @param st Station been updated
 
 */
 
void UpdateAirplanesOnNewStation(const Station *st)
 
{
 
	/* only 1 station is updated per function call, so it is enough to get entry_point once */
 
	const AirportFTAClass *ap = st->Airport();
 
	const AirportFTAClass *ap = st->airport.GetFTA();
 

	
 
	Aircraft *v;
 
	FOR_ALL_AIRCRAFT(v) {
 
		if (v->IsNormalAircraft()) {
 
			if (v->targetairport == st->index) { // if heading to this airport
 
				/* update position of airplane. If plane is not flying, landing, or taking off
src/airport.cpp
Show inline comments
 
@@ -388,13 +388,13 @@ const AirportFTAClass *GetAirport(const 
 
 * @param hangar_tile The tile on which the vehicle is build
 
 * @return The position (index in airport node array) where the aircraft ends up
 
 */
 
byte GetVehiclePosOnBuild(TileIndex hangar_tile)
 
{
 
	const Station *st = Station::GetByTile(hangar_tile);
 
	const AirportFTAClass *apc = st->Airport();
 
	const AirportFTAClass *apc = st->airport.GetFTA();
 
	/* When we click on hangar we know the tile it is on. By that we know
 
	 * its position in the array of depots the airport has.....we can search
 
	 * layout for #th position of depot. Since layout must start with a listing
 
	 * of all depots, it is simple */
 
	for (uint i = 0;; i++) {
 
		if (st->GetHangarTile(i) == hangar_tile) {
src/airport.h
Show inline comments
 
@@ -177,13 +177,13 @@ public:
 
DECLARE_ENUM_AS_BIT_SET(AirportFTAClass::Flags)
 

	
 

	
 
/** Internal structure used in openttd - Finite sTate mAchine --> FTA */
 
struct AirportFTA {
 
	AirportFTA *next;        ///< possible extra movement choices from this position
 
	uint64 block;            ///< 64 bit blocks (st->airport_flags), should be enough for the most complex airports
 
	uint64 block;            ///< 64 bit blocks (st->airport.flags), should be enough for the most complex airports
 
	byte position;           ///< the position that an airplane is at
 
	byte next_position;      ///< next position from this position
 
	byte heading;            ///< heading (current orders), guiding an airplane to its target on an airport
 
};
 

	
 
const AirportFTAClass *GetAirport(const byte airport_type);
src/disaster_cmd.cpp
Show inline comments
 
@@ -231,13 +231,13 @@ static bool DisasterTick_Zeppeliner(Disa
 

	
 
	if (v->current_order.GetDestination() > 2) {
 
		if (++v->age <= 13320) return true;
 

	
 
		if (IsValidTile(v->tile) && IsAirportTile(v->tile)) {
 
			Station *st = Station::GetByTile(v->tile);
 
			CLRBITS(st->airport_flags, RUNWAY_IN_block);
 
			CLRBITS(st->airport.flags, RUNWAY_IN_block);
 
			AI::NewEvent(GetTileOwner(v->tile), new AIEventDisasterZeppelinerCleared(st->index));
 
		}
 

	
 
		SetDisasterVehiclePos(v, v->x_pos, v->y_pos, v->z_pos);
 
		delete v;
 
		return false;
 
@@ -268,13 +268,13 @@ static bool DisasterTick_Zeppeliner(Disa
 
	} else if (v->age == 350) {
 
		v->current_order.SetDestination(3);
 
		v->age = 0;
 
	}
 

	
 
	if (IsValidTile(v->tile) && IsAirportTile(v->tile)) {
 
		SETBITS(Station::GetByTile(v->tile)->airport_flags, RUNWAY_IN_block);
 
		SETBITS(Station::GetByTile(v->tile)->airport.flags, RUNWAY_IN_block);
 
	}
 

	
 
	return true;
 
}
 

	
 
/**
 
@@ -677,13 +677,13 @@ static void Disaster_Zeppeliner_Init()
 

	
 
	/* Pick a random place, unless we find a small airport */
 
	int x = TileX(Random()) * TILE_SIZE + TILE_SIZE / 2;
 

	
 
	Station *st;
 
	FOR_ALL_STATIONS(st) {
 
		if (st->airport.tile != INVALID_TILE && (st->airport_type == AT_SMALL || st->airport_type == AT_LARGE)) {
 
		if (st->airport.tile != INVALID_TILE && (st->airport.type == AT_SMALL || st->airport.type == AT_LARGE)) {
 
			x = (TileX(st->airport.tile) + 2) * TILE_SIZE;
 
			break;
 
		}
 
	}
 

	
 
	DisasterVehicle *v = new DisasterVehicle();
src/newgrf_airporttiles.cpp
Show inline comments
 
@@ -222,13 +222,13 @@ static void AirportTileResolver(Resolver
 
	res->SetTriggers   = NULL;
 
	res->GetVariable   = AirportTileGetVariable;
 
	res->ResolveReal   = AirportTileResolveReal;
 

	
 
	assert(st != NULL);
 
	res->psa                  = NULL;
 
	res->u.airport.airport_id = st->airport_type;
 
	res->u.airport.airport_id = st->airport.type;
 
	res->u.airport.st         = st;
 
	res->u.airport.tile       = tile;
 

	
 
	res->callback        = CBID_NO_CALLBACK;
 
	res->callback_param1 = 0;
 
	res->callback_param2 = 0;
src/newgrf_engine.cpp
Show inline comments
 
@@ -193,13 +193,13 @@ enum {
 
 */
 
static byte MapAircraftMovementState(const Aircraft *v)
 
{
 
	const Station *st = GetTargetAirportIfValid(v);
 
	if (st == NULL) return AMS_TTDP_FLIGHT_TO_TOWER;
 

	
 
	const AirportFTAClass *afc = st->Airport();
 
	const AirportFTAClass *afc = st->airport.GetFTA();
 
	uint16 amdflag = afc->MovingData(v->pos)->flag;
 

	
 
	switch (v->state) {
 
		case HANGAR:
 
			/* The international airport is a special case as helicopters can land in
 
			 * front of the hanger. Helicopters also change their air.state to
 
@@ -597,13 +597,13 @@ static uint32 VehicleGetVariable(const R
 
				uint16 altitude = v->z_pos - w->z_pos; // Aircraft height - shadow height
 
				byte airporttype = ATP_TTDP_LARGE;
 

	
 
				const Station *st = GetTargetAirportIfValid(Aircraft::From(v));
 

	
 
				if (st != NULL && st->airport.tile != INVALID_TILE) {
 
					airporttype = st->GetAirportSpec()->ttd_airport_type;
 
					airporttype = st->airport.GetSpec()->ttd_airport_type;
 
				}
 

	
 
				return (altitude << 8) | airporttype;
 
			}
 

	
 
		case 0x45: { // Curvature info
src/newgrf_station.cpp
Show inline comments
 
@@ -521,17 +521,17 @@ uint32 Station::GetNewGRFVariable(const 
 
				if (HasBit(this->goods[cargo_type].acceptance_pickup, GoodsEntry::PICKUP)) SetBit(value, cargo_type);
 
			}
 
			return value;
 
		}
 

	
 
		case 0x8A: return this->had_vehicle_of_type;
 
		case 0xF1: return (this->airport.tile != INVALID_TILE) ? this->GetAirportSpec()->ttd_airport_type : ATP_TTDP_LARGE;
 
		case 0xF1: return (this->airport.tile != INVALID_TILE) ? this->airport.GetSpec()->ttd_airport_type : ATP_TTDP_LARGE;
 
		case 0xF2: return (this->truck_stops != NULL) ? this->truck_stops->status : 0;
 
		case 0xF3: return (this->bus_stops != NULL)   ? this->bus_stops->status   : 0;
 
		case 0xF6: return this->airport_flags;
 
		case 0xF7: return GB(this->airport_flags, 8, 8);
 
		case 0xF6: return this->airport.flags;
 
		case 0xF7: return GB(this->airport.flags, 8, 8);
 
	}
 

	
 
	/* Handle cargo variables with parameter, 0x60 to 0x65 */
 
	if (variable >= 0x60 && variable <= 0x65) {
 
		CargoID c = GetCargoTranslation(parameter, object->u.station.statspec->grffile);
 

	
src/order_cmd.cpp
Show inline comments
 
@@ -532,13 +532,13 @@ CommandCost CmdInsertOrder(TileIndex til
 
					if (st == NULL) return CMD_ERROR;
 

	
 
					CommandCost ret = CheckOwnership(st->owner);
 
					ret.SetGlobalErrorMessage();
 
					if (ret.Failed()) return ret;
 

	
 
					if (!CanVehicleUseStation(v, st) || st->GetAirportSpec()->nof_depots == 0) {
 
					if (!CanVehicleUseStation(v, st) || st->airport.GetSpec()->nof_depots == 0) {
 
						return CMD_ERROR;
 
					}
 
				} else {
 
					const Depot *dp = Depot::GetIfValid(new_order.GetDestination());
 

	
 
					if (dp == NULL) return CMD_ERROR;
src/saveload/afterload.cpp
Show inline comments
 
@@ -591,14 +591,14 @@ bool AfterLoadGame()
 
	/* Oilrig was moved from id 15 to 9. We have to do this conversion
 
	 * here as AfterLoadVehicles can check it indirectly via the newgrf
 
	 * code. */
 
	if (CheckSavegameVersion(139)) {
 
		Station *st;
 
		FOR_ALL_STATIONS(st) {
 
			if (st->airport.tile != INVALID_TILE && st->airport_type == 15) {
 
				st->airport_type = AT_OILRIG;
 
			if (st->airport.tile != INVALID_TILE && st->airport.type == 15) {
 
				st->airport.type = AT_OILRIG;
 
			}
 
		}
 
	}
 

	
 
	/* Update all vehicles */
 
	AfterLoadVehicles(true);
 
@@ -731,13 +731,13 @@ bool AfterLoadGame()
 
						if (IsTileType(t1, MP_INDUSTRY) &&
 
								GetIndustryGfx(t1) == GFX_OILRIG_1) {
 
							/* The internal encoding of oil rigs was changed twice.
 
							 * It was 3 (till 2.2) and later 5 (till 5.1).
 
							 * Setting it unconditionally does not hurt.
 
							 */
 
							Station::GetByTile(t)->airport_type = AT_OILRIG;
 
							Station::GetByTile(t)->airport.type = AT_OILRIG;
 
						} else {
 
							DeleteOilRig(t);
 
						}
 
						break;
 
					}
 

	
 
@@ -2092,14 +2092,14 @@ bool AfterLoadGame()
 
	}
 

	
 
	if (CheckSavegameVersion(140)) {
 
		Station *st;
 
		FOR_ALL_STATIONS(st) {
 
			if (st->airport.tile != INVALID_TILE) {
 
				st->airport.w = st->GetAirportSpec()->size_x;
 
				st->airport.h = st->GetAirportSpec()->size_y;
 
				st->airport.w = st->airport.GetSpec()->size_x;
 
				st->airport.h = st->airport.GetSpec()->size_y;
 
			}
 
		}
 
	}
 

	
 
	/* Road stops is 'only' updating some caches */
 
	AfterLoadRoadStops();
src/saveload/oldloader_sl.cpp
Show inline comments
 
@@ -729,17 +729,17 @@ static const OldChunks station_chunk[] =
 

	
 
	OCL_SVAR(  OC_UINT8, Station, time_since_load ),
 
	OCL_SVAR(  OC_UINT8, Station, time_since_unload ),
 
	OCL_SVAR(  OC_UINT8, Station, delete_ctr ),
 
	OCL_SVAR(  OC_UINT8, Station, owner ),
 
	OCL_SVAR(  OC_UINT8, Station, facilities ),
 
	OCL_SVAR( OC_TTD | OC_UINT8, Station, airport_type ),
 
	OCL_SVAR( OC_TTO | OC_FILE_U16 | OC_VAR_U64, Station, airport_flags ),
 
	OCL_SVAR( OC_TTD | OC_UINT8, Station, airport.type ),
 
	OCL_SVAR( OC_TTO | OC_FILE_U16 | OC_VAR_U64, Station, airport.flags ),
 
	OCL_NULL( 3 ),          ///< bus/truck status, blocked months, no longer in use
 
	OCL_CNULL( OC_TTD, 1 ), ///< unknown
 
	OCL_SVAR( OC_TTD | OC_FILE_U16 | OC_VAR_U64, Station, airport_flags ),
 
	OCL_SVAR( OC_TTD | OC_FILE_U16 | OC_VAR_U64, Station, airport.flags ),
 
	OCL_CNULL( OC_TTD, 2 ), ///< last_vehicle. now last_vehicle_type
 
	OCL_CNULL( OC_TTD, 4 ), ///< junk at end of chunk
 

	
 
	OCL_END()
 
};
 

	
 
@@ -757,18 +757,18 @@ static bool LoadOldStation(LoadgameState
 
			if (IsInsideBS(_old_string_id, 0x180F, 32)) {
 
				st->string_id = STR_SV_STNAME + (_old_string_id - 0x180F); // automatic name
 
			} else {
 
				st->string_id = _old_string_id + 0x2800; // custom name
 
			}
 

	
 
			if (HasBit(st->airport_flags, 8)) {
 
				st->airport_type = 1; // large airport
 
			} else if (HasBit(st->airport_flags, 6)) {
 
				st->airport_type = 3; // oil rig
 
			if (HasBit(st->airport.flags, 8)) {
 
				st->airport.type = 1; // large airport
 
			} else if (HasBit(st->airport.flags, 6)) {
 
				st->airport.type = 3; // oil rig
 
			} else {
 
				st->airport_type = 0; // small airport
 
				st->airport.type = 0; // small airport
 
			}
 
		} else {
 
			st->string_id = RemapOldStringID(_old_string_id);
 
		}
 
	} else {
 
		delete st;
src/saveload/station_sl.cpp
Show inline comments
 
@@ -169,20 +169,20 @@ static const SaveLoad _old_station_desc[
 

	
 
	    SLE_VAR(Station, time_since_load,            SLE_UINT8),
 
	    SLE_VAR(Station, time_since_unload,          SLE_UINT8),
 
	    SLE_VAR(Station, delete_ctr,                 SLE_UINT8),
 
	    SLE_VAR(Station, owner,                      SLE_UINT8),
 
	    SLE_VAR(Station, facilities,                 SLE_UINT8),
 
	    SLE_VAR(Station, airport_type,               SLE_UINT8),
 
	    SLE_VAR(Station, airport.type,               SLE_UINT8),
 

	
 
	SLE_CONDNULL(2, 0, 5),  ///< Truck/bus stop status
 
	SLE_CONDNULL(1, 0, 4),  ///< Blocked months
 

	
 
	SLE_CONDVAR(Station, airport_flags,              SLE_VAR_U64 | SLE_FILE_U16,  0,  2),
 
	SLE_CONDVAR(Station, airport_flags,              SLE_VAR_U64 | SLE_FILE_U32,  3, 45),
 
	SLE_CONDVAR(Station, airport_flags,              SLE_UINT64,                 46, SL_MAX_VERSION),
 
	SLE_CONDVAR(Station, airport.flags,              SLE_VAR_U64 | SLE_FILE_U16,  0,  2),
 
	SLE_CONDVAR(Station, airport.flags,              SLE_VAR_U64 | SLE_FILE_U32,  3, 45),
 
	SLE_CONDVAR(Station, airport.flags,              SLE_UINT64,                 46, SL_MAX_VERSION),
 

	
 
	SLE_CONDNULL(2, 0, 25), ///< last-vehicle
 
	SLE_CONDVAR(Station, last_vehicle_type,          SLE_UINT8,                  26, SL_MAX_VERSION),
 

	
 
	SLE_CONDNULL(2, 3, 25), ///< custom station class and id
 
	SLE_CONDVAR(Station, build_date,                 SLE_FILE_U16 | SLE_VAR_I32,  3, 30),
 
@@ -331,14 +331,14 @@ static const SaveLoad _station_desc[] = 
 
	      SLE_REF(Station, bus_stops,                  REF_ROADSTOPS),
 
	      SLE_REF(Station, truck_stops,                REF_ROADSTOPS),
 
	      SLE_VAR(Station, dock_tile,                  SLE_UINT32),
 
	      SLE_VAR(Station, airport.tile,               SLE_UINT32),
 
	  SLE_CONDVAR(Station, airport.w,                  SLE_FILE_U8 | SLE_VAR_U16, 140, SL_MAX_VERSION),
 
	  SLE_CONDVAR(Station, airport.h,                  SLE_FILE_U8 | SLE_VAR_U16, 140, SL_MAX_VERSION),
 
	      SLE_VAR(Station, airport_type,               SLE_UINT8),
 
	      SLE_VAR(Station, airport_flags,              SLE_UINT64),
 
	      SLE_VAR(Station, airport.type,               SLE_UINT8),
 
	      SLE_VAR(Station, airport.flags,              SLE_UINT64),
 

	
 
	      SLE_VAR(Station, indtype,                    SLE_UINT8),
 

	
 
	      SLE_VAR(Station, time_since_load,            SLE_UINT8),
 
	      SLE_VAR(Station, time_since_unload,          SLE_UINT8),
 
	      SLE_VAR(Station, last_vehicle_type,          SLE_UINT8),
src/saveload/vehicle_sl.cpp
Show inline comments
 
@@ -162,13 +162,13 @@ void ConvertOldMultiheadToNew()
 
/** need to be called to load aircraft from old version */
 
void UpdateOldAircraft()
 
{
 
	/* set airport_flags to 0 for all airports just to be sure */
 
	Station *st;
 
	FOR_ALL_STATIONS(st) {
 
		st->airport_flags = 0; // reset airport
 
		st->airport.flags = 0; // reset airport
 
	}
 

	
 
	Aircraft *a;
 
	FOR_ALL_AIRCRAFT(a) {
 
		/* airplane has another vehicle with subtype 4 (shadow), helicopter also has 3 (rotor)
 
		 * skip those */
src/station.cpp
Show inline comments
 
@@ -37,13 +37,12 @@ BaseStation::~BaseStation()
 
}
 

	
 
Station::Station(TileIndex tile) :
 
	SpecializedStation<Station, false>(tile),
 
	bus_station(INVALID_TILE, 0, 0),
 
	truck_station(INVALID_TILE, 0, 0),
 
	airport(INVALID_TILE, 0, 0),
 
	dock_tile(INVALID_TILE),
 
	indtype(IT_INVALID),
 
	time_since_load(255),
 
	time_since_unload(255),
 
	last_vehicle_type(VEH_INVALID)
 
{
 
@@ -220,13 +219,13 @@ uint Station::GetCatchmentRadius() const
 

	
 
	if (_settings_game.station.modified_catchment) {
 
		if (this->bus_stops          != NULL)         ret = max<uint>(ret, CA_BUS);
 
		if (this->truck_stops        != NULL)         ret = max<uint>(ret, CA_TRUCK);
 
		if (this->train_station.tile != INVALID_TILE) ret = max<uint>(ret, CA_TRAIN);
 
		if (this->dock_tile          != INVALID_TILE) ret = max<uint>(ret, CA_DOCK);
 
		if (this->airport.tile       != INVALID_TILE) ret = max<uint>(ret, this->GetAirportSpec()->catchment);
 
		if (this->airport.tile       != INVALID_TILE) ret = max<uint>(ret, this->airport.GetSpec()->catchment);
 
	} else {
 
		if (this->bus_stops != NULL || this->truck_stops != NULL || this->train_station.tile != INVALID_TILE || this->dock_tile != INVALID_TILE || this->airport.tile != INVALID_TILE) {
 
			ret = CA_UNMODIFIED;
 
		}
 
	}
 

	
src/station_base.h
Show inline comments
 
@@ -42,12 +42,31 @@ struct GoodsEntry {
 
	byte rating;
 
	byte last_speed;
 
	byte last_age;
 
	StationCargoList cargo; ///< The cargo packets of cargo waiting in this station
 
};
 

	
 
/** All airport-related information. Only valid if tile != INVALID_TILE. */
 
struct Airport : public TileArea {
 
	Airport() : TileArea(INVALID_TILE, 0, 0) {}
 

	
 
	uint64 flags;       ///< stores which blocks on the airport are taken. was 16 bit earlier on, then 32
 
	byte type;
 

	
 
	const AirportSpec *GetSpec() const
 
	{
 
		if (this->tile == INVALID_TILE) return &AirportSpec::dummy;
 
		return AirportSpec::Get(this->type);
 
	}
 

	
 
	const AirportFTAClass *GetFTA() const
 
	{
 
		if (this->tile == INVALID_TILE) return GetAirport(AT_DUMMY);
 
		return this->GetSpec()->fsm;
 
	}
 
};
 

	
 
typedef SmallVector<Industry *, 2> IndustryVector;
 

	
 
/** Station data structure */
 
struct Station : SpecializedStation<Station, false> {
 
public:
 
@@ -55,41 +74,26 @@ public:
 
	{
 
		return type == ROADSTOP_BUS ? bus_stops : truck_stops;
 
	}
 

	
 
	RoadStop *GetPrimaryRoadStop(const struct RoadVehicle *v) const;
 

	
 
	const AirportFTAClass *Airport() const
 
	{
 
		if (airport.tile == INVALID_TILE) return GetAirport(AT_DUMMY);
 
		return GetAirport(airport_type);
 
	}
 

	
 
	const AirportSpec *GetAirportSpec() const
 
	{
 
		if (airport.tile == INVALID_TILE) return &AirportSpec::dummy;
 
		return AirportSpec::Get(this->airport_type);
 
	}
 

	
 
	RoadStop *bus_stops;    ///< All the road stops
 
	TileArea bus_station;   ///< Tile area the bus 'station' part covers
 
	RoadStop *truck_stops;  ///< All the truck stops
 
	TileArea truck_station; ///< Tile area the truck 'station' part covers
 

	
 
	TileArea airport;       ///< Tile area the airport covers
 
	Airport airport;        ///< Tile area the airport covers
 
	TileIndex dock_tile;    ///< The location of the dock
 

	
 
	IndustryType indtype;   ///< Industry type to get the name from
 

	
 
	StationHadVehicleOfTypeByte had_vehicle_of_type;
 

	
 
	byte time_since_load;
 
	byte time_since_unload;
 
	byte airport_type;
 

	
 
	uint64 airport_flags;   ///< stores which blocks on the airport are taken. was 16 bit earlier on, then 32
 

	
 
	byte last_vehicle_type;
 
	std::list<Vehicle *> loading_vehicles;
 
	GoodsEntry goods[NUM_CARGO];  ///< Goods at this station
 
	uint32 always_accepted;       ///< Bitmask of always accepted cargo types (by houses, HQs, industry tiles when industry doesn't accept cargo)
 

	
 
@@ -127,14 +131,14 @@ public:
 
		return IsAirportTile(tile) && GetStationIndex(tile) == this->index;
 
	}
 

	
 
	FORCEINLINE TileIndex GetHangarTile(uint hangar_num) const
 
	{
 
		assert(this->airport.tile != INVALID_TILE);
 
		assert(hangar_num < this->GetAirportSpec()->nof_depots);
 
		return this->airport.tile + ToTileIndexDiff(this->GetAirportSpec()->depot_table[hangar_num]);
 
		assert(hangar_num < this->airport.GetSpec()->nof_depots);
 
		return this->airport.tile + ToTileIndexDiff(this->airport.GetSpec()->depot_table[hangar_num]);
 
	}
 

	
 
	/* virtual */ uint32 GetNewGRFVariable(const ResolverObject *object, byte variable, byte parameter, bool *available) const;
 

	
 
	/* virtual */ void GetTileArea(TileArea *ta, StationType type) const;
 
};
src/station_cmd.cpp
Show inline comments
 
@@ -63,13 +63,13 @@ bool IsHangar(TileIndex t)
 
	assert(IsTileType(t, MP_STATION));
 

	
 
	/* If the tile isn't an airport there's no chance it's a hangar. */
 
	if (!IsAirport(t)) return false;
 

	
 
	const Station *st = Station::GetByTile(t);
 
	const AirportSpec *as = st->GetAirportSpec();
 
	const AirportSpec *as = st->airport.GetSpec();
 

	
 
	for (uint i = 0; i < as->nof_depots; i++) {
 
		if (st->GetHangarTile(i) == t) return true;
 
	}
 

	
 
	return false;
 
@@ -410,13 +410,13 @@ void Station::GetTileArea(TileArea *ta, 
 
 */
 
void Station::UpdateVirtCoord()
 
{
 
	Point pt = RemapCoords2(TileX(this->xy) * TILE_SIZE, TileY(this->xy) * TILE_SIZE);
 

	
 
	pt.y -= 32;
 
	if ((this->facilities & FACIL_AIRPORT) && this->airport_type == AT_OILRIG) pt.y -= 16;
 
	if ((this->facilities & FACIL_AIRPORT) && this->airport.type == AT_OILRIG) pt.y -= 16;
 

	
 
	SetDParam(0, this->index);
 
	SetDParam(1, this->facilities);
 
	this->sign.UpdatePosition(pt.x, pt.y, STR_VIEWPORT_STATION);
 

	
 
	SetWindowDirty(WC_STATION_VIEW, this->index);
 
@@ -2071,13 +2071,13 @@ void UpdateAirportsNoise()
 
	const Station *st;
 

	
 
	FOR_ALL_TOWNS(t) t->noise_reached = 0;
 

	
 
	FOR_ALL_STATIONS(st) {
 
		if (st->airport.tile != INVALID_TILE) {
 
			const AirportSpec *as = st->GetAirportSpec();
 
			const AirportSpec *as = st->airport.GetSpec();
 
			Town *nearest = AirportGetNearestTown(as, st->airport.tile);
 
			nearest->noise_reached += GetAirportNoiseLevelForTown(as, nearest->xy, st->airport.tile);
 
		}
 
	}
 
}
 

	
 
@@ -2139,13 +2139,13 @@ CommandCost CmdBuildAirport(TileIndex ti
 
			authority_refuse_message = STR_ERROR_LOCAL_AUTHORITY_REFUSES_NOISE;
 
		}
 
	} else {
 
		uint num = 0;
 
		const Station *st;
 
		FOR_ALL_STATIONS(st) {
 
			if (st->town == t && (st->facilities & FACIL_AIRPORT) && st->airport_type != AT_OILRIG) num++;
 
			if (st->town == t && (st->facilities & FACIL_AIRPORT) && st->airport.type != AT_OILRIG) num++;
 
		}
 
		if (num >= 2) {
 
			authority_refuse_message = STR_ERROR_LOCAL_AUTHORITY_REFUSES_AIRPORT;
 
		}
 
	}
 

	
 
@@ -2202,14 +2202,14 @@ CommandCost CmdBuildAirport(TileIndex ti
 

	
 
	if (flags & DC_EXEC) {
 
		/* Always add the noise, so there will be no need to recalculate when option toggles */
 
		nearest->noise_reached += newnoise_level;
 

	
 
		st->AddFacility(FACIL_AIRPORT, tile);
 
		st->airport_type = (byte)p1;
 
		st->airport_flags = 0;
 
		st->airport.type = (byte)p1;
 
		st->airport.flags = 0;
 

	
 
		st->rect.BeforeAddRect(tile, w, h, StationRect::ADD_TRY);
 

	
 
		it = as->table[layout];
 
		do {
 
			TileIndex cur_tile = tile + ToTileIndexDiff(it->ti);
 
@@ -2290,13 +2290,13 @@ static CommandCost RemoveAirport(TileInd
 
			DeleteAnimatedTile(tile_cur);
 
			DoClearSquare(tile_cur);
 
		}
 
	}
 

	
 
	if (flags & DC_EXEC) {
 
		const AirportSpec *as = st->GetAirportSpec();
 
		const AirportSpec *as = st->airport.GetSpec();
 
		for (uint i = 0; i < as->nof_depots; ++i) {
 
			DeleteWindowById(
 
				WC_VEHICLE_DEPOT, st->GetHangarTile(i)
 
			);
 
		}
 

	
 
@@ -3372,13 +3372,13 @@ void BuildOilRig(TileIndex tile)
 

	
 
	assert(IsTileType(tile, MP_INDUSTRY));
 
	DeleteAnimatedTile(tile);
 
	MakeOilrig(tile, st->index, GetWaterClass(tile));
 

	
 
	st->owner = OWNER_NONE;
 
	st->airport_type = AT_OILRIG;
 
	st->airport.type = AT_OILRIG;
 
	st->airport.Add(tile);
 
	st->dock_tile = tile;
 
	st->facilities = FACIL_AIRPORT | FACIL_DOCK;
 
	st->build_date = _date;
 

	
 
	st->rect.BeforeAddTile(tile, StationRect::ADD_FORCE);
 
@@ -3403,13 +3403,13 @@ void DeleteOilRig(TileIndex tile)
 
	MakeWaterKeepingClass(tile, OWNER_NONE);
 
	MarkTileDirtyByTile(tile);
 

	
 
	st->dock_tile = INVALID_TILE;
 
	st->airport.Clear();
 
	st->facilities &= ~(FACIL_AIRPORT | FACIL_DOCK);
 
	st->airport_flags = 0;
 
	st->airport.flags = 0;
 

	
 
	st->rect.AfterRemoveTile(st, tile);
 

	
 
	st->UpdateVirtCoord();
 
	st->RecomputeIndustriesNear();
 
	if (!st->IsInUse()) delete st;
src/table/airport_movement.h
Show inline comments
 
@@ -15,13 +15,13 @@
 

	
 
/* state machine input struct (from external file, etc.)
 
 * Finite sTate mAchine --> FTA */
 
struct AirportFTAbuildup {
 
	byte position; // the position that an airplane is at
 
	byte heading;  // the current orders (eg. TAKEOFF, HANGAR, ENDLANDING, etc.)
 
	uint64 block;  // the block this position is on on the airport (st->airport_flags)
 
	uint64 block;  // the block this position is on on the airport (st->airport.flags)
 
	byte next;     // next position from this position
 
};
 

	
 
///////////////////////////////////////////////////////////////////////
 
/////*********Movement Positions on Airports********************///////
 

	
src/town_gui.cpp
Show inline comments
 
@@ -477,13 +477,13 @@ public:
 
	{
 
		/* Stations refer to towns. */
 
		const Station *st;
 
		FOR_ALL_STATIONS(st) {
 
			if (st->town == this->town) {
 
				/* Non-oil rig stations are always a problem. */
 
				if (!(st->facilities & FACIL_AIRPORT) || st->airport_type != AT_OILRIG) return false;
 
				if (!(st->facilities & FACIL_AIRPORT) || st->airport.type != AT_OILRIG) return false;
 
				/* We can only automatically delete oil rigs *if* there's no vehicle on them. */
 
				if (DoCommand(st->airport.tile, 0, 0, DC_NONE, CMD_LANDSCAPE_CLEAR).Failed()) return false;
 
			}
 
		}
 

	
 
		/* Depots refer to towns. */
src/vehicle.cpp
Show inline comments
 
@@ -623,14 +623,14 @@ void Vehicle::PreDestructor()
 
	}
 

	
 
	if (this->type == VEH_AIRCRAFT && this->IsPrimaryVehicle()) {
 
		Aircraft *a = Aircraft::From(this);
 
		Station *st = GetTargetAirportIfValid(a);
 
		if (st != NULL) {
 
			const AirportFTA *layout = st->Airport()->layout;
 
			CLRBITS(st->airport_flags, layout[a->previous_pos].block | layout[a->pos].block);
 
			const AirportFTA *layout = st->airport.GetFTA()->layout;
 
			CLRBITS(st->airport.flags, layout[a->previous_pos].block | layout[a->pos].block);
 
		}
 
	}
 

	
 

	
 
	if (this->type == VEH_ROAD && this->IsPrimaryVehicle()) {
 
		RoadVehicle *v = RoadVehicle::From(this);
 
@@ -1871,13 +1871,13 @@ bool CanVehicleUseStation(EngineID engin
 

	
 
		case VEH_SHIP:
 
			return (st->facilities & FACIL_DOCK) != 0;
 

	
 
		case VEH_AIRCRAFT:
 
			return (st->facilities & FACIL_AIRPORT) != 0 &&
 
					(st->Airport()->flags & (e->u.air.subtype & AIR_CTOL ? AirportFTAClass::AIRPLANES : AirportFTAClass::HELICOPTERS)) != 0;
 
					(st->airport.GetFTA()->flags & (e->u.air.subtype & AIR_CTOL ? AirportFTAClass::AIRPLANES : AirportFTAClass::HELICOPTERS)) != 0;
 

	
 
		default:
 
			return false;
 
	}
 
}
 

	
src/water_cmd.cpp
Show inline comments
 
@@ -736,13 +736,13 @@ static Vehicle *FloodVehicleProc(Vehicle
 
static void FloodVehicles(TileIndex tile)
 
{
 
	byte z = 0;
 

	
 
	if (IsAirportTile(tile)) {
 
		const Station *st = Station::GetByTile(tile);
 
		z = 1 + st->Airport()->delta_z;
 
		z = 1 + st->airport.GetFTA()->delta_z;
 
		TILE_AREA_LOOP(tile, st->airport) {
 
			if (st->TileBelongsToAirport(tile)) FindVehicleOnPos(tile, &z, &FloodVehicleProc);
 
		}
 

	
 
		/* No vehicle could be flooded on this airport anymore */
 
		return;
 
@@ -781,13 +781,13 @@ static void FloodVehicle(Vehicle *v)
 
	if (v->type == VEH_AIRCRAFT) {
 
		/* Crashing aircraft are always at z_pos == 1, never on z_pos == 0,
 
		 * because that's always the shadow. Except for the heliport, because
 
		 * that station has a big z_offset for the aircraft. */
 
		if (!IsAirportTile(v->tile) || GetTileMaxZ(v->tile) != 0) return;
 
		const Station *st = Station::GetByTile(v->tile);
 
		const AirportFTAClass *airport = st->Airport();
 
		const AirportFTAClass *airport = st->airport.GetFTA();
 

	
 
		if (v->z_pos != airport->delta_z + 1) return;
 
	} else {
 
		v = v->First();
 
	}
 

	
0 comments (0 inline, 0 general)