From 25c7e5de10fcb8ea7716f3558db056b286495372 Mon Sep 17 00:00:00 2001 From: frosch Date: Sun, 17 Jul 2022 23:06:53 +0200 Subject: [PATCH] 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. --- src/ground_vehicle.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ground_vehicle.cpp b/src/ground_vehicle.cpp index f6e44c2e29..a29a220aaf 100644 --- a/src/ground_vehicle.cpp +++ b/src/ground_vehicle.cpp @@ -56,12 +56,14 @@ void GroundVehicle::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);