diff options
author | michi_cc <michi_cc@openttd.org> | 2011-10-04 21:35:29 +0000 |
---|---|---|
committer | michi_cc <michi_cc@openttd.org> | 2011-10-04 21:35:29 +0000 |
commit | 3cb1dcf31cc9c01b0c6e6f4b65808a580d2bc9bd (patch) | |
tree | ebb58ecdef70d61756cfa251b6889b4878893fd7 /src/vehicle_base.h | |
parent | 655cee276c7bdd2aafe37369896b9350fc769bd4 (diff) | |
download | openttd-3cb1dcf31cc9c01b0c6e6f4b65808a580d2bc9bd.tar.xz |
(svn r22997) -Feature: [NewGRF] Allow access to other vehicles in the vehicle chain in VarAction 2.
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 958144115..5fc2500eb 100644 --- a/src/vehicle_base.h +++ b/src/vehicle_base.h @@ -499,6 +499,22 @@ public: } /** + * Get the vehicle at offset #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 Vehicle *Move(int n) + { + 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. */ |