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

@@ -1449,7 +1449,7 @@ double TESt4R::GetPF(double const PP, double const dt, double const Vel)
result = dv - dV1; result = dv - dV1;
RapidStatus = BrakeDelayFlag == bdelay_R && ((Vel > 55 && RapidStatus == true) || Vel > 70); RapidStatus = (BrakeDelayFlag & bdelay_R) == bdelay_R && ((Vel > 55 && RapidStatus == true) || Vel > 70);
RapidTemp = RapidTemp + (0.9 * int(RapidStatus) - RapidTemp) * dt / 2; RapidTemp = RapidTemp + (0.9 * int(RapidStatus) - RapidTemp) * dt / 2;
temp = 1.9 - RapidTemp; temp = 1.9 - RapidTemp;
@@ -1752,7 +1752,7 @@ double TLSt::GetPF(double const PP, double const dt, double const Vel)
// if Vel>55 then temp:=0.72 else // if Vel>55 then temp:=0.72 else
// temp:=1;{R} // temp:=1;{R}
// cisnienie PP // cisnienie PP
RapidTemp = RapidTemp + (RM * int(Vel > 55 && BrakeDelayFlag == bdelay_R) - RapidTemp) * dt / 2; RapidTemp = RapidTemp + (RM * int(Vel > 55 && (BrakeDelayFlag & bdelay_R) == bdelay_R) - RapidTemp) * dt / 2;
temp = 1 - RapidTemp; temp = 1 - RapidTemp;
if (EDFlag > 0.2) if (EDFlag > 0.2)
temp = 10000; temp = 10000;
@@ -1971,7 +1971,7 @@ double TEStED::GetPF(double const PP, double const dt, double const Vel)
dv = dv + PF(MPP, VVP, 0.02); dv = dv + PF(MPP, VVP, 0.02);
Miedzypoj->Flow(dv * dt * 0.15); Miedzypoj->Flow(dv * dt * 0.15);
RapidTemp = RapidTemp + (RM * int(Vel > RV && BrakeDelayFlag == bdelay_R) - RapidTemp) * dt / 2; RapidTemp = RapidTemp + (RM * int(Vel > RV && (BrakeDelayFlag & bdelay_R) == bdelay_R) - RapidTemp) * dt / 2;
temp = std::max(1 - RapidTemp, 0.001); temp = std::max(1 - RapidTemp, 0.001);
// if EDFlag then temp:=1000; // if EDFlag then temp:=1000;
// temp:=temp/(1-); // temp:=temp/(1-);

View File

