Changeset - r14726:e42b5d6d3c6a
[Not reviewed]
master
0 2 0
yexo - 14 years ago 2010-03-05 23:21:30
yexo@openttd.org
(svn r19324) -Codechange: introduce AirportSpec::GetWithoutOverride to get a non-const pointer to a given airportspec
2 files changed with 16 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/newgrf_airport.cpp
Show inline comments
 
@@ -18,23 +18,37 @@
 
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
 
 * 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
 
 */
 
/* static */ const AirportSpec *AirportSpec::Get(byte type)
 
{
 
	if (type == AT_OILRIG) return &oilrig;
 
	assert(type < lengthof(AirportSpec::specs));
 
	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;
 
	if (_settings_game.station.never_expire_airports) return true;
 
	return _cur_year <= this->max_year;
 
}
src/newgrf_airport.h
Show inline comments
 
@@ -44,12 +44,13 @@ struct AirportSpec {
 
	byte catchment;                        ///< catchment area of this airport
 
	Year min_year;                         ///< first year the airport is available
 
	Year max_year;                         ///< last year the airport is available
 
	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;
 

	
 
	static void ResetAirports();
 

	
 
	static AirportSpec dummy;
0 comments (0 inline, 0 general)