Changeset - r22865:bde693471fdc
[Not reviewed]
master
0 1 0
PeterN - 7 years ago 2018-05-19 21:05:51
peter@fuzzle.org
Fix: Tractive effort was slightly too high as per NewGRF spec. (#6785)
1 file changed with 2 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/ground_vehicle.cpp
Show inline comments
 
@@ -49,26 +49,26 @@ void GroundVehicle<T, Type>::PowerChange
 
	/* If air drag is set to zero (default), the resulting air drag coefficient is dependent on max speed. */
 
	if (air_drag_value == 0) {
 
		uint16 max_speed = v->GetDisplayMaxSpeed();
 
		/* Simplification of the method used in TTDPatch. It uses <= 10 to change more steadily from 128 to 196. */
 
		air_drag = (max_speed <= 10) ? 192 : max(2048 / max_speed, 1);
 
	} else {
 
		/* According to the specs, a value of 0x01 in the air drag property means "no air drag". */
 
		air_drag = (air_drag_value == 1) ? 0 : air_drag_value;
 
	}
 

	
 
	this->gcache.cached_air_drag = air_drag + 3 * air_drag * number_of_parts / 20;
 

	
 
	max_te *= 10000; // Tractive effort in (tonnes * 1000 * 10 =) N.
 
	max_te /= 256;   // Tractive effort is a [0-255] coefficient.
 
	max_te *= 9800; // Tractive effort in (tonnes * 1000 * 9.8 =) N.
 
	max_te /= 256;  // Tractive effort is a [0-255] coefficient.
 
	if (this->gcache.cached_power != total_power || this->gcache.cached_max_te != max_te) {
 
		/* Stop the vehicle if it has no power. */
 
		if (total_power == 0) this->vehstatus |= VS_STOPPED;
 

	
 
		this->gcache.cached_power = total_power;
 
		this->gcache.cached_max_te = max_te;
 
		SetWindowDirty(WC_VEHICLE_DETAILS, this->index);
 
		SetWindowWidgetDirty(WC_VEHICLE_VIEW, this->index, WID_VV_START_STOP);
 
	}
 

	
 
	this->gcache.cached_max_track_speed = max_track_speed;
 
}
0 comments (0 inline, 0 general)