@@ -18,6 +18,13 @@ constexpr int P{bdelay_P};
constexpr int R{bdelay_R}; constexpr int R{bdelay_R};
constexpr int M{bdelay_M}; constexpr int M{bdelay_M};
// how the AI runs the consist the inspector looks at: as a train (Obey_train), or shunting it
constexpr bool as_train{true};
constexpr bool shunting{false};
// whether the train stands, as AutoRewident() tells the inspector
constexpr bool standstill{true};
constexpr bool moving{false};
brake_setting::vehicle locomotive(int const Delays = G | P | R) { brake_setting::vehicle locomotive(int const Delays = G | P | R) {
return {Delays, true, 17.0, 80000.0}; return {Delays, true, 17.0, 80000.0};
} }
@@ -51,7 +58,7 @@ TEST_CASE("brake setting: the locomotives don't count into the length and mass o
auto consist{train(locomotive(), 20, freight_wagon(15.0, 30.0))}; auto consist{train(locomotive(), 20, freight_wagon(15.0, 30.0))};
consist.insert(consist.begin(), locomotive()); consist.insert(consist.begin(), locomotive());
CHECK(brake_setting::choose_train_setting(consist) == train_setting::freight_p); CHECK(brake_setting::choose_train_setting(consist) == train_setting::freight_p);
auto const settings{brake_setting::choose(consist)}; auto const settings{brake_setting::choose(consist, as_train)};
CHECK(settings[0] == G); CHECK(settings[0] == G);
CHECK(settings[1] == G); CHECK(settings[1] == G);
for (std::size_t i = 2; i < settings.size(); ++i) { for (std::size_t i = 2; i < settings.size(); ++i) {
@@ -66,7 +73,7 @@ TEST_CASE("brake setting: the locomotives don't count into the length and mass o
TEST_CASE("brake setting: the locomotive and the first five wagons on G, the rest on P (Cw-1 §19.3b)") { TEST_CASE("brake setting: the locomotive and the first five wagons on G, the rest on P (Cw-1 §19.3b)") {
auto const consist{train(locomotive(), 12, freight_wagon(15.0, 60.0))}; auto const consist{train(locomotive(), 12, freight_wagon(15.0, 60.0))};
REQUIRE(brake_setting::choose_train_setting(consist) == train_setting::freight_gp); REQUIRE(brake_setting::choose_train_setting(consist) == train_setting::freight_gp);
auto const settings{brake_setting::choose(consist)}; auto const settings{brake_setting::choose(consist, as_train)};
REQUIRE(settings.size() == consist.size()); REQUIRE(settings.size() == consist.size());
for (std::size_t i = 0; i < settings.size(); ++i) { for (std::size_t i = 0; i < settings.size(); ++i) {
CAPTURE(i); CAPTURE(i);
@@ -79,7 +86,7 @@ TEST_CASE("brake setting: a locomotive in the middle of the train doesn't put fi
consist.emplace_back(locomotive()); consist.emplace_back(locomotive());
consist.insert(consist.end(), 8, freight_wagon(15.0, 60.0)); consist.insert(consist.end(), 8, freight_wagon(15.0, 60.0));
REQUIRE(brake_setting::choose_train_setting(consist) == train_setting::freight_gp); REQUIRE(brake_setting::choose_train_setting(consist) == train_setting::freight_gp);
auto const settings{brake_setting::choose(consist)}; auto const settings{brake_setting::choose(consist, as_train)};
CHECK(settings[1] == G); CHECK(settings[1] == G);
CHECK(settings[5] == G); CHECK(settings[5] == G);
CHECK(settings[6] == P); CHECK(settings[6] == P);
@@ -98,7 +105,7 @@ TEST_CASE("brake setting: a heavy freight train runs on G, a wagon without G has
consist.emplace_back(passenger_car(P)); consist.emplace_back(passenger_car(P));
consist.emplace_back(passenger_car()); consist.emplace_back(passenger_car());
REQUIRE(brake_setting::choose_train_setting(consist) == train_setting::freight_g); REQUIRE(brake_setting::choose_train_setting(consist) == train_setting::freight_g);
auto const settings{brake_setting::choose(consist)}; auto const settings{brake_setting::choose(consist, as_train)};
for (std::size_t i = 0; i + 2 < settings.size(); ++i) { for (std::size_t i = 0; i + 2 < settings.size(); ++i) {
CAPTURE(i); CAPTURE(i);
CHECK(settings[i] == G); CHECK(settings[i] == G);
@@ -118,7 +125,7 @@ TEST_CASE("brake setting: in a train on G a locomotive and the vehicle it's driv
consist.emplace_back(locomotive(P | R)); consist.emplace_back(locomotive(P | R));
consist.emplace_back(0, false, 20.0, 40000.0); consist.emplace_back(0, false, 20.0, 40000.0);
REQUIRE(brake_setting::choose_train_setting(consist) == train_setting::freight_g); REQUIRE(brake_setting::choose_train_setting(consist) == train_setting::freight_g);
auto settings{brake_setting::choose(consist)}; auto settings{brake_setting::choose(consist, as_train)};
CHECK(settings.front() == P); CHECK(settings.front() == P);
CHECK(settings[settings.size() - 2] == P); CHECK(settings[settings.size() - 2] == P);
CHECK(settings.back() == 0); CHECK(settings.back() == 0);
@@ -128,7 +135,7 @@ TEST_CASE("brake setting: in a train on G a locomotive and the vehicle it's driv
controlcar.driven = true; controlcar.driven = true;
consist.front() = controlcar; consist.front() = controlcar;
consist.back() = locomotive(); consist.back() = locomotive();
settings = brake_setting::choose(consist); settings = brake_setting::choose(consist, as_train);
CHECK(settings.front() == P); CHECK(settings.front() == P);
CHECK(settings.back() == G); CHECK(settings.back() == G);
} }
@@ -140,7 +147,7 @@ TEST_CASE("brake setting: in the long locomotive setting a vehicle without G bra
consist.insert(consist.end(), 8, freight_wagon(15.0, 60.0)); consist.insert(consist.end(), 8, freight_wagon(15.0, 60.0));
consist.emplace_back(passenger_car()); consist.emplace_back(passenger_car());
REQUIRE(brake_setting::choose_train_setting(consist) == train_setting::freight_gp); REQUIRE(brake_setting::choose_train_setting(consist) == train_setting::freight_gp);
auto const settings{brake_setting::choose(consist)}; auto const settings{brake_setting::choose(consist, as_train)};
CHECK(settings[2] == G); CHECK(settings[2] == G);
CHECK(settings[3] == P); CHECK(settings[3] == P);
CHECK(settings[4] == G); CHECK(settings[4] == G);
@@ -148,6 +155,23 @@ TEST_CASE("brake setting: in the long locomotive setting a vehicle without G bra
CHECK(settings.back() == P); CHECK(settings.back() == P);
} }
TEST_CASE("brake setting: a heavy consist being shunted has nothing cut out, a wagon without G brakes on P") {
// §19.9 is about trains: the same consist the AI shunts rather than runs as a train
auto consist{train(locomotive(), 30, freight_wagon(15.0, 80.0))};
consist.emplace_back(passenger_car(P));
consist.emplace_back(passenger_car());
REQUIRE(brake_setting::choose_train_setting(consist) == train_setting::freight_g);
auto const settings{brake_setting::choose(consist, shunting)};
for (std::size_t i = 0; i + 2 < settings.size(); ++i) {
CAPTURE(i);
CHECK(settings[i] == G);
}
CHECK(settings[settings.size() - 2] == P);
CHECK(settings.back() == P);
// as a train they're cut out
CHECK(brake_setting::choose(consist, as_train).back() == brake_setting::cut_out);
}
TEST_CASE("brake setting: a car with its brake cut out counts as one on P in a passenger train (Cw-1 §18.3)") { TEST_CASE("brake setting: a car with its brake cut out counts as one on P in a passenger train (Cw-1 §18.3)") {
auto consist{train(locomotive(), 5, passenger_car())}; auto consist{train(locomotive(), 5, passenger_car())};
consist.insert(consist.end(), 3, passenger_car(P)); consist.insert(consist.end(), 3, passenger_car(P));
@@ -180,12 +204,13 @@ void charge_and_apply(test::vehicle &Vehicle) {
Vehicle.run(20.0); Vehicle.run(20.0);
} }
// the inspector at work on a heavy train on G with the vehicle at its end, as AutoRewident() does it // the inspector at work on a heavy train on G with the vehicle at its end, as AutoRewident() does it, the AI
int inspect_heavy_train(test::vehicle &Vehicle) { // running it as a train or shunting it, standing or on the run
int inspect_heavy_train(test::vehicle &Vehicle, bool const Train = as_train, bool const Standstill = standstill) {
auto consist{train(locomotive(), 30, freight_wagon(15.0, 80.0))}; auto consist{train(locomotive(), 30, freight_wagon(15.0, 80.0))};
consist.emplace_back(brake_setting::describe(Vehicle.mover(), false)); consist.emplace_back(brake_setting::describe(Vehicle.mover(), false));
auto const setting{brake_setting::choose(consist).back()}; auto const setting{brake_setting::choose(consist, Train).back()};
brake_setting::apply(Vehicle.mover(), setting); brake_setting::apply(Vehicle.mover(), setting, Standstill);
return setting; return setting;
} }
@@ -193,8 +218,8 @@ int inspect_heavy_train(test::vehicle &Vehicle) {
int inspect_light_train(test::vehicle &Vehicle) { int inspect_light_train(test::vehicle &Vehicle) {
auto consist{train(locomotive(), 4, freight_wagon())}; auto consist{train(locomotive(), 4, freight_wagon())};
consist.emplace_back(brake_setting::describe(Vehicle.mover(), false)); consist.emplace_back(brake_setting::describe(Vehicle.mover(), false));
auto const setting{brake_setting::choose(consist).back()}; auto const setting{brake_setting::choose(consist, as_train).back()};
brake_setting::apply(Vehicle.mover(), setting); brake_setting::apply(Vehicle.mover(), setting, standstill);
return setting; return setting;
} }
@@ -269,22 +294,96 @@ TEST_CASE("brake setting: the inspector never puts back a brake cut out for anot
CHECK(brake_setting::is_cut_out(other.mover())); CHECK(brake_setting::is_cut_out(other.mover()));
} }
TEST_CASE("brake setting: shunting puts back a brake the inspector cut out, and cuts none out") {
test::vehicle car{passenger_car_definition()};
charge_and_apply(car);
// shunted in a heavy consist: nothing is cut out, the car is on P and brakes
CHECK(inspect_heavy_train(car, shunting) == P);
CHECK(false == brake_setting::is_cut_out(car.mover()));
CHECK(car->BrakeDelayFlag == P);
CHECK(car->BrakePress > 1.0);
// cut out when the consist became a train, then shunted again (e.g. left in a yard): the brake is back
REQUIRE(inspect_heavy_train(car) == brake_setting::cut_out);
REQUIRE(car->BrakeCutOutByInspector);
CHECK(inspect_heavy_train(car, shunting) == P);
CHECK(false == brake_setting::is_cut_out(car.mover()));
CHECK(false == car->BrakeCutOutByInspector);
car.hold_brake_pipe(5.0);
car.run(300.0);
charge_and_apply(car);
CHECK(car->BrakePress > 1.0);
// a brake cut out for a reason of its own stays cut out in shunting too
test::vehicle other{passenger_car_definition()};
other->Hamulec->SetBrakeStatus(other->Hamulec->GetBrakeStatus() | b_dmg);
CHECK(inspect_heavy_train(other, shunting) == P);
CHECK(brake_setting::is_cut_out(other.mover()));
}
TEST_CASE("brake setting: the inspector doesn't cut a brake out on the run, it waits for a standstill") {
test::vehicle car{passenger_car_definition()};
charge_and_apply(car);
REQUIRE(car->BrakePress > 1.0);
// the train checked on the run (the order changed mid-run): the car keeps its brake and its setting
auto const setting{car->BrakeDelayFlag};
CHECK(inspect_heavy_train(car, as_train, moving) == brake_setting::cut_out);
CHECK(false == brake_setting::is_cut_out(car.mover()));
CHECK(false == car->BrakeCutOutByInspector);
CHECK(car->BrakeDelayFlag == setting);
car.run(5.0);
CHECK(car->BrakePress > 1.0);
// the next check, standing, cuts it out
CHECK(inspect_heavy_train(car) == brake_setting::cut_out);
CHECK(brake_setting::is_cut_out(car.mover()));
CHECK(car->BrakeCutOutByInspector);
// a brake cut out already stays cut out on the run, and one put back on the run is back
CHECK(inspect_heavy_train(car, as_train, moving) == brake_setting::cut_out);
CHECK(car->BrakeCutOutByInspector);
CHECK(inspect_heavy_train(car, shunting, moving) == P);
CHECK(false == brake_setting::is_cut_out(car.mover()));
CHECK(false == car->BrakeCutOutByInspector);
}
TEST_CASE("brake setting: R+Mg brakes as hard as R at speed, the rapid stage of an LSt kept") {
// the inspector sets R+Mg (Cw-1 §18.2), the bits of R and Mg together: the valves test the bit of R, not
// the whole setting, so the high stage of R at speed stays on with Mg. the EU07's LSt given an Mg here
auto const definition{test::definition::fiz("4e_v1/4e").set("Cntrl", "BrakeDelays", "GPR+Mg")};
auto const service = [&](int const Setting) {
test::reseed_random();
test::vehicle real{definition, 160.0};
real->DecManualBrakeLevel(ManualBrakePosNo);
real->BrakeDelaySwitch(Setting); // false when already set
REQUIRE(real->BrakeDelayFlag == Setting);
real.hold_brake_pipe(5.0);
real.run(60.0);
real.hold_brake_pipe(3.5);
real.run(10.0);
REQUIRE(real->Vel > 100.0);
return real->BrakePress;
};
auto const rapid{service(R)};
CHECK(service(R | M) == doctest::Approx(rapid).epsilon(0.01));
// and P has no high stage
CHECK(service(P) < rapid - 1.0);
}
TEST_CASE("brake setting: a vehicle without the setting the train needs gets the other one of G and P") { TEST_CASE("brake setting: a vehicle without the setting the train needs gets the other one of G and P") {
// a light freight train with a wagon which has G only // a light freight train with a wagon which has G only
auto consist{train(locomotive(), 4, freight_wagon(15.0, 20.0))}; auto consist{train(locomotive(), 4, freight_wagon(15.0, 20.0))};
consist.emplace_back(G, false, 15.0, 20000.0); consist.emplace_back(G, false, 15.0, 20000.0);
REQUIRE(brake_setting::choose_train_setting(consist) == train_setting::freight_p); REQUIRE(brake_setting::choose_train_setting(consist) == train_setting::freight_p);
CHECK(brake_setting::choose(consist).back() == G); CHECK(brake_setting::choose(consist, as_train).back() == G);
// and a vehicle with neither is left alone // and a vehicle with neither is left alone
consist.emplace_back(R, false, 15.0, 20000.0); consist.emplace_back(R, false, 15.0, 20000.0);
CHECK(brake_setting::choose(consist).back() == 0); CHECK(brake_setting::choose(consist, as_train).back() == 0);
} }
TEST_CASE("brake setting: a passenger train on R carries at most three cars on P, fewer than those on R (Cw-1 §18.3)") { TEST_CASE("brake setting: a passenger train on R carries at most three cars on P, fewer than those on R (Cw-1 §18.3)") {
auto consist{train(locomotive(), 4, passenger_car())}; auto consist{train(locomotive(), 4, passenger_car())};
consist.insert(consist.end(), 3, passenger_car(P)); consist.insert(consist.end(), 3, passenger_car(P));
CHECK(brake_setting::choose_train_setting(consist) == train_setting::passenger_r); CHECK(brake_setting::choose_train_setting(consist) == train_setting::passenger_r);
auto const settings{brake_setting::choose(consist)}; auto const settings{brake_setting::choose(consist, as_train)};
CHECK(settings[0] == R); CHECK(settings[0] == R);
CHECK(settings[1] == R); CHECK(settings[1] == R);
CHECK(settings.back() == P); CHECK(settings.back() == P);
@@ -292,7 +391,7 @@ TEST_CASE("brake setting: a passenger train on R carries at most three cars on P
// as many cars on P as on R: all on P // as many cars on P as on R: all on P
consist.emplace_back(passenger_car(P)); consist.emplace_back(passenger_car(P));
CHECK(brake_setting::choose_train_setting(consist) == train_setting::passenger_p); CHECK(brake_setting::choose_train_setting(consist) == train_setting::passenger_p);
for (auto const setting : brake_setting::choose(consist)) { for (auto const setting : brake_setting::choose(consist, as_train)) {
CHECK(setting == P); CHECK(setting == P);
} }
// the inspector of the earlier releases kept such a train on R // the inspector of the earlier releases kept such a train on R
@@ -307,14 +406,14 @@ TEST_CASE("brake setting: freight wagons in a passenger train on R count as cars
auto consist{train(locomotive(), 6, passenger_car())}; auto consist{train(locomotive(), 6, passenger_car())};
consist.emplace_back(freight_wagon()); consist.emplace_back(freight_wagon());
REQUIRE(brake_setting::choose_train_setting(consist) == train_setting::passenger_r); REQUIRE(brake_setting::choose_train_setting(consist) == train_setting::passenger_r);
CHECK(brake_setting::choose(consist).back() == P); CHECK(brake_setting::choose(consist, as_train).back() == P);
} }
TEST_CASE("brake setting: cars with a magnetic rail brake run on R+Mg in a train on R (Cw-1 §18.2)") { TEST_CASE("brake setting: cars with a magnetic rail brake run on R+Mg in a train on R (Cw-1 §18.2)") {
auto consist{train(locomotive(G | P | R | M), 3, passenger_car(P | R | M))}; auto consist{train(locomotive(G | P | R | M), 3, passenger_car(P | R | M))};
consist.emplace_back(passenger_car()); consist.emplace_back(passenger_car());
REQUIRE(brake_setting::choose_train_setting(consist) == train_setting::passenger_r); REQUIRE(brake_setting::choose_train_setting(consist) == train_setting::passenger_r);
auto const settings{brake_setting::choose(consist)}; auto const settings{brake_setting::choose(consist, as_train)};
CHECK(settings[0] == R); // the locomotive stays on R CHECK(settings[0] == R); // the locomotive stays on R
CHECK(settings[1] == (R | M)); CHECK(settings[1] == (R | M));
CHECK(settings.back() == R); CHECK(settings.back() == R);
@@ -323,7 +422,7 @@ TEST_CASE("brake setting: cars with a magnetic rail brake run on R+Mg in a train
TEST_CASE("brake setting: a light engine runs on R where it has it") { TEST_CASE("brake setting: a light engine runs on R where it has it") {
std::vector<brake_setting::vehicle> const consist{locomotive(), locomotive(G | P)}; std::vector<brake_setting::vehicle> const consist{locomotive(), locomotive(G | P)};
CHECK(brake_setting::choose_train_setting(consist) == train_setting::light_engine); CHECK(brake_setting::choose_train_setting(consist) == train_setting::light_engine);
auto const settings{brake_setting::choose(consist)}; auto const settings{brake_setting::choose(consist, as_train)};
CHECK(settings[0] == R); CHECK(settings[0] == R);
CHECK(settings[1] == P); CHECK(settings[1] == P);
} }
@@ -331,7 +430,7 @@ TEST_CASE("brake setting: a light engine runs on R where it has it") {
TEST_CASE("brake setting: the inspector of the earlier releases counted the locomotives into the train's mass") { TEST_CASE("brake setting: the inspector of the earlier releases counted the locomotives into the train's mass") {
// 300 m and 600 t of wagons: P by Cw-1, the long locomotive setting before // 300 m and 600 t of wagons: P by Cw-1, the long locomotive setting before
auto const consist{train(locomotive(), 20, freight_wagon(15.0, 30.0))}; auto const consist{train(locomotive(), 20, freight_wagon(15.0, 30.0))};
CHECK(brake_setting::choose(consist)[1] == P); CHECK(brake_setting::choose(consist, as_train)[1] == P);
CHECK(brake_setting::choose_legacy(consist)[1] == G); CHECK(brake_setting::choose_legacy(consist)[1] == G);
CHECK(brake_setting::choose_legacy(consist)[6] == P); CHECK(brake_setting::choose_legacy(consist)[6] == P);
} }

View File

@@ -2086,8 +2086,12 @@ void TController::AutoRewident()
for (auto const *d = pVehicles[0]; d != nullptr; d = d->Next()) { for (auto const *d = pVehicles[0]; d != nullptr; d = d->Next()) {
consist.emplace_back(brake_setting::describe(*d->MoverParameters, d == pVehicle)); 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 // 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)}; // 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 // a light engine counts as a passenger train for the braking below
auto const passengertrain{brake_setting::passenger(brake_setting::choose_train_setting(consist))}; auto const passengertrain{brake_setting::passenger(brake_setting::choose_train_setting(consist))};
// 3. Nastawianie // 3. Nastawianie
@@ -2098,7 +2102,7 @@ void TController::AutoRewident()
continue; 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 // 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 // potentially release manual brake
d->MoverParameters->DecManualBrakeLevel( ManualBrakePosNo ); d->MoverParameters->DecManualBrakeLevel( ManualBrakePosNo );
d->MoverParameters->SpringBrake.Activate = false; 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; 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)}; auto const setting{choose_train_setting(Consist)};
std::vector<int> settings; std::vector<int> settings;
settings.reserve(Consist.size()); settings.reserve(Consist.size());
@@ -154,9 +154,10 @@ std::vector<int> choose(std::vector<vehicle> const &Consist) {
if (has(item.delays, bdelay_G)) { if (has(item.delays, bdelay_G)) {
settings.emplace_back(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 // 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)); settings.emplace_back(pick(item.delays, bdelay_P, bdelay_P));
} }
else { else {
@@ -249,21 +250,22 @@ vehicle describe(TMoverParameters const &Vehicle, bool const Driven) {
return described; return described;
} }
void apply(TMoverParameters &Vehicle, int const Setting) { void apply(TMoverParameters &Vehicle, int const Setting, bool const Standstill) {
auto &brake{*Vehicle.Hamulec}; auto &brake{*Vehicle.Hamulec};
if (Vehicle.BrakeCutOutByInspector && false == is_cut_out(Vehicle)) { if (Vehicle.BrakeCutOutByInspector && false == is_cut_out(Vehicle)) {
// someone put the brake back in the meantime, it's theirs now // someone put the brake back in the meantime, it's theirs now
Vehicle.BrakeCutOutByInspector = false; Vehicle.BrakeCutOutByInspector = false;
} }
if (Setting == cut_out) { 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 // 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 // distributor, cut off the brake pipe, has no air left to brake with and lets the cylinders go
brake.ForceEmptiness(); brake.ForceEmptiness();
brake.SetBrakeStatus(brake.GetBrakeStatus() | b_dmg); brake.SetBrakeStatus(brake.GetBrakeStatus() | b_dmg);
Vehicle.BrakeCutOutByInspector = true; 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; return;
} }
if (Vehicle.BrakeCutOutByInspector) { 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) // 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 // 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 // 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 // brake working, on P. Train tells the AI runs the consist as a train (Obey_train): §19.9 is about
std::vector<int> choose(std::vector<vehicle> const &Consist); // 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 // 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 // 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 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, // 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. // 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 // The vehicle remembers the inspector did it. A brake is cut out only with the train at a standstill
// cut out (it charges from the brake pipe again), then sets the vehicle to it (0: leaves the setting // (Standstill): on the run the vehicle is left as it is until the inspector looks at the train again
// as it is). A brake cut out by anyone else stays cut out // standing, rather than losing its brake while moving. Any other setting first puts back a brake the
void apply(TMoverParameters &Vehicle, int Setting); // 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 } // namespace brake_setting