Changeset - r19597:c168704d50ac
[Not reviewed]
master
0 2 0
frosch - 12 years ago 2012-09-16 16:31:53
frosch@openttd.org
(svn r24528) -Fix: [NewGRF] RandomAction 84 should interpret register 100 as signed.
2 files changed with 24 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/newgrf_engine.cpp
Show inline comments
 
@@ -349,12 +349,19 @@ static inline const Vehicle *GRV(const R
 
		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 R
 
					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);
 
		}
 
	}
 
}
src/vehicle_base.h
Show inline comments
 
@@ -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.
 
	 */
0 comments (0 inline, 0 general)