18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-22 04:24:59 +01:00

fix: make the odometer test's scratch directory in the build directory for CI

Sonar (S5443) flags the shared temporary directory; the tests now use one
in their working directory. Also makes the scratch directory non-copyable
and spells out the optional checks Sonar asked about.
This commit is contained in:
jerrrrycho
2026-11-08 04:23:30 +01:00
parent 6dc42e976f
commit 1083f3cb5d
3 changed files with 8 additions and 5 deletions

View File

@@ -12323,7 +12323,7 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con
gauge.Load(Parser, DynamicObject);
// the counter shows the odometer of the vehicle, kept between the sessions (eu07/maszyna#72). its offset
// was the state it started each session with, now it is that only for a vehicle with no known state
if (auto const seed{odometer::counter_seed(gauge.offset(), gauge.scale())})
if (auto const seed{odometer::counter_seed(gauge.offset(), gauge.scale())}; seed.has_value())
mvControlled->Odometer.seed(*seed);
gauge.offset(0.f);
gauge.AssignDouble(&mvControlled->Odometer.km);

View File

@@ -153,9 +153,9 @@ double guessed_state(std::string const &Vehicle) {
reading starting_state(store const &States, std::string const &Vehicle, std::filesystem::path const &Vehicledirectory) {
reading result;
if (auto const saved{States.find(Vehicle)}) {
if (auto const saved{States.find(Vehicle)}; saved.has_value()) {
result.begin(*saved, origin::saved);
} else if (auto const legacy{legacy_state(Vehicledirectory, Vehicle)}) {
} else if (auto const legacy{legacy_state(Vehicledirectory, Vehicle)}; legacy.has_value()) {
result.begin(*legacy, origin::legacy);
} else {
result.begin(guessed_state(Vehicle), origin::guessed);