From dc7bd0efe6e5dd9d14695f047dbb709d47b31828 Mon Sep 17 00:00:00 2001 From: Hirek193 Date: Sun, 29 Nov 2026 08:36:15 +0100 Subject: [PATCH] fix(vehicle): the headlight dimmer by the active cab, the pantograph by its end SetLightDimmings(), which the dimmer commands of the cab and the AI's hints call, picked the headlights to put out by iDirection, while RaLightsSet() picks them by the active cab (CabEnd(CabActive)) since the mover became physics::Vehicle. From cab -1 with iDirection > 0 the dimmer put out A and RaLightsSet() B, so both ends went dark. Both now use the end of the active cab: cab 1 the A headlights, cab -1 the B ones, and none without an active cab. This changes behaviour against staging, where RaLightsSet() compared CabActive with the end numbers (0 put out A, 1 put out B, -1 nothing) and SetLightDimmings() went by iDirection. updatePantographMotion() read pantographs[i] by the animation index, past the two ends for a model with more than two pantograph animations (an old fault, staging DynObj.cpp). It reads pantographs[PantographEnd(i)] now, as the voltage and the count of raised pantographs already do. --- vehicle/dynamic/lights.cpp | 27 ++++++--------------------- vehicle/dynamic/update.cpp | 2 +- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/vehicle/dynamic/lights.cpp b/vehicle/dynamic/lights.cpp index 11ea04fc8..663469aa9 100644 --- a/vehicle/dynamic/lights.cpp +++ b/vehicle/dynamic/lights.cpp @@ -162,7 +162,6 @@ void TDynamicObject::RaLightsSet(int head, int rear) void TDynamicObject::SetLightDimmings() { - auto const vehicleend{iDirection > 0 ? VehicleEnd::front : VehicleEnd::rear}; if (Controller == Humandriver) { @@ -172,36 +171,22 @@ void TDynamicObject::SetLightDimmings() HighBeamLights = false; DimHeadlights = false; - // obsługa OFF + // obsługa OFF: the headlights at the end of the active cab, as RaLightsSet() picks them: A at the front, B at the + // rear, none without an active cab if (dps.isOff) { - // physics->iLights[vehicleend] &= 0 | light::rearendsignals; // zostawiamy tylko tabliczki jesli sa HighBeamLights = false; DimHeadlights = false; - switch (vehicleend) + if (auto const cabend{CabEnd(physics->CabActive)}; cabend.has_value()) { - case VehicleEnd::front: - HeadlightsAoff = true; - break; - case VehicleEnd::rear: - HeadlightsBoff = true; - break; - default: - break; + (*cabend == VehicleEnd::front ? HeadlightsAoff : HeadlightsBoff) = true; } } else { - switch (vehicleend) + if (auto const cabend{CabEnd(physics->CabActive)}; cabend.has_value()) { - case VehicleEnd::front: - HeadlightsAoff = false; - break; - case VehicleEnd::rear: - HeadlightsBoff = false; - break; - default: - break; + (*cabend == VehicleEnd::front ? HeadlightsAoff : HeadlightsBoff) = false; } } diff --git a/vehicle/dynamic/update.cpp b/vehicle/dynamic/update.cpp index 6d41fb379..4c70f7979 100644 --- a/vehicle/dynamic/update.cpp +++ b/vehicle/dynamic/update.cpp @@ -1186,7 +1186,7 @@ void TDynamicObject::updatePantographMotion( int const i, TAnimPant *p, double c pantspeedfactor = std::max( 0.0, pantspeedfactor ); k = p->fAngleL; if( pantspeedfactor > 0.0 - && physics->pantographs[i].is_active )// jeśli ma być podniesiony + && physics->pantographs[PantographEnd( i )].is_active )// jeśli ma być podniesiony { if (PantDiff > 0.001) // jeśli nie dolega do drutu { // jeśli poprzednia wysokość jest mniejsza niż pożądana, zwiększyć kąt dolnego