summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2010-03-05 23:21:23 +0000
committeryexo <yexo@openttd.org>2010-03-05 23:21:23 +0000
commit664934e6f6c24aa63b0bd3b3e4a0333eab53d612 (patch)
tree3db50490dede46651b27580983401f48150ce5a8 /src
parent308781664b6b316f6f13822d292f3c5c787d62c9 (diff)
downloadopenttd-664934e6f6c24aa63b0bd3b3e4a0333eab53d612.tar.xz
(svn r19323) -Codechange: copy the AirportSpec original array to an internal array in AirportSpec
Diffstat (limited to 'src')
-rw-r--r--src/newgrf.cpp2
-rw-r--r--src/newgrf_airport.cpp17
-rw-r--r--src/newgrf_airport.h5
3 files changed, 21 insertions, 3 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index ad212be14..aca51117d 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -36,6 +36,7 @@
#include "newgrf_townname.h"
#include "newgrf_industries.h"
#include "newgrf_airporttiles.h"
+#include "newgrf_airport.h"
#include "rev.h"
#include "fios.h"
#include "rail.h"
@@ -5907,6 +5908,7 @@ static void ResetNewGRFData()
/* Reset airport-related structures */
ResetCustomAirports();
+ AirportSpec::ResetAirports();
AirportTileSpec::ResetAirportTiles();
/* Reset canal sprite groups and flags */
diff --git a/src/newgrf_airport.cpp b/src/newgrf_airport.cpp
index b2cf3e84e..c5bc5eb55 100644
--- a/src/newgrf_airport.cpp
+++ b/src/newgrf_airport.cpp
@@ -18,6 +18,8 @@
AirportSpec AirportSpec::dummy = {NULL, NULL, 0, 0, 0, 0, 0, MIN_YEAR, MIN_YEAR, ATP_TTDP_LARGE};
AirportSpec AirportSpec::oilrig = {NULL, NULL, 0, 1, 1, 0, 4, MIN_YEAR, MIN_YEAR, ATP_TTDP_OILRIG};
+AirportSpec AirportSpec::specs[NUM_AIRPORTS];
+
/**
* Retrieve airport spec for the given airport
* @param type index of airport
@@ -26,9 +28,8 @@ AirportSpec AirportSpec::oilrig = {NULL, NULL, 0, 1, 1, 0, 4, MIN_YEAR, MIN_YEAR
/* static */ const AirportSpec *AirportSpec::Get(byte type)
{
if (type == AT_OILRIG) return &oilrig;
- assert(type < NUM_AIRPORTS);
- extern const AirportSpec _origin_airport_specs[];
- return &_origin_airport_specs[type];
+ assert(type < lengthof(AirportSpec::specs));
+ return &AirportSpec::specs[type];
}
bool AirportSpec::IsAvailable() const
@@ -37,3 +38,13 @@ bool AirportSpec::IsAvailable() const
if (_settings_game.station.never_expire_airports) return true;
return _cur_year <= this->max_year;
}
+
+/**
+ * This function initialize the airportspec array.
+ */
+void AirportSpec::ResetAirports()
+{
+ extern const AirportSpec _origin_airport_specs[];
+ memset(&AirportSpec::specs, 0, sizeof(AirportSpec::specs));
+ memcpy(&AirportSpec::specs, &_origin_airport_specs, sizeof(AirportSpec) * NUM_AIRPORTS);
+}
diff --git a/src/newgrf_airport.h b/src/newgrf_airport.h
index 4876418de..ae72a3e94 100644
--- a/src/newgrf_airport.h
+++ b/src/newgrf_airport.h
@@ -50,8 +50,13 @@ struct AirportSpec {
bool IsAvailable() const;
+ static void ResetAirports();
+
static AirportSpec dummy;
static AirportSpec oilrig;
+
+private:
+ static AirportSpec specs[NUM_AIRPORTS];
};