18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-20 16:14:58 +01:00

fix: a latching line breaker lever goes off with the breaker knocked out (#277)

The EP05's single two-state line breaker lever stayed on once the converter
overload relay knocked the breaker out: every press of the toggle tried to
close the open breaker, which the tripped relay refused. A press now puts
a lever left on over an open breaker off first.

(eu07/maszyna#394)
This commit is contained in:
jerrrrycho
2026-11-08 14:48:04 +01:00
committed by GitHub
parent 3487e75f9a
commit 5f46aca43a
5 changed files with 181 additions and 5 deletions

View File

@@ -15,6 +15,7 @@ http://mozilla.org/MPL/2.0/.
#include "stdafx.h"
#include "vehicle/Train.h"
#include "vehicle/horn.h"
#include "vehicle/linebreaker.h"
#include "utilities/Globals.h"
#include "simulation/simulation.h"
@@ -3652,16 +3653,22 @@ void TTrain::OnCommand_linebreakertoggle(TTrain *Train, command_data const &Comm
if (Command.action == GLFW_PRESS)
{
// press or hold...
if (Train->m_linebreakerstate == 0)
// a single two-state lever stays where it was put, also when the line breaker gets knocked out
auto const latchinglever{Train->ggMainOnButton.SubModel == nullptr && Train->ggMainOffButton.SubModel == nullptr && Train->ggMainButton.SubModel != nullptr &&
Train->ggMainButton.type() == TGaugeType::toggle};
switch (linebreaker::pressed(Train->m_linebreakerstate, latchinglever, Train->ggMainButton.GetDesiredValue() > 0.5))
{
case linebreaker::toggle::close:
// ...to close the circuit
// NOTE: bit of a dirty shortcut here
OnCommand_linebreakerclose(Train, Command);
}
else if (Train->m_linebreakerstate == 1)
{
// ...to open the circuit
break;
case linebreaker::toggle::open:
// ...to open the circuit, or to put the lever off if the circuit was already opened
OnCommand_linebreakeropen(Train, Command);
break;
default:
break;
}
}
else if (Command.action == GLFW_RELEASE)