18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-20 18:35:00 +01:00

fix: the inspector takes a train below 1 km/h for standing and a bank run for a train (review of #282)

The AI inspects the train while it still creeps to a stop (W4, Shunt to Obey_train) and as it couples, so the 0.05 km/h threshold missed the §19.9 cut-out; it now uses EU07_AI_MOVEMENT. Bank counts as a train, as in the braking tables.
This commit is contained in:
jerrrrycho
2026-11-08 21:38:16 +01:00
parent 276b36d85f
commit 64d1b7f847
4 changed files with 77 additions and 10 deletions

View File

@@ -12,8 +12,10 @@ http://mozilla.org/MPL/2.0/.
#include "McZapkie/MOVER.h"
#include "McZapkie/hamulce.h"
#include "vehicle/Driver.h"
#include <algorithm>
#include <cmath>
namespace brake_setting {
@@ -156,8 +158,8 @@ std::vector<int> choose(std::vector<vehicle> const &Consist, bool const Train) {
}
else if (item.powered || item.driven || item.delays == 0 || false == Train) {
// a locomotive, or the vehicle the train is driven from, keeps a working brake: on P. a vehicle
// which tells no settings at all is left alone. a consist being shunted isn't a train and §19.9
// doesn't apply to it: its wagons keep their brakes, on P
// which tells no settings at all is left alone. a consist being shunted isn't a train (a bank
// engine's run is) and §19.9 doesn't apply to it: its wagons keep their brakes, on P
settings.emplace_back(pick(item.delays, bdelay_P, bdelay_P));
}
else {
@@ -171,6 +173,14 @@ std::vector<int> choose(std::vector<vehicle> const &Consist, bool const Train) {
return settings;
}
bool runs_as_train(int const Orders) {
return (Orders & (Obey_train | Bank)) != 0;
}
bool at_standstill(double const Velocity) {
return std::abs(Velocity) < EU07_AI_MOVEMENT;
}
std::vector<int> choose_legacy(std::vector<vehicle> const &Consist) {
wagon_counts const counts{Consist};
auto length{0.0};