diff options
author | frosch <frosch@openttd.org> | 2012-09-16 16:31:53 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2012-09-16 16:31:53 +0000 |
commit | 38f265c0838050f4ff42ff539bb00475ac5d4872 (patch) | |
tree | 55b0d425b8f007a9415496f87c99b1b2ec2fb8f0 /src/vehicle_base.h | |
parent | e37e2d92a62b4a66d6af0bc4da233a9f442a90c6 (diff) | |
download | openttd-38f265c0838050f4ff42ff539bb00475ac5d4872.tar.xz |
(svn r24528) -Fix: [NewGRF] RandomAction 84 should interpret register 100 as signed.
Diffstat (limited to 'src/vehicle_base.h')
-rw-r--r-- | src/vehicle_base.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/vehicle_base.h b/src/vehicle_base.h index 6c9ba195e..ab06695e2 100644 --- a/src/vehicle_base.h +++ b/src/vehicle_base.h @@ -534,6 +534,22 @@ public: } /** + * Get the vehicle at offset \a n of this vehicle chain. + * @param n Offset from the current vehicle. + * @return The new vehicle or NULL if the offset is out-of-bounds. + */ + inline const Vehicle *Move(int n) const + { + const Vehicle *v = this; + if (n < 0) { + for (int i = 0; i != n && v != NULL; i--) v = v->Previous(); + } else { + for (int i = 0; i != n && v != NULL; i++) v = v->Next(); + } + return v; + } + + /** * Get the first order of the vehicles order list. * @return first order of order list. */ |