mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-02 07:22:42 +01:00
refactor(physics): the controllers and the switches of the cab are private to the vehicle
The positions of the master and the secondary controller, of the analog
controller and of the lights selector, the occupied cab, the horns, the radio
and its fuse, the radio-stop, the wipers' switch, the dimmer, the mirrors'
button, the end-of-train signalling and the forced resistor fans: fourteen
fields the cab, the AI, the scenery and the tests wrote straight into
physics::Vehicle are private now. The rest of the simulator reads them through
queries named as the fields were (MainCtrlPos(), Radio(), ...) and changes them
through operations (SetMainCtrlPos(), SetRadio(), ...), so every place that
moves a controller past its own stepping (IncMainCtrl()) is named and can be
found; the compiler keeps anything else out. Inside the vehicle they keep
their meaning under camelCase names. The queries return const references, as
the gauges of the cab bind to them.
The .fiz keys are untouched.
No change in behaviour: the golden traces recorded on dfb43c4f match bit for bit.
This commit is contained in:
+16
-16
@@ -130,23 +130,23 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
// radio
|
||||
case driver_hint::radioon: {
|
||||
if( AIControllFlag ) {
|
||||
occupied->Radio = true;
|
||||
occupied->SetRadio(true);
|
||||
}
|
||||
remove_hint( driver_hint::radiooff );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const /*Parameter*/) {
|
||||
return occupied->Radio == true; } );
|
||||
return occupied->Radio() == true; } );
|
||||
break;
|
||||
}
|
||||
case driver_hint::radiofuseon: {
|
||||
if( AIControllFlag ) {
|
||||
occupied->RadioFuse = true;
|
||||
occupied->SetRadioFuse(true);
|
||||
}
|
||||
hint(
|
||||
Action,
|
||||
[this](float const /*Parameter*/) {
|
||||
return occupied->RadioFuse == true; } );
|
||||
return occupied->RadioFuse() == true; } );
|
||||
break;
|
||||
}
|
||||
case driver_hint::radiochannel: {
|
||||
@@ -162,13 +162,13 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
}
|
||||
case driver_hint::radiooff: {
|
||||
if( AIControllFlag ) {
|
||||
occupied->Radio = false;
|
||||
occupied->SetRadio(false);
|
||||
}
|
||||
remove_hint( driver_hint::radioon );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const /*Parameter*/) {
|
||||
return occupied->Radio == false; } );
|
||||
return occupied->Radio() == false; } );
|
||||
break;
|
||||
}
|
||||
// oil pump
|
||||
@@ -507,7 +507,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
// master controller
|
||||
case driver_hint::mastercontrollersetidle: {
|
||||
if( AIControllFlag ) {
|
||||
while( mvControlling->RList[mvControlling->MainCtrlPos].Mn == 0
|
||||
while( mvControlling->RList[mvControlling->MainCtrlPos()].Mn == 0
|
||||
&& mvControlling->IncMainCtrl(1) ) {
|
||||
// all work is done in the loop header
|
||||
}
|
||||
@@ -516,16 +516,16 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
hint(
|
||||
Action,
|
||||
[this]( float const /*Parameter*/ ) {
|
||||
return mvControlling->RList[mvControlling->MainCtrlPos].Mn > 0; } );
|
||||
return mvControlling->RList[mvControlling->MainCtrlPos()].Mn > 0; } );
|
||||
break;
|
||||
}
|
||||
case driver_hint::mastercontrollersetseriesmode: {
|
||||
if (AIControllFlag && mvControlling->RList[ mvControlling->MainCtrlPos ].Bn > 1) {
|
||||
if (AIControllFlag && mvControlling->RList[ mvControlling->MainCtrlPos() ].Bn > 1) {
|
||||
// limit yourself to series mode
|
||||
if( mvControlling->ScndCtrlPos ) {
|
||||
if( mvControlling->ScndCtrlPos() ) {
|
||||
mvControlling->DecScndCtrl( 2 );
|
||||
}
|
||||
while( mvControlling->RList[mvControlling->MainCtrlPos].Bn > 1
|
||||
while( mvControlling->RList[mvControlling->MainCtrlPos()].Bn > 1
|
||||
&& mvControlling->DecMainCtrl(1) ) {
|
||||
// all work is performed in the header
|
||||
}
|
||||
@@ -534,7 +534,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
hint(
|
||||
Action,
|
||||
[this]( float const /*Parameter*/ ) {
|
||||
return mvControlling->RList[mvControlling->MainCtrlPos].Bn < 2; } );
|
||||
return mvControlling->RList[mvControlling->MainCtrlPos()].Bn < 2; } );
|
||||
break;
|
||||
}
|
||||
case driver_hint::mastercontrollersetzerospeed: {
|
||||
@@ -1007,19 +1007,19 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
// horns
|
||||
case driver_hint::hornon: {
|
||||
if( AIControllFlag ) {
|
||||
occupied->WarningSignal = static_cast<int>( Actionparameter );
|
||||
occupied->SetWarningSignal(static_cast<int>( Actionparameter ));
|
||||
}
|
||||
remove_hint( driver_hint::hornoff );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const /*Parameter*/) {
|
||||
// NOTE: we provide slightly larger horn activation window for human driver
|
||||
return fWarningDuration + 5.0 < 0.05 || occupied->WarningSignal != 0; } );
|
||||
return fWarningDuration + 5.0 < 0.05 || occupied->WarningSignal() != 0; } );
|
||||
break;
|
||||
}
|
||||
case driver_hint::hornoff: {
|
||||
if( AIControllFlag ) {
|
||||
occupied->WarningSignal = 0;
|
||||
occupied->SetWarningSignal(0);
|
||||
}
|
||||
/*
|
||||
// NOTE: for human driver the hint to switch horn on will disappear automatically
|
||||
@@ -1027,7 +1027,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
return ( occupied->WarningSignal == 0 ); } );
|
||||
return ( occupied->WarningSignal() == 0 ); } );
|
||||
*/
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user