18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-01 07:07:05 +01:00

refactor(physics): what the rest of the simulator only reads of a vehicle is private to it

53 fields of physics::Vehicle that only the vehicle itself writes, and the rest
of the simulator reads, are private, with a query each, named as the field was
(Vmax(), TotalMass(), Ft(), nrot(), NAxles(), PhysicActivation(), ...): the
compiler now keeps the cab, the AI, the scenery, the renderer and the tests from
changing what the definition gives or the physics works out. The fields were
picked by what is never written outside the class, of plain types, with no
other member of the same name to confuse; inside the class they keep their
meaning under camelCase names. The one place outside that cleared a flag of
the AI through a reference does it through ClearAIFlag().

No change in behaviour: the golden traces recorded on dfb43c4f match bit for bit.
This commit is contained in:
2026-11-29 13:17:56 +01:00
parent 74f0aa240d
commit 5879c228dc
88 changed files with 1053 additions and 992 deletions
+3 -3
View File
@@ -63,7 +63,7 @@ mouse_slider::bind( user_command const &Command ) {
auto const powerrange { static_cast<double>(
vehicle->CoupledCtrl ?
vehicle->MainCtrlPosNo + vehicle->ScndCtrlPosNo :
vehicle->MainCtrlPosNo + vehicle->ScndCtrlPosNo() :
vehicle->MainCtrlPosNo ) };
// for simplicity upper half of the range controls power, lower controls brakes
@@ -79,14 +79,14 @@ mouse_slider::bind( user_command const &Command ) {
break;
}
case user_command::mastercontrollerset: {
m_valuerange = vehicle->CoupledCtrl ? vehicle->MainCtrlPosNo + vehicle->ScndCtrlPosNo : vehicle->MainCtrlPosNo;
m_valuerange = vehicle->CoupledCtrl ? vehicle->MainCtrlPosNo + vehicle->ScndCtrlPosNo() : vehicle->MainCtrlPosNo;
m_value = vehicle->CoupledCtrl ? vehicle->MainCtrlPos() + vehicle->ScndCtrlPos() : vehicle->MainCtrlPos();
m_analogue = false;
m_invertrange = false;
break;
}
case user_command::secondcontrollerset: {
m_valuerange = vehicle->ScndCtrlPosNo;
m_valuerange = vehicle->ScndCtrlPosNo();
m_value = vehicle->ScndCtrlPos();
m_analogue = false;
m_invertrange = true;