mirror of https://github.com/OpenTTD/OpenTTD
(svn r19323) -Codechange: copy the AirportSpec original array to an internal array in AirportSpec
parent
308781664b
commit
664934e6f6
|
@ -36,6 +36,7 @@
|
||||||
#include "newgrf_townname.h"
|
#include "newgrf_townname.h"
|
||||||
#include "newgrf_industries.h"
|
#include "newgrf_industries.h"
|
||||||
#include "newgrf_airporttiles.h"
|
#include "newgrf_airporttiles.h"
|
||||||
|
#include "newgrf_airport.h"
|
||||||
#include "rev.h"
|
#include "rev.h"
|
||||||
#include "fios.h"
|
#include "fios.h"
|
||||||
#include "rail.h"
|
#include "rail.h"
|
||||||
|
@ -5907,6 +5908,7 @@ static void ResetNewGRFData()
|
||||||
|
|
||||||
/* Reset airport-related structures */
|
/* Reset airport-related structures */
|
||||||
ResetCustomAirports();
|
ResetCustomAirports();
|
||||||
|
AirportSpec::ResetAirports();
|
||||||
AirportTileSpec::ResetAirportTiles();
|
AirportTileSpec::ResetAirportTiles();
|
||||||
|
|
||||||
/* Reset canal sprite groups and flags */
|
/* Reset canal sprite groups and flags */
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
AirportSpec AirportSpec::dummy = {NULL, NULL, 0, 0, 0, 0, 0, MIN_YEAR, MIN_YEAR, ATP_TTDP_LARGE};
|
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::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
|
* Retrieve airport spec for the given airport
|
||||||
* @param type index of 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)
|
/* static */ const AirportSpec *AirportSpec::Get(byte type)
|
||||||
{
|
{
|
||||||
if (type == AT_OILRIG) return &oilrig;
|
if (type == AT_OILRIG) return &oilrig;
|
||||||
assert(type < NUM_AIRPORTS);
|
assert(type < lengthof(AirportSpec::specs));
|
||||||
extern const AirportSpec _origin_airport_specs[];
|
return &AirportSpec::specs[type];
|
||||||
return &_origin_airport_specs[type];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AirportSpec::IsAvailable() const
|
bool AirportSpec::IsAvailable() const
|
||||||
|
@ -37,3 +38,13 @@ bool AirportSpec::IsAvailable() const
|
||||||
if (_settings_game.station.never_expire_airports) return true;
|
if (_settings_game.station.never_expire_airports) return true;
|
||||||
return _cur_year <= this->max_year;
|
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);
|
||||||
|
}
|
||||||
|
|
|
@ -50,8 +50,13 @@ struct AirportSpec {
|
||||||
|
|
||||||
bool IsAvailable() const;
|
bool IsAvailable() const;
|
||||||
|
|
||||||
|
static void ResetAirports();
|
||||||
|
|
||||||
static AirportSpec dummy;
|
static AirportSpec dummy;
|
||||||
static AirportSpec oilrig;
|
static AirportSpec oilrig;
|
||||||
|
|
||||||
|
private:
|
||||||
|
static AirportSpec specs[NUM_AIRPORTS];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue