Changeset - r14705:be9a20100bed
[Not reviewed]
master
0 5 0
yexo - 14 years ago 2010-03-01 20:17:21
yexo@openttd.org
(svn r19299) -Codechange: store the most compatible ttd airport type in AirportSpec
-Fix: [NewGRF] return the ttd airport type in station var 0xF1
5 files changed with 30 insertions and 43 deletions:
0 comments (0 inline, 0 general)
src/newgrf_airport.cpp
Show inline comments
 
@@ -12,14 +12,14 @@
 
#include "stdafx.h"
 
#include "airport.h"
 
#include "newgrf_airport.h"
 
#include "date_func.h"
 
#include "settings_type.h"
 

	
 
AirportSpec AirportSpec::dummy = {NULL, NULL, 0, 0, 0, 0, 0, MIN_YEAR, MIN_YEAR};
 
AirportSpec AirportSpec::oilrig = {NULL, NULL, 0, 1, 1, 0, 4, MIN_YEAR, MIN_YEAR};
 
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};
 

	
 
/**
 
 * Retrieve airport spec for the given airport
 
 * @param type index of airport
 
 * @return A pointer to the corresponding AirportSpec
 
 */
src/newgrf_airport.h
Show inline comments
 
@@ -20,12 +20,20 @@ typedef byte StationGfx;
 

	
 
struct AirportTileTable {
 
	TileIndexDiffC ti;
 
	StationGfx gfx;
 
};
 

	
 
/** TTDP airport types. Used to map our types to TTDPatch's */
 
enum {
 
	ATP_TTDP_SMALL,    ///< Same as AT_SMALL
 
	ATP_TTDP_LARGE,    ///< Same as AT_LARGE
 
	ATP_TTDP_HELIPORT, ///< Same as AT_HELIPORT
 
	ATP_TTDP_OILRIG,   ///< Same as AT_OILRIG
 
};
 

	
 
/**
 
 * Defines the data structure for an airport.
 
 */
 
struct AirportSpec {
 
	const AirportTileTable * const *table; ///< list of the tiles composing the airport
 
	const TileIndexDiffC *depot_table;     ///< gives the position of the depots on the airports
 
@@ -33,12 +41,13 @@ struct AirportSpec {
 
	byte size_x;                           ///< size of airport in x direction
 
	byte size_y;                           ///< size of airport in y direction
 
	byte noise_level;                      ///< noise that this airport generates
 
	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
 
	byte ttd_airport_type;                 ///< ttdpatch airport type (Small/Large/Helipad/Oilrig)
 

	
 
	static const AirportSpec *Get(byte type);
 

	
 
	bool IsAvailable() const;
 

	
 
	static AirportSpec dummy;
src/newgrf_engine.cpp
Show inline comments
 
@@ -363,21 +363,12 @@ static byte MapAircraftMovementAction(co
 
		default:
 
			return AMA_TTDP_IN_HANGAR;
 
	}
 
}
 

	
 

	
 
/* TTDP airport types. Used to map our types to TTDPatch's */
 
enum {
 
	ATP_TTDP_SMALL,
 
	ATP_TTDP_LARGE,
 
	ATP_TTDP_HELIPORT,
 
