unorthodox-paradox / omsi_2_csb_ai_enhancements

AI enhancements for CSB vehicles
1 stars 0 forks source link

Prevent simultaneous triggering of both left and right indicator mode #71

Closed unorthodox-paradox closed 5 years ago

unorthodox-paradox commented 5 years ago

Symptoms

When pushing and holding pushed both the key mapped to blinker_left_set and blinker_right_set at the same time, all indicator lights, including dashboard ones, activate and remain activated until either key gets released. This is obviously wrong.

Identified causes and resolution progress

The problem lies with the fact that the triggers were not designed to be invoked simultaneously, since the actual cockpit lever cannot in reality be in two states at the same instant. What actually happens is that the two triggers sort of cancel each other out, causing repeated inversions of the lever's state (left → right), therefore resetting the indicator interval timer, in turn causing the actual lights to remain on in perpetuity, due to the timer never expiring.

Resolution should be straightforward: Just make these triggers mutually-exclusive. The trigger that happens to be invoked first should raise a flag, letting the other know it should not run until the first's key has been released (signaled by the corresponding _off counterpart lowering the flag). Also make sure to unset the flag when the AI takes over a previously user-controlled vehicle, to prevent any complications.

User-level workarounds

Don't use both triggers at once (duh!).