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/newgrf_engine.cpp | |
parent | e37e2d92a62b4a66d6af0bc4da233a9f442a90c6 (diff) | |
download | openttd-38f265c0838050f4ff42ff539bb00475ac5d4872.tar.xz |
(svn r24528) -Fix: [NewGRF] RandomAction 84 should interpret register 100 as signed.
Diffstat (limited to 'src/newgrf_engine.cpp')
-rw-r--r-- | src/newgrf_engine.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp index 219f2ae92..657adce3e 100644 --- a/src/newgrf_engine.cpp +++ b/src/newgrf_engine.cpp @@ -349,12 +349,19 @@ static inline const Vehicle *GRV(const ResolverObject *object) case VSG_SCOPE_PARENT: return object->u.vehicle.parent; case VSG_SCOPE_RELATIVE: { if (object->u.vehicle.self == NULL) return NULL; + + int32 count = GB(object->count, 0, 4); + if (count == 0) count = GetRegister(0x100); + const Vehicle *v = NULL; switch (GB(object->count, 6, 2)) { default: NOT_REACHED(); case 0x00: // count back (away from the engine), starting at this vehicle + v = object->u.vehicle.self; + break; case 0x01: // count forward (toward the engine), starting at this vehicle v = object->u.vehicle.self; + count = -count; break; case 0x02: // count back, starting at the engine v = object->u.vehicle.parent; @@ -372,10 +379,7 @@ static inline const Vehicle *GRV(const ResolverObject *object) break; } } - uint32 count = GB(object->count, 0, 4); - if (count == 0) count = GetRegister(0x100); - while (v != NULL && count-- != 0) v = (GB(object->count, 6, 2) == 0x01) ? v->Previous() : v->Next(); - return v; + return v->Move(count); } } } |