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

fix: the inspector cuts brakes out only in a train at a standstill, R+Mg keeps the rapid stage (review of #282)

- §19.9 cut-outs only when the AI runs the consist as a train (Obey_train); in shunting a wagon without G brakes on P,
  which also puts back a brake the inspector cut out before
- no new cut-out while the consist moves: left to the next inspection at a standstill (putting back still happens)
- ESt4R, LSt and EStED test the bit of R, so R+Mg keeps the high-speed stage of R as on the KE and Oerlikon valves
This commit is contained in:
jerrrrycho
2026-11-08 18:03:13 +01:00
parent 81f10e4d90
commit 7db67c3ce7
5 changed files with 148 additions and 39 deletions

View File

@@ -2086,8 +2086,12 @@ void TController::AutoRewident()
for (auto const *d = pVehicles[0]; d != nullptr; d = d->Next()) {
consist.emplace_back(brake_setting::describe(*d->MoverParameters, d == pVehicle));
}
// 2. Określenie typu pociągu i nastaw: by the brake instruction Cw-1 (eu07/maszyna#350), or as the releases before it did
auto const settings{Global.AIBrakeSettingCw1 ? brake_setting::choose(consist) : brake_setting::choose_legacy(consist)};
// 2. Określenie typu pociągu i nastaw: by the brake instruction Cw-1 (eu07/maszyna#350), or as the releases before it did.
// brakes are cut out (Cw-1 §19.9) only in a train, not in a consist being shunted
auto const train{(OrderCurrentGet() & Obey_train) != 0};
auto const settings{Global.AIBrakeSettingCw1 ? brake_setting::choose(consist, train) : brake_setting::choose_legacy(consist)};
// and only at a standstill: a check on the run (the order changed mid-run) leaves them to the next one
auto const standstill{false == (mvOccupied->Vel > EU07_AI_NOMOVEMENT)};
// a light engine counts as a passenger train for the braking below
auto const passengertrain{brake_setting::passenger(brake_setting::choose_train_setting(consist))};
// 3. Nastawianie
@@ -2098,7 +2102,7 @@ void TController::AutoRewident()
continue;
}
// the setting, a brake cut out in a train on G (Cw-1 §19.9) or put back when the train no longer needs it cut out
brake_setting::apply(*d->MoverParameters, *setting);
brake_setting::apply(*d->MoverParameters, *setting, standstill);
// potentially release manual brake
d->MoverParameters->DecManualBrakeLevel( ManualBrakePosNo );
d->MoverParameters->SpringBrake.Activate = false;

View File

@@ -115,7 +115,7 @@ train_setting choose_train_setting(std::vector<vehicle> const &Consist) {
return train_setting::freight_p;
}
std::vector<int> choose(std::vector<vehicle> const &Consist) {
std::vector<int> choose(std::vector<vehicle> const &Consist, bool const Train) {
auto const setting{choose_train_setting(Consist)};
std::vector<int> settings;
settings.reserve(Consist.size());
@@ -154,9 +154,10 @@ std::vector<int> choose(std::vector<vehicle> const &Consist) {
if (has(item.delays, bdelay_G)) {
settings.emplace_back(bdelay_G);
}
else if (item.powered || item.driven || item.delays == 0) {
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
// 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
settings.emplace_back(pick(item.delays, bdelay_P, bdelay_P));
}
else {
@@ -249,21 +250,22 @@ vehicle describe(TMoverParameters const &Vehicle, bool const Driven) {
return described;
}
void apply(TMoverParameters &Vehicle, int const Setting) {
void apply(TMoverParameters &Vehicle, int const Setting, bool const Standstill) {
auto &brake{*Vehicle.Hamulec};
if (Vehicle.BrakeCutOutByInspector && false == is_cut_out(Vehicle)) {
// someone put the brake back in the meantime, it's theirs now
Vehicle.BrakeCutOutByInspector = false;
}
if (Setting == cut_out) {
if (false == is_cut_out(Vehicle)) {
if (false == is_cut_out(Vehicle) && Standstill) {
// close the cut-out cock and empty the brake with the releaser, as the scenery's '0' does: the
// distributor, cut off the brake pipe, has no air left to brake with and lets the cylinders go
brake.ForceEmptiness();
brake.SetBrakeStatus(brake.GetBrakeStatus() | b_dmg);
Vehicle.BrakeCutOutByInspector = true;
}
// a brake cut out already, by the inspector or for a reason of its own, stays as it is
// a brake cut out already, by the inspector or for a reason of its own, stays as it is. on the run the
// vehicle is left alone, brake and setting, until the inspector looks at the train standing
return;
}
if (Vehicle.BrakeCutOutByInspector) {

View File

@@ -56,8 +56,10 @@ constexpr bool passenger(train_setting const Setting) {
// without the setting the train needs gets the other one of G and P it has, and 0 (left as it is)
// when it has neither. In a train on G (freight_g) a wagon without G gets cut_out instead: its brake
// is to be cut out (Cw-1 §19.9). A locomotive and the vehicle the train is driven from keep their
// brake working, on P
std::vector<int> choose(std::vector<vehicle> const &Consist);
// brake working, on P. Train tells the AI runs the consist as a train (Obey_train): §19.9 is about
// trains, so in shunting (or banking) nothing is cut out and a wagon without G brakes on P, which puts
// back a brake the inspector cut out before
std::vector<int> choose(std::vector<vehicle> const &Consist, bool Train);
// the inspector of the releases before eu07/maszyna#350, kept for ai.brakesetting.cw1 no. the settings
// are requests: a vehicle which doesn't have the one asked for keeps its own
@@ -73,9 +75,11 @@ vehicle describe(TMoverParameters const &Vehicle, bool Driven);
// the inspector puts the vehicle on Setting, as choose() gives it. cut_out cuts the brake out the way
// the scenery's '0' does: b_dmg, which cuts the distributor off the brake pipe (as the cab's cut-out,
// trainbrakeoperationtoggle, does), and its reservoirs emptied, so the brake releases and stays off.
// The vehicle remembers the inspector did it. Any other setting first puts back a brake the inspector
// cut out (it charges from the brake pipe again), then sets the vehicle to it (0: leaves the setting
// as it is). A brake cut out by anyone else stays cut out
void apply(TMoverParameters &Vehicle, int Setting);
// The vehicle remembers the inspector did it. A brake is cut out only with the train at a standstill
// (Standstill): on the run the vehicle is left as it is until the inspector looks at the train again
// standing, rather than losing its brake while moving. Any other setting first puts back a brake the
// inspector cut out (it charges from the brake pipe again), then sets the vehicle to it (0: leaves the
// setting as it is). A brake cut out by anyone else stays cut out
void apply(TMoverParameters &Vehicle, int Setting, bool Standstill);
} // namespace brake_setting