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

refactor(sonar): split chained assignments (cpp:S1121)

This commit is contained in:
jerrrrycho
2026-10-10 16:16:50 +02:00
parent 2d1cac601e
commit 6b77352293
4 changed files with 58 additions and 18 deletions

View File

@@ -489,7 +489,9 @@ TMoverParameters::TMoverParameters(double VelInitial, std::string TypeNameInit,
for (int k = 1; k < 9; ++k) for (int k = 1; k < 9; ++k)
compressorrow[k] = 0; compressorrow[k] = 0;
CompressorList[0][0] = 0.0; CompressorList[0][0] = 0.0;
CompressorList[1][0] = CompressorList[2][0] = CompressorList[3][0] = 1.0; CompressorList[1][0] = 1.0;
CompressorList[2][0] = 1.0;
CompressorList[3][0] = 1.0;
for (int b = -1; b <= MainBrakeMaxPos; ++b) for (int b = -1; b <= MainBrakeMaxPos; ++b)
{ {
@@ -669,8 +671,8 @@ bool TMoverParameters::Dettach(int ConnectNo)
if (couplingstate < 0) if (couplingstate < 0)
{ {
// gdy scisniete zderzaki, chyba ze zerwany sprzeg (wirtualnego nie odpinamy z drugiej strony) // gdy scisniete zderzaki, chyba ze zerwany sprzeg (wirtualnego nie odpinamy z drugiej strony)
std::tie(coupler.Connected, coupler.ConnectedNr, coupler.CouplingFlag) = std::tie(othercoupler.Connected, othercoupler.ConnectedNr, othercoupler.CouplingFlag) = std::tie(othercoupler.Connected, othercoupler.ConnectedNr, othercoupler.CouplingFlag) = std::make_tuple(nullptr, -1, coupling::faux);
std::make_tuple(nullptr, -1, coupling::faux); std::tie(coupler.Connected, coupler.ConnectedNr, coupler.CouplingFlag) = std::make_tuple(nullptr, -1, coupling::faux);
} }
else if (couplingstate > 0) else if (couplingstate > 0)
{ // odłączamy węże i resztę, pozostaje sprzęg fizyczny, który wymaga dociśnięcia (z wirtualnym nic) { // odłączamy węże i resztę, pozostaje sprzęg fizyczny, który wymaga dociśnięcia (z wirtualnym nic)
@@ -8187,8 +8189,16 @@ double TMoverParameters::dizel_MomentumRetarder(double n, double dt)
void TMoverParameters::dizel_HeatSet(float const Value) void TMoverParameters::dizel_HeatSet(float const Value)
{ {
dizel_heat.Te = // TODO: don't include ambient temperature, pull it from environment data instead // TODO: don't include ambient temperature, pull it from environment data instead
dizel_heat.Ts = dizel_heat.To = dizel_heat.Tsr = dizel_heat.Twy = dizel_heat.Tsr2 = dizel_heat.Twy2 = dizel_heat.temperatura1 = dizel_heat.temperatura2 = Value; dizel_heat.Te = Value;
dizel_heat.Ts = Value;
dizel_heat.To = Value;
dizel_heat.Tsr = Value;
dizel_heat.Twy = Value;
dizel_heat.Tsr2 = Value;
dizel_heat.Twy2 = Value;
dizel_heat.temperatura1 = Value;
dizel_heat.temperatura2 = Value;
} }
// calculates diesel engine temperature and heat transfers // calculates diesel engine temperature and heat transfers
@@ -10929,7 +10939,8 @@ void TMoverParameters::LoadFIZ_Cntrl(std::string const &line)
// traction motor fans // traction motor fans
{ {
auto lookup = starts.find(extract_value("MotorBlowersStart", line)); auto lookup = starts.find(extract_value("MotorBlowersStart", line));
MotorBlowers[end::front].start_type = MotorBlowers[end::rear].start_type = lookup != starts.end() ? lookup->second : start_t::manual; MotorBlowers[end::rear].start_type = lookup != starts.end() ? lookup->second : start_t::manual;
MotorBlowers[end::front].start_type = MotorBlowers[end::rear].start_type;
} }
// compartment lights // compartment lights
{ {

View File

@@ -76,7 +76,11 @@ inline float3 SafeNormalize(const float3 &v)
auto const l = v.Length(); auto const l = v.Length();
float3 retVal; float3 retVal;
if (l == 0) if (l == 0)
retVal.x = retVal.y = retVal.z = 0; {
retVal.x = 0;
retVal.y = 0;
retVal.z = 0;
}
else else
retVal = v / l; retVal = v / l;
return retVal; return retVal;
@@ -104,7 +108,9 @@ class float4
float w; float w;
float4() float4()
{ {
x = y = z = 0.f; x = 0.f;
y = 0.f;
z = 0.f;
w = 1.f; w = 1.f;
}; };
float4(float a, float b, float c, float d) float4(float a, float b, float c, float d)
@@ -236,7 +242,10 @@ public:
{ {
for (auto &element : e) for (auto &element : e)
element = 0; element = 0;
e[0] = e[5] = e[10] = e[15] = 1.0f; e[0] = 1.0f;
e[5] = 1.0f;
e[10] = 1.0f;
e[15] = 1.0f;
} }
const float *operator[](int i) const const float *operator[](int i) const
{ {

View File

@@ -589,7 +589,8 @@ TTrain::TTrain()
// McZapkie-240302 - przyda sie do tachometru // McZapkie-240302 - przyda sie do tachometru
fTachoVelocity = 0; fTachoVelocity = 0;
fTachoCount = 0; fTachoCount = 0;
fPPress = fNPress = 0; fPPress = 0;
fNPress = 0;
// asMessage=""; // asMessage="";
pMechOffset = glm::dvec3(0, 0, 0); pMechOffset = glm::dvec3(0, 0, 0);
@@ -628,7 +629,8 @@ TTrain::TTrain()
{ {
for (auto &press : fPress[i]) for (auto &press : fPress[i])
press = 0.0; press = 0.0;
bBrakes[i][0] = bBrakes[i][1] = false; bBrakes[i][0] = false;
bBrakes[i][1] = false;
} }
} }
@@ -8522,7 +8524,12 @@ bool TTrain::Update(double const Deltatime)
fHCurrent[3] = static_cast<float>(mvSecond->ShowCurrent(3) * 1.05); fHCurrent[3] = static_cast<float>(mvSecond->ShowCurrent(3) * 1.05);
} }
else else
fHCurrent[0] = fHCurrent[1] = fHCurrent[2] = fHCurrent[3] = 0.0; // gdy nie ma człona {
fHCurrent[0] = 0.0; // gdy nie ma człona
fHCurrent[1] = 0.0;
fHCurrent[2] = 0.0;
fHCurrent[3] = 0.0;
}
} }
else else
{ // normalne pokazywanie { // normalne pokazywanie
@@ -8649,9 +8656,19 @@ bool TTrain::Update(double const Deltatime)
} }
else else
{ {
fPress[i][0] = fPress[i][1] = fPress[i][2] = fPress[i][3] = fPress[i][4] = fPress[i][5] = 0; fPress[i][0] = 0;
bDoors[i][0] = bDoors[i][1] = bDoors[i][2] = bDoors[i][3] = bDoors[i][4] = false; fPress[i][1] = 0;
bBrakes[i][0] = bBrakes[i][1] = false; fPress[i][2] = 0;
fPress[i][3] = 0;
fPress[i][4] = 0;
fPress[i][5] = 0;
bDoors[i][0] = false;
bDoors[i][1] = false;
bDoors[i][2] = false;
bDoors[i][3] = false;
bDoors[i][4] = false;
bBrakes[i][0] = false;
bBrakes[i][1] = false;
bSlip[i] = false; bSlip[i] = false;
iUnits[i] = 0; iUnits[i] = 0;
cCode[i] = 0; //'0'; cCode[i] = 0; //'0';
@@ -10692,7 +10709,8 @@ void TTrain::DynamicSet(TDynamicObject *d)
// jeździć dobrze // jeździć dobrze
// również hamowanie wykonuje się zaworem w członie, a nie w silnikowym... // również hamowanie wykonuje się zaworem w członie, a nie w silnikowym...
DynamicObject = d; // jedyne miejsce zmiany DynamicObject = d; // jedyne miejsce zmiany
mvOccupied = mvControlled = d ? DynamicObject->MoverParameters : nullptr; // albo silnikowy w EZT mvControlled = d ? DynamicObject->MoverParameters : nullptr; // albo silnikowy w EZT
mvOccupied = mvControlled;
if (DynamicObject == nullptr) if (DynamicObject == nullptr)
{ {

View File

@@ -463,9 +463,11 @@ void TTraction::PowerSet(TTractionPowerSource *ps)
else else
{ // ustalenie punktu zasilania (nie ma jeszcze połączeń między przęsłami) { // ustalenie punktu zasilania (nie ma jeszcze połączeń między przęsłami)
psPowered = ps; // ustawienie bezpośredniego zasilania dla przęsła psPowered = ps; // ustawienie bezpośredniego zasilania dla przęsła
psPower[0] = psPower[1] = ps; // a to chyba nie jest dobry pomysł, bo nawet zasilane przęsło psPower[0] = ps; // a to chyba nie jest dobry pomysł, bo nawet zasilane przęsło
psPower[1] = ps;
// powinno mieć wskazania na inne // powinno mieć wskazania na inne
fResistance[0] = fResistance[1] = 0.0; // a liczy się tylko rezystancja zasilacza fResistance[0] = 0.0; // a liczy się tylko rezystancja zasilacza
fResistance[1] = 0.0;
} }
}; };