mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-22 02:05:01 +01:00
fix: AI wagon inspector cuts out the brake of wagons without G in a train on G (eu07/maszyna#350)
Cw-1 §19.9: in a freight train braked on G, the brake of a vehicle that has
no G setting (e.g. a passenger car with P and R) is cut out. The inspector
put such wagons on P; now it cuts their brake out the way the scenery's '0'
flag does (b_dmg, the distributor's reservoirs emptied), so the brake
releases and stays off.
- The vehicle remembers the inspector cut it out
(TMoverParameters::BrakeCutOutByInspector); the next inspection puts such
a brake back and sets it to what the new train needs. A brake cut out for
any other reason (scenery, player, damage) is never put back; the cab's
cut-out toggle hands an inspector's cut-out over to the player.
- Locomotives and the vehicle the train is driven from keep a working
brake (on P). In the long locomotive setting (§19.3b) the train runs on
P, so a wagon without G stays on P there.
- The braking tables after the settings leave cut-out brakes out.
- §18.3: a car with R whose brake is cut out counts as one on P.
- ai.brakesetting.cw1 no keeps the earlier behaviour: nothing cut out.
The choice and the cutting out stay in vehicle/brakesetting.{h,cpp}, with
unit tests on real wagons.
This commit is contained in:
@@ -11,6 +11,8 @@ http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#include <vector>
|
||||
|
||||
class TMoverParameters;
|
||||
|
||||
// the brake setting (G/P/R/Mg) the virtual wagon inspector (TController::AutoRewident) chooses for every
|
||||
// vehicle of a train, by the rules of the brake instruction Cw-1 (Mw56), §18 and §19 (eu07/maszyna#350)
|
||||
namespace brake_setting {
|
||||
@@ -21,6 +23,8 @@ struct vehicle {
|
||||
bool powered{false}; // a locomotive or a powered unit, as opposed to a wagon
|
||||
double length{0.0}; // [m]
|
||||
double mass{0.0}; // with its load [kg]
|
||||
bool cut_out{false}; // the brake is cut out for a reason of its own (damage, the scenario, the player)
|
||||
bool driven{false}; // the vehicle the train is driven from: its brake is never cut out
|
||||
};
|
||||
|
||||
// the kind of train the inspector takes the consist for, and how it sets the brakes
|
||||
@@ -36,6 +40,9 @@ enum class train_setting {
|
||||
// how many wagons next to the locomotive stay on G in a freight_gp train
|
||||
inline constexpr int freight_gp_wagons_on_g{5};
|
||||
|
||||
// the setting choose() gives a vehicle whose brake is to be cut out (Cw-1 §19.9)
|
||||
inline constexpr int cut_out{-1};
|
||||
|
||||
// the train setting by Cw-1. Consist runs from the head of the train to its rear
|
||||
train_setting choose_train_setting(std::vector<vehicle> const &Consist);
|
||||
|
||||
@@ -47,11 +54,28 @@ constexpr bool passenger(train_setting const Setting) {
|
||||
|
||||
// the brake setting (bdelay_*) for every vehicle of Consist, in the same order, by Cw-1. a vehicle
|
||||
// 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. Cw-1 §19.9 would have the brake of such a vehicle cut out instead
|
||||
// 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);
|
||||
|
||||
// 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
|
||||
std::vector<int> choose_legacy(std::vector<vehicle> const &Consist);
|
||||
|
||||
// the brake of the vehicle is cut out (b_dmg), whoever did it
|
||||
bool is_cut_out(TMoverParameters const &Vehicle);
|
||||
|
||||
// what choose() needs to know of the vehicle. a brake the inspector cut out itself doesn't count as
|
||||
// cut out: the inspector decides about it anew
|
||||
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);
|
||||
|
||||
} // namespace brake_setting
|
||||
|
||||
Reference in New Issue
Block a user