Changeset - r14849:27386629fac1
[Not reviewed]
master
0 23 0
yexo - 15 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
 
@@ -96,7 +96,7 @@
 
	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)
 
@@ -120,7 +120,7 @@
 

	
 
	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;
 
}
 

	
 

	
src/ai/api/ai_depotlist.cpp
Show inline comments
 
@@ -29,7 +29,7 @@ AIDepotList::AIDepotList(AITile::Transpo
 
			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));
 
					}
src/ai/api/ai_order.cpp
Show inline comments
 
@@ -181,7 +181,7 @@ static const Order *ResolveOrder(Vehicle
 
			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);
 
		}
 

	
src/ai/api/ai_town.cpp
Show inline comments
 
@@ -188,7 +188,7 @@
 
	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);
 
}
src/aircraft_cmd.cpp
Show inline comments
 
@@ -116,8 +116,8 @@ static StationID FindNearestHangar(const
 
	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) &&
 
@@ -415,7 +415,7 @@ bool Aircraft::FindClosestDepot(TileInde
 
{
 
	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);
 

	
 
@@ -515,7 +515,7 @@ static void CheckIfAircraftNeedsService(
 
	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)) {
 
@@ -841,7 +841,7 @@ static bool AircraftController(Aircraft 
 
		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) {
 
@@ -989,7 +989,7 @@ static bool AircraftController(Aircraft 
 
					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 {
 

	
 
@@ -1125,9 +1125,9 @@ static bool HandleCrashedAircraft(Aircra
 
		 * 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;
 
@@ -1281,7 +1281,7 @@ static void MaybeCrashAirplane(Aircraft 
 

	
 
	/* 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;
 
@@ -1343,7 +1343,7 @@ void AircraftNextAirportPos_and_Order(Ai
 
	}
 

	
 
	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);
 
}
 

	
 
@@ -1468,7 +1468,7 @@ static void AircraftEventHandler_AtTermi
 
			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) {
 
@@ -1546,7 +1546,7 @@ static void AircraftEventHandler_Flying(
 
					 * 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;
 
@@ -1609,7 +1609,7 @@ static void AircraftEventHandler_HeliEnd
 
	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;
 
}
 

	
 
@@ -1646,7 +1646,7 @@ static void AirportClearBlock(const Airc
 
	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);
 
	}
 
}
 

	
 
@@ -1655,7 +1655,7 @@ static void AirportGoToNextPosition(Airc
 
	/* 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
 
@@ -1725,7 +1725,7 @@ static bool AirportHasBlock(Aircraft *v,
 
			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;
 
@@ -1766,14 +1766,14 @@ static bool AirportSetBlocks(Aircraft *v
 
		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;
 
@@ -1783,10 +1783,10 @@ static bool FreeTerminal(Aircraft *v, by
 
{
 
	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;
 
		}
 
	}
 
@@ -1820,7 +1820,7 @@ static bool AirportFindFreeTerminal(Airc
 

	
 
		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;
 
@@ -1871,7 +1871,7 @@ static bool AirportFindFreeHelipad(Aircr
 

	
 
		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) */
 
@@ -1974,7 +1974,7 @@ Station *GetTargetAirportIfValid(const A
 
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) {
src/airport.cpp
Show inline comments
 
@@ -391,7 +391,7 @@ const AirportFTAClass *GetAirport(const 
 
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
src/airport.h
Show inline comments
 
@@ -180,7 +180,7 @@ DECLARE_ENUM_AS_BIT_SET(AirportFTAClass:
 
/** 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
src/disaster_cmd.cpp
Show inline comments
 
@@ -234,7 +234,7 @@ static bool DisasterTick_Zeppeliner(Disa
 

	
 
		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));
 
		}
 

	
 
@@ -271,7 +271,7 @@ static bool DisasterTick_Zeppeliner(Disa
 
	}
 

	
 
	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;
 
@@ -680,7 +680,7 @@ static void Disaster_Zeppeliner_Init()
 

	
 
	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;
 
		}
src/newgrf_airporttiles.cpp
Show inline comments
 
@@ -225,7 +225,7 @@ static void AirportTileResolver(Resolver
 

	
 
	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;
 

	
src/newgrf_engine.cpp
Show inline comments
 
@@ -196,7 +196,7 @@ static byte MapAircraftMovementState(con
 
	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) {
 
@@ -600,7 +600,7 @@ static uint32 VehicleGetVariable(const R
 
				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;
src/newgrf_station.cpp
Show inline comments
 
@@ -524,11 +524,11 @@ uint32 Station::GetNewGRFVariable(const 
 
		}
 

	
 
		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 */
src/order_cmd.cpp
Show inline comments
 
@@ -535,7 +535,7 @@ CommandCost CmdInsertOrder(TileIndex til
 
					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 {
src/saveload/afterload.cpp
Show inline comments
 
@@ -594,8 +594,8 @@ bool AfterLoadGame()
 
	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;
 
			}
 
		}
 
	}
 
@@ -734,7 +734,7 @@ bool AfterLoadGame()
 
							 * 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);
 
						}
 
@@ -2095,8 +2095,8 @@ bool AfterLoadGame()
 
		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;
 
			}
 
		}
 
	}
src/saveload/oldloader_sl.cpp
Show inline comments
 
@@ -732,11 +732,11 @@ static const OldChunks station_chunk[] =
 
	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
 

	
 
@@ -760,12 +760,12 @@ static bool LoadOldStation(LoadgameState
 
				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);
src/saveload/station_sl.cpp
Show inline comments
 
@@ -172,14 +172,14 @@ static const SaveLoad _old_station_desc[
 
	    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),
 
@@ -334,8 +334,8 @@ static const SaveLoad _station_desc[] = 
 
	      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),
 

	
src/saveload/vehicle_sl.cpp
Show inline comments
 
@@ -165,7 +165,7 @@ 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;
src/station.cpp
Show inline comments
 
@@ -40,7 +40,6 @@ 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),
 
@@ -223,7 +222,7 @@ uint Station::GetCatchmentRadius() const
 
		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
 
@@ -45,6 +45,25 @@ struct GoodsEntry {
 
	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;
 

	
 
@@ -58,24 +77,12 @@ public:
 

	
 
	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
 
@@ -84,9 +91,6 @@ public:
 

	
 
	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;
 
@@ -130,8 +134,8 @@ public:
 
	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;
src/station_cmd.cpp
Show inline comments
 
@@ -66,7 +66,7 @@ bool IsHangar(TileIndex t)
 
	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;
 
@@ -413,7 +413,7 @@ 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);
 
@@ -2074,7 +2074,7 @@ void UpdateAirportsNoise()
 

	
 
	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);
 
		}
 
