Changeset - r5924:db4ab5a5371a
[Not reviewed]
master
0 5 0
tron - 18 years ago 2007-02-03 13:03:11
tron@openttd.org
(svn r8559) -Fix

-Codechange: Put the airport movement data into struct AirportFTAClass
5 files changed with 35 insertions and 32 deletions:
0 comments (0 inline, 0 general)
src/aircraft_cmd.cpp
Show inline comments
 
@@ -916,7 +916,6 @@ static byte GetAircraftFlyingAltitude(co
 
static bool AircraftController(Vehicle *v)
 
{
 
	Station *st;
 
	const AirportMovingData *amd;
 
	Vehicle *u;
 
	byte z, maxz, curz;
 
	Direction newdir;
 
@@ -937,7 +936,7 @@ static bool AircraftController(Vehicle *
 
	}
 

	
 
	// get airport moving data
 
	amd = GetAirportMovingData(st->airport_type, v->u.air.pos);
 
	const AirportMovingData *amd = GetAirport(st->airport_type)->MovingData(v->u.air.pos);
 

	
 
	// Helicopter raise
 
	if (amd->flag & AMED_HELI_RAISE) {
src/airport.cpp
Show inline comments
 
@@ -30,6 +30,7 @@ static AirportFTAClass *Intercontinental
 
static AirportFTAClass *HeliStation;
 

	
 
static void AirportFTAClass_Constructor(AirportFTAClass *apc,
 
	const AirportMovingData *moving_data,
 
	const byte *terminals, const byte *helipads,
 
	const byte entry_point,  const AcceptPlanes acc_planes,
 
	const AirportFTAbuildup *apFA,
 
@@ -54,6 +55,7 @@ void InitializeAirports(void)
 

	
 
	AirportFTAClass_Constructor(
 
		CountryAirport,
 
		_airport_moving_data_country,
 
		_airport_terminal_country,
 
		NULL,
 
		16,
 
@@ -69,6 +71,7 @@ void InitializeAirports(void)
 

	
 
	AirportFTAClass_Constructor(
 
		CityAirport,
 
		_airport_moving_data_town,
 
		_airport_terminal_city,
 
		NULL,
 
		19,
 
@@ -84,6 +87,7 @@ void InitializeAirports(void)
 

	
 
	AirportFTAClass_Constructor(
 
		MetropolitanAirport,
 
		_airport_moving_data_metropolitan,
 
		_airport_terminal_metropolitan,
 
		NULL,
 
		20,
 
@@ -99,6 +103,7 @@ void InitializeAirports(void)
 

	
 
	AirportFTAClass_Constructor(
 
		InternationalAirport,
 
		_airport_moving_data_international,
 
		_airport_terminal_international,
 
		_airport_helipad_international,
 
		37,
 
@@ -114,6 +119,7 @@ void InitializeAirports(void)
 

	
 
	AirportFTAClass_Constructor(
 
		IntercontinentalAirport,
 
		_airport_moving_data_intercontinental,
 
		_airport_terminal_intercontinental,
 
		_airport_helipad_intercontinental,
 
		43,
 
@@ -124,11 +130,11 @@ void InitializeAirports(void)
 
		9,11
 
	);
 

	
 
	// heliport, oilrig
 
	Heliport = MallocT<AirportFTAClass>(1);
 

	
 
	AirportFTAClass_Constructor(
 
		Heliport,
 
		_airport_moving_data_heliport,
 
		NULL,
 
		_airport_helipad_heliport_oilrig,
 
		7,
 
@@ -139,13 +145,26 @@ void InitializeAirports(void)
 
		1, 1
 
	);
 

	
 
	Oilrig = Heliport;  // exactly the same structure for heliport/oilrig, so share state machine
 
	Oilrig = MallocT<AirportFTAClass>(1);
 
	AirportFTAClass_Constructor(
 
		Oilrig,
 
		_airport_moving_data_oilrig,
 
		NULL,
 
		_airport_helipad_heliport_oilrig,
 
		7,
 
		HELICOPTERS_ONLY,
 
		_airport_fta_heliport_oilrig,
 
		NULL,
 
		0,
 
		1, 1
 
	);
 

	
 
	// commuter airport
 
	CommuterAirport = MallocT<AirportFTAClass>(1);
 

	
 
	AirportFTAClass_Constructor(
 
		CommuterAirport,
 
		_airport_moving_data_commuter,
 
		_airport_terminal_commuter,
 
		_airport_helipad_commuter,
 
		22,
 
@@ -161,6 +180,7 @@ void InitializeAirports(void)
 

	
 
	AirportFTAClass_Constructor(
 
		HeliDepot,
 
		_airport_moving_data_helidepot,
 
		NULL,
 
		_airport_helipad_helidepot,
 
		4,
 
@@ -176,6 +196,7 @@ void InitializeAirports(void)
 

	
 
	AirportFTAClass_Constructor(
 
		HeliStation,
 
		_airport_moving_data_helistation,
 
		NULL,
 
		_airport_helipad_helistation,
 
		25,
 
@@ -202,6 +223,7 @@ void UnInitializeAirports(void)
 
}
 

	
 
static void AirportFTAClass_Constructor(AirportFTAClass *apc,
 
	const AirportMovingData *moving_data,
 
	const byte *terminals, const byte *helipads,
 
	const byte entry_point, const AcceptPlanes acc_planes,
 
	const AirportFTAbuildup *apFA,
 
@@ -212,6 +234,7 @@ static void AirportFTAClass_Constructor(
 
	byte nofterminals, nofhelipads;
 
	byte nofterminalgroups, nofhelipadgroups;
 

	
 
	apc->moving_data = moving_data;
 
	apc->size_x = size_x;
 
	apc->size_y = size_y;
 

	
 
@@ -469,12 +492,6 @@ const AirportFTAClass *GetAirport(const 
 
	}
 
}
 

	
 
const AirportMovingData *GetAirportMovingData(byte airport_type, byte position)
 
{
 
	assert(airport_type < lengthof(_airport_moving_datas));
 
	assert(position < GetAirport(airport_type)->nofelements);
 
	return &_airport_moving_datas[airport_type][position];
 
}
 

	
 
uint32 GetValidAirports(void)
 
{
src/airport.h
Show inline comments
 
@@ -130,6 +130,14 @@ typedef struct AirportMovingData {
 

	
 
// Finite sTate mAchine --> FTA
 
typedef struct AirportFTAClass {
 
	public:
 
		const AirportMovingData *MovingData(byte position) const
 
		{
 
			assert(position < nofelements);
 
			return &moving_data[position];
 
		}
 

	
 
	const AirportMovingData *moving_data;
 
	byte nofelements;                     // number of positions the airport consists of
 
	const byte *terminals;
 
	const byte *helipads;
 
@@ -154,7 +162,6 @@ typedef struct AirportFTA {
 
void InitializeAirports(void);
 
void UnInitializeAirports(void);
 
const AirportFTAClass *GetAirport(const byte airport_type);
 
const AirportMovingData *GetAirportMovingData(byte airport_type, byte position);
 

	
 
/** Get buildable airport bitmask.
 
 * @return get all buildable airports at this given time, bitmasked.
src/airport_movement.h
Show inline comments
 
@@ -771,24 +771,4 @@ static const AirportFTAbuildup _airport_
 
	{ MAX_ELEMENTS, 0, 0, 0 } // end marker. DO NOT REMOVE
 
};
 

	
 

	
 
static const AirportMovingData * const _airport_moving_datas[] = {
 
	_airport_moving_data_country,           // Country Airfield (small) 4x3
 
	_airport_moving_data_town,              // City Airport (large) 6x6
 
	_airport_moving_data_heliport,          // Heliport
 
	_airport_moving_data_metropolitan,      // Metropolitain Airport (large) - 2 runways
 
	_airport_moving_data_international,     // International Airport (xlarge) - 2 runways
 
	_airport_moving_data_commuter,          // Commuter Airfield (small) 5x4
 
	_airport_moving_data_helidepot,         // Helidepot
 
	_airport_moving_data_intercontinental,  // Intercontinental Airport (xxlarge) - 4 runways
 
	_airport_moving_data_helistation,       // Helistation
 
	NULL,
 
	NULL,
 
	NULL,
 
	NULL,
 
	NULL,
 
	NULL,
 
	_airport_moving_data_oilrig             // Oilrig
 
};
 

	
 
#endif /* AIRPORT_MOVEMENT_H */
src/newgrf_engine.cpp
Show inline comments
 
@@ -288,7 +288,7 @@ enum {
 
static byte MapAircraftMovementState(const Vehicle *v)
 
{
 
	const Station *st = GetStation(v->u.air.targetairport);
 
	byte amdflag = GetAirportMovingData(st->airport_type, v->u.air.pos)->flag;
 
	byte amdflag = GetAirport(st->airport_type)->MovingData(v->u.air.pos)->flag;
 

	
 
	switch (v->u.air.state) {
 
		case HANGAR:
0 comments (0 inline, 0 general)