17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-06 19:48:35 +01:00

fix(sonar): addressing reliability/security issues

This commit is contained in:
jerrrrycho
2026-10-03 20:21:28 +02:00
parent 51521a135a
commit d88fa5d8e2
32 changed files with 189 additions and 162 deletions

View File

@@ -1732,7 +1732,11 @@ class TMoverParameters
// bounds-safe read access to MotorParam
TMotorParameters const &motor_param(int const Position) const
{
return MotorParam[std::clamp(Position, 0, MotorParametersArraySize)];
if (Position < 0)
return MotorParam[0];
if (Position > MotorParametersArraySize)
return MotorParam[MotorParametersArraySize];
return MotorParam[Position];
}
TTransmision Transmision;
// record {liczba zebow przekladni}

View File

@@ -1752,6 +1752,11 @@ void TMoverParameters::LowVoltagePowerCheck(double const Deltatime)
void TMoverParameters::PowerCouplersCheck(double const Deltatime, coupling const Coupling)
{
if (Coupling != coupling::highvoltage && Coupling != coupling::power110v && Coupling != coupling::power24v)
{
// only power couplings carry voltage
return;
}
auto localvoltage{0.0};
@@ -6392,10 +6397,7 @@ double TMoverParameters::TractionForce(double dt)
// PosRatio = 1.0 * (PosRatio * 0 + 1) * PosRatio; // 1 * 1 * PosRatio = PosRatio
Hamulec->SetED(0);
// (Hamulec as TLSt).SetLBP(LocBrakePress);
if (PosRatio > eimv_pr)
tmp = 4;
else
tmp = 4; // szybkie malenie, powolne wzrastanie
tmp = 4; // szybkie malenie, powolne wzrastanie
}
dmoment = eimv[eimv_Fful];
// NOTE: the commands to operate the sandbox are likely to conflict with other similar ai decisions
@@ -8022,8 +8024,6 @@ double TMoverParameters::dizel_fillcheck(int mcp, double dt)
}
if (enrot > nreg) // nad predkoscia regulatora zeruj dawke
realfill = 0;
if (enrot < nreg) // pod predkoscia regulatora dawka zadana
realfill = realfill;
if (enrot < dizel_nreg_min && RList[mcp].R > 0.001) // jesli ponizej biegu jalowego i niezerowa dawka, to dawaj pelna
realfill = 1;
}
@@ -9118,7 +9118,7 @@ bool TMoverParameters::readMPT0(std::string const &line)
}
if (true == parser.getTokens(1, false))
{
int autoswitch;
int autoswitch{0};
parser >> autoswitch;
MotorParam[idx].AutoSwitch = autoswitch == 1;
}
@@ -9174,7 +9174,7 @@ bool TMoverParameters::readMPTElectricSeries(std::string const &line)
parser >> MotorParam[idx].mfi >> MotorParam[idx].mIsat >> MotorParam[idx].fi >> MotorParam[idx].Isat;
if (true == parser.getTokens(1, false))
{
int autoswitch;
int autoswitch{0};
parser >> autoswitch;
MotorParam[idx].AutoSwitch = autoswitch == 1;
}
@@ -9223,7 +9223,7 @@ bool TMoverParameters::readMPTDieselEngine(std::string const &line)
parser >> MotorParam[idx].mIsat >> MotorParam[idx].fi >> MotorParam[idx].mfi;
if (true == parser.getTokens(1, false))
{
int autoswitch;
int autoswitch{0};
parser >> autoswitch;
MotorParam[idx].AutoSwitch = autoswitch == 1;
}
@@ -11048,7 +11048,7 @@ void TMoverParameters::LoadFIZ_DCEMUED(std::string const &line)
void TMoverParameters::LoadFIZ_SpringBrake(std::string const &line)
{
double vol;
double vol{1.0};
extract_value(vol, "Volume", line, "1");
if (!SpringBrake.Cylinder)
SpringBrake.Cylinder = std::make_shared<TReservoir>();

View File

@@ -3516,10 +3516,7 @@ double TMHZ_K5P::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
LimCP = std::min(LimCP, HP); // pozycja + czasowy lub zasilanie
ActFlowSpeed = 4;
if (LimCP > CP) // podwyzszanie szybkie
CP = CP + 9 * std::min(abs(LimCP - CP), 0.05) * PR(CP, LimCP) * dt; // zbiornik sterujacy;
else
CP = CP + 9 * std::min(abs(LimCP - CP), 0.05) * PR(CP, LimCP) * dt; // zbiornik sterujacy
CP = CP + 9 * std::min(abs(LimCP - CP), 0.05) * PR(CP, LimCP) * dt; // zbiornik sterujacy
double uop = UnbrakeOverPressure; // unbrake over pressure in actual state
ManualOvrldActive = UniversalFlag & TUniversalBrake::ub_HighPressure; // button is pressed
@@ -3699,10 +3696,7 @@ double TMHZ_6P::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
LimCP = std::min(LimCP, HP); // pozycja + czasowy lub zasilanie
ActFlowSpeed = 4;
if (LimCP > CP) // podwyzszanie szybkie
CP = CP + 9 * std::min(abs(LimCP - CP), 0.05) * PR(CP, LimCP) * dt; // zbiornik sterujacy;
else
CP = CP + 9 * std::min(abs(LimCP - CP), 0.05) * PR(CP, LimCP) * dt; // zbiornik sterujacy
CP = CP + 9 * std::min(abs(LimCP - CP), 0.05) * PR(CP, LimCP) * dt; // zbiornik sterujacy
dpPipe = std::min(HP, CP + TP + RedAdj);