summaryrefslogtreecommitdiff
path: root/src/newgrf_engine.cpp
diff options
context:
space:
mode:
authormichi_cc <michi_cc@openttd.org>2011-10-04 21:35:35 +0000
committermichi_cc <michi_cc@openttd.org>2011-10-04 21:35:35 +0000
commit12e28de8187808b166541ee8fa339e38037538fd (patch)
tree272ac6edf884229f7d6356cbb880c8ec299ba3dd /src/newgrf_engine.cpp
parent3cb1dcf31cc9c01b0c6e6f4b65808a580d2bc9bd (diff)
downloadopenttd-12e28de8187808b166541ee8fa339e38037538fd.tar.xz
(svn r22998) -Add [FS#2521]: [NewGRF] Act2 var 0x62 to get curvature/position difference to the n-th vehicle in vehicle chain.
Diffstat (limited to 'src/newgrf_engine.cpp')
-rw-r--r--src/newgrf_engine.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp
index 80e249710..5dd020f61 100644
--- a/src/newgrf_engine.cpp
+++ b/src/newgrf_engine.cpp
@@ -652,6 +652,34 @@ static uint32 VehicleGetVariable(Vehicle *v, const ResolverObject *object, byte
}
return 0;
+ case 0x62: { // Curvature/position difference for n-th vehicle in chain [signed number relative to vehicle]
+ /* Format: zzyyxxFD
+ * zz - Signed difference of z position between the selected and this vehicle.
+ * yy - Signed difference of y position between the selected and this vehicle.
+ * xx - Signed difference of x position between the selected and this vehicle.
+ * F - Flags, bit 7 corresponds to VS_HIDDEN.
+ * D - Dir difference, like in 0x45.
+ */
+ if (!v->IsGroundVehicle()) return 0;
+
+ const Vehicle *u = v->Move((int8)parameter);
+ if (u == NULL) return 0;
+
+ /* Get direction difference. */
+ bool prev = (int8)parameter < 0;
+ uint32 ret = prev ? DirDifference(u->direction, v->direction) : DirDifference(v->direction, u->direction);
+ if (ret > DIRDIFF_REVERSE) ret |= 0x08;
+
+ if (u->vehstatus & VS_HIDDEN) ret |= 0x80;
+
+ /* Get position difference. */
+ ret |= ((prev ? u->x_pos - v->x_pos : v->x_pos - u->x_pos) & 0xFF) << 8;
+ ret |= ((prev ? u->y_pos - v->y_pos : v->y_pos - u->y_pos) & 0xFF) << 16;
+ ret |= ((prev ? u->z_pos - v->z_pos : v->z_pos - u->z_pos) & 0xFF) << 24;
+
+ return ret;
+ }
+
case 0xFE:
case 0xFF: {
uint16 modflags = 0;