summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-05-06 20:05:10 +0000
committerrubidium <rubidium@openttd.org>2007-05-06 20:05:10 +0000
commitb46e37774d9a3995164351d3f05d815ef0748f26 (patch)
tree1148b6278ecb74f946ee13a44b5d210eb66c0076 /src
parentfeadd868197ed53e7185630ed97f92b68f75f819 (diff)
downloadopenttd-b46e37774d9a3995164351d3f05d815ef0748f26.tar.xz
(svn r9803) -Feature(tte): support for "curvature info", Action 2 for train, variable 45 (mart3p).
Diffstat (limited to 'src')
-rw-r--r--src/newgrf_engine.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp
index e1b24de2e..4e72919cb 100644
--- a/src/newgrf_engine.cpp
+++ b/src/newgrf_engine.cpp
@@ -589,6 +589,25 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
return (altitude << 8) | airporttype;
}
+ case 0x45: { // Curvature info
+ /* Format: xxxTxBxF
+ * F - previous wagon to current wagon, 0 if vehicle is first
+ * B - current wagon to next wagon, 0 if wagon is last
+ * T - previous wagon to next wagon, 0 in an S-bend
+ */
+ if (v->type != VEH_TRAIN) return 0;
+
+ const Vehicle *u_p = GetPrevVehicleInChain(v);
+ const Vehicle *u_n = v->next;
+ DirDiff f = (u_p == NULL) ? DIRDIFF_SAME : DirDifference(u_p->direction, v->direction);
+ DirDiff b = (u_n == NULL) ? DIRDIFF_SAME : DirDifference(v->direction, u_n->direction);
+ DirDiff t = ChangeDirDiff(f, b);
+
+ return ((t > DIRDIFF_REVERSE ? t | 8 : t) << 16) |
+ ((b > DIRDIFF_REVERSE ? b | 8 : b) << 8) |
+ ( f > DIRDIFF_REVERSE ? f | 8 : f);
+ }
+
case 0x46: // Motion counter
return v->motion_counter;