18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-02 15:26:53 +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
+14 -14
View File
@@ -124,7 +124,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const /*Parameter*/) {
return occupied->AutomaticCabActivation || (occupied->CabMaster == false && occupied->CabActive == 0); } );
return occupied->AutomaticCabActivation || (occupied->CabMaster() == false && occupied->CabActive == 0); } );
break;
}
// radio
@@ -560,7 +560,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
Action,
[this](float const /*Parameter*/) {
return mvControlling->EIMDirectionChangeAllow(); },
static_cast<float>(mvControlling->MainCtrlMaxDirChangePos) );
static_cast<float>(mvControlling->MainCtrlMaxDirChangePos()) );
break;
}
case driver_hint::tractiveforcedecrease: {
@@ -571,12 +571,12 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) {
return std::abs(mvControlling->Ft) <= Parameter; },
return std::abs(mvControlling->Ft()) <= Parameter; },
static_cast<float>(std::min(
0.0,
std::max(
std::abs( mvControlling->Ft ) * 0.95,
std::abs( mvControlling->Ft ) - 5.0 ) )) );
std::abs( mvControlling->Ft() ) * 0.95,
std::abs( mvControlling->Ft() ) - 5.0 ) )) );
break;
}
case driver_hint::tractiveforceincrease: {
@@ -598,14 +598,14 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::bufferscompress: {
if (aiControlled && std::abs( mvControlling->Ft ) < 50000.0) {
if (aiControlled && std::abs( mvControlling->Ft() ) < 50000.0) {
IncSpeed();
}
remove_master_controller_hints();
hint(
Action,
[this](float const /*Parameter*/) {
return std::abs(mvControlling->Ft) > 30.0 || false == OrderCurrentGet().HasAny(DriverOrder::disconnect); } );
return std::abs(mvControlling->Ft()) > 30.0 || false == OrderCurrentGet().HasAny(DriverOrder::disconnect); } );
break;
}
@@ -725,7 +725,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const /*Parameter*/) {
return mvControlling->diesel.heat.auxiliary_water_circuit == false || mvControlling->WaterCircuitsLink == true; } );
return mvControlling->diesel.heat.auxiliary_water_circuit == false || mvControlling->WaterCircuitsLink() == true; } );
break;
}
case driver_hint::watercircuitslinkoff: {
@@ -736,7 +736,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const /*Parameter*/) {
return mvControlling->diesel.heat.auxiliary_water_circuit == false || mvControlling->WaterCircuitsLink == false; } );
return mvControlling->diesel.heat.auxiliary_water_circuit == false || mvControlling->WaterCircuitsLink() == false; } );
break;
}
case driver_hint::waittemperaturetoolow: {
@@ -901,7 +901,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
case driver_hint::independentbrakeapply: {
if (aiControlled && occupied->brakes.IndependentPosition() < 1.0) {
occupied->IncLocalBrakeLevel( LocalBrakePosNo );
if (occupied->EIMCtrlEmergency) {
if (occupied->EIMCtrlEmergency()) {
occupied->DecLocalBrakeLevel(1);
}
}
@@ -910,7 +910,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
Action,
[this](float const Parameter) {
return occupied->brakes.IndependentPosition() >= Parameter; },
( LocalBrakePosNo - ( occupied->EIMCtrlEmergency ? 1 : 0 ) ) / LocalBrakePosNo );
( LocalBrakePosNo - ( occupied->EIMCtrlEmergency() ? 1 : 0 ) ) / LocalBrakePosNo );
break;
}
case driver_hint::independentbrakerelease: {
@@ -980,7 +980,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const /*Parameter*/) {
return mvControlling->Sand == 0 || mvControlling->SandDose == true || mvControlling->SlippingWheels == false; } );
return mvControlling->Sand == 0 || mvControlling->SandDose() == true || mvControlling->SlippingWheels() == false; } );
break;
}
case driver_hint::sandingoff: {
@@ -991,7 +991,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const /*Parameter*/) {
return mvControlling->Sand == 0 || mvControlling->SandDose == false; } );
return mvControlling->Sand == 0 || mvControlling->SandDose() == false; } );
break;
}
case driver_hint::antislip: {
@@ -1001,7 +1001,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const /*Parameter*/) {
return mvControlling->brakes.config.antiSlipType != 1 || (mvControlling->brakes.distributor->GetBrakeStatus() & b_asb) != 0 || mvControlling->SlippingWheels == false; } );
return mvControlling->brakes.config.antiSlipType != 1 || (mvControlling->brakes.distributor->GetBrakeStatus() & b_asb) != 0 || mvControlling->SlippingWheels() == false; } );
break;
}
// horns