mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-20 10:24:58 +01:00
refactor(simulation): fix the Sonar remarks on the test mode code
- TController::TableCheck() calls TSpeedPos::Update() as it did before the test mode: the check for a signal passed at danger is a call of its own after it (CheckSignalPassedAtDanger), so the update lines nest no deeper than on master (S134). A switch is a track, so a signal's update never takes the switch-change branch and the check runs in the same place as before; the physicslogs of all 15 scenario cases are byte for byte the same. - null_imgui_renderer is final (S1235), to_string(test_result) uses `using enum` (S6177), init_result_cell() is const (S5817), ConfigParseTest() takes a std::string_view (S6009) and the test settings struct is declared apart from its member (S3646).
This commit is contained in:
@@ -768,7 +768,8 @@ void TController::TableCheck(double fDistance)
|
||||
{ // aktualizacja rekordów z wyjątkiem ostatniego
|
||||
if (sSpeedTable[i].iFlags & spEnabled) // jeśli pozycja istotna
|
||||
{
|
||||
if (UpdateSpeedPosition(sSpeedTable[i]))
|
||||
auto const passedbefore { TestFlag( sSpeedTable[ i ].iFlags, spElapsed ) };
|
||||
if (sSpeedTable[i].Update())
|
||||
{
|
||||
if( Global.iWriteLogEnabled & 8 ) {
|
||||
WriteLog( "Speed table for " + OwnerName() + " detected switch change at " + sSpeedTable[ i ].trTrack->name() + " (generating fresh trace)" );
|
||||
@@ -794,6 +795,8 @@ void TController::TableCheck(double fDistance)
|
||||
// nie kontynuujemy pętli, trzeba doskanować ciąg dalszy
|
||||
break;
|
||||
}
|
||||
// a switch is a track, the update of a signal never ends the loop above
|
||||
CheckSignalPassedAtDanger( sSpeedTable[ i ], passedbefore );
|
||||
if (sSpeedTable[i].iFlags & spTrack) // jeśli odcinek
|
||||
{
|
||||
if( sSpeedTable[ i ].fDist + sSpeedTable[ i ].trTrack->Length() < -fLength ) // a skład wyjechał całą długością poza
|
||||
@@ -817,8 +820,10 @@ void TController::TableCheck(double fDistance)
|
||||
}
|
||||
}
|
||||
}
|
||||
// aktualizacja ostatniego; a signal at stop often is the last, the scan doesn't go past it
|
||||
UpdateSpeedPosition(sSpeedTable[iLast]);
|
||||
auto const lastpassedbefore { TestFlag( sSpeedTable[ iLast ].iFlags, spElapsed ) };
|
||||
sSpeedTable[iLast].Update(); // aktualizacja ostatniego
|
||||
// a signal at stop often is the last, the scan doesn't go past it
|
||||
CheckSignalPassedAtDanger( sSpeedTable[ iLast ], lastpassedbefore );
|
||||
// WriteLog("TableCheck: Upate last track. Dist=" + AnsiString(sSpeedTable[iLast].fDist));
|
||||
if( sSpeedTable[ iLast ].fDist < fDistance ) {
|
||||
TableTraceRoute( fDistance, pVehicles[ end::rear ] ); // doskanowanie dalszego odcinka
|
||||
@@ -843,17 +848,14 @@ bool is_signal_at_stop( TSpeedPos const &Point )
|
||||
|
||||
} // namespace
|
||||
|
||||
bool TController::UpdateSpeedPosition( TSpeedPos &Point ) const
|
||||
void TController::CheckSignalPassedAtDanger( TSpeedPos const &Point, bool const Passedbefore ) const
|
||||
{
|
||||
auto const passedbefore { TestFlag( Point.iFlags, spElapsed ) };
|
||||
auto const switchchanged { Point.Update() };
|
||||
if( false == passedbefore
|
||||
if( false == Passedbefore
|
||||
&& TestFlag( Point.iFlags, spElapsed )
|
||||
&& is_signal_at_stop( Point )
|
||||
&& ( mvOccupied->CategoryFlag & 1 ) != 0 ) { // railway only
|
||||
simulation::test().signal_passed_at_danger( OwnerName(), Point.evEvent->m_name );
|
||||
}
|
||||
return switchchanged;
|
||||
}
|
||||
|
||||
auto const passengerstopmaxdistance { 400.0 }; // maximum allowed distance between passenger stop point and consist head
|
||||
|
||||
Reference in New Issue
Block a user