mirror of https://github.com/OpenTTD/OpenTTD
(svn r8559) -Fix
-Codechange: Put the airport movement data into struct AirportFTAClassrelease/0.6
parent
2e30da531b
commit
1a3b4b7394
|
@ -916,7 +916,6 @@ static byte GetAircraftFlyingAltitude(const Vehicle *v)
|
||||||
static bool AircraftController(Vehicle *v)
|
static bool AircraftController(Vehicle *v)
|
||||||
{
|
{
|
||||||
Station *st;
|
Station *st;
|
||||||
const AirportMovingData *amd;
|
|
||||||
Vehicle *u;
|
Vehicle *u;
|
||||||
byte z, maxz, curz;
|
byte z, maxz, curz;
|
||||||
Direction newdir;
|
Direction newdir;
|
||||||
|
@ -937,7 +936,7 @@ static bool AircraftController(Vehicle *v)
|
||||||
}
|
}
|
||||||
|
|
||||||
// get airport moving data
|
// 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
|
// Helicopter raise
|
||||||
if (amd->flag & AMED_HELI_RAISE) {
|
if (amd->flag & AMED_HELI_RAISE) {
|
||||||
|
|
|
@ -30,6 +30,7 @@ static AirportFTAClass *IntercontinentalAirport;
|
||||||
static AirportFTAClass *HeliStation;
|
static AirportFTAClass *HeliStation;
|
||||||
|
|
||||||
static void AirportFTAClass_Constructor(AirportFTAClass *apc,
|
static void AirportFTAClass_Constructor(AirportFTAClass *apc,
|
||||||
|
const AirportMovingData *moving_data,
|
||||||
const byte *terminals, const byte *helipads,
|
const byte *terminals, const byte *helipads,
|
||||||
const byte entry_point, const AcceptPlanes acc_planes,
|
const byte entry_point, const AcceptPlanes acc_planes,
|
||||||
const AirportFTAbuildup *apFA,
|
const AirportFTAbuildup *apFA,
|
||||||
|
@ -54,6 +55,7 @@ void InitializeAirports(void)
|
||||||
|
|
||||||
AirportFTAClass_Constructor(
|
AirportFTAClass_Constructor(
|
||||||
CountryAirport,
|
CountryAirport,
|
||||||
|
_airport_moving_data_country,
|
||||||
_airport_terminal_country,
|
_airport_terminal_country,
|
||||||
NULL,
|
NULL,
|
||||||
16,
|
16,
|
||||||
|
@ -69,6 +71,7 @@ void InitializeAirports(void)
|
||||||
|
|
||||||
AirportFTAClass_Constructor(
|
AirportFTAClass_Constructor(
|
||||||
CityAirport,
|
CityAirport,
|
||||||
|
_airport_moving_data_town,
|
||||||
_airport_terminal_city,
|
_airport_terminal_city,
|
||||||
NULL,
|
NULL,
|
||||||
19,
|
19,
|
||||||
|
@ -84,6 +87,7 @@ void InitializeAirports(void)
|
||||||
|
|
||||||
AirportFTAClass_Constructor(
|
AirportFTAClass_Constructor(
|
||||||
MetropolitanAirport,
|
MetropolitanAirport,
|
||||||
|
_airport_moving_data_metropolitan,
|
||||||
_airport_terminal_metropolitan,
|
_airport_terminal_metropolitan,
|
||||||
NULL,
|
NULL,
|
||||||
20,
|
20,
|
||||||
|
@ -99,6 +103,7 @@ void InitializeAirports(void)
|
||||||
|
|
||||||
AirportFTAClass_Constructor(
|
AirportFTAClass_Constructor(
|
||||||
InternationalAirport,
|
InternationalAirport,
|
||||||
|
_airport_moving_data_international,
|
||||||
_airport_terminal_international,
|
_airport_terminal_international,
|
||||||
_airport_helipad_international,
|
_airport_helipad_international,
|
||||||
37,
|
37,
|
||||||
|
@ -114,6 +119,7 @@ void InitializeAirports(void)
|
||||||
|
|
||||||
AirportFTAClass_Constructor(
|
AirportFTAClass_Constructor(
|
||||||
IntercontinentalAirport,
|
IntercontinentalAirport,
|
||||||
|
_airport_moving_data_intercontinental,
|
||||||
_airport_terminal_intercontinental,
|
_airport_terminal_intercontinental,
|
||||||
_airport_helipad_intercontinental,
|
_airport_helipad_intercontinental,
|
||||||
43,
|
43,
|
||||||
|
@ -124,11 +130,11 @@ void InitializeAirports(void)
|
||||||
9,11
|
9,11
|
||||||
);
|
);
|
||||||
|
|
||||||
// heliport, oilrig
|
|
||||||
Heliport = MallocT<AirportFTAClass>(1);
|
Heliport = MallocT<AirportFTAClass>(1);
|
||||||
|
|
||||||
AirportFTAClass_Constructor(
|
AirportFTAClass_Constructor(
|
||||||
Heliport,
|
Heliport,
|
||||||
|
_airport_moving_data_heliport,
|
||||||
NULL,
|
NULL,
|
||||||
_airport_helipad_heliport_oilrig,
|
_airport_helipad_heliport_oilrig,
|
||||||
7,
|
7,
|
||||||
|
@ -139,13 +145,26 @@ void InitializeAirports(void)
|
||||||
1, 1
|
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
|
// commuter airport
|
||||||
CommuterAirport = MallocT<AirportFTAClass>(1);
|
CommuterAirport = MallocT<AirportFTAClass>(1);
|
||||||
|
|
||||||
AirportFTAClass_Constructor(
|
AirportFTAClass_Constructor(
|
||||||
CommuterAirport,
|
CommuterAirport,
|
||||||
|
_airport_moving_data_commuter,
|
||||||
_airport_terminal_commuter,
|
_airport_terminal_commuter,
|
||||||
_airport_helipad_commuter,
|
_airport_helipad_commuter,
|
||||||
22,
|
22,
|
||||||
|
@ -161,6 +180,7 @@ void InitializeAirports(void)
|
||||||
|
|
||||||
AirportFTAClass_Constructor(
|
AirportFTAClass_Constructor(
|
||||||
HeliDepot,
|
HeliDepot,
|
||||||
|
_airport_moving_data_helidepot,
|
||||||
NULL,
|
NULL,
|
||||||
_airport_helipad_helidepot,
|
_airport_helipad_helidepot,
|
||||||
4,
|
4,
|
||||||
|
@ -176,6 +196,7 @@ void InitializeAirports(void)
|
||||||
|
|
||||||
AirportFTAClass_Constructor(
|
AirportFTAClass_Constructor(
|
||||||
HeliStation,
|
HeliStation,
|
||||||
|
_airport_moving_data_helistation,
|
||||||
NULL,
|
NULL,
|
||||||
_airport_helipad_helistation,
|
_airport_helipad_helistation,
|
||||||
25,
|
25,
|
||||||
|
@ -202,6 +223,7 @@ void UnInitializeAirports(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void AirportFTAClass_Constructor(AirportFTAClass *apc,
|
static void AirportFTAClass_Constructor(AirportFTAClass *apc,
|
||||||
|
const AirportMovingData *moving_data,
|
||||||
const byte *terminals, const byte *helipads,
|
const byte *terminals, const byte *helipads,
|
||||||
const byte entry_point, const AcceptPlanes acc_planes,
|
const byte entry_point, const AcceptPlanes acc_planes,
|
||||||
const AirportFTAbuildup *apFA,
|
const AirportFTAbuildup *apFA,
|
||||||
|
@ -212,6 +234,7 @@ static void AirportFTAClass_Constructor(AirportFTAClass *apc,
|
||||||
byte nofterminals, nofhelipads;
|
byte nofterminals, nofhelipads;
|
||||||
byte nofterminalgroups, nofhelipadgroups;
|
byte nofterminalgroups, nofhelipadgroups;
|
||||||
|
|
||||||
|
apc->moving_data = moving_data;
|
||||||
apc->size_x = size_x;
|
apc->size_x = size_x;
|
||||||
apc->size_y = size_y;
|
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)
|
uint32 GetValidAirports(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -130,6 +130,14 @@ typedef struct AirportMovingData {
|
||||||
|
|
||||||
// Finite sTate mAchine --> FTA
|
// Finite sTate mAchine --> FTA
|
||||||
typedef struct AirportFTAClass {
|
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
|
byte nofelements; // number of positions the airport consists of
|
||||||
const byte *terminals;
|
const byte *terminals;
|
||||||
const byte *helipads;
|
const byte *helipads;
|
||||||
|
@ -154,7 +162,6 @@ typedef struct AirportFTA {
|
||||||
void InitializeAirports(void);
|
void InitializeAirports(void);
|
||||||
void UnInitializeAirports(void);
|
void UnInitializeAirports(void);
|
||||||
const AirportFTAClass *GetAirport(const byte airport_type);
|
const AirportFTAClass *GetAirport(const byte airport_type);
|
||||||
const AirportMovingData *GetAirportMovingData(byte airport_type, byte position);
|
|
||||||
|
|
||||||
/** Get buildable airport bitmask.
|
/** Get buildable airport bitmask.
|
||||||
* @return get all buildable airports at this given time, bitmasked.
|
* @return get all buildable airports at this given time, bitmasked.
|
||||||
|
|
|
@ -771,24 +771,4 @@ static const AirportFTAbuildup _airport_fta_helistation[] = {
|
||||||
{ MAX_ELEMENTS, 0, 0, 0 } // end marker. DO NOT REMOVE
|
{ 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 */
|
#endif /* AIRPORT_MOVEMENT_H */
|
||||||
|
|
|
@ -288,7 +288,7 @@ enum {
|
||||||
static byte MapAircraftMovementState(const Vehicle *v)
|
static byte MapAircraftMovementState(const Vehicle *v)
|
||||||
{
|
{
|
||||||
const Station *st = GetStation(v->u.air.targetairport);
|
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) {
|
switch (v->u.air.state) {
|
||||||
case HANGAR:
|
case HANGAR:
|
||||||
|
|
Loading…
Reference in New Issue