diff options
author | tron <tron@openttd.org> | 2007-02-03 13:03:11 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2007-02-03 13:03:11 +0000 |
commit | 1a3b4b7394314864356dfb5e40e12dedd4b670d9 (patch) | |
tree | f379d9c86409257099d882453dc9dafc2fd07f67 | |
parent | 2e30da531b61fda9ce04f31101724d4f58d882c3 (diff) | |
download | openttd-1a3b4b7394314864356dfb5e40e12dedd4b670d9.tar.xz |
(svn r8559) -Fix
-Codechange: Put the airport movement data into struct AirportFTAClass
-rw-r--r-- | src/aircraft_cmd.cpp | 3 | ||||
-rw-r--r-- | src/airport.cpp | 33 | ||||
-rw-r--r-- | src/airport.h | 9 | ||||
-rw-r--r-- | src/airport_movement.h | 20 | ||||
-rw-r--r-- | src/newgrf_engine.cpp | 2 |
5 files changed, 35 insertions, 32 deletions
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index 7ab5a6185..a4b0ad68f 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -916,7 +916,6 @@ static byte GetAircraftFlyingAltitude(const Vehicle *v) 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 *v) } // 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) { diff --git a/src/airport.cpp b/src/airport.cpp index 0c1370a72..52544331c 100644 --- a/src/airport.cpp +++ b/src/airport.cpp @@ -30,6 +30,7 @@ static AirportFTAClass *IntercontinentalAirport; 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(AirportFTAClass *apc, 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 byte airport_type) } } -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) { diff --git a/src/airport.h b/src/airport.h index 75c275e2d..a020b14ef 100644 --- a/src/airport.h +++ b/src/airport.h @@ -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. diff --git a/src/airport_movement.h b/src/airport_movement.h index ac0937cc1..4892a4f32 100644 --- a/src/airport_movement.h +++ b/src/airport_movement.h @@ -771,24 +771,4 @@ static const AirportFTAbuildup _airport_fta_helistation[] = { { 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 */ diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp index 7732c77f1..08e910cf1 100644 --- a/src/newgrf_engine.cpp +++ b/src/newgrf_engine.cpp @@ -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: |