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

Merge remote-tracking branch 'origin/master' into feat/mains-before-pantographs

This commit is contained in:
jerrrrycho
2026-11-11 21:12:11 +01:00
85 changed files with 13936 additions and 495 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;
/*
@@ -1255,6 +1257,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
@@ -1264,6 +1267,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
@@ -2007,6 +2015,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
@@ -2015,6 +2026,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
@@ -2112,6 +2124,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*/
@@ -2269,6 +2284,7 @@ class TMoverParameters
int SpeedCtrlAutoTurnOffFlag = 0; /*czy tempomat sam się wyłącza*/
bool EIMCtrlAdditionalZeros = false; /*czy ma dodatkowe zero jazdy i zero hamowania */
bool EIMCtrlEmergency = false; /*czy ma dodatkowe zero jazdy i zero hamowania */
bool EIMCtrlMainEmergency = false; /*czy zadajnik typu 2 (Elf) ma pozycje hamowania naglego ponizej swojej pozycji 0*/
double eimv_pr = 0; /*realizowany procent dostepnej sily rozruchu/hamowania*/
double eimv[21];
static std::vector<std::string> const eimv_labels;
@@ -2386,6 +2402,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*/
@@ -2443,6 +2463,15 @@ class TMoverParameters
int MainCtrlNoPowerPos() const; // highest setting of master controller which won't cause engine to generate extra power
int MainCtrlActualPowerPos() const; // current actual setting of master controller, relative to the highest setting not generating extra power
int MainCtrlPowerPos() const; // current setting of master controller, relative to the highest setting not generating extra power
// positions the master controller of the EIMCtrlType 2 (Elf) has below its own position 0, the emergency brake (0 or 1)
int EIMCtrlEmergencyPositions() const;
// whether the master controller is in its emergency brake position (EIMCtrlType 2 with EIMCtrlMainEmergency)
bool IsMainCtrlEmergencyPos() const;
// the master controller position sent to the coupled vehicles ("MainCtrl"), the same with and without
// EIMCtrlMainEmergency: the Elf's positions without the emergency brake one, which goes as the full braking
int MainCtrlPosForCoupled() const;
// the master controller position of this vehicle for one received from a coupled vehicle ("MainCtrl")
int MainCtrlPosFromCoupled(int Position) const;
/*! pomocniczy nastawnik:*/
bool IncScndCtrl(int CtrlSpeed);
bool DecScndCtrl(int CtrlSpeed);
@@ -2523,6 +2552,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};
@@ -2568,6 +2608,13 @@ class TMoverParameters
{
return JointEngineStart ? range_t::consist : range_t::local;
}
// 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