From 20dd63a5902bc7905a5785c28058542783b1a3b0 Mon Sep 17 00:00:00 2001 From: yexo Date: Fri, 5 Mar 2010 23:21:30 +0000 Subject: [PATCH] (svn r19324) -Codechange: introduce AirportSpec::GetWithoutOverride to get a non-const pointer to a given airportspec --- src/newgrf_airport.cpp | 16 +++++++++++++++- src/newgrf_airport.h | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/newgrf_airport.cpp b/src/newgrf_airport.cpp index c5bc5eb55e..20c0ba0e79 100644 --- a/src/newgrf_airport.cpp +++ b/src/newgrf_airport.cpp @@ -21,7 +21,8 @@ AirportSpec AirportSpec::oilrig = {NULL, NULL, 0, 1, 1, 0, 4, MIN_YEAR, MIN_YEAR AirportSpec AirportSpec::specs[NUM_AIRPORTS]; /** - * Retrieve airport spec for the given airport + * Retrieve airport spec for the given airport. If an override is available + * it is returned. * @param type index of airport * @return A pointer to the corresponding AirportSpec */ @@ -32,6 +33,19 @@ AirportSpec AirportSpec::specs[NUM_AIRPORTS]; return &AirportSpec::specs[type]; } +/** + * Retrieve airport spec for the given airport. Even if an override is + * available the base spec is returned. + * @param type index of airport + * @return A pointer to the corresponding AirportSpec + */ +/* 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 (_cur_year < this->min_year) return false; diff --git a/src/newgrf_airport.h b/src/newgrf_airport.h index ae72a3e94a..bdbaafd64b 100644 --- a/src/newgrf_airport.h +++ b/src/newgrf_airport.h @@ -47,6 +47,7 @@ struct AirportSpec { TTDPAirportType ttd_airport_type; ///< ttdpatch airport type (Small/Large/Helipad/Oilrig) static const AirportSpec *Get(byte type); + static AirportSpec *GetWithoutOverride(byte type); bool IsAvailable() const;