From 6d1dc477f620fdef35782fdb641461a6a916e389 Mon Sep 17 00:00:00 2001 From: peter1138 Date: Mon, 1 May 2006 12:00:14 +0000 Subject: (svn r4644) - NewGRF: support for variable 0x44, aircraft information. (mart3p) --- newgrf_engine.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/newgrf_engine.c b/newgrf_engine.c index 5fe555b5a..3b486a3ab 100644 --- a/newgrf_engine.c +++ b/newgrf_engine.c @@ -391,6 +391,15 @@ static byte MapAircraftMovementAction(const Vehicle *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) { @@ -468,6 +477,27 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by case 0x43: /* Player information */ return v->owner; + case 0x44: /* Aircraft information */ + if (v->type != VEH_Aircraft) return -1; + + { + const Vehicle *w = v->next; + uint16 altitude = v->z_pos - w->z_pos; /* Aircraft height - shadow height */ + byte airporttype; + + switch (GetStation(v->u.air.targetairport)->airport_type) { + case AT_SMALL: airporttype = ATP_TTDP_SMALL; break; + case AT_METROPOLITAN: + case AT_INTERNATIONAL: + 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; + } + + return (altitude << 8) | airporttype; + } + case 0x46: /* Motion counter */ return 0; } -- cgit v1.2.3-70-g09d2