@@ -2142,7 +2142,7 @@ CommandCost CmdBuildAirport(TileIndex ti
 
		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;
 
@@ -2205,8 +2205,8 @@ CommandCost CmdBuildAirport(TileIndex ti
 
		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);
 

	
 
@@ -2293,7 +2293,7 @@ static CommandCost RemoveAirport(TileInd
 
	}
 

	
 
	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)
 
@@ -3375,7 +3375,7 @@ void BuildOilRig(TileIndex 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;
 
@@ -3406,7 +3406,7 @@ void DeleteOilRig(TileIndex 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);
 

	
src/table/airport_movement.h
Show inline comments
 
@@ -18,7 +18,7 @@
 
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
 
};
 

	
src/town_gui.cpp
Show inline comments
 
@@ -480,7 +480,7 @@ public:
 
		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;
 
			}
src/vehicle.cpp
Show inline comments
 
@@ -626,8 +626,8 @@ void Vehicle::PreDestructor()
 
		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);
 
		}
 
	}
 

	
 
@@ -1874,7 +1874,7 @@ bool CanVehicleUseStation(EngineID engin
 

	
 
		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
 
@@ -739,7 +739,7 @@ static void FloodVehicles(TileIndex tile
 

	
 
	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);
 
		}
 
@@ -784,7 +784,7 @@ static void FloodVehicle(Vehicle *v)
 
		 * 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 {
0 comments (0 inline, 0 general)