mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-03 10:05:23 +01:00
fix: SonarQube findings of the buffer stops
- The notice of a finished hit is taken out of the contact with std::exchange before it goes to the scenery, so what the scenery does with it can't reach the one held in the contact. - The loops count whole steps (an int, the number of steps taken with ceil) instead of adding a floating step. - The local final of bufferstop::contact() is ending (final is a contextual keyword). Unit tests 1294/1294.
This commit is contained in:
@@ -15,6 +15,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "utilities/Globals.h"
|
||||
#include "utilities/Logs.h"
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <format>
|
||||
#include <string>
|
||||
|
||||
@@ -116,7 +117,8 @@ void physics::Vehicle::buffer_stop_contact(double const dt)
|
||||
auto would{bufferstop::outcome::none};
|
||||
auto vehiclecrush{0.0};
|
||||
input.dt = monitor_step;
|
||||
for (auto time = 0.0; time < monitor_time; time += monitor_step)
|
||||
auto const steps{static_cast<int>(std::ceil(monitor_time / monitor_step - 1e-9))};
|
||||
for (auto index{0}; index < steps; ++index)
|
||||
{
|
||||
auto const step{bufferstop::contact(installation.stop, state, input)};
|
||||
would = bufferstop::worse(would, step.result);
|
||||
|
||||
Reference in New Issue
Block a user