Changeset - r17247:abf58ea32236
[Not reviewed]
master
0 1 0
rubidium - 14 years ago 2011-02-06 16:45:27
rubidium@openttd.org
(svn r21997) -Fix [FS#4473]: when the difference between force and resistance is smaller than the mass(*4) there would be no acceleration anymore, even when at higher (or lower) speed the force and resistance balance out better
1 file changed with 10 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/ground_vehicle.cpp
Show inline comments
 
@@ -151,8 +151,16 @@ int GroundVehicle<T, Type>::GetAccelerat
 
	}
 

	
 
	if (mode == AS_ACCEL) {
 
		/* Divide by 4 to compensate for the wacky game scale. */
 
		return (force - resistance) / (mass * 4);
 
		/* Easy way out when there is no acceleration. */
 
		if (force == resistance) return 0;
 

	
 
		/* When we accelerate, make sure we always keep doing that, even when
 
		 * the excess force is more than the mass. Otherwise a vehicle going
 
		 * down hill will never slow down enough, and a vehicle that came up
 
		 * a hill will never speed up enough to (eventually) get back to the
 
		 * same (maximum) speed. */
 
		int accel = (force - resistance) / (mass * 4);
 
		return force < resistance ? min(-1, accel) : max(1, accel);
 
	} else {
 
		return min(-force - resistance, -10000) / mass;
 
	}
0 comments (0 inline, 0 general)