summaryrefslogtreecommitdiff
path: root/newgrf_engine.c
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2006-05-01 12:00:14 +0000
committerpeter1138 <peter1138@openttd.org>2006-05-01 12:00:14 +0000
commit6d1dc477f620fdef35782fdb641461a6a916e389 (patch)
tree58a2cd4bbd3fe18c6a1b1b8db30b962881da2437 /newgrf_engine.c
parentf0ea2b05517e9966c218174e9338da607d3212bd (diff)
downloadopenttd-6d1dc477f620fdef35782fdb641461a6a916e389.tar.xz
(svn r4644) - NewGRF: support for variable 0x44, aircraft information. (mart3p)
Diffstat (limited to 'newgrf_engine.c')
-rw-r--r--newgrf_engine.c30
1 files changed, 30 insertions, 0 deletions
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;
}