mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-09 11:22:25 +01:00
AI braking: move the uphill power-off check into its own function
The condition added for holding the speed uphill near a stop pushed the cognitive complexity of control_tractive_force() to 26, over the 25 SonarCloud allows. It now lives in is_too_fast_uphill(); the behaviour is unchanged.
This commit is contained in:
@@ -8110,11 +8110,7 @@ void TController::control_tractive_force() {
|
||||
cue_action( driver_hint::mastercontrollersetzerospeed );
|
||||
}
|
||||
else if( velocity > VelDesired + SpeedCtrlMargin
|
||||
|| ( fAccGravity < -0.01 ?
|
||||
AccDesired < 0.0
|
||||
// holding the speed uphill on the way to a stop asks for no speeding up
|
||||
|| ( VelNext == 0.0 && ActualProximityDist <= fMaxProximityDist && AbsAccS > AccDesired + 0.05 ) :
|
||||
AbsAccS > AccDesired + 10.05 )
|
||||
|| ( fAccGravity < -0.01 ? is_too_fast_uphill() : AbsAccS > AccDesired + 10.05 )
|
||||
|| IsAnyCouplerStretched ) {
|
||||
// jak za bardzo przyspiesza albo prędkość przekroczona
|
||||
// dodany wyjatek na "pelna w przod"
|
||||
@@ -8126,6 +8122,13 @@ void TController::control_tractive_force() {
|
||||
SpeedSet(); // ciągla regulacja prędkości
|
||||
}
|
||||
|
||||
bool TController::is_too_fast_uphill() const {
|
||||
|
||||
if( AccDesired < 0.0 ) { return true; }
|
||||
// holding the speed uphill on the way to a stop asks for no speeding up
|
||||
return ( VelNext == 0.0 && ActualProximityDist <= fMaxProximityDist && AbsAccS > AccDesired + 0.05 );
|
||||
}
|
||||
|
||||
void TController::increase_tractive_force() {
|
||||
|
||||
if( fActionTime < 0.0 ) { return; } // gdy jest nakaz poczekać z jazdą, to nie ruszać
|
||||
|
||||
@@ -358,6 +358,7 @@ private:
|
||||
void control_motor_connectors();
|
||||
void control_tractive_force();
|
||||
void increase_tractive_force();
|
||||
bool is_too_fast_uphill() const;
|
||||
void control_braking_force();
|
||||
// how far short of a stop the AI aims: in train running the middle of the 8-15 m window before a signal,
|
||||
// otherwise (a W4 stop point, shunting, coupling) half the minimum proximity distance, as before
|
||||
|
||||
Reference in New Issue
Block a user