1
0
Fork 0

Change: If a train gets stranded on unpowered tracks, provide some minimum power to resolve the deadlock.

This is meant in particular for trains with multiple engines, which are powered on different track types.
If the train traversed from one track type to another, the first engine may lose power before the second engine gains it.
The train needs some momentum/minimum-speed to cross this power gap.
pull/9953/head
frosch 2022-07-17 23:06:53 +02:00
parent 81115d271d
commit 25c7e5de10
1 changed files with 5 additions and 3 deletions

View File

@ -56,12 +56,14 @@ void GroundVehicle<T, Type>::PowerChanged()
this->gcache.cached_air_drag = air_drag + 3 * air_drag * number_of_parts / 20;
if (total_power == 0) {
/* Ensure that vehicles are never completely stuck */
total_power = 1;
}
max_te *= GROUND_ACCELERATION; // 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);