diff options
author | yexo <yexo@openttd.org> | 2010-03-05 23:21:51 +0000 |
---|---|---|
committer | yexo <yexo@openttd.org> | 2010-03-05 23:21:51 +0000 |
commit | 585b036c90b9984bf5a1ecc79e6932182fa8adc0 (patch) | |
tree | df4b7bd9a7b682d76ec4209622545fe90e825209 | |
parent | c42e2a9bfc2114d54257832a644d485244c0c537 (diff) | |
download | openttd-585b036c90b9984bf5a1ecc79e6932182fa8adc0.tar.xz |
(svn r19327) -Codechange: make the oilrig a part of the original airports array so some special cases can be removed
-rw-r--r-- | src/ai/api/ai_airport.cpp | 2 | ||||
-rw-r--r-- | src/airport.h | 2 | ||||
-rw-r--r-- | src/newgrf_airport.cpp | 8 | ||||
-rw-r--r-- | src/newgrf_airport.h | 2 | ||||
-rw-r--r-- | src/table/airport_defaults.h | 9 |
5 files changed, 12 insertions, 11 deletions
diff --git a/src/ai/api/ai_airport.cpp b/src/ai/api/ai_airport.cpp index ce30782cb..7b1119765 100644 --- a/src/ai/api/ai_airport.cpp +++ b/src/ai/api/ai_airport.cpp @@ -22,7 +22,7 @@ /* static */ bool AIAirport::IsAirportInformationAvailable(AirportType type) { - return type >= 0 && type < (AirportType)NUM_AIRPORTS; + return type >= 0 && type < (AirportType)NUM_AIRPORTS && AirportSpec::Get(type)->enabled; } /* static */ Money AIAirport::GetPrice(AirportType type) diff --git a/src/airport.h b/src/airport.h index c3b2c5d83..e532643a2 100644 --- a/src/airport.h +++ b/src/airport.h @@ -35,8 +35,8 @@ enum { AT_HELIDEPOT = 6, AT_INTERCON = 7, AT_HELISTATION = 8, - NUM_AIRPORTS = 9, AT_OILRIG = 9, + NUM_AIRPORTS = 10, AT_DUMMY = 255 }; diff --git a/src/newgrf_airport.cpp b/src/newgrf_airport.cpp index cad50c044..e39ab29a9 100644 --- a/src/newgrf_airport.cpp +++ b/src/newgrf_airport.cpp @@ -20,8 +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}; -AirportSpec AirportSpec::oilrig = {NULL, NULL, 0, 1, 1, 0, 4, MIN_YEAR, MIN_YEAR, STR_NULL, ATP_TTDP_OILRIG, APC_BEGIN}; +AirportSpec AirportSpec::dummy = {NULL, NULL, 0, 0, 0, 0, 0, MIN_YEAR, MIN_YEAR, STR_NULL, ATP_TTDP_LARGE, APC_BEGIN, false}; AirportSpec AirportSpec::specs[NUM_AIRPORTS]; @@ -33,7 +32,6 @@ AirportSpec AirportSpec::specs[NUM_AIRPORTS]; */ /* static */ const AirportSpec *AirportSpec::Get(byte type) { - if (type == AT_OILRIG) return &oilrig; assert(type < lengthof(AirportSpec::specs)); return &AirportSpec::specs[type]; } @@ -46,13 +44,13 @@ AirportSpec AirportSpec::specs[NUM_AIRPORTS]; */ /* static */ AirportSpec *AirportSpec::GetWithoutOverride(byte type) { - if (type == AT_OILRIG) return &oilrig; assert(type < lengthof(AirportSpec::specs)); return &AirportSpec::specs[type]; } bool AirportSpec::IsAvailable() const { + if (!this->enabled) return false; if (_cur_year < this->min_year) return false; if (_settings_game.station.never_expire_airports) return true; return _cur_year <= this->max_year; @@ -156,7 +154,7 @@ void BindAirportSpecs() { for (int i = 0; i < NUM_AIRPORTS; i++) { AirportSpec *as = AirportSpec::GetWithoutOverride(i); - BindAirportSpecToClass(as); + if (as->enabled) BindAirportSpecToClass(as); } } diff --git a/src/newgrf_airport.h b/src/newgrf_airport.h index 358ecd2d6..cb542f316 100644 --- a/src/newgrf_airport.h +++ b/src/newgrf_airport.h @@ -61,6 +61,8 @@ struct AirportSpec { StringID name; ///< name of this airport TTDPAirportType ttd_airport_type; ///< ttdpatch airport type (Small/Large/Helipad/Oilrig) AirportClassID aclass; ///< the class to which this airport type belongs + /* Newgrf data */ + bool enabled; ///< entity still avaible (by default true).newgrf can disable it, though static const AirportSpec *Get(byte type); static AirportSpec *GetWithoutOverride(byte type); diff --git a/src/table/airport_defaults.h b/src/table/airport_defaults.h index e6423e7d9..b8d50debe 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) \ - {att, depot_tbl, num_depots, size_x, size_y, noise, catchment, min_year, max_year, name, ttdpatch_type, class_id} +#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} /** 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) + AS_GENERIC(_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) + 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) /* The helidepot and helistation have ATP_TTDP_SMALL because they are at ground level */ extern const AirportSpec _origin_airport_specs[] = { @@ -399,6 +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), }; assert_compile(NUM_AIRPORTS == lengthof(_origin_airport_specs)); |