(svn r19299) -Codechange: store the most compatible ttd airport type in AirportSpec

-Fix: [NewGRF] return the ttd airport type in station var 0xF1
replace/41b28d7194a279bdc17475d4fbe2ea6ec885a466
yexo 14 years ago
parent fe5bb036a0
commit 3cda09170c

@ -15,8 +15,8 @@
#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

@ -23,6 +23,14 @@ struct AirportTileTable {
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.
*/
@ -36,6 +44,7 @@ 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
byte ttd_airport_type; ///< ttdpatch airport type (Small/Large/Helipad/Oilrig)
static const AirportSpec *Get(byte type);

@ -366,15 +366,6 @@ static byte MapAircraftMovementAction(const Aircraft *v)
}
/* 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)
{
@ -608,22 +599,8 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
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;

@ -524,7 +524,7 @@ uint32 Station::GetNewGRFVariable(const ResolverObject *object, byte variable, b
}
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;

@ -377,27 +377,28 @@ static AirportTileTable *_tile_table_helistation[] = {
#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));

Loading…
Cancel
Save