summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/airport.cpp124
-rw-r--r--src/airport.h2
-rw-r--r--src/newgrf_airport.cpp2
-rw-r--r--src/newgrf_airport.h1
-rw-r--r--src/openttd.cpp6
-rw-r--r--src/table/airport_defaults.h10
6 files changed, 47 insertions, 98 deletions
diff --git a/src/airport.cpp b/src/airport.cpp
index a699cea20..00ef18137 100644
--- a/src/airport.cpp
+++ b/src/airport.cpp
@@ -20,7 +20,6 @@
#include "newgrf_airport.h"
#include "table/strings.h"
#include "table/airporttile_ids.h"
-#include "table/airport_defaults.h"
/* Uncomment this to print out a full report of the airport-structure
* You should either use
@@ -29,22 +28,7 @@
* - false: give a summarized report which only shows current and next position */
//#define DEBUG_AIRPORT false
-static AirportFTAClass *_dummy_airport;
-static AirportFTAClass *_country_airport;
-static AirportFTAClass *_city_airport;
-static AirportFTAClass *_oilrig;
-static AirportFTAClass *_heliport;
-static AirportFTAClass *_metropolitan_airport;
-static AirportFTAClass *_international_airport;
-static AirportFTAClass *_commuter_airport;
-static AirportFTAClass *_heli_depot;
-static AirportFTAClass *_intercontinental_airport;
-static AirportFTAClass *_heli_station;
-
-
-void InitializeAirports()
-{
- _dummy_airport = new AirportFTAClass(
+static AirportFTAClass _airportfta_dummy(
_airport_moving_data_dummy,
NULL,
NULL,
@@ -54,7 +38,7 @@ void InitializeAirports()
0
);
- _country_airport = new AirportFTAClass(
+static AirportFTAClass _airportfta_country(
_airport_moving_data_country,
_airport_terminal_country,
NULL,
@@ -64,7 +48,7 @@ void InitializeAirports()
0
);
- _city_airport = new AirportFTAClass(
+static AirportFTAClass _airportfta_city(
_airport_moving_data_town,
_airport_terminal_city,
NULL,
@@ -74,7 +58,27 @@ void InitializeAirports()
0
);
- _metropolitan_airport = new AirportFTAClass(
+static AirportFTAClass _airportfta_oilrig(
+ _airport_moving_data_oilrig,
+ NULL,
+ _airport_helipad_heliport_oilrig,
+ _airport_entries_heliport_oilrig,
+ AirportFTAClass::HELICOPTERS,
+ _airport_fta_heliport_oilrig,
+ 54
+ );
+
+static AirportFTAClass _airportfta_heliport(
+ _airport_moving_data_heliport,
+ NULL,
+ _airport_helipad_heliport_oilrig,
+ _airport_entries_heliport_oilrig,
+ AirportFTAClass::HELICOPTERS,
+ _airport_fta_heliport_oilrig,
+ 60
+ );
+
+static AirportFTAClass _airportfta_metropolitan(
_airport_moving_data_metropolitan,
_airport_terminal_metropolitan,
NULL,
@@ -84,7 +88,7 @@ void InitializeAirports()
0
);
- _international_airport = new AirportFTAClass(
+static AirportFTAClass _airportfta_international(
_airport_moving_data_international,
_airport_terminal_international,
_airport_helipad_international,
@@ -94,37 +98,7 @@ void InitializeAirports()
0
);
- _intercontinental_airport = new AirportFTAClass(
- _airport_moving_data_intercontinental,
- _airport_terminal_intercontinental,
- _airport_helipad_intercontinental,
- _airport_entries_intercontinental,
- AirportFTAClass::ALL,
- _airport_fta_intercontinental,
- 0
- );
-
- _heliport = new AirportFTAClass(
- _airport_moving_data_heliport,
- NULL,
- _airport_helipad_heliport_oilrig,
- _airport_entries_heliport_oilrig,
- AirportFTAClass::HELICOPTERS,
- _airport_fta_heliport_oilrig,
- 60
- );
-
- _oilrig = new AirportFTAClass(
- _airport_moving_data_oilrig,
- NULL,
- _airport_helipad_heliport_oilrig,
- _airport_entries_heliport_oilrig,
- AirportFTAClass::HELICOPTERS,
- _airport_fta_heliport_oilrig,
- 54
- );
-
- _commuter_airport = new AirportFTAClass(
+static AirportFTAClass _airportfta_commuter(
_airport_moving_data_commuter,
_airport_terminal_commuter,
_airport_helipad_commuter,
@@ -134,7 +108,7 @@ void InitializeAirports()
0
);
- _heli_depot = new AirportFTAClass(
+static AirportFTAClass _airportfta_helidepot(
_airport_moving_data_helidepot,
NULL,
_airport_helipad_helidepot,
@@ -144,7 +118,17 @@ void InitializeAirports()
0
);
- _heli_station = new AirportFTAClass(
+static AirportFTAClass _airportfta_intercontinental(
+ _airport_moving_data_intercontinental,
+ _airport_terminal_intercontinental,
+ _airport_helipad_intercontinental,
+ _airport_entries_intercontinental,
+ AirportFTAClass::ALL,
+ _airport_fta_intercontinental,
+ 0
+ );
+
+static AirportFTAClass _airportfta_helistation(
_airport_moving_data_helistation,
NULL,
_airport_helipad_helistation,
@@ -153,21 +137,8 @@ void InitializeAirports()
_airport_fta_helistation,
0
);
-}
-void UnInitializeAirports()
-{
- delete _dummy_airport;
- delete _country_airport;
- delete _city_airport;
- delete _heliport;
- delete _metropolitan_airport;
- delete _international_airport;
- delete _commuter_airport;
- delete _heli_depot;
- delete _intercontinental_airport;
- delete _heli_station;
-}
+#include "table/airport_defaults.h"
static uint16 AirportGetNofElements(const AirportFTAbuildup *apFA);
@@ -407,20 +378,5 @@ static void AirportPrintOut(uint nofelements, const AirportFTA *layout, bool ful
const AirportFTAClass *GetAirport(const byte airport_type)
{
- /* FIXME -- AircraftNextAirportPos_and_Order -> Needs something nicer, don't like this code
- * needs constant change if more airports are added */
- switch (airport_type) {
- default: NOT_REACHED();
- case AT_SMALL: return _country_airport;
- case AT_LARGE: return _city_airport;
- case AT_METROPOLITAN: return _metropolitan_airport;
- case AT_HELIPORT: return _heliport;
- case AT_OILRIG: return _oilrig;
- case AT_INTERNATIONAL: return _international_airport;
- case AT_COMMUTER: return _commuter_airport;
- case AT_HELIDEPOT: return _heli_depot;
- case AT_INTERCON: return _intercontinental_airport;
- case AT_HELISTATION: return _heli_station;
- case AT_DUMMY: return _dummy_airport;
- }
+ return AirportSpec::Get(airport_type)->fsm;
}
diff --git a/src/airport.h b/src/airport.h
index e532643a2..c6ddea0c9 100644
--- a/src/airport.h
+++ b/src/airport.h
@@ -185,8 +185,6 @@ struct AirportFTA {
byte heading; ///< heading (current orders), guiding an airplane to its target on an airport
};
-void InitializeAirports();
-void UnInitializeAirports();
const AirportFTAClass *GetAirport(const byte airport_type);
extern const byte * const _airport_sections[];
diff --git a/src/newgrf_airport.cpp b/src/newgrf_airport.cpp
index e39ab29a9..c9eac9ec0 100644
--- a/src/newgrf_airport.cpp
+++ b/src/newgrf_airport.cpp
@@ -20,7 +20,7 @@
static AirportClass _airport_classes[APC_MAX];
-AirportSpec AirportSpec::dummy = {NULL, NULL, 0, 0, 0, 0, 0, MIN_YEAR, MIN_YEAR, STR_NULL, ATP_TTDP_LARGE, APC_BEGIN, false};
+AirportSpec AirportSpec::dummy = {NULL, NULL, NULL, 0, 0, 0, 0, 0, MIN_YEAR, MIN_YEAR, STR_NULL, ATP_TTDP_LARGE, APC_BEGIN, false};
AirportSpec AirportSpec::specs[NUM_AIRPORTS];
diff --git a/src/newgrf_airport.h b/src/newgrf_airport.h
index da5950f66..495ca8ac5 100644
--- a/src/newgrf_airport.h
+++ b/src/newgrf_airport.h
@@ -49,6 +49,7 @@ enum TTDPAirportType {
* Defines the data structure for an airport.
*/
struct AirportSpec {
+ const struct AirportFTAClass *fsm; ///< the finite statemachine for the default airports
const AirportTileTable * const *table; ///< list of the tiles composing the airport
const TileIndexDiffC *depot_table; ///< gives the position of the depots on the airports
byte nof_depots; ///< the number of depots in this airport
diff --git a/src/openttd.cpp b/src/openttd.cpp
index 057d288b9..1dd69b904 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -333,9 +333,6 @@ static void ShutdownGame()
/* stop the AI */
AI::Uninitialize(false);
- /* Uninitialize airport state machines */
- UnInitializeAirports();
-
/* Uninitialize variables that are allocated dynamically */
GamelogReset();
_town_pool.CleanPool();
@@ -605,9 +602,6 @@ int ttd_main(int argc, char *argv[])
/* initialize screenshot formats */
InitializeScreenshotFormats();
- /* initialize airport state machines */
- InitializeAirports();
-
/* initialize all variables that are allocated dynamically */
InitializeDynamicVariables();
diff --git a/src/table/airport_defaults.h b/src/table/airport_defaults.h
index b8d50debe..8207021ba 100644
--- a/src/table/airport_defaults.h
+++ b/src/table/airport_defaults.h
@@ -377,16 +377,16 @@ static AirportTileTable *_tile_table_helistation[] = {
#undef MKEND
/** General AirportSpec definition. */
-#define AS_GENERIC(att, depot_tbl, num_depots, size_x, size_y, noise, catchment, min_year, max_year, ttdpatch_type, class_id, name, enabled) \
- {att, depot_tbl, num_depots, size_x, size_y, noise, catchment, min_year, max_year, name, ttdpatch_type, class_id, enabled}
+#define AS_GENERIC(fsm, att, depot_tbl, num_depots, size_x, size_y, noise, catchment, min_year, max_year, ttdpatch_type, class_id, name, enabled) \
+ {fsm, att, depot_tbl, num_depots, size_x, size_y, noise, catchment, min_year, max_year, name, ttdpatch_type, class_id, enabled}
/** AirportSpec definition for airports without any depot. */
#define AS_ND(ap_name, size_x, size_y, min_year, max_year, catchment, noise, ttdpatch_type, class_id, name) \
- AS_GENERIC(_tile_table_##ap_name, NULL, 0, size_x, size_y, noise, catchment, min_year, max_year, ttdpatch_type, class_id, name, true)
+ AS_GENERIC(&_airportfta_##ap_name, _tile_table_##ap_name, NULL, 0, size_x, size_y, noise, catchment, min_year, max_year, ttdpatch_type, class_id, name, true)
/** AirportSpec definition for airports with at least one depot. */
#define AS(ap_name, size_x, size_y, min_year, max_year, catchment, noise, ttdpatch_type, class_id, name) \
- AS_GENERIC(_tile_table_##ap_name, _airport_depots_##ap_name, lengthof(_airport_depots_##ap_name), size_x, size_y, noise, catchment, min_year, max_year, ttdpatch_type, class_id, name, true)
+ AS_GENERIC(&_airportfta_##ap_name, _tile_table_##ap_name, _airport_depots_##ap_name, lengthof(_airport_depots_##ap_name), size_x, size_y, noise, catchment, min_year, max_year, ttdpatch_type, class_id, name, true)
/* The helidepot and helistation have ATP_TTDP_SMALL because they are at ground level */
extern const AirportSpec _origin_airport_specs[] = {
@@ -399,7 +399,7 @@ extern const AirportSpec _origin_airport_specs[] = {
AS(helidepot, 2, 2, 1976, MAX_YEAR, 4, 2, ATP_TTDP_SMALL, APC_HELIPORT, STR_AIRPORT_HELIDEPOT),
AS(intercontinental, 9, 11, 2002, MAX_YEAR, 10, 25, ATP_TTDP_LARGE, APC_HUB, STR_AIRPORT_INTERCONTINENTAL),
AS(helistation, 4, 2, 1980, MAX_YEAR, 4, 3, ATP_TTDP_SMALL, APC_HELIPORT, STR_AIRPORT_HELISTATION),
- AS_GENERIC(NULL, NULL, 0, 1, 1, 0, 4, 0, 0, ATP_TTDP_OILRIG, APC_HELIPORT, STR_NULL, false),
+ AS_GENERIC(&_airportfta_oilrig, NULL, NULL, 0, 1, 1, 0, 4, 0, 0, ATP_TTDP_OILRIG, APC_HELIPORT, STR_NULL, false),
};
assert_compile(NUM_AIRPORTS == lengthof(_origin_airport_specs));