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

Merge branch 'master' into feat/renderers-cleanup

This commit is contained in:
2026-11-16 21:44:48 +01:00
264 changed files with 41203 additions and 10041 deletions

View File

@@ -14,7 +14,9 @@ http://mozilla.org/MPL/2.0/.
#include <map>
#include <optional>
#include "hamulce.h"
#include "couplerphysics.h"
#include "scripting/ladderlogic.h"
#include "vehicle/odometerreading.h"
class cParser;
/*
@@ -299,6 +301,16 @@ enum class operation_t
/// <summary>Disable button release transition.</summary>
disable_off,
};
/// <summary>What else the line contactors of a vehicle need before they can close (LineContactorsInterlock in the Cntrl. section).</summary>
enum class line_contactors_interlock
{
/// <summary>Nothing more, the legacy behaviour.</summary>
none,
/// <summary>The converter of the vehicle itself running, where it drives the traction motor fans (ET42).</summary>
converter,
/// <summary>The traction motor blowers of the vehicle running.</summary>
motor_blowers
};
/// <summary>Auto-start method for ancillary devices (mutually exclusive).</summary>
enum class start_t
{
@@ -1257,6 +1269,7 @@ struct TCoupling
double Dist = 0.0; /*strzalka ugiecia zderzaków*/
bool CheckCollision = false; /*czy sprawdzac sile czy pedy*/
float stretch_duration{0.f}; // seconds, elapsed time with excessive force applied to the coupler
bool broken{false}; // the coupler broke (damage_coupler()), until it's repaired (repair_coupler())
// optional adapter piece
double adapter_length{0.0}; // meters, value added on the given end to standard vehicle (half)length
double adapter_height{0.0}; // meters, distance from rail level
@@ -1266,6 +1279,11 @@ struct TCoupling
power_coupling power_110v;
power_coupling power_24v;
// the physical model of the coupling (couplerphysics in eu07.ini), see couplerphysics.h: the parameters of this end,
// and the state of the coupling with the vehicle at this end, which that vehicle keeps alike on its own end
coupler_physics::end_parameters physics;
coupler_physics::pair_state physics_state;
int sounds{0}; // sounds emitted by the coupling devices
bool Render = false; /*ABu: czy rysowac jak zaczepiony sprzeg*/
std::string control_type; // abstraction of control coupling interface and communication standard
@@ -2009,6 +2027,9 @@ class TMoverParameters
glm::vec3 Front{};
std::string Name; /*nazwa wlasna*/
TCoupling Couplers[2]; // urzadzenia zderzno-sprzegowe, polaczenia miedzy wagonami
// the physical coupler model covers the vehicle: it's in the player's train or in one the player's train closes in on
// (vehicle_table::update_coupler_physics()); with couplerphysics all in eu07.ini every vehicle is covered
bool CouplerPhysics{false};
std::array<neighbour_data, 2> Neighbours; // potential collision sources
bool Power110vIsAvailable = false; // cached availability of 110v power
bool Power24vIsAvailable = false; // cached availability of 110v power
@@ -2017,6 +2038,7 @@ class TMoverParameters
int SoundFlag = 0; /*!o patrz stale sound_ */
int AIFlag{0}; // HACK: events of interest for consist owner
double DistCounter = 0.0; /*! licznik kilometrow */
odometer::reading Odometer; // total distance run, kept between the sessions (eu07/maszyna#72)
std::pair<double, double> EnergyMeter; // energy <drawn, returned> from grid [kWh]
double V = 0.0; // predkosc w [m/s] względem sprzęgów (dodania gdy jedzie w stronę 0)
double Vel = 0.0; // moduł prędkości w [km/h], używany przez AI
@@ -2114,6 +2136,9 @@ class TMoverParameters
bool UnlockPipe = false; /*unlockig brake pipe button pressed*/
int BrakeDelayFlag = 0; /*nastawa opoznienia ham. osob/towar/posp/exp 0/1/2/4*/
int BrakeDelays = 0; /*nastawy mozliwe do uzyskania*/
// the AI wagon inspector cut the brake out (b_dmg) and puts it back when the train no longer needs it
// cut out (brake_setting::apply). Anyone else cutting it out or putting it back takes it over
bool BrakeCutOutByInspector = false;
int BrakeOpModeFlag = 0; /*nastawa trybu pracy PS/PN/EP/MED 1/2/4/8*/
int BrakeOpModes = 0; /*nastawy mozliwe do uzyskania*/
bool DynamicBrakeFlag = false; /*czy wlaczony hamulec elektrodymiczny*/
@@ -2150,6 +2175,11 @@ class TMoverParameters
// config, Engine:JointEngineStart. whether the cab's line breaker / engine start switch works the vehicles in multiple
// too; when it doesn't, the cab has separate switches for them (mainb_*, mainc_*)
bool JointEngineStart{true};
// config, .fiz Cntrl.PantRequiresMain: the line breaker closes without traction voltage and holds without it, and the
// pantographs rise and stay up only while it's closed (EU05, EP05, ČD 181 family); off, the pantographs come first and the line
// breaker needs their voltage. what the main circuit feeds still needs the voltage (MainCircuitPowered()), and without
// it the undervoltage relay opens the line contactors (NoVoltRelay)
bool PantographsRequireMains{false};
bool LineBreakerClosesOnlyAtNoPowerPos{false};
bool ControlPressureSwitch{false}; // activates if the main pipe and/or brake cylinder pressure aren't within operational levels
bool HasControlPressureSwitch{true};
@@ -2209,13 +2239,17 @@ class TMoverParameters
start_t GroundRelayStart{start_t::manual}; // relay activation method
bool StLinFlag = false; /*!o styczniki liniowe*/
bool StLinSwitchOff{false}; // state of the button forcing motor connectors open
line_contactors_interlock LineContactorsInterlock{line_contactors_interlock::none}; // what else the line contactors need to close
double LouvresOpenPressure{5.0}; // main reservoir pressure [bar] at which the pneumatic louvres of the motor fans open (ET22)
bool ResistorsFlag = false; /*!o jazda rezystorowa*/
double RventRot = 0.0; /*!s obroty wentylatorow rozruchowych*/
double PantographVoltage{0.0}; // voltage supplied to pantographs
double PantPress = 0.0; /*Cisnienie w zbiornikach pantografow*/
bool PantPressSwitchActive{false}; // state of the pantograph pressure switch. gets primed at defined pressure level in pantograph air system
bool PantPressLockActive{false}; // pwr system state flag. fires when pressure switch activates by pantograph pressure dropping below defined level
bool NoVoltRelay{true}; // switches off if the power level drops below threshold
// switches off if the power level drops below threshold, which opens the line breaker; with PantographsRequireMains
// it opens the line contactors instead, and switches back on only with the master controller at zero or the first position
bool NoVoltRelay{true};
bool OvervoltageRelay{true}; // switches off if the power level goes above threshold
bool s_CAtestebrake = false; // hunter-091012: zmienna dla testu ca
std::array<std::pair<double, double>, 4> PowerCircuits; // 24v, 110v, 3x400v and 3000v power circuits, voltage from local sources and current draw pairs
@@ -2385,6 +2419,10 @@ class TMoverParameters
int DettachStatus(int ConnectNo);
bool Dettach(int ConnectNo);
void damage_coupler(int const End);
// repairs the broken coupler of the end, and the one of the vehicle it was coupled with, so they can be coupled
// again; the vehicles clear their coupler damage once neither of their couplers is broken. returns: whether there
// was a broken coupler to repair
bool repair_coupler(int const End);
void Derail(DerailReason Reason);
bool DirectionForward();
bool DirectionBackward(void); /*! kierunek ruchu*/
@@ -2547,6 +2585,17 @@ class TMoverParameters
double BrakeForceP(double press, double velocity) const;
double BrakeForce(const TTrackParam &Track);
double CouplerForce(int const End, double dt);
// whether the coupling at the end is computed by the physical model: couplerphysics set in eu07.ini, and this
// vehicle or the one at the end covered by it (CouplerPhysics), or every vehicle with couplerphysics all
bool coupler_physics_at(int const End) const;
// the force of the coupling at the end by the physical model (couplerphysics in eu07.ini), see couplerphysics.h
double coupler_force_physical(int const End, double const dt);
// with the physical model: whether the vehicles at the end hit the stop of their springs at the last update and
// still close in on it, so that they collide; a hit hard enough breaks the coupling or crushes the buffers
bool coupler_stop_hit(int const End, TMoverParameters &Other, int const OtherEnd);
// couples the automatic couplers of the end and of the other vehicle pressed against each other, unless the hit
// is too fast for them to catch
void automatic_coupling(int const End, TMoverParameters &Other, int const OtherEnd);
void CollisionDetect(int const End, double const dt);
// closing speed of a collision [km/h] above which the vehicles involved may derail, adjusted for their mass ratio
static constexpr double SafeCollisionVelocity{15.0};
@@ -2592,6 +2641,26 @@ class TMoverParameters
{
return JointEngineStart ? range_t::consist : range_t::local;
}
// whether the pneumatic louvres of the motor fans are still closed, the main reservoir short of the pressure that opens them
bool LouvresClosed() const
{
return Compressor < LouvresOpenPressure;
}
// whether the devices the line contactors are interlocked with (LineContactorsInterlock) let them close
bool LineContactorsInterlockReleased() const;
// whether the line contactors wait for the converter of the vehicle, switched off with its local switch (converterlocal_sw).
// the AI driver doesn't leave it so: the converters of the other vehicles running, it would wait for the contactors forever
bool LineContactorsHeldByLocalConverterSwitch() const
{
return LineContactorsInterlock == line_contactors_interlock::converter && false == ConverterAllowLocal;
}
// whether the vehicle has a driver's cab: it has the driver's brake valve (BrakeHandle in the Cntrl. section of the
// .fiz), which the wagons and most cars of the units without a cab don't (a few copy the Cntrl. section of the cab
// car, as the EN57 s car does). it's the vehicle type's, unlike the cab the scenario puts a driver in
bool HasDriverCab() const
{
return BrakeHandle != TBrakeHandle::NoHandle;
}
// whether the cab command opening the main circuit opens it where the only cab switch of the circuit is the button
// closing it: on a diesel that's the starter button, and the command is the one way to stop an engine whose fuel pump
// starts on its own (eu07/maszyna#427). the other vehicles with such a button keep ignoring the command
@@ -2638,6 +2707,11 @@ class TMoverParameters
bool HeatingSwitch(bool const State, range_t const Notify = range_t::consist);
void HeatingSwitch_(bool const State);
double EnginePowerSourceVoltage() const; // returns voltage of defined main engine power source
// whether the main circuit feeds what runs on it (the converter, a compressor, the heating, the motor and resistor
// blowers, the traction motors): the line breaker closed, and where it closes ahead of the pantographs and holds
// without traction voltage (PantographsRequireMains) also the voltage there, at least the one the undervoltage
// trip takes. everywhere else it's the same as Mains
bool MainCircuitPowered() const;
/*-funkcje typowe dla lokomotywy elektrycznej*/
void LowVoltagePowerCheck(double const Deltatime);
@@ -2650,6 +2724,8 @@ class TMoverParameters
void FuelPumpCheck(double const Timestep);
void OilPumpCheck(double const Timestep);
void MotorBlowersCheck(double const Timestep);
// whether the circuit a traction motor blower runs off has power: the battery, the converter or the main circuit, by its start type
bool MotorBlowerPowerIsAvailable(cooling_fan const &Blower) const;
void PantographsCheck(double const Timestep);
void LightsCheck(double const Timestep);
bool FuseOn(range_t const Notify = range_t::consist); // bezpiecznik nadamiary