mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-20 22:04:59 +01:00
fix(ai): a brake cut-out skipped on the run is done once the train stands
A train formed by coupling is inspected at the first buffer contact, above the speed the inspector takes for a standstill, so its wagons without G kept their brakes (Cw-1 §19.9) until some later stop, if any. brake_setting::apply() now tells when it left a cut-out because the train was moving; AutoRewident keeps that as a pending re-inspection and TController::reinspect_brakes() runs it again once the train is below EU07_AI_MOVEMENT. The flag is dropped when the order stops being a train run. The legacy inspector (ai.brakesetting.cw1 no) never cuts a brake out and is unchanged.
This commit is contained in:
@@ -2435,9 +2435,10 @@ void TController::AutoRewident()
|
||||
// brakes are cut out (Cw-1 §19.9) only in a train (a bank engine's run included), not in a consist being shunted
|
||||
auto const train{brake_setting::runs_as_train(OrderCurrentGet())};
|
||||
auto const settings{Global.AIBrakeSettingCw1 ? brake_setting::choose(consist, train) : brake_setting::choose_legacy(consist)};
|
||||
// and only at a standstill, the train creeping to a stop or coupling included: a check on the run (the order changed
|
||||
// mid-run) leaves them to the next one
|
||||
// and only at a standstill, the train creeping to a stop included: a check on the run (the order changed mid-run, or
|
||||
// the train was just formed by coupling, which the AI does above that speed) leaves them to reinspect_brakes()
|
||||
auto const standstill{brake_setting::at_standstill(mvOccupied->Vel)};
|
||||
auto reinspect{false};
|
||||
// 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
|
||||
@@ -2448,11 +2449,15 @@ 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, standstill);
|
||||
if (brake_setting::apply(*d->MoverParameters, *setting, standstill)) {
|
||||
// a brake to cut out, with the train moving: left for the next standstill
|
||||
reinspect = true;
|
||||
}
|
||||
// potentially release manual brake
|
||||
d->MoverParameters->DecManualBrakeLevel( ManualBrakePosNo );
|
||||
d->MoverParameters->SpringBrake.Activate = false;
|
||||
}
|
||||
BrakeReinspectionPending = reinspect;
|
||||
//ustawianie trybu pracy zadajnika hamulca, wystarczy raz po inicjalizacji AI
|
||||
if( true == AIControllFlag ) {
|
||||
// if a human is in charge leave the brake mode up to them, otherwise do as you like
|
||||
@@ -2545,6 +2550,25 @@ void TController::AutoRewident()
|
||||
|
||||
}
|
||||
|
||||
// a brake the inspector had to cut out (Cw-1 §19.9) while the train was moving gets cut out once the train stands.
|
||||
// a train formed by coupling is looked at as the buffers meet, above the speed the inspector takes for a standstill,
|
||||
// and with no stop ahead nothing would look at it standing again (eu07/maszyna#350)
|
||||
void TController::reinspect_brakes()
|
||||
{
|
||||
if (false == BrakeReinspectionPending) {
|
||||
return;
|
||||
}
|
||||
if (false == brake_setting::runs_as_train(OrderCurrentGet())) {
|
||||
// no longer a train: nothing is cut out in a consist being shunted
|
||||
BrakeReinspectionPending = false;
|
||||
return;
|
||||
}
|
||||
if (brake_setting::at_standstill(mvOccupied->Vel)) {
|
||||
// standing, the inspector leaves nothing for later: this clears the flag
|
||||
AutoRewident();
|
||||
}
|
||||
}
|
||||
|
||||
double TController::ESMVelocity(bool Main)
|
||||
{
|
||||
double fCurrentCoeff = 0.9;
|
||||
@@ -5320,6 +5344,8 @@ TController::Update( double const Timedelta ) {
|
||||
// mode specific actions
|
||||
handle_engine();
|
||||
handle_orders();
|
||||
// a brake the wagon inspector left to cut out while the train was moving
|
||||
reinspect_brakes();
|
||||
// situational velocity and acceleration adjustments
|
||||
pick_optimal_speed( awarenessrange );
|
||||
if( iEngineActive ) {
|
||||
|
||||
@@ -674,6 +674,8 @@ private:
|
||||
bool doors_open() const;
|
||||
bool doors_permit_active() const;
|
||||
void AutoRewident(); // ustawia hamulce w składzie
|
||||
void reinspect_brakes(); // AutoRewident() again once the train stands, when it left a brake to cut out on the run
|
||||
bool BrakeReinspectionPending{ false }; // AutoRewident() left a brake to cut out (Cw-1 §19.9) for the next standstill
|
||||
void announce( announcement_t const Announcement );
|
||||
// members
|
||||
double fLength = 0.0; // długość składu (do wyciągania z ograniczeń)
|
||||
|
||||
@@ -260,23 +260,28 @@ vehicle describe(TMoverParameters const &Vehicle, bool const Driven) {
|
||||
return described;
|
||||
}
|
||||
|
||||
void apply(TMoverParameters &Vehicle, int const Setting, bool const Standstill) {
|
||||
bool 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) && 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;
|
||||
if (is_cut_out(Vehicle)) {
|
||||
// a brake cut out already, by the inspector or for a reason of its own, stays as it is
|
||||
return false;
|
||||
}
|
||||
// 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 (false == Standstill) {
|
||||
// on the run the vehicle is left alone, brake and setting, until the inspector looks at the train
|
||||
// standing: the caller is told to come back
|
||||
return true;
|
||||
}
|
||||
// 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;
|
||||
return false;
|
||||
}
|
||||
if (Vehicle.BrakeCutOutByInspector) {
|
||||
// open the cut-out cock: the distributor charges from the brake pipe again
|
||||
@@ -286,6 +291,7 @@ void apply(TMoverParameters &Vehicle, int const Setting, bool const Standstill)
|
||||
if (Setting != 0) {
|
||||
Vehicle.BrakeDelaySwitch(Setting);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace brake_setting
|
||||
|
||||
@@ -67,8 +67,10 @@ bool runs_as_train(int Orders);
|
||||
|
||||
// the train stands for the inspector: slower than the AI takes for a deliberate movement (EU07_AI_MOVEMENT).
|
||||
// the AI looks at the train while it still creeps to a stop (at a W4, or switching from shunting to the train
|
||||
// run) and as it couples (at the coupling speed), so a stricter threshold would miss those checks; a train
|
||||
// really on the run (an order changed mid-run) stays above it
|
||||
// run), so a stricter threshold would miss those checks; a train really on the run (an order changed mid-run)
|
||||
// stays above it, and so does one being formed by coupling: the AI drives onto the standing cut faster than
|
||||
// that and looks at the new train at the first buffer contact. apply() tells of the cut-outs such a look
|
||||
// left for the next one, at a standstill
|
||||
bool at_standstill(double Velocity);
|
||||
|
||||
// the inspector of the releases before eu07/maszyna#350, kept for ai.brakesetting.cw1 no. the settings
|
||||
@@ -89,7 +91,9 @@ vehicle describe(TMoverParameters const &Vehicle, bool Driven);
|
||||
// (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);
|
||||
// setting as it is). A brake cut out by anyone else stays cut out.
|
||||
// Returns true when a cut-out was left for later because the train was moving: the inspector has to look
|
||||
// at the train again once it stands (TController::reinspect_brakes() does)
|
||||
bool apply(TMoverParameters &Vehicle, int Setting, bool Standstill);
|
||||
|
||||
} // namespace brake_setting
|
||||
|
||||
Reference in New Issue
Block a user