Changeset - r14729:e9e99770f7ff
[Not reviewed]
master
0 5 0
yexo - 15 years ago 2010-03-05 23:21:51
yexo@openttd.org
(svn r19327) -Codechange: make the oilrig a part of the original airports array so some special cases can be removed
5 files changed with 12 insertions and 11 deletions:
0 comments (0 inline, 0 general)
src/ai/api/ai_airport.cpp
Show inline comments
 
@@ -19,13 +19,13 @@
 
{
 
	return IsAirportInformationAvailable(type) && ::AirportSpec::Get(type)->IsAvailable();
 
}
 

	
 
/* 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)
 
{
 
	if (!IsValidAirportType(type)) return -1;
 

	
src/airport.h
Show inline comments
 
@@ -32,14 +32,14 @@ enum {
 
	AT_METROPOLITAN  =   3,
 
	AT_INTERNATIONAL =   4,
 
	AT_COMMUTER      =   5,
 
	AT_HELIDEPOT     =   6,
 
	AT_INTERCON      =   7,
 
	AT_HELISTATION   =   8,
 
	NUM_AIRPORTS     =   9,
 
	AT_OILRIG        =   9,
 
	NUM_AIRPORTS     =  10,
 
	AT_DUMMY         = 255
 
};
 

	
 
enum {
 
	AMED_NOSPDCLAMP = 1 << 0,
 
	AMED_TAKEOFF    = 1 << 1,
src/newgrf_airport.cpp
Show inline comments
 
@@ -17,45 +17,43 @@
 
#include "core/alloc_type.hpp"
 
#include "newgrf.h"
 
#include "table/strings.h"
 

	
 
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];
 

	
 
/**
 
 * 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 (!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;
 
}
 

	
 
/**
 
@@ -153,13 +151,13 @@ static void BindAirportSpecToClass(Airpo
 
 * Tie all airportspecs to their class.
 
 */
 
void BindAirportSpecs()
 
{
 
	for (int i = 0; i < NUM_AIRPORTS; i++) {
 
		AirportSpec *as = AirportSpec::GetWithoutOverride(i);
 
		BindAirportSpecToClass(as);
 
		if (as->enabled) BindAirportSpecToClass(as);
 
	}
 
}
 

	
 

	
 
/**
 
 * Retrieve an airport spec from a class.
src/newgrf_airport.h
Show inline comments
 
@@ -58,12 +58,14 @@ 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
 
	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);
 

	
 
	bool IsAvailable() const;
 

	
src/table/airport_defaults.h
Show inline comments
 
@@ -374,34 +374,35 @@ static AirportTileTable *_tile_table_hel
 
};
 

	
 
#undef MK
 
#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[] = {
 
	AS(country, 4, 3, 0, 1959, 4, 3, ATP_TTDP_SMALL, APC_SMALL, STR_AIRPORT_SMALL),
 
	AS(city, 6, 6, 1955, MAX_YEAR, 5, 5, ATP_TTDP_LARGE, APC_LARGE, STR_AIRPORT_CITY),
 
	AS_ND(heliport, 1, 1, 1963, MAX_YEAR, 4, 1, ATP_TTDP_HELIPORT, APC_HELIPORT, STR_AIRPORT_HELIPORT),
 
	AS(metropolitan, 6, 6, 1980, MAX_YEAR, 6, 8, ATP_TTDP_LARGE, APC_LARGE, STR_AIRPORT_METRO),
 
	AS(international, 7, 7, 1990, MAX_YEAR, 8, 17, ATP_TTDP_LARGE, APC_HUB, STR_AIRPORT_INTERNATIONAL),
 
	AS(commuter, 5, 4, 1983, MAX_YEAR, 4, 4, ATP_TTDP_SMALL, APC_SMALL, STR_AIRPORT_COMMUTER),
 
	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));
 

	
 
#undef AS
 
#undef AS_ND
0 comments (0 inline, 0 general)