mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-27 21:45:16 +01:00
* refactor(cab): the cab's state of the line breaker is an enum class TTrain::m_linebreakerstate kept 0, 1 and 2 for open, closed and closing (the closing control held long enough). It is linebreaker::state now, which linebreaker::pressed() takes too; every comparison and assignment names the state. Nothing writes the state out: it isn't in the Python dictionary of the cab, the black box, the physics log or the network. No change in behaviour (eu07/maszyna#148). * refactor(physics): fcfuH takes fcfu without writing it out and reading it back A definition of an induction motor drive without fcfuH gave the dynamic brake fcfu through text: std::to_string() of the value as the default of extract_value(). The loader assigns it now. For any figure of up to six decimals the value is the same to the bit (the test compares both ways over more than 70000 figures, and through the loader); the game's definitions have one or two. Only a figure of more than six decimals, which the text rounded to six, or one past the largest value, which read back as 0 from "inf", gives another; the test pins both (eu07/maszyna#99).
27 lines
650 B
C++
27 lines
650 B
C++
/*
|
|
This Source Code Form is subject to the
|
|
terms of the Mozilla Public License, v.
|
|
2.0. If a copy of the MPL was not
|
|
distributed with this file, You can
|
|
obtain one at
|
|
http://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
#include "stdafx.h"
|
|
#include "vehicle/linebreaker.h"
|
|
|
|
namespace linebreaker {
|
|
|
|
toggle pressed(state const Breakerstate, bool const Latchinglever, bool const Leveron) {
|
|
if (Breakerstate == state::closed) {
|
|
return toggle::open;
|
|
}
|
|
if (Breakerstate != state::open) {
|
|
return toggle::none;
|
|
}
|
|
// the line breaker is open; a lever left on goes off first
|
|
return Latchinglever && Leveron ? toggle::open : toggle::close;
|
|
}
|
|
|
|
} // namespace linebreaker
|