	ATP_TTDP_OILRIG,
 
};
 

	
 

	
 
/* Vehicle Resolver Functions */
 
static inline const Vehicle *GRV(const ResolverObject *object)
 
{
 
	switch (object->scope) {
 
		default: NOT_REACHED();
 
		case VSG_SCOPE_SELF: return object->u.vehicle.self;
 
@@ -605,28 +596,14 @@ static uint32 VehicleGetVariable(const R
 
				const Vehicle *w = v->Next();
 
				uint16 altitude = v->z_pos - w->z_pos; // Aircraft height - shadow height
 
				byte airporttype = ATP_TTDP_LARGE;
 

	
 
				const Station *st = GetTargetAirportIfValid(Aircraft::From(v));
 

	
 
				if (st != NULL) {
 
					switch (st->airport_type) {
 
						/* Note, Helidepot and Helistation are treated as small airports
 
						 * as they are at ground level. */
 
						case AT_HELIDEPOT:
 
						case AT_HELISTATION:
 
						case AT_COMMUTER:
 
						case AT_SMALL:         airporttype = ATP_TTDP_SMALL; break;
 
						case AT_METROPOLITAN:
 
						case AT_INTERNATIONAL:
 
						case AT_INTERCON:
 
						case AT_LARGE:         airporttype = ATP_TTDP_LARGE; break;
 
						case AT_HELIPORT:      airporttype = ATP_TTDP_HELIPORT; break;
 
						case AT_OILRIG:        airporttype = ATP_TTDP_OILRIG; break;
 
						default:               airporttype = ATP_TTDP_LARGE; break;
 
					}
 
				if (st != NULL && st->airport.tile != INVALID_TILE) {
 
					airporttype = st->GetAirportSpec()->ttd_airport_type;
 
				}
 

	
 
				return (altitude << 8) | airporttype;
 
			}
 

	
 
		case 0x45: { // Curvature info
src/newgrf_station.cpp
Show inline comments
 
@@ -521,13 +521,13 @@ uint32 Station::GetNewGRFVariable(const 
 
				if (HasBit(this->goods[cargo_type].acceptance_pickup, GoodsEntry::PICKUP)) SetBit(value, cargo_type);
 
			}
 
			return value;
 
		}
 

	
 
		case 0x8A: return this->had_vehicle_of_type;
 
		case 0xF1: return this->airport_type;
 
		case 0xF1: return (this->airport.tile != INVALID_TILE) ? this->GetAirportSpec()->ttd_airport_type : ATP_TTDP_LARGE;
 
		case 0xF2: return (this->truck_stops != NULL) ? this->truck_stops->status : 0;
 
		case 0xF3: return (this->bus_stops != NULL)   ? this->bus_stops->status   : 0;
 
		case 0xF6: return this->airport_flags;
 
		case 0xF7: return GB(this->airport_flags, 8, 8);
 
	}
 

	
src/table/airport_defaults.h
Show inline comments
 
@@ -374,33 +374,34 @@ 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) \
 
	{att, depot_tbl, num_depots, size_x, size_y, noise, catchment, min_year, max_year}
 
#define AS_GENERIC(att, depot_tbl, num_depots, size_x, size_y, noise, catchment, min_year, max_year, ttdpatch_type) \
 
	{att, depot_tbl, num_depots, size_x, size_y, noise, catchment, min_year, max_year, ttdpatch_type}
 

	
 
/** AirportSpec definition for airports without any depot. */
 
#define AS_ND(ap_name, size_x, size_y, min_year, max_year, catchment, noise) \
 
	AS_GENERIC(_tile_table_##ap_name, NULL, 0, size_x, size_y, noise, catchment, min_year, max_year)
 
#define AS_ND(ap_name, size_x, size_y, min_year, max_year, catchment, noise, ttdpatch_type) \
 
	AS_GENERIC(_tile_table_##ap_name, NULL, 0, size_x, size_y, noise, catchment, min_year, max_year, ttdpatch_type)
 

	
 
/** AirportSpec definition for airports with at least one depot. */
 
#define AS(ap_name, size_x, size_y, min_year, max_year, catchment, noise) \
 
	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)
 
#define AS(ap_name, size_x, size_y, min_year, max_year, catchment, noise, ttdpatch_type) \
 
	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)
 

	
 
/* 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),
 
	AS(city, 6, 6, 1955, MAX_YEAR, 5, 5),
 
	AS_ND(heliport, 1, 1, 1963, MAX_YEAR, 4, 1),
 
	AS(metropolitan, 6, 6, 1980, MAX_YEAR, 6, 8),
 
	AS(international, 7, 7, 1990, MAX_YEAR, 8, 17),
 
	AS(commuter, 5, 4, 1983, MAX_YEAR, 4, 4),
 
	AS(helidepot, 2, 2, 1976, MAX_YEAR, 4, 2),
 
	AS(intercontinental, 9, 11, 2002, MAX_YEAR, 10, 25),
 
	AS(helistation, 4, 2, 1980, MAX_YEAR, 4, 3),
 
	AS(country, 4, 3, 0, 1959, 4, 3, ATP_TTDP_SMALL),
 
	AS(city, 6, 6, 1955, MAX_YEAR, 5, 5, ATP_TTDP_LARGE),
 
	AS_ND(heliport, 1, 1, 1963, MAX_YEAR, 4, 1, ATP_TTDP_HELIPORT),
 
	AS(metropolitan, 6, 6, 1980, MAX_YEAR, 6, 8, ATP_TTDP_LARGE),
 
	AS(international, 7, 7, 1990, MAX_YEAR, 8, 17, ATP_TTDP_LARGE),
 
	AS(commuter, 5, 4, 1983, MAX_YEAR, 4, 4, ATP_TTDP_SMALL),
 
	AS(helidepot, 2, 2, 1976, MAX_YEAR, 4, 2, ATP_TTDP_SMALL),
 
	AS(intercontinental, 9, 11, 2002, MAX_YEAR, 10, 25, ATP_TTDP_LARGE),
 
	AS(helistation, 4, 2, 1980, MAX_YEAR, 4, 3, ATP_TTDP_SMALL),
 
};
 

	
 
assert_compile(NUM_AIRPORTS == lengthof(_origin_airport_specs));
 

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