diff --git a/Console/PoKeys55.cpp b/Console/PoKeys55.cpp
index 2f82bbb0..40d23c83 100644
--- a/Console/PoKeys55.cpp
+++ b/Console/PoKeys55.cpp
@@ -145,7 +145,7 @@ bool TPoKeys55::Connect()
DeviceIDFromRegistry = ToLower( DeviceIDFromRegistry );
DeviceIDToFind = ToLower( DeviceIDToFind );
// Now check if the hardware ID we are looking at contains the correct VID/PID
- MatchFound = ( contains( DeviceIDFromRegistry, DeviceIDToFind ) );
+ MatchFound = contains(DeviceIDFromRegistry, DeviceIDToFind);
if (MatchFound == true)
{
// Device must have been found. Open read and write handles. In order to do this,we
@@ -160,7 +160,7 @@ bool TPoKeys55::Connect()
SetupDiGetDeviceInterfaceDetail(DeviceInfoTable, InterfaceDataStructure, nullptr, 0,
&StructureSize, nullptr);
DetailedInterfaceDataStructure =
- (PSP_DEVICE_INTERFACE_DETAIL_DATA)(malloc(StructureSize)); // Allocate enough memory
+ (PSP_DEVICE_INTERFACE_DETAIL_DATA)malloc(StructureSize); // Allocate enough memory
if (DetailedInterfaceDataStructure == nullptr) // if null,error,couldn't allocate enough memory
{ // Can't really recover from this situation,just exit instead.
SetupDiDestroyDeviceInfoList(
@@ -175,12 +175,12 @@ bool TPoKeys55::Connect()
// the device.
// We store the handles in the global variables "WriteHandle" and "ReadHandle",which we
// will use later to actually communicate.
- WriteHandle = CreateFile((DetailedInterfaceDataStructure->DevicePath), GENERIC_WRITE,
+ WriteHandle = CreateFile(DetailedInterfaceDataStructure->DevicePath, GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, 0, 0);
ErrorStatus = GetLastError();
// if (ErrorStatus==ERROR_SUCCESS)
// ToggleLedBtn->Enabled=true;//Make button no longer greyed out
- ReadHandle = CreateFile((DetailedInterfaceDataStructure->DevicePath), GENERIC_READ,
+ ReadHandle = CreateFile(DetailedInterfaceDataStructure->DevicePath, GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, 0, 0);
ErrorStatus = GetLastError();
if (ErrorStatus == ERROR_SUCCESS)
@@ -222,7 +222,7 @@ bool TPoKeys55::Write(unsigned char c, unsigned char b3, unsigned char b4, unsig
// The following call to WriteFile() sends 64 bytes of data to the USB device.
WriteFile(WriteHandle, &OutputBuffer, 65, &BytesWritten,
0); // Blocking function, unless an "overlapped" structure is used
- return (BytesWritten == 65);
+ return BytesWritten == 65;
// Read(); //odczyt trzeba zrobić inaczej - w tym miejscu będzie za szybko i nic się nie odczyta
}
@@ -240,7 +240,7 @@ bool TPoKeys55::Read()
// InputPacketBuffer[0] is the report ID, which we don't care about.
// InputPacketBuffer[1] is an echo back of the command.
// InputPacketBuffer[2] contains the I/O port pin value for the pushbutton.
- return (BytesRead == 65) ? InputBuffer[7] == cRequest : false;
+ return BytesRead == 65 ? InputBuffer[7] == cRequest : false;
}
//---------------------------------------------------------------------------
bool TPoKeys55::ReadLoop(int i)
@@ -305,13 +305,13 @@ bool TPoKeys55::Update(bool pause)
{
case 0: // uaktualnienie PWM raz na jakiś czas
OutputBuffer[9] = 0x3F; // maska użytych PWM
- *((int *)(OutputBuffer + 10)) = iPWM[0]; // PWM1 (pin 22)
- *((int *)(OutputBuffer + 14)) = iPWM[1]; // PWM2 (pin 21)
- *((int *)(OutputBuffer + 18)) = iPWM[2]; // PWM3 (pin 20)
- *((int *)(OutputBuffer + 22)) = iPWM[3]; // PWM4 (pin 19)
- *((int *)(OutputBuffer + 26)) = iPWM[4]; // PWM5 (pin 18)
- *((int *)(OutputBuffer + 30)) = iPWM[5]; // PWM6 (pin 17)
- *((int *)(OutputBuffer + 34)) = iPWM[7]; // PWM period
+ *(int *)(OutputBuffer + 10) = iPWM[0]; // PWM1 (pin 22)
+ *(int *)(OutputBuffer + 14) = iPWM[1]; // PWM2 (pin 21)
+ *(int *)(OutputBuffer + 18) = iPWM[2]; // PWM3 (pin 20)
+ *(int *)(OutputBuffer + 22) = iPWM[3]; // PWM4 (pin 19)
+ *(int *)(OutputBuffer + 26) = iPWM[4]; // PWM5 (pin 18)
+ *(int *)(OutputBuffer + 30) = iPWM[5]; // PWM6 (pin 17)
+ *(int *)(OutputBuffer + 34) = iPWM[7]; // PWM period
if (Write(0xCB, 1)) // wysłanie ustawień (1-ustaw, 0-odczyt)
iRepeats = 0; // informacja, że poszło dobrze
++iFaza; // ta faza została zakończona
@@ -340,7 +340,7 @@ bool TPoKeys55::Update(bool pause)
Write(0x31, 0); // 0x31: blokowy odczyt wejść
else if (Read())
{ // jest odebrana ramka i zgodność numeru żądania
- iInputs[0] = *((int *)(InputBuffer + 3)); // odczyt 32 bitów
+ iInputs[0] = *(int *)(InputBuffer + 3); // odczyt 32 bitów
iFaza = 3; // skoro odczytano, można kolejny cykl
iRepeats = 0; // zerowanie licznika prób
}
@@ -348,7 +348,7 @@ bool TPoKeys55::Update(bool pause)
++iRepeats; // licznik nieudanych prób
break;
case 3: // ustawienie wyjść analogowych, 0..4095 mapować na 0..65520 (<<4)
- if (Write(0x41, 43 - 1, (iPWM[6] >> 4), (iPWM[6] << 4))) // wysłanie ustawień
+ if (Write(0x41, 43 - 1, iPWM[6] >> 4, iPWM[6] << 4)) // wysłanie ustawień
iRepeats = 0; // informacja, że poszło dobrze
iFaza = 0; //++iFaza; //ta faza została zakończona
// powinno jeszcze przyjść potwierdzenie o kodzie 0x41
@@ -366,7 +366,7 @@ bool TPoKeys55::Update(bool pause)
iRepeats = 1; // w nowej fazie nowe szanse, ale nie od 0!
bNoError = false; // zgłosić błąd
}
- return (bNoError); // true oznacza prawidłowe działanie
+ return bNoError; // true oznacza prawidłowe działanie
// czy w przypadku błędu komunikacji z PoKeys włączać pauzę?
// dopiero poprawne podłączenie zeruje licznik prób
};
diff --git a/McZapkie/MOVER.h b/McZapkie/MOVER.h
index 34650052..cd046eba 100644
--- a/McZapkie/MOVER.h
+++ b/McZapkie/MOVER.h
@@ -300,26 +300,26 @@ enum light
{
/// Headlight, left.
- headlight_left = (1 << 0),
+ headlight_left = 1 << 0,
/// Red marker, left.
- redmarker_left = (1 << 1),
+ redmarker_left = 1 << 1,
/// Headlight, upper centre.
- headlight_upper = (1 << 2),
+ headlight_upper = 1 << 2,
// TBD, TODO: redmarker_upper support?
/// Headlight, right.
- headlight_right = (1 << 4),
+ headlight_right = 1 << 4,
/// Red marker, right.
- redmarker_right = (1 << 5),
+ redmarker_right = 1 << 5,
/// Rear-end markers (combined).
- rearendsignals = (1 << 6),
+ rearendsignals = 1 << 6,
/// Auxiliary light, left (e.g. ditch light).
- auxiliary_left = (1 << 7),
+ auxiliary_left = 1 << 7,
/// Auxiliary light, right.
- auxiliary_right = (1 << 8),
+ auxiliary_right = 1 << 8,
/// High-beam headlight, left.
- highbeamlight_left = (1 << 9),
+ highbeamlight_left = 1 << 9,
/// High-beam headlight, right.
- highbeamlight_right = (1 << 10)
+ highbeamlight_right = 1 << 10
};
/// Door operation method (who controls them and how) — mutually exclusive.
@@ -1211,8 +1211,8 @@ struct TCoupling
double beta = 0.0;
TCouplerType CouplerType = TCouplerType::NoCoupler; /*typ sprzegu*/
int AutomaticCouplingFlag = coupling::coupler;
- int AllowedFlag = (coupling::coupler | coupling::brakehose); // Ra: maska dostępnych
- int PowerFlag = (coupling::power110v | coupling::power24v);
+ int AllowedFlag = coupling::coupler | coupling::brakehose; // Ra: maska dostępnych
+ int PowerFlag = coupling::power110v | coupling::power24v;
int PowerCoupling = coupling::permanent; // type of coupling required for power transfer
/*zmienne*/
bool AutomaticCouplingAllowed{true}; // whether automatic coupling can be currently performed
@@ -1238,11 +1238,11 @@ struct TCoupling
inline bool has_adapter() const
{
- return (adapter_type != TCouplerType::NoCoupler);
+ return adapter_type != TCouplerType::NoCoupler;
}
inline TCouplerType const type() const
{
- return (adapter_type == TCouplerType::NoCoupler ? CouplerType : adapter_type);
+ return adapter_type == TCouplerType::NoCoupler ? CouplerType : adapter_type;
}
};
@@ -2092,7 +2092,7 @@ class TMoverParameters
bool CabMaster = false; // czy pojazd jest nadrzędny w składzie
inline bool IsCabMaster()
{
- return ((CabActive == CabOccupied) && CabMaster);
+ return CabActive == CabOccupied && CabMaster;
} // czy aktualna kabina jest na pewno tą, z której można sterować
bool AutomaticCabActivation = true; // czy zmostkowany rozrzad przelacza sie sam przy zmianie kabiny
int InactiveCabFlag = 0; // co sie dzieje przy dezaktywacji kabiny
@@ -2300,7 +2300,7 @@ class TMoverParameters
bool EIMDirectionChangeAllow(void) const;
inline double IsVehicleEIMBrakingFactor()
{
- return ((DynamicBrakeFlag && ResistorsFlag) ? 0.0 : eimv[eimv_Ipoj] < 0 ? -1.0 : 1.0);
+ return DynamicBrakeFlag && ResistorsFlag ? 0.0 : eimv[eimv_Ipoj] < 0 ? -1.0 : 1.0;
}
void BrakeLevelSet(double b);
bool BrakeLevelAdd(double b);
@@ -2317,7 +2317,7 @@ class TMoverParameters
double ShowEngineRotation(int VehN);
// Q *******************************************************************************************
- double GetTrainsetVoltage(int const Coupling = (coupling::heating | coupling::highvoltage)) const;
+ double GetTrainsetVoltage(int const Coupling = coupling::heating | coupling::highvoltage) const;
double GetTrainsetHighVoltage() const;
bool switch_physics(bool const State);
double LocalBrakeRatio(void);
diff --git a/McZapkie/Mover.cpp b/McZapkie/Mover.cpp
index ad4869c6..769d0136 100644
--- a/McZapkie/Mover.cpp
+++ b/McZapkie/Mover.cpp
@@ -42,7 +42,7 @@ double ComputeCollision(double &v1, double &v2, double m1, double m2, double bet
{ // oblicza zmiane predkosci i przyrost pedu wskutek kolizji
assert(beta < 1.0);
- if ((v1 < v2) && (vc == true))
+ if (v1 < v2 && vc == true)
return 0;
else
{
@@ -57,7 +57,7 @@ double ComputeCollision(double &v1, double &v2, double m1, double m2, double bet
int DirPatch(int Coupler1, int Coupler2)
{ // poprawka dla liczenia sil przy ustawieniu przeciwnym obiektow
- return (Coupler1 != Coupler2 ? 1 : -1);
+ return Coupler1 != Coupler2 ? 1 : -1;
}
int DirF(int CouplerN)
@@ -131,7 +131,7 @@ void TSecuritySystem::update(double dt, double vel, bool pwr, int cab)
}
bool just_powered_on = !power && pwr;
- bool just_activated = CabDependent && (cabactive != cab);
+ bool just_activated = CabDependent && cabactive != cab;
/* enabling battery */
if (cabsignal_enabled && (just_powered_on || just_activated))
@@ -275,7 +275,7 @@ double TableInterpolation(std::map &Map, double Parameter)
upper--;
}
double ratio = (upper->second - lower->second) / (upper->first - lower->first);
- return (lower->second + (Parameter - lower->first) * ratio);
+ return lower->second + (Parameter - lower->first) * ratio;
}
// *************************************************************************************************
@@ -298,17 +298,17 @@ double TMoverParameters::Current(double n, double U)
MotorCurrent = 0;
// i dzialanie hamulca ED w EP09
- if ((DynamicBrakeType == dbrake_automatic) && (TrainType != dt_EZT))
+ if (DynamicBrakeType == dbrake_automatic && TrainType != dt_EZT)
{
- if (((Hamulec->GetEDBCP() < 0.25) && (Vadd < 1)) || (BrakePress > 2.1))
+ if ((Hamulec->GetEDBCP() < 0.25 && Vadd < 1) || BrakePress > 2.1)
DynamicBrakeFlag = false;
- else if ((BrakePress > 0.25) && (Hamulec->GetEDBCP() > 0.25))
+ else if (BrakePress > 0.25 && Hamulec->GetEDBCP() > 0.25)
DynamicBrakeFlag = true;
- DynamicBrakeFlag = (DynamicBrakeFlag && Power110vIsAvailable);
+ DynamicBrakeFlag = DynamicBrakeFlag && Power110vIsAvailable;
}
- if ((DynamicBrakeType == dbrake_automatic) && (TrainType == dt_EZT))
+ if (DynamicBrakeType == dbrake_automatic && TrainType == dt_EZT)
{
- DynamicBrakeFlag = (Power110vIsAvailable && (TUHEX_Active || (Vadd > TUHEX_MinIw)) && DynamicBrakeEMUStatus);
+ DynamicBrakeFlag = Power110vIsAvailable && (TUHEX_Active || Vadd > TUHEX_MinIw) && DynamicBrakeEMUStatus;
}
// wylacznik cisnieniowy yBARC - to jest chyba niepotrzebne tutaj Q: no to usuwam...
@@ -327,17 +327,17 @@ double TMoverParameters::Current(double n, double U)
//- WriteLog("B");
}
- ResistorsFlag = (RList[MainCtrlActualPos].R > 0.01); // and (!DelayCtrlFlag)
- ResistorsFlag = (ResistorsFlag || ((DynamicBrakeFlag == true) && (DynamicBrakeType == dbrake_automatic)));
+ ResistorsFlag = RList[MainCtrlActualPos].R > 0.01; // and (!DelayCtrlFlag)
+ ResistorsFlag = ResistorsFlag || (DynamicBrakeFlag == true && DynamicBrakeType == dbrake_automatic);
- if ((TrainType == dt_ET22) && (DelayCtrlFlag) && (MainCtrlActualPos > 1))
+ if (TrainType == dt_ET22 && DelayCtrlFlag && MainCtrlActualPos > 1)
Bn = 1.0 - 1.0 / RList[MainCtrlActualPos].Bn;
else
Bn = 1; // to jest wykonywane dla EU07
R = RList[MainCtrlActualPos].R * Bn + CircuitRes;
- if ((TrainType != dt_EZT) || (Imin != IminLo) || (false == ScndS))
+ if (TrainType != dt_EZT || Imin != IminLo || false == ScndS)
{
// yBARC - boczniki na szeregu poprawnie
Mn = RList[MainCtrlActualPos].Mn; // to jest wykonywane dla EU07
@@ -352,12 +352,12 @@ double TMoverParameters::Current(double n, double U)
}
}
- if (DynamicBrakeFlag && (!FuseFlag) && (DynamicBrakeType == dbrake_automatic) && Power110vIsAvailable && Mains) // hamowanie EP09 //TUHEX
+ if (DynamicBrakeFlag && !FuseFlag && DynamicBrakeType == dbrake_automatic && Power110vIsAvailable && Mains) // hamowanie EP09 //TUHEX
{
// TODO: zrobic bardziej uniwersalne nie tylko dla EP09
MotorCurrent = -std::max(MotorParam[0].fi * (Vadd / (Vadd + MotorParam[0].Isat) - MotorParam[0].fi0), 0.) * n * 2.0 / DynamicBrakeRes;
}
- else if ((RList[MainCtrlActualPos].Bn == 0) || (false == StLinFlag))
+ else if (RList[MainCtrlActualPos].Bn == 0 || false == StLinFlag)
{
// wylaczone
MotorCurrent = 0;
@@ -368,7 +368,7 @@ double TMoverParameters::Current(double n, double U)
if (ScndCtrlActualPos < 255) // tak smiesznie bede wylaczal
{
- if ((ScndInMain) && (RList[MainCtrlActualPos].ScndAct != 255))
+ if (ScndInMain && RList[MainCtrlActualPos].ScndAct != 255)
{
SP = RList[MainCtrlActualPos].ScndAct;
}
@@ -387,7 +387,7 @@ double TMoverParameters::Current(double n, double U)
Delta:=SQR(Isf*Rz+Mn*fi*n-U)+4*U*Isf*Rz;
MotorCurrent:=(U-Isf*Rz-Mn*fi*n+SQRT(Delta))/(2*Rz)
end*/
- if ((DynamicBrakeType == dbrake_switch) && (TrainType == dt_ET42))
+ if (DynamicBrakeType == dbrake_switch && TrainType == dt_ET42)
{ // z Megapacka
Rz = WindingRes + R;
MotorCurrent = -MotorParam[SP].fi * n / Rz; //{hamowanie silnikiem na oporach rozruchowych}
@@ -426,7 +426,7 @@ double TMoverParameters::Current(double n, double U)
}
// writepaslog("MotorCurrent ", FloatToStr(MotorCurrent));
- if ((DynamicBrakeType == dbrake_switch) && ((BrakePress > 2.0) || (PipePress < 3.6)))
+ if (DynamicBrakeType == dbrake_switch && (BrakePress > 2.0 || PipePress < 3.6))
{
Im = 0;
MotorCurrent = 0;
@@ -450,9 +450,9 @@ double TMoverParameters::Current(double n, double U)
if (FuzzyLogic(MotorCurrent, (double)ImaxLo / 10.0, p_elengproblem))
if (MainSwitch(false))
EventFlag = true; /*uszkodzony silnik (uplywy)*/
- if ((FuzzyLogic(abs(Im), Imax * 2, p_elengproblem) || FuzzyLogic(abs(n), nmax * 1.11, p_elengproblem)))
+ if (FuzzyLogic(abs(Im), Imax * 2, p_elengproblem) || FuzzyLogic(abs(n), nmax * 1.11, p_elengproblem))
/* or FuzzyLogic(Abs(U/Mn),2*NominalVoltage,1)) then */ /*poprawic potem*/
- if ((SetFlag(DamageFlag, dtrain_engine)))
+ if (SetFlag(DamageFlag, dtrain_engine))
EventFlag = true;
/*! dorobic grzanie oporow rozruchowych i silnika*/
}
@@ -587,7 +587,7 @@ bool TMoverParameters::Attach(int ConnectNo, int ConnectToNr, TMoverParameters *
// Ra: zwykle wykonywane dwukrotnie, dla każdego pojazdu oddzielnie
// Ra: trzeba by odróżnić wymóg dociśnięcia od uszkodzenia sprzęgu przy podczepianiu AI do składu
- if ((ConnectTo == nullptr) || (CouplingType == coupling::faux))
+ if (ConnectTo == nullptr || CouplingType == coupling::faux)
{
return false;
}
@@ -596,7 +596,7 @@ bool TMoverParameters::Attach(int ConnectNo, int ConnectToNr, TMoverParameters *
auto &othercoupler = ConnectTo->Couplers[(ConnectToNr != 2 ? ConnectToNr : coupler.ConnectedNr)];
auto const distance{CouplerDist(this, ConnectTo) - (coupler.adapter_length + othercoupler.adapter_length)};
- auto const couplercheck{(Enforce) || ((distance <= dEpsilon) && (coupler.type() != TCouplerType::NoCoupler) && (coupler.type() == othercoupler.type()))};
+ auto const couplercheck{Enforce || (distance <= dEpsilon && coupler.type() != TCouplerType::NoCoupler && coupler.type() == othercoupler.type())};
if (false == couplercheck)
{
@@ -621,7 +621,7 @@ bool TMoverParameters::Attach(int ConnectNo, int ConnectToNr, TMoverParameters *
othercoupler.CouplingFlag = CouplingType;
othercoupler.ConnectedNr = ConnectNo;
- if ((true == Audible) && (couplingchange != 0))
+ if (true == Audible && couplingchange != 0)
{
// set sound event flag
int soundflag{sound::none};
@@ -651,9 +651,9 @@ int TMoverParameters::DettachStatus(int ConnectNo)
if (TestFlag(DamageFlag, dtrain_coupling))
return -Couplers[ConnectNo].CouplingFlag; // hak urwany - rozłączanie jest OK
// CouplerDist(ConnectNo);
- if ((Couplers[ConnectNo].type() != TCouplerType::Screw) || (Neighbours[ConnectNo].distance < 0.01))
+ if (Couplers[ConnectNo].type() != TCouplerType::Screw || Neighbours[ConnectNo].distance < 0.01)
return -Couplers[ConnectNo].CouplingFlag; // można rozłączać, jeśli dociśnięty
- return (Neighbours[ConnectNo].distance > 0.2) ? -Couplers[ConnectNo].CouplingFlag : Couplers[ConnectNo].CouplingFlag;
+ return Neighbours[ConnectNo].distance > 0.2 ? -Couplers[ConnectNo].CouplingFlag : Couplers[ConnectNo].CouplingFlag;
};
bool TMoverParameters::Dettach(int ConnectNo)
@@ -699,7 +699,7 @@ bool TMoverParameters::Dettach(int ConnectNo)
SetFlag(coupler.sounds, soundflag);
}
- return (couplingstate < 0);
+ return couplingstate < 0;
};
bool TMoverParameters::DirectionForward()
@@ -709,14 +709,14 @@ bool TMoverParameters::DirectionForward()
return false;
}
- if ((MainCtrlPosNo > 0) && (DirActive < 1) && ((CabActive != 0) || ((InactiveCabFlag & activation::neutraldirection) == 0)))
+ if (MainCtrlPosNo > 0 && DirActive < 1 && (CabActive != 0 || (InactiveCabFlag & activation::neutraldirection) == 0))
{
++DirActive;
DirAbsolute = DirActive * CabActive;
SendCtrlToNext("Direction", DirActive, CabActive);
return true;
}
- else if ((DirActive == 1) && (IsMainCtrlNoPowerPos()) && (TrainType == dt_EZT) && (EngineType != TEngineType::ElectricInductionMotor))
+ else if (DirActive == 1 && IsMainCtrlNoPowerPos() && TrainType == dt_EZT && EngineType != TEngineType::ElectricInductionMotor)
return MinCurrentSwitch(true); //"wysoki rozruch" EN57
return false;
};
@@ -737,10 +737,10 @@ void TMoverParameters::BrakeLevelSet(double b)
BrakeCtrlPosR = fBrakeCtrlPos;
int x = static_cast(std::floor(fBrakeCtrlPos)); // jeśli odwołujemy się do BrakeCtrlPos w pośrednich, to musi być
// obcięte a nie zaokrągone
- while ((x > BrakeCtrlPos) && (BrakeCtrlPos < BrakeCtrlPosNo)) // jeśli zwiększyło się o 1
+ while (x > BrakeCtrlPos && BrakeCtrlPos < BrakeCtrlPosNo) // jeśli zwiększyło się o 1
if (!IncBrakeLevelOld()) // T_MoverParameters::
break; // wyjście awaryjne
- while ((x < BrakeCtrlPos) && (BrakeCtrlPos >= -1)) // jeśli zmniejszyło się o 1
+ while (x < BrakeCtrlPos && BrakeCtrlPos >= -1) // jeśli zmniejszyło się o 1
if (!DecBrakeLevelOld()) // T_MoverParameters::
break;
BrakePressureActual = BrakePressureTable[BrakeCtrlPos]; // skopiowanie pozycji
@@ -768,7 +768,7 @@ bool TMoverParameters::BrakeLevelAdd(double b)
{ // dodanie wartości (b) do pozycji hamulca (w tym ujemnej)
// zwraca false, gdy po dodaniu było by poza zakresem
BrakeLevelSet(fBrakeCtrlPos + b);
- return b > 0.0 ? (fBrakeCtrlPos < BrakeCtrlPosNo) : (BrakeCtrlPos > -1.0); // true, jeśli można kontynuować
+ return b > 0.0 ? fBrakeCtrlPos < BrakeCtrlPosNo : BrakeCtrlPos > -1.0; // true, jeśli można kontynuować
};
bool TMoverParameters::IncBrakeLevel()
@@ -786,7 +786,7 @@ bool TMoverParameters::ChangeCab(int direction)
if (std::abs(CabOccupied + direction) < 2)
{
CabOccupied = CabOccupied + direction;
- if ((BrakeCtrlPosNo > 0) && ((BrakeSystem == TBrakeSystem::Pneumatic) || (BrakeSystem == TBrakeSystem::ElectroPneumatic)))
+ if (BrakeCtrlPosNo > 0 && (BrakeSystem == TBrakeSystem::Pneumatic || BrakeSystem == TBrakeSystem::ElectroPneumatic))
{
BrakeLevelSet(Handle->GetPos(bh_NP));
LimPipePress = PipePress;
@@ -809,20 +809,20 @@ bool TMoverParameters::CurrentSwitch(bool const State)
{
if (TrainType != dt_EZT)
{
- (MinCurrentSwitch(State));
+ MinCurrentSwitch(State);
}
return true;
}
// TBD, TODO: split off shunt mode toggle into a separate command? It doesn't make much sense to have these two together like that
// dla 2Ls150
- if ((EngineType == TEngineType::DieselEngine) && (true == ShuntModeAllow) && (DirActive == 0))
+ if (EngineType == TEngineType::DieselEngine && true == ShuntModeAllow && DirActive == 0)
{
// przed ustawieniem kierunku
ShuntMode = State;
return true;
}
// for SM42/SP42
- if ((EngineType == TEngineType::DieselElectric) && (true == ShuntModeAllow) && (IsMainCtrlNoPowerPos()))
+ if (EngineType == TEngineType::DieselElectric && true == ShuntModeAllow && IsMainCtrlNoPowerPos())
{
ShuntMode = State;
return true;
@@ -834,7 +834,7 @@ bool TMoverParameters::CurrentSwitch(bool const State)
bool TMoverParameters::IsMotorOverloadRelayHighThresholdOn() const
{
- return ((ImaxHi > ImaxLo) && (Imax > ImaxLo));
+ return ImaxHi > ImaxLo && Imax > ImaxLo;
}
// KURS90 - sprężarka pantografów; Ra 2014-07: teraz jest to zbiornik rozrządu, chociaż to jeszcze nie tak
@@ -843,20 +843,20 @@ void TMoverParameters::UpdatePantVolume(double dt)
// check the pantograph compressor while at it
// TODO: move the check to a separate method
// automatic start if the pressure is too low
- PantCompFlag |= ((PantPress < 4.2) && (true == (Pantographs[end::front].is_active | Pantographs[end::rear].is_active)) // TODO: any_pantograph_is_active method
- && ((PantographCompressorStart == start_t::automatic) || (PantographCompressorStart == start_t::manualwithautofallback)));
+ PantCompFlag |= PantPress < 4.2 && true == (Pantographs[end::front].is_active | Pantographs[end::rear].is_active) // TODO: any_pantograph_is_active method
+ && (PantographCompressorStart == start_t::automatic || PantographCompressorStart == start_t::manualwithautofallback);
auto const lowvoltagepower{Power24vIsAvailable || Power110vIsAvailable};
PantCompFlag &= lowvoltagepower;
- if ((EnginePowerSource.SourceType == TPowerSource::CurrentCollector) // tylko jeśli pantografujący
- && (EnginePowerSource.CollectorParameters.CollectorsNo > 0))
+ if (EnginePowerSource.SourceType == TPowerSource::CurrentCollector // tylko jeśli pantografujący
+ && EnginePowerSource.CollectorParameters.CollectorsNo > 0)
{
// Ra 2014-07: zasadniczo, to istnieje zbiornik rozrządu i zbiornik pantografów - na razie mamy razem
// Ra 2014-07: kurek trójdrogowy łączy spr.pom. z pantografami i wyłącznikiem ciśnieniowym WS
// Ra 2014-07: zbiornika rozrządu nie pompuje się tu, tylko pantografy; potem można zamknąć
// WS i odpalić resztę
- if (PantAutoValve ? (PantPress < ScndPipePress) : bPantKurek3) // kurek zamyka połączenie z ZG
+ if (PantAutoValve ? PantPress < ScndPipePress : bPantKurek3) // kurek zamyka połączenie z ZG
{ // zbiornik pantografu połączony ze zbiornikiem głównym - małą sprężarką się tego nie napompuje
// Ra 2013-12: Niebugocław mówi, że w EZT nie ma potrzeby odcinać kurkiem
PantPress = ScndPipePress;
@@ -871,11 +871,11 @@ void TMoverParameters::UpdatePantVolume(double dt)
// włączona mała sprężarka
PantVolume += dt
// Ra 2013-12: Niebugocław mówi, że w EZT nabija 1.5 raz wolniej niż jak było 0.005
- * (TrainType == dt_EZT ? 0.003 : 0.005) / std::max(1.0, PantPress) * (0.45 - ((0.1 / PantVolume / 10) - 0.1)) / 0.45;
+ * (TrainType == dt_EZT ? 0.003 : 0.005) / std::max(1.0, PantPress) * (0.45 - (0.1 / PantVolume / 10 - 0.1)) / 0.45;
}
- PantPress = std::clamp((10.0 * PantVolume) - 1.0, 0.0, EnginePowerSource.CollectorParameters.MaxPress); // tu by się przydała objętość zbiornika
+ PantPress = std::clamp(10.0 * PantVolume - 1.0, 0.0, EnginePowerSource.CollectorParameters.MaxPress); // tu by się przydała objętość zbiornika
}
- if (!PantCompFlag && (PantVolume > 0.1))
+ if (!PantCompFlag && PantVolume > 0.1)
PantVolume -= dt * 0.0003 * std::max(1.0, PantPress * 0.5); // nieszczelności: 0.0003=0.3l/s
if (PantPress < EnginePowerSource.CollectorParameters.MinPress)
@@ -890,7 +890,7 @@ void TMoverParameters::UpdatePantVolume(double dt)
if (GetTrainsetHighVoltage() < EnginePowerSource.CollectorParameters.MinV)
{
// TODO: check whether line breaker should be open EMU-wide
- MainSwitch(false, (TrainType == dt_EZT ? range_t::unit : range_t::local));
+ MainSwitch(false, TrainType == dt_EZT ? range_t::unit : range_t::local);
}
}
else
@@ -911,7 +911,7 @@ void TMoverParameters::UpdatePantVolume(double dt)
{
// NOTE: we require active low power source to prime the pressure switch
// this is a work-around for potential isssues caused by the switch activating on otherwise idle vehicles, but should check whether it's accurate
- if ((true == Power24vIsAvailable) || (true == Power110vIsAvailable))
+ if (true == Power24vIsAvailable || true == Power110vIsAvailable)
{
// prime the pressure switch
PantPressSwitchActive = true;
@@ -938,18 +938,18 @@ void TMoverParameters::UpdateBatteryVoltage(double dt)
{ // przeliczenie obciążenia baterii
double sn1 = 0.0, sn2 = 0.0, sn3 = 0.0, sn4 = 0.0,
sn5 = 0.0; // Ra: zrobić z tego amperomierz NN
- if ((BatteryVoltage > 0) && (EngineType != TEngineType::DieselEngine) && (EngineType != TEngineType::WheelsDriven) && (NominalBatteryVoltage > 0))
+ if (BatteryVoltage > 0 && EngineType != TEngineType::DieselEngine && EngineType != TEngineType::WheelsDriven && NominalBatteryVoltage > 0)
{
// HACK: allow to draw power also from adjacent converter, applicable for EMUs
// TODO: expand power cables system to include low voltage power transfers
// HACK: emulate low voltage generator powered directly by the diesel engine
- auto const converteractive{(Power110vIsAvailable) || ((EngineType == TEngineType::DieselElectric) && (true == Mains)) || ((EngineType == TEngineType::DieselEngine) && (true == Mains))};
+ auto const converteractive{Power110vIsAvailable || (EngineType == TEngineType::DieselElectric && true == Mains) || (EngineType == TEngineType::DieselEngine && true == Mains)};
- if ((NominalBatteryVoltage / BatteryVoltage < 1.22) && Battery)
+ if (NominalBatteryVoltage / BatteryVoltage < 1.22 && Battery)
{ // 110V
if (!converteractive)
- sn1 = (dt * 2.0); // szybki spadek do ok 90V
+ sn1 = dt * 2.0; // szybki spadek do ok 90V
else
sn1 = 0;
if (converteractive)
@@ -957,7 +957,7 @@ void TMoverParameters::UpdateBatteryVoltage(double dt)
else
sn2 = 0;
if (Mains)
- sn3 = (dt * 0.05);
+ sn3 = dt * 0.05;
else
sn3 = 0;
if (iLights[0] & 63) // 64=blachy, nie ciągną prądu //rozpisać na poszczególne żarówki...
@@ -969,10 +969,10 @@ void TMoverParameters::UpdateBatteryVoltage(double dt)
else
sn5 = 0;
};
- if ((NominalBatteryVoltage / BatteryVoltage >= 1.22) && Battery)
+ if (NominalBatteryVoltage / BatteryVoltage >= 1.22 && Battery)
{ // 90V
if (PantCompFlag)
- sn1 = (dt * 0.0046);
+ sn1 = dt * 0.0046;
else
sn1 = 0;
if (converteractive)
@@ -980,15 +980,15 @@ void TMoverParameters::UpdateBatteryVoltage(double dt)
else
sn2 = 0;
if (Mains)
- sn3 = (dt * 0.001);
+ sn3 = dt * 0.001;
else
sn3 = 0;
if (iLights[0] & 63) // 64=blachy, nie ciągną prądu
- sn4 = (dt * 0.0030);
+ sn4 = dt * 0.0030;
else
sn4 = 0;
if (iLights[1] & 63) // 64=blachy, nie ciągną prądu
- sn5 = (dt * 0.0010);
+ sn5 = dt * 0.0010;
else
sn5 = 0;
};
@@ -1003,9 +1003,9 @@ void TMoverParameters::UpdateBatteryVoltage(double dt)
sn4 = dt * 0.000001;
sn5 = dt * 0.000001; // bardzo powolny spadek przy wyłączonych bateriach
};
- BatteryVoltage -= (sn1 + sn2 + sn3 + sn4 + sn5);
+ BatteryVoltage -= sn1 + sn2 + sn3 + sn4 + sn5;
if (NominalBatteryVoltage / BatteryVoltage > 1.57)
- if (MainSwitch(false) && (EngineType != TEngineType::DieselEngine) && (EngineType != TEngineType::WheelsDriven))
+ if (MainSwitch(false) && EngineType != TEngineType::DieselEngine && EngineType != TEngineType::WheelsDriven)
EventFlag = true; // wywalanie szybkiego z powodu zbyt niskiego napiecia
if (BatteryVoltage > NominalBatteryVoltage)
BatteryVoltage = NominalBatteryVoltage; // wstrzymanie ładowania pow. 110V
@@ -1066,7 +1066,7 @@ double TMoverParameters::LocalBrakeRatio(void)
{
double LBR;
if (BrakeHandle == TBrakeHandle::MHZ_EN57)
- if ((BrakeOpModeFlag >= bom_EP))
+ if (BrakeOpModeFlag >= bom_EP)
LBR = Handle->GetEP(BrakeCtrlPosR);
else
LBR = 0;
@@ -1118,7 +1118,7 @@ double TMoverParameters::RealPipeRatio(void)
double rpp;
if (DeltaPipePress > 0)
- rpp = (CntrlPipePress - PipePress) / (DeltaPipePress);
+ rpp = (CntrlPipePress - PipePress) / DeltaPipePress;
else
rpp = 0;
return rpp;
@@ -1135,7 +1135,7 @@ double TMoverParameters::PipeRatio(void)
if (DeltaPipePress > 0)
if (false) // SPKS!! no to jak nie wchodzimy to po co branch?
{
- if ((3.0 * PipePress) > (HighPipePress + LowPipePress + LowPipePress))
+ if (3.0 * PipePress > HighPipePress + LowPipePress + LowPipePress)
pr = (HighPipePress - std::min(HighPipePress, PipePress)) / (DeltaPipePress * 4.0 / 3.0);
else
pr = (HighPipePress - 1.0 / 3.0 * DeltaPipePress - std::max(LowPipePress, PipePress)) / (DeltaPipePress * 2.0 / 3.0);
@@ -1155,26 +1155,26 @@ double TMoverParameters::PipeRatio(void)
double TMoverParameters::EngineRPMRatio() const
{
- return std::clamp((EngineType == TEngineType::DieselElectric ? ((60.0 * std::abs(enrot)) / DElist[MainCtrlPosNo].RPM) :
- EngineType == TEngineType::DieselEngine ? (std::abs(enrot) / nmax) :
- 1.0), // shouldn't ever get here but, eh
+ return std::clamp(EngineType == TEngineType::DieselElectric ? 60.0 * std::abs(enrot) / DElist[MainCtrlPosNo].RPM :
+ EngineType == TEngineType::DieselEngine ? std::abs(enrot) / nmax :
+ 1.0, // shouldn't ever get here but, eh
0.0, 1.0);
}
double TMoverParameters::EngineIdleRPM() const
{
- return (EngineType == TEngineType::DieselEngine ? dizel_nmin * 60 :
- EngineType == TEngineType::DieselElectric ? DElist[MainCtrlNoPowerPos()].RPM :
- std::numeric_limits::max()); // shouldn't ever get here but, eh
+ return EngineType == TEngineType::DieselEngine ? dizel_nmin * 60 :
+ EngineType == TEngineType::DieselElectric ? DElist[MainCtrlNoPowerPos()].RPM :
+ std::numeric_limits::max(); // shouldn't ever get here but, eh
}
double TMoverParameters::EngineMaxRPM() const
{
- return (EngineType == TEngineType::DieselEngine ? dizel_nmax * 60 :
- EngineType == TEngineType::DieselElectric ? DElist[MainCtrlPosNo].RPM :
- std::numeric_limits::max()); // shouldn't ever get here but, eh
+ return EngineType == TEngineType::DieselEngine ? dizel_nmax * 60 :
+ EngineType == TEngineType::DieselElectric ? DElist[MainCtrlPosNo].RPM :
+ std::numeric_limits::max(); // shouldn't ever get here but, eh
}
// *************************************************************************************************
@@ -1203,12 +1203,12 @@ void TMoverParameters::CollisionDetect(int const End, double const dt)
{
case 0:
{
- CCF = ComputeCollision(velocity, othervehiclevelocity, TotalMass, othervehicle->TotalMass, (coupler.beta + othercoupler.beta) / 2.0, VirtualCoupling) / (dt);
+ CCF = ComputeCollision(velocity, othervehiclevelocity, TotalMass, othervehicle->TotalMass, (coupler.beta + othercoupler.beta) / 2.0, VirtualCoupling) / dt;
break; // yB: ej ej ej, a po
}
case 1:
{
- CCF = ComputeCollision(othervehiclevelocity, velocity, othervehicle->TotalMass, TotalMass, (coupler.beta + othercoupler.beta) / 2.0, VirtualCoupling) / (dt);
+ CCF = ComputeCollision(othervehiclevelocity, velocity, othervehicle->TotalMass, TotalMass, (coupler.beta + othercoupler.beta) / 2.0, VirtualCoupling) / dt;
break;
}
default:
@@ -1219,13 +1219,13 @@ void TMoverParameters::CollisionDetect(int const End, double const dt)
if (Global.crash_damage)
{
- if ((-coupler.Dist >= coupler.DmaxB) && (FuzzyLogic(std::abs(CCF), 5.0 * (coupler.FmaxC + 1.0), p_coupldmg)))
+ if (-coupler.Dist >= coupler.DmaxB && FuzzyLogic(std::abs(CCF), 5.0 * (coupler.FmaxC + 1.0), p_coupldmg))
{
// small chance to smash the coupler if it's hit with excessive force
damage_coupler(End);
}
- if ((coupler.CouplingFlag == coupling::faux || (true == TestFlag(othervehicle->DamageFlag, dtrain_out))))
+ if (coupler.CouplingFlag == coupling::faux || true == TestFlag(othervehicle->DamageFlag, dtrain_out))
{ // HACK: limit excessive speed derailment checks to vehicles which aren't part of the same consist
auto const safevelocitylimit{15.0};
auto const velocitydifference{glm::length(glm::angleAxis(Rot.Rz, glm::dvec3{0, 1, 0}) * V - glm::angleAxis(othervehicle->Rot.Rz, glm::dvec3{0, 1, 0}) * othervehicle->V) *
@@ -1234,7 +1234,7 @@ void TMoverParameters::CollisionDetect(int const End, double const dt)
if (velocitydifference > safevelocitylimit)
{
// HACK: crude estimation for potential derail, will take place with velocity difference > 15 km/h adjusted for vehicle mass ratio
- if ((false == TestFlag(DamageFlag, dtrain_out)) || (false == TestFlag(othervehicle->DamageFlag, dtrain_out)))
+ if (false == TestFlag(DamageFlag, dtrain_out) || false == TestFlag(othervehicle->DamageFlag, dtrain_out))
{
WriteLog("Bad driving: " + Name + " and " + othervehicle->Name + " collided with velocity " + to_string(velocitydifference, 0) + " km/h");
}
@@ -1407,7 +1407,7 @@ double TMoverParameters::ComputeMovement(double dt, double dt1, const TTrackShap
// velocity change
auto const Vprev{V};
V += (3.0 * AccS - AccSprev) * dt / 2.0; // przyrost predkosci
- if ((V * Vprev <= 0) && (std::abs(FStand) > std::abs(FTrain)))
+ if (V * Vprev <= 0 && std::abs(FStand) > std::abs(FTrain))
{
// tlumienie predkosci przy hamowaniu
// zahamowany
@@ -1418,7 +1418,7 @@ double TMoverParameters::ComputeMovement(double dt, double dt1, const TTrackShap
AccSVBased = std::lerp(AccSVBased, (V - Vprev) / dt, std::clamp(dt * 3.0, 0.0, 1.0));
// vertical acceleration
- AccVert = (std::abs(AccVert) < 0.01 ? 0.0 : AccVert * 0.5);
+ AccVert = std::abs(AccVert) < 0.01 ? 0.0 : AccVert * 0.5;
// szarpanie
/*
#ifdef EU07_USE_FUZZYLOGIC
@@ -1438,7 +1438,7 @@ double TMoverParameters::ComputeMovement(double dt, double dt1, const TTrackShap
{
if (TestFlag(Track.DamageFlag, dtrack_norail))
Derail(END_OF_TRACK);
- if (FuzzyLogic((AccN / g) * (1.0 + 0.1 * (Track.DamageFlag & dtrack_freerail)), TrackW / Dim.H, 1))
+ if (FuzzyLogic(AccN / g * (1.0 + 0.1 * (Track.DamageFlag & dtrack_freerail)), TrackW / Dim.H, 1))
Derail(TOO_HIGH_SPEED);
// wykolejanie na poszerzeniu toru
if (FuzzyLogic(abs(Track.Width - TrackW), TrackW / 10.0, 1))
@@ -1500,7 +1500,7 @@ double TMoverParameters::FastComputeMovement(double dt, const TTrackShape &Shape
// velocity change
auto const Vprev{V};
V += (3.0 * AccS - AccSprev) * dt / 2.0; // przyrost predkosci
- if ((V * Vprev <= 0) && (std::abs(FStand) > std::abs(FTrain)))
+ if (V * Vprev <= 0 && std::abs(FStand) > std::abs(FTrain))
{
// tlumienie predkosci przy hamowaniu
// zahamowany
@@ -1512,7 +1512,7 @@ double TMoverParameters::FastComputeMovement(double dt, const TTrackShape &Shape
// simple mode skips calculation of vertical acceleration
AccVert = 0.0;
- if ((true == TestFlag(DamageFlag, dtrain_out)) && (Vel < 1.0))
+ if (true == TestFlag(DamageFlag, dtrain_out) && Vel < 1.0)
{
V = 0.0;
AccS = 0.0;
@@ -1555,14 +1555,14 @@ void TMoverParameters::compute_movement_(double const Deltatime)
{
if (MotorOverloadRelayHighThreshold)
{ // set high threshold
- if ((TrainType != dt_ET42) ? (RList[MainCtrlPos].Bn < 2) : (MainCtrlPos == 0))
+ if (TrainType != dt_ET42 ? RList[MainCtrlPos].Bn < 2 : MainCtrlPos == 0)
{
Imax = ImaxHi;
}
}
else
{ // set low threshold
- if ((TrainType != dt_ET42) || (MainCtrlPos == 0))
+ if (TrainType != dt_ET42 || MainCtrlPos == 0)
{
Imax = ImaxLo;
}
@@ -1597,7 +1597,7 @@ void TMoverParameters::compute_movement_(double const Deltatime)
}
}
- if ((EngineType == TEngineType::DieselEngine) || (EngineType == TEngineType::DieselElectric))
+ if (EngineType == TEngineType::DieselEngine || EngineType == TEngineType::DieselElectric)
{
if (dizel_Update(Deltatime))
{
@@ -1645,16 +1645,16 @@ void TMoverParameters::compute_movement_(double const Deltatime)
UpdateBatteryVoltage(Deltatime);
UpdateScndPipePressure(Deltatime); // druga rurka, youBy
- if (((DCEMUED_CC & 1) != 0) && ((Couplers[end::front].CouplingFlag & coupling::control) != 0))
+ if ((DCEMUED_CC & 1) != 0 && (Couplers[end::front].CouplingFlag & coupling::control) != 0)
{
DynamicBrakeEMUStatus &= Couplers[end::front].Connected->DynamicBrakeEMUStatus;
}
- if (((DCEMUED_CC & 2) != 0) && ((Couplers[end::rear].CouplingFlag & coupling::control) != 0))
+ if ((DCEMUED_CC & 2) != 0 && (Couplers[end::rear].CouplingFlag & coupling::control) != 0)
{
DynamicBrakeEMUStatus &= Couplers[end::rear].Connected->DynamicBrakeEMUStatus;
}
- if ((BrakeSlippingTimer > 0.8) && (ASBType != 128))
+ if (BrakeSlippingTimer > 0.8 && ASBType != 128)
{ // ASBSpeed=0.8
// hamulec antypoślizgowy - wyłączanie
Hamulec->ASB(0);
@@ -1670,8 +1670,8 @@ void TMoverParameters::compute_movement_(double const Deltatime)
PowerCouplersCheck(Deltatime, coupling::power24v);
Power24vVoltage = std::max(PowerCircuits[0].first, GetTrainsetVoltage(coupling::power24v));
- Power24vIsAvailable = (Power24vVoltage > 0);
- Power110vIsAvailable = ((PowerCircuits[1].first > 0) || (GetTrainsetVoltage(coupling::power110v) > 0));
+ Power24vIsAvailable = Power24vVoltage > 0;
+ Power110vIsAvailable = PowerCircuits[1].first > 0 || GetTrainsetVoltage(coupling::power110v) > 0;
}
void TMoverParameters::MainsCheck(double const Deltatime)
@@ -1698,7 +1698,7 @@ void TMoverParameters::MainsCheck(double const Deltatime)
break;
}
}
- auto const maincircuitpowersupply{(std::abs(localvoltage) > 0.1) || (GetTrainsetHighVoltage() > 0.1)};
+ auto const maincircuitpowersupply{std::abs(localvoltage) > 0.1 || GetTrainsetHighVoltage() > 0.1};
if (true == maincircuitpowersupply)
{
@@ -1712,7 +1712,7 @@ void TMoverParameters::MainsCheck(double const Deltatime)
else
{
// optional automatic circuit start
- if ((MainsStart != start_t::manual) && (false == (Mains || dizel_startup)))
+ if (MainsStart != start_t::manual && false == (Mains || dizel_startup))
{
MainSwitch(true);
}
@@ -1780,7 +1780,7 @@ void TMoverParameters::PowerCouplersCheck(double const Deltatime, coupling const
case TPowerSource::Main:
{
// HACK: main circuit can be fed through couplers, so we explicitly check pantograph supply here
- localvoltage = (true == Mains ? PantographVoltage : 0.0);
+ localvoltage = true == Mains ? PantographVoltage : 0.0;
break;
}
default:
@@ -1855,22 +1855,22 @@ void TMoverParameters::PowerCouplersCheck(double const Deltatime, coupling const
auto const oppositehighvoltagecoupling{(oppositecoupler.CouplingFlag & coupling::highvoltage) != 0};
auto const oppositeheatingcoupling{(oppositecoupler.CouplingFlag & coupling::heating) != 0};
- oppositecouplingispresent = (oppositehighvoltagecoupling || oppositeheatingcoupling);
- localpowerexportisenabled = (oppositehighvoltagecoupling || (oppositeheatingcoupling && localpowersource && Heating));
+ oppositecouplingispresent = oppositehighvoltagecoupling || oppositeheatingcoupling;
+ localpowerexportisenabled = oppositehighvoltagecoupling || (oppositeheatingcoupling && localpowersource && Heating);
break;
}
case coupling::power110v:
{
- oppositecouplingispresent = (TestFlag(oppositecoupler.CouplingFlag, oppositecoupler.PowerCoupling)) && ((oppositecoupler.PowerFlag & coupling::power110v) != 0);
- localpowerexportisenabled = (oppositecouplingispresent);
+ oppositecouplingispresent = TestFlag(oppositecoupler.CouplingFlag, oppositecoupler.PowerCoupling) && (oppositecoupler.PowerFlag & coupling::power110v) != 0;
+ localpowerexportisenabled = oppositecouplingispresent;
break;
}
case coupling::power24v:
{
- oppositecouplingispresent = (TestFlag(oppositecoupler.CouplingFlag, oppositecoupler.PowerCoupling)) && ((oppositecoupler.PowerFlag & coupling::power24v) != 0);
- localpowerexportisenabled = (oppositecouplingispresent);
+ oppositecouplingispresent = TestFlag(oppositecoupler.CouplingFlag, oppositecoupler.PowerCoupling) && (oppositecoupler.PowerFlag & coupling::power24v) != 0;
+ localpowerexportisenabled = oppositecouplingispresent;
break;
}
@@ -1880,14 +1880,14 @@ void TMoverParameters::PowerCouplersCheck(double const Deltatime, coupling const
}
}
- auto const *coupling = (Coupling == coupling::highvoltage ? &coupler.power_high :
- Coupling == coupling::power110v ? &coupler.power_110v :
- Coupling == coupling::power24v ? &coupler.power_24v :
- nullptr);
- auto *oppositecoupling = (Coupling == coupling::highvoltage ? &oppositecoupler.power_high :
- Coupling == coupling::power110v ? &oppositecoupler.power_110v :
- Coupling == coupling::power24v ? &oppositecoupler.power_24v :
- nullptr);
+ auto const *coupling = Coupling == coupling::highvoltage ? &coupler.power_high :
+ Coupling == coupling::power110v ? &coupler.power_110v :
+ Coupling == coupling::power24v ? &coupler.power_24v :
+ nullptr;
+ auto *oppositecoupling = Coupling == coupling::highvoltage ? &oppositecoupler.power_high :
+ Coupling == coupling::power110v ? &oppositecoupler.power_110v :
+ Coupling == coupling::power24v ? &oppositecoupler.power_24v :
+ nullptr;
// start with base voltage
oppositecoupling->voltage = abslocalvoltage;
@@ -1897,19 +1897,19 @@ void TMoverParameters::PowerCouplersCheck(double const Deltatime, coupling const
if (coupler.Connected != nullptr)
{
auto const &connectedcoupler{coupler.Connected->Couplers[coupler.ConnectedNr]};
- auto const *connectedcoupling = (Coupling == coupling::highvoltage ? &connectedcoupler.power_high :
- Coupling == coupling::power110v ? &connectedcoupler.power_110v :
- Coupling == coupling::power24v ? &connectedcoupler.power_24v :
- nullptr);
+ auto const *connectedcoupling = Coupling == coupling::highvoltage ? &connectedcoupler.power_high :
+ Coupling == coupling::power110v ? &connectedcoupler.power_110v :
+ Coupling == coupling::power24v ? &connectedcoupler.power_24v :
+ nullptr;
auto const connectedvoltage{(connectedcoupling->is_live ? connectedcoupling->voltage : 0.0)};
oppositecoupling->voltage = std::max(oppositecoupling->voltage, connectedvoltage - coupling->current * 0.02);
- oppositecoupling->is_live = (connectedvoltage > 0.1) && (oppositecouplingispresent);
+ oppositecoupling->is_live = connectedvoltage > 0.1 && oppositecouplingispresent;
}
// draw from local source
if (localpowersource)
{
oppositecoupling->voltage = std::max(oppositecoupling->voltage, abslocalvoltage - coupling->current * 0.02);
- oppositecoupling->is_live |= (abslocalvoltage > 0.1) && (localpowerexportisenabled);
+ oppositecoupling->is_live |= abslocalvoltage > 0.1 && localpowerexportisenabled;
}
}
@@ -1938,19 +1938,19 @@ void TMoverParameters::PowerCouplersCheck(double const Deltatime, coupling const
}
}
- auto *totalcurrent = (Coupling == coupling::highvoltage ? &TotalCurrent :
- Coupling == coupling::power110v ? &PowerCircuits[1].second :
- Coupling == coupling::power24v ? &PowerCircuits[0].second :
- nullptr);
+ auto *totalcurrent = Coupling == coupling::highvoltage ? &TotalCurrent :
+ Coupling == coupling::power110v ? &PowerCircuits[1].second :
+ Coupling == coupling::power24v ? &PowerCircuits[0].second :
+ nullptr;
for (auto side = 0; side < 2; ++side)
{
auto &coupler{Couplers[side]};
- auto *coupling = (Coupling == coupling::highvoltage ? &coupler.power_high :
- Coupling == coupling::power110v ? &coupler.power_110v :
- Coupling == coupling::power24v ? &coupler.power_24v :
- nullptr);
+ auto *coupling = Coupling == coupling::highvoltage ? &coupler.power_high :
+ Coupling == coupling::power110v ? &coupler.power_110v :
+ Coupling == coupling::power24v ? &coupler.power_24v :
+ nullptr;
coupling->current = 0.0;
@@ -1960,11 +1960,11 @@ void TMoverParameters::PowerCouplersCheck(double const Deltatime, coupling const
}
auto const &connectedothercoupler{coupler.Connected->Couplers[(coupler.ConnectedNr == end::front ? end::rear : end::front)]};
- auto const *connectedothercoupling = (Coupling == coupling::highvoltage ? &connectedothercoupler.power_high :
- Coupling == coupling::power110v ? &connectedothercoupler.power_110v :
- Coupling == coupling::power24v ? &connectedothercoupler.power_24v :
- nullptr);
- auto const extracurrent = (Coupling == coupling::highvoltage ? std::abs(Itot) * IsVehicleEIMBrakingFactor() : 0.0);
+ auto const *connectedothercoupling = Coupling == coupling::highvoltage ? &connectedothercoupler.power_high :
+ Coupling == coupling::power110v ? &connectedothercoupler.power_110v :
+ Coupling == coupling::power24v ? &connectedothercoupler.power_24v :
+ nullptr;
+ auto const extracurrent = Coupling == coupling::highvoltage ? std::abs(Itot) * IsVehicleEIMBrakingFactor() : 0.0;
if (false == localpowersource)
{
@@ -2018,9 +2018,9 @@ double TMoverParameters::ShowEngineRotation(int VehN)
void TMoverParameters::ConverterCheck(double const Timestep)
{
// TODO: move other converter checks here, to have it all in one place for potential device object
- if ((ConverterStart != start_t::disabled) && (ConverterOverloadRelayOffWhenMainIsOff))
+ if (ConverterStart != start_t::disabled && ConverterOverloadRelayOffWhenMainIsOff)
{
- ConvOvldFlag |= (!Mains && Power24vIsAvailable);
+ ConvOvldFlag |= !Mains && Power24vIsAvailable;
}
switch (ConverterStart)
@@ -2038,7 +2038,7 @@ void TMoverParameters::ConverterCheck(double const Timestep)
}
case start_t::direction:
{
- ConverterAllow = (DirActive != 0);
+ ConverterAllow = DirActive != 0;
}
default:
{
@@ -2046,10 +2046,10 @@ void TMoverParameters::ConverterCheck(double const Timestep)
}
}
- if ((ConverterAllow) && (ConverterAllowLocal) && (false == ConvOvldFlag) &&
- (false == PantPressLockActive)
+ if (ConverterAllow && ConverterAllowLocal && false == ConvOvldFlag &&
+ false == PantPressLockActive
// HACK: allow carriages to operate converter without (missing) fuse prerequisite
- && ((Power > 1.0 ? Mains : GetTrainsetHighVoltage() > 0.0)))
+ && (Power > 1.0 ? Mains : GetTrainsetHighVoltage() > 0.0))
{
// delay timer can be optionally configured, and is set anew whenever converter goes off
if (ConverterStartDelayTimer <= 0.0)
@@ -2067,7 +2067,7 @@ void TMoverParameters::ConverterCheck(double const Timestep)
ConverterStartDelayTimer = static_cast(ConverterStartDelay);
}
- if ((ConverterOverloadRelayStart == start_t::converter) && (false == (ConverterAllow && ConverterAllowLocal)) && (false == TestFlag(EngDmgFlag, 4)))
+ if (ConverterOverloadRelayStart == start_t::converter && false == (ConverterAllow && ConverterAllowLocal) && false == TestFlag(EngDmgFlag, 4))
{
// reset converter overload relay if the converter was switched off, unless it's damaged
ConvOvldFlag = false;
@@ -2084,12 +2084,12 @@ void TMoverParameters::HeatingCheck(double const Timestep)
{
case TPowerSource::Generator:
{
- if ((HeatingPowerSource.EngineGenerator.engine_revolutions != nullptr) && (HeatingPowerSource.EngineGenerator.revolutions_max > 0))
+ if (HeatingPowerSource.EngineGenerator.engine_revolutions != nullptr && HeatingPowerSource.EngineGenerator.revolutions_max > 0)
{
auto &generator{HeatingPowerSource.EngineGenerator};
// TBD, TODO: engine-generator transmission
- generator.revolutions = *(generator.engine_revolutions);
+ generator.revolutions = *generator.engine_revolutions;
auto const absrevolutions{std::abs(generator.revolutions)};
generator.voltage = (false == HeatingAllow ? 0.0 :
@@ -2143,7 +2143,7 @@ void TMoverParameters::HeatingCheck(double const Timestep)
}
case TPowerSource::Main:
{
- voltage = (true == Mains ? std::max(GetTrainsetHighVoltage(), PantographVoltage) : 0.0);
+ voltage = true == Mains ? std::max(GetTrainsetHighVoltage(), PantographVoltage) : 0.0;
break;
}
default:
@@ -2152,7 +2152,7 @@ void TMoverParameters::HeatingCheck(double const Timestep)
}
}
- Heating = (voltage > heatingpowerthreshold);
+ Heating = voltage > heatingpowerthreshold;
if (Heating)
{
@@ -2164,20 +2164,20 @@ void TMoverParameters::HeatingCheck(double const Timestep)
void TMoverParameters::WaterPumpCheck(double const Timestep)
{
// NOTE: breaker override with start type is sm42 specific hack, replace with ability to define the presence of the breaker
- WaterPump.is_active = ((true == (Power24vIsAvailable || Power110vIsAvailable)) && (true == WaterPump.breaker) && (false == WaterPump.is_disabled) &&
- ((true == WaterPump.is_active) || (true == WaterPump.is_enabled) || (WaterPump.start_type == start_t::battery)));
+ WaterPump.is_active = true == (Power24vIsAvailable || Power110vIsAvailable) && true == WaterPump.breaker && false == WaterPump.is_disabled &&
+ (true == WaterPump.is_active || true == WaterPump.is_enabled || WaterPump.start_type == start_t::battery);
}
// water heater status check
void TMoverParameters::WaterHeaterCheck(double const Timestep)
{
- WaterHeater.is_active = ((false == WaterHeater.is_damaged) && (true == (Power24vIsAvailable || Power110vIsAvailable)) && (true == WaterHeater.is_enabled) && (true == WaterHeater.breaker) &&
- ((WaterHeater.is_active) || (WaterHeater.config.temp_min < 0) || (dizel_heat.temperatura1 < WaterHeater.config.temp_min)));
+ WaterHeater.is_active = false == WaterHeater.is_damaged && true == (Power24vIsAvailable || Power110vIsAvailable) && true == WaterHeater.is_enabled && true == WaterHeater.breaker &&
+ (WaterHeater.is_active || WaterHeater.config.temp_min < 0 || dizel_heat.temperatura1 < WaterHeater.config.temp_min);
- WaterHeater.is_damaged = ((true == WaterHeater.is_damaged) || ((true == WaterHeater.is_active) && (false == WaterPump.is_active)));
+ WaterHeater.is_damaged = true == WaterHeater.is_damaged || (true == WaterHeater.is_active && false == WaterPump.is_active);
- if ((WaterHeater.config.temp_max > 0) && (dizel_heat.temperatura1 > WaterHeater.config.temp_max))
+ if (WaterHeater.config.temp_max > 0 && dizel_heat.temperatura1 > WaterHeater.config.temp_max)
{
WaterHeater.is_active = false;
}
@@ -2187,29 +2187,28 @@ void TMoverParameters::WaterHeaterCheck(double const Timestep)
void TMoverParameters::FuelPumpCheck(double const Timestep)
{
- FuelPump.is_active = ((true == (Power24vIsAvailable || Power110vIsAvailable)) && (false == FuelPump.is_disabled) &&
- ((FuelPump.is_active) || (FuelPump.start_type == start_t::manual ? (FuelPump.is_enabled) :
- FuelPump.start_type == start_t::automatic ? (dizel_startup || Mains) :
- FuelPump.start_type == start_t::manualwithautofallback ? (FuelPump.is_enabled || dizel_startup || Mains) :
- false))); // shouldn't ever get this far but, eh
+ FuelPump.is_active = true == (Power24vIsAvailable || Power110vIsAvailable) && false == FuelPump.is_disabled &&
+ (FuelPump.is_active || (FuelPump.start_type == start_t::manual ? FuelPump.is_enabled :
+ FuelPump.start_type == start_t::automatic ? dizel_startup || Mains :
+ FuelPump.start_type == start_t::manualwithautofallback ? FuelPump.is_enabled || dizel_startup || Mains :
+ false)); // shouldn't ever get this far but, eh
}
// oil pump status update
void TMoverParameters::OilPumpCheck(double const Timestep)
{
- OilPump.is_active = ((true == (Power24vIsAvailable || Power110vIsAvailable)) && (false == Mains) && (false == OilPump.is_disabled) &&
- ((OilPump.is_active) || (OilPump.start_type == start_t::manual ? (OilPump.is_enabled) :
- OilPump.start_type == start_t::automatic ? (dizel_startup) :
- OilPump.start_type == start_t::manualwithautofallback ? (OilPump.is_enabled || dizel_startup) :
- false))); // shouldn't ever get this far but, eh
+ OilPump.is_active = true == (Power24vIsAvailable || Power110vIsAvailable) && false == Mains && false == OilPump.is_disabled &&
+ (OilPump.is_active || (OilPump.start_type == start_t::manual ? OilPump.is_enabled :
+ OilPump.start_type == start_t::automatic ? dizel_startup :
+ OilPump.start_type == start_t::manualwithautofallback ? OilPump.is_enabled || dizel_startup :
+ false)); // shouldn't ever get this far but, eh
auto const minpressure{OilPump.pressure_minimum > 0.f ? OilPump.pressure_minimum : 0.15f}; // arbitrary fallback value
- OilPump.pressure_target = (
- enrot > 0.1 ? std::lerp( minpressure, OilPump.pressure_maximum, static_cast( EngineRPMRatio() ) ) * OilPump.resource_amount :
+ OilPump.pressure_target = enrot > 0.1 ? std::lerp( minpressure, OilPump.pressure_maximum, static_cast( EngineRPMRatio() ) ) * OilPump.resource_amount :
true == OilPump.is_active ? std::min( minpressure + 0.1f, OilPump.pressure_maximum ) : // slight pressure margin to give time to switch off the pump and start the engine
- 0.f );
+ 0.f;
if (OilPump.pressure < OilPump.pressure_target)
{
@@ -2250,16 +2249,16 @@ void TMoverParameters::MotorBlowersCheck(double const Timestep)
disable |= !blower.is_active;
}
}
- blower.is_active = (
+ blower.is_active =
// TODO: bind properly power source when ld is in place
(blower.start_type == start_t::battery ? Power24vIsAvailable :
blower.start_type == start_t::converter ? Power110vIsAvailable :
Mains) // power source
// breaker condition disabled until it's implemented in the class data
// && ( true == blower.breaker )
- && (false == disable) &&
- ((true == blower.is_active) || ((blower.stop_timer == 0.f) // HACK: will be true for blower with exceeded start_velocity, and for one without start_velocity
- && (blower.start_type == start_t::manual ? blower.is_enabled : true))));
+ && false == disable &&
+ (true == blower.is_active || (blower.stop_timer == 0.f // HACK: will be true for blower with exceeded start_velocity, and for one without start_velocity
+ && (blower.start_type == start_t::manual ? blower.is_enabled : true)));
}
// update
for (auto &fan : MotorBlowers)
@@ -2289,15 +2288,15 @@ void TMoverParameters::PantographsCheck(double const Timestep)
{
auto &valve{PantsValve};
- auto const lowvoltagepower{valve.solenoid ? (Power24vIsAvailable || Power110vIsAvailable) : true};
+ auto const lowvoltagepower{valve.solenoid ? Power24vIsAvailable || Power110vIsAvailable : true};
auto const autostart{valve.start_type == start_t::automatic || valve.start_type == start_t::manualwithautofallback};
auto const manualcontrol{valve.start_type == start_t::manual || valve.start_type == start_t::manualwithautofallback};
- PantsValve.is_active = (((valve.spring ? lowvoltagepower : true)) // spring actuator needs power to maintain non-default state
- && (((manualcontrol && lowvoltagepower) ? false == valve.is_disabled : true)) // needs power to change state
- && ((valve.is_active) || (autostart ? lowvoltagepower :
- !autostart ? (lowvoltagepower && valve.is_enabled) :
- false))); // shouldn't ever get this far but, eh
+ PantsValve.is_active = (valve.spring ? lowvoltagepower : true) // spring actuator needs power to maintain non-default state
+ && (manualcontrol && lowvoltagepower ? false == valve.is_disabled : true) // needs power to change state
+ && (valve.is_active || (autostart ? lowvoltagepower :
+ !autostart ? lowvoltagepower && valve.is_enabled :
+ false)); // shouldn't ever get this far but, eh
}
size_t pant_id = 0;
@@ -2305,20 +2304,18 @@ void TMoverParameters::PantographsCheck(double const Timestep)
{
auto &valve{pantograph.valve};
- auto const lowvoltagepower{valve.solenoid ? (Power24vIsAvailable || Power110vIsAvailable) : true};
+ auto const lowvoltagepower{valve.solenoid ? Power24vIsAvailable || Power110vIsAvailable : true};
auto const autostart{valve.start_type == start_t::automatic || valve.start_type == start_t::manualwithautofallback};
auto const manualcontrol{valve.start_type == start_t::manual || valve.start_type == start_t::manualwithautofallback};
- valve.is_active = (((valve.spring ? lowvoltagepower : true)) // spring actuator needs power to maintain non-default state
- && (((manualcontrol && lowvoltagepower) ? false == valve.is_disabled : true)) // needs power to change state, without it just pass through
- && (((manualcontrol && lowvoltagepower) ? false == PantAllDown : true)) &&
- ((valve.is_active) || (manualcontrol && lowvoltagepower && valve.is_enabled) || (autostart && lowvoltagepower))); // shouldn't ever get this far but, eh
+ valve.is_active = (valve.spring ? lowvoltagepower : true) // spring actuator needs power to maintain non-default state
+ && (manualcontrol && lowvoltagepower ? false == valve.is_disabled : true) // needs power to change state, without it just pass through
+ && (manualcontrol && lowvoltagepower ? false == PantAllDown : true) &&
+ (valve.is_active || (manualcontrol && lowvoltagepower && valve.is_enabled) || (autostart && lowvoltagepower)); // shouldn't ever get this far but, eh
- auto const pantographexists{(EnginePowerSource.SourceType == TPowerSource::CurrentCollector) && (EnginePowerSource.CollectorParameters.PhysicalLayout & (1 << pant_id))};
+ auto const pantographexists{EnginePowerSource.SourceType == TPowerSource::CurrentCollector && EnginePowerSource.CollectorParameters.PhysicalLayout & 1 << pant_id};
- pantograph.is_active = ((valve.is_active) && (PantsValve.is_active) && (pantographexists)
- // && ( ) // TODO: add other checks
- );
+ pantograph.is_active = valve.is_active && PantsValve.is_active && pantographexists;
pant_id++;
}
@@ -2329,10 +2326,10 @@ void TMoverParameters::LightsCheck(double const Timestep)
auto &light{CompartmentLights};
- light.is_active = (
+ light.is_active =
// TODO: bind properly power source when ld is in place
(Power24vIsAvailable || Power110vIsAvailable) // power source
- && (false == light.is_disabled) && ((true == light.is_active) || (light.start_type == start_t::manual ? light.is_enabled : true)));
+ && false == light.is_disabled && (true == light.is_active || (light.start_type == start_t::manual ? light.is_enabled : true));
light.intensity = (light.is_active ? 1.0f : 0.0f)
// TODO: bind properly power source when ld is in place
@@ -2377,17 +2374,17 @@ double TMoverParameters::ShowCurrent(int AmpN) const
bool TMoverParameters::IncMainCtrl(int CtrlSpeed)
{
// basic fail conditions:
- if ((MainCtrlPosNo <= 0) || (CabActive == 0))
+ if (MainCtrlPosNo <= 0 || CabActive == 0)
{
// nie ma sterowania
return false;
}
- if ((TrainType == dt_ET22) && (ScndCtrlPos != 0))
+ if (TrainType == dt_ET22 && ScndCtrlPos != 0)
{
// w ET22 nie da się kręcić nastawnikiem przy włączonym boczniku
return false;
}
- if ((TrainType == dt_EZT) && (DirActive == 0))
+ if (TrainType == dt_EZT && DirActive == 0)
{
// w EZT nie da się załączyć pozycji bez ustawienia kierunku
return false;
@@ -2405,13 +2402,13 @@ bool TMoverParameters::IncMainCtrl(int CtrlSpeed)
{
if (CtrlSpeed > 1)
{
- OK = (IncMainCtrl(1) && IncMainCtrl(CtrlSpeed - 1)); // a fail will propagate up the recursion chain. should this be || instead?
+ OK = IncMainCtrl(1) && IncMainCtrl(CtrlSpeed - 1); // a fail will propagate up the recursion chain. should this be || instead?
}
else
{
++MainCtrlPos;
OK = true;
- if ((EIMCtrlType == 0) && (SpeedCtrlAutoTurnOffFlag & 1 == 1) && (MainCtrlActualPos != MainCtrlPos))
+ if (EIMCtrlType == 0 && SpeedCtrlAutoTurnOffFlag & 1 == 1 && MainCtrlActualPos != MainCtrlPos)
{
DecScndCtrl(2);
SpeedCtrlUnit.IsActive = false;
@@ -2434,7 +2431,7 @@ bool TMoverParameters::IncMainCtrl(int CtrlSpeed)
{
break; // this means ET40 won't react at all to fast acceleration command. should it issue just IncMainCtrl(1) instead?
}
- while ((RList[MainCtrlPos].R > 0.0) && IncMainCtrl(1))
+ while (RList[MainCtrlPos].R > 0.0 && IncMainCtrl(1))
{
// all work is done in the loop header
;
@@ -2476,7 +2473,7 @@ bool TMoverParameters::IncMainCtrl(int CtrlSpeed)
//}
}
- if ((TrainType == dt_ET42) && (true == DynamicBrakeFlag))
+ if (TrainType == dt_ET42 && true == DynamicBrakeFlag)
{
if (MainCtrlPos > 20)
{
@@ -2491,7 +2488,7 @@ bool TMoverParameters::IncMainCtrl(int CtrlSpeed)
{
if (CtrlSpeed > 1)
{
- while ((MainCtrlPos < MainCtrlPosNo) && (IncMainCtrl(1)))
+ while (MainCtrlPos < MainCtrlPosNo && IncMainCtrl(1))
{
;
}
@@ -2500,7 +2497,7 @@ bool TMoverParameters::IncMainCtrl(int CtrlSpeed)
{
++MainCtrlPos;
}
- CompressorAllow = (MainCtrlPowerPos() > 0);
+ CompressorAllow = MainCtrlPowerPos() > 0;
OK = true;
break;
}
@@ -2544,7 +2541,7 @@ bool TMoverParameters::IncMainCtrl(int CtrlSpeed)
{
if (DelayCtrlFlag)
{
- if ((LastRelayTime >= InitialCtrlDelay) && (MainCtrlPos == 1))
+ if (LastRelayTime >= InitialCtrlDelay && MainCtrlPos == 1)
LastRelayTime = 0;
}
else if (LastRelayTime > CtrlDelay)
@@ -2561,7 +2558,7 @@ bool TMoverParameters::DecMainCtrl(int CtrlSpeed)
{
bool OK = false;
// basic fail conditions:
- if ((MainCtrlPosNo <= 0) || (CabActive == 0))
+ if (MainCtrlPosNo <= 0 || CabActive == 0)
{
// nie ma sterowania
OK = false;
@@ -2575,9 +2572,9 @@ bool TMoverParameters::DecMainCtrl(int CtrlSpeed)
// TBD, TODO: replace with mainctrlpowerpos() check?
if (MainCtrlPos > 0)
{
- if ((TrainType != dt_ET22) || (ScndCtrlPos == 0)) // Ra: ET22 blokuje nastawnik przy boczniku
+ if (TrainType != dt_ET22 || ScndCtrlPos == 0) // Ra: ET22 blokuje nastawnik przy boczniku
{
- if (CoupledCtrl && (ScndCtrlPos > 0))
+ if (CoupledCtrl && ScndCtrlPos > 0)
{
ScndCtrlPos--; // wspolny wal
OK = true;
@@ -2590,18 +2587,18 @@ bool TMoverParameters::DecMainCtrl(int CtrlSpeed)
case TEngineType::DieselElectric:
case TEngineType::ElectricInductionMotor:
{
- if (((CtrlSpeed == 1) && (EngineType != TEngineType::DieselElectric)) || ((CtrlSpeed == 1) && (EngineType == TEngineType::DieselElectric)))
+ if ((CtrlSpeed == 1 && EngineType != TEngineType::DieselElectric) || (CtrlSpeed == 1 && EngineType == TEngineType::DieselElectric))
{
MainCtrlPos--;
OK = true;
- if ((EIMCtrlType == 0) && (SpeedCtrlAutoTurnOffFlag & 1 == 1) && (MainCtrlActualPos != MainCtrlPos))
+ if (EIMCtrlType == 0 && SpeedCtrlAutoTurnOffFlag & 1 == 1 && MainCtrlActualPos != MainCtrlPos)
{
DecScndCtrl(2);
SpeedCtrlUnit.IsActive = false;
}
}
else if (CtrlSpeed > 1)
- OK = (DecMainCtrl(1) && DecMainCtrl(CtrlSpeed - 1)); // CtrlSpeed-1);
+ OK = DecMainCtrl(1) && DecMainCtrl(CtrlSpeed - 1); // CtrlSpeed-1);
break;
}
@@ -2623,7 +2620,7 @@ bool TMoverParameters::DecMainCtrl(int CtrlSpeed)
OK = true;
if (RList[MainCtrlPos].R == 0) // Q: tu zrobilem = ;]
DecMainCtrl(1);
- while ((RList[MainCtrlPos].R > 0) && DecMainCtrl(1))
+ while (RList[MainCtrlPos].R > 0 && DecMainCtrl(1))
; // takie chamskie, potem poprawie}
}
break;
@@ -2638,7 +2635,7 @@ bool TMoverParameters::DecMainCtrl(int CtrlSpeed)
}
else if (CtrlSpeed > 1)
{
- while ((MainCtrlPos > 0) || (RList[MainCtrlPos].Mn > 0))
+ while (MainCtrlPos > 0 || RList[MainCtrlPos].Mn > 0)
DecMainCtrl(1);
OK = true;
}
@@ -2735,19 +2732,19 @@ bool TMoverParameters::IncScndCtrl(int CtrlSpeed)
{
bool OK = false;
- if ((DynamicBrakeFlag) && (TrainType == dt_ET42) && (CabActive != 0) && (IsMainCtrlNoPowerPos()) && (ScndCtrlPos == 0))
+ if (DynamicBrakeFlag && TrainType == dt_ET42 && CabActive != 0 && IsMainCtrlNoPowerPos() && ScndCtrlPos == 0)
{
OK = DynamicBrakeSwitch(false);
}
- else if ((ScndCtrlPosNo > 0) && (CabActive != 0) && !((TrainType == dt_ET42) && ((Imax == ImaxHi) || ((DynamicBrakeFlag) && (MainCtrlPowerPos() > 0)))))
+ else if (ScndCtrlPosNo > 0 && CabActive != 0 && !(TrainType == dt_ET42 && (Imax == ImaxHi || (DynamicBrakeFlag && MainCtrlPowerPos() > 0))))
{
// if (RList[MainCtrlPos].R=0) and (MainCtrlPos>0) and (ScndCtrlPos CtrlDelay)
LastRelayTime = 0;
- if ((OK) && (EngineType == TEngineType::ElectricInductionMotor) && (ScndCtrlPosNo == 1) && (MainCtrlPos > 0))
+ if (OK && EngineType == TEngineType::ElectricInductionMotor && ScndCtrlPosNo == 1 && MainCtrlPos > 0)
{
SpeedCtrlValue = Vel;
- if ((EIMCtrlType == 0) && (SpeedCtrlAutoTurnOffFlag & 1 == 1))
+ if (EIMCtrlType == 0 && SpeedCtrlAutoTurnOffFlag & 1 == 1)
{
MainCtrlActualPos = MainCtrlPos;
}
SpeedCtrlUnit.IsActive = true;
}
- if ((OK) && (SpeedCtrl) && (ScndCtrlPos == 1) && (EngineType == TEngineType::DieselEngine))
+ if (OK && SpeedCtrl && ScndCtrlPos == 1 && EngineType == TEngineType::DieselEngine)
{
// NOTE: round() already adds 0.5, are the ones added here as well correct?
SpeedCtrlValue = Round(Vel);
@@ -2808,14 +2805,14 @@ bool TMoverParameters::DecScndCtrl(int CtrlSpeed)
{
bool OK = false;
- if ((IsMainCtrlNoPowerPos()) && (CabActive != 0) && (TrainType == dt_ET42) && (ScndCtrlPos == 0) && !(DynamicBrakeFlag) && (CtrlSpeed == 1))
+ if (IsMainCtrlNoPowerPos() && CabActive != 0 && TrainType == dt_ET42 && ScndCtrlPos == 0 && !DynamicBrakeFlag && CtrlSpeed == 1)
{
// Ra: AI wywołuje z CtrlSpeed=2 albo gdy ScndCtrlPos>0
OK = DynamicBrakeSwitch(true);
}
- else if ((ScndCtrlPosNo > 0) && (CabActive != 0))
+ else if (ScndCtrlPosNo > 0 && CabActive != 0)
{
- if ((ScndCtrlPos > 0) && (!CoupledCtrl) && ((EngineType != TEngineType::DieselElectric) || (!AutoRelayFlag)))
+ if (ScndCtrlPos > 0 && !CoupledCtrl && (EngineType != TEngineType::DieselElectric || !AutoRelayFlag))
{
if (CtrlSpeed == 1)
{
@@ -2843,7 +2840,7 @@ bool TMoverParameters::DecScndCtrl(int CtrlSpeed)
if (LastRelayTime > CtrlDownDelay)
LastRelayTime = 0;
- if ((OK) && (EngineType == TEngineType::ElectricInductionMotor) && (ScndCtrlPosNo == 1))
+ if (OK && EngineType == TEngineType::ElectricInductionMotor && ScndCtrlPosNo == 1)
{
SpeedCtrlValue = 0;
SpeedCtrlUnit.IsActive = false;
@@ -2853,7 +2850,7 @@ bool TMoverParameters::DecScndCtrl(int CtrlSpeed)
}
}
- if ((OK) && (SpeedCtrl) && (ScndCtrlPos == 0) && (EngineType == TEngineType::DieselEngine))
+ if (OK && SpeedCtrl && ScndCtrlPos == 0 && EngineType == TEngineType::DieselEngine)
{
SpeedCtrlValue = 0;
SpeedCtrlUnit.IsActive = false;
@@ -2879,13 +2876,13 @@ int TMoverParameters::GetVirtualScndPos()
bool TMoverParameters::IsScndCtrlNoPowerPos() const
{
// TODO: refine the check on account of potential electric series vehicles with speed control
- return ((ScndCtrlPos == 0) || (true == SpeedCtrl));
+ return ScndCtrlPos == 0 || true == SpeedCtrl;
}
bool TMoverParameters::IsScndCtrlMaxPowerPos() const
{
// TODO: refine the check on account of potential electric series vehicles with speed control
- return ((ScndCtrlPos == ScndCtrlPosNo) || (true == SpeedCtrl));
+ return ScndCtrlPos == ScndCtrlPosNo || true == SpeedCtrl;
}
// *************************************************************************************************
@@ -2896,7 +2893,7 @@ bool TMoverParameters::CabActivisation(bool const Enforce)
{
bool OK = false;
- OK = Enforce || (CabActive == 0); // numer kabiny, z której jest sterowanie
+ OK = Enforce || CabActive == 0; // numer kabiny, z której jest sterowanie
if (OK)
{
CabActive = CabOccupied; // sterowanie jest z kabiny z obsadą
@@ -2973,7 +2970,7 @@ bool TMoverParameters::CabDeactivisationAuto(bool const Enforce)
bool TMoverParameters::AddPulseForce(int Multipler)
{
bool APF;
- if ((EngineType == TEngineType::WheelsDriven) && (EnginePowerSource.SourceType == TPowerSource::InternalSource) && (EnginePowerSource.PowerType == TPowerType::BioPower))
+ if (EngineType == TEngineType::WheelsDriven && EnginePowerSource.SourceType == TPowerSource::InternalSource && EnginePowerSource.PowerType == TPowerType::BioPower)
{
DirActive = CabActive;
DirAbsolute = DirActive * CabActive;
@@ -2986,7 +2983,7 @@ bool TMoverParameters::AddPulseForce(int Multipler)
else
PulseForce = PulseForce * Multipler;
PulseForceCount = PulseForceCount + abs(Multipler);
- APF = (PulseForce > 0);
+ APF = PulseForce > 0;
}
else
APF = false;
@@ -3070,7 +3067,7 @@ bool TMoverParameters::Sandbox(bool const State, range_t const Notify)
if (SandDose == false)
{
// switch on
- if ((Sand > 0) && (DirActive != 0))
+ if (Sand > 0 && DirActive != 0)
{
SandDose = true;
result = true;
@@ -3087,7 +3084,7 @@ bool TMoverParameters::Sandbox(bool const State, range_t const Notify)
if (Notify != range_t::local)
{
// if requested pass the command on
- auto const couplingtype = (Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control);
+ auto const couplingtype = Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control;
if (State == true)
{
@@ -3166,11 +3163,11 @@ bool TMoverParameters::BatterySwitch(bool State, range_t const Notify)
// switching batteries does not require activation
if (Notify != range_t::local)
{
- SendCtrlToNext("BatterySwitch", (State ? 1 : 0), 1, (Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control));
- SendCtrlToNext("BatterySwitch", (State ? 1 : 0), -1, (Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control));
+ SendCtrlToNext("BatterySwitch", State ? 1 : 0, 1, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control);
+ SendCtrlToNext("BatterySwitch", State ? 1 : 0, -1, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control);
}
- return (Battery != initialstate);
+ return Battery != initialstate;
}
// *************************************************************************************************
@@ -3250,12 +3247,12 @@ bool TMoverParameters::DirectionBackward(void)
return false;
}
- if ((DirActive == 1) && (MainCtrlPos == 0) && (TrainType == dt_EZT) && (EngineType != TEngineType::ElectricInductionMotor))
+ if (DirActive == 1 && MainCtrlPos == 0 && TrainType == dt_EZT && EngineType != TEngineType::ElectricInductionMotor)
if (MinCurrentSwitch(false))
{
return true;
}
- if ((MainCtrlPosNo > 0) && (DirActive > -1) && ((CabActive != 0) || ((InactiveCabFlag & activation::neutraldirection) == 0)))
+ if (MainCtrlPosNo > 0 && DirActive > -1 && (CabActive != 0 || (InactiveCabFlag & activation::neutraldirection) == 0))
{
if (EngineType == TEngineType::WheelsDriven)
--CabActive;
@@ -3276,7 +3273,7 @@ bool TMoverParameters::EIMDirectionChangeAllow(void) const
// NOTE: disabled while eimic variables aren't immediately synced with master controller changes inside ai module
OK = (EngineType != TEngineType::ElectricInductionMotor || ((eimic <= 0) && (eimic_real <= 0) && (Vel < 0.1)));
*/
- OK = (MainCtrlPos <= MainCtrlMaxDirChangePos);
+ OK = MainCtrlPos <= MainCtrlMaxDirChangePos;
return OK;
}
@@ -3287,7 +3284,7 @@ bool TMoverParameters::EIMDirectionChangeAllow(void) const
bool TMoverParameters::AntiSlippingButton(void)
{
// NOTE: disabled the sandbox part, it's already controlled by another part of the AI routine
- return (AntiSlippingBrake() /*|| Sandbox(true)*/);
+ return AntiSlippingBrake() /*|| Sandbox(true)*/;
}
// water pump breaker state toggle
@@ -3305,10 +3302,10 @@ bool TMoverParameters::WaterPumpBreakerSwitch(bool State, range_t const Notify)
if (Notify != range_t::local)
{
- SendCtrlToNext("WaterPumpBreakerSwitch", (WaterPump.breaker ? 1 : 0), CabActive, (Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control));
+ SendCtrlToNext("WaterPumpBreakerSwitch", WaterPump.breaker ? 1 : 0, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control);
}
- return (WaterPump.breaker != initialstate);
+ return WaterPump.breaker != initialstate;
}
// water pump state toggle
@@ -3327,10 +3324,10 @@ bool TMoverParameters::WaterPumpSwitch(bool State, range_t const Notify)
if (Notify != range_t::local)
{
- SendCtrlToNext("WaterPumpSwitch", (WaterPump.is_enabled ? 1 : 0), CabActive, (Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control));
+ SendCtrlToNext("WaterPumpSwitch", WaterPump.is_enabled ? 1 : 0, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control);
}
- return (WaterPump.is_enabled != initialstate);
+ return WaterPump.is_enabled != initialstate;
}
// water pump state toggle
@@ -3349,10 +3346,10 @@ bool TMoverParameters::WaterPumpSwitchOff(bool State, range_t const Notify)
if (Notify != range_t::local)
{
- SendCtrlToNext("WaterPumpSwitchOff", (WaterPump.is_disabled ? 1 : 0), CabActive, (Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control));
+ SendCtrlToNext("WaterPumpSwitchOff", WaterPump.is_disabled ? 1 : 0, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control);
}
- return (WaterPump.is_disabled != initialstate);
+ return WaterPump.is_disabled != initialstate;
}
// water heater breaker state toggle
@@ -3370,10 +3367,10 @@ bool TMoverParameters::WaterHeaterBreakerSwitch(bool State, range_t const Notify
if (Notify != range_t::local)
{
- SendCtrlToNext("WaterHeaterBreakerSwitch", (WaterHeater.breaker ? 1 : 0), CabActive, (Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control));
+ SendCtrlToNext("WaterHeaterBreakerSwitch", WaterHeater.breaker ? 1 : 0, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control);
}
- return (WaterHeater.breaker != initialstate);
+ return WaterHeater.breaker != initialstate;
}
// water heater state toggle
@@ -3391,10 +3388,10 @@ bool TMoverParameters::WaterHeaterSwitch(bool State, range_t const Notify)
if (Notify != range_t::local)
{
- SendCtrlToNext("WaterHeaterSwitch", (WaterHeater.is_enabled ? 1 : 0), CabActive, (Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control));
+ SendCtrlToNext("WaterHeaterSwitch", WaterHeater.is_enabled ? 1 : 0, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control);
}
- return (WaterHeater.is_enabled != initialstate);
+ return WaterHeater.is_enabled != initialstate;
}
// water circuits link state toggle
@@ -3413,10 +3410,10 @@ bool TMoverParameters::WaterCircuitsLinkSwitch(bool State, range_t const Notify)
if (Notify != range_t::local)
{
- SendCtrlToNext("WaterCircuitsLinkSwitch", (WaterCircuitsLink ? 1 : 0), CabActive, (Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control));
+ SendCtrlToNext("WaterCircuitsLinkSwitch", WaterCircuitsLink ? 1 : 0, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control);
}
- return (WaterCircuitsLink != initialstate);
+ return WaterCircuitsLink != initialstate;
}
// fuel pump state toggle
@@ -3435,10 +3432,10 @@ bool TMoverParameters::FuelPumpSwitch(bool State, range_t const Notify)
if (Notify != range_t::local)
{
- SendCtrlToNext("FuelPumpSwitch", (FuelPump.is_enabled ? 1 : 0), CabActive, (Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control));
+ SendCtrlToNext("FuelPumpSwitch", FuelPump.is_enabled ? 1 : 0, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control);
}
- return (FuelPump.is_enabled != initialstate);
+ return FuelPump.is_enabled != initialstate;
}
bool TMoverParameters::FuelPumpSwitchOff(bool State, range_t const Notify)
@@ -3456,10 +3453,10 @@ bool TMoverParameters::FuelPumpSwitchOff(bool State, range_t const Notify)
if (Notify != range_t::local)
{
- SendCtrlToNext("FuelPumpSwitchOff", (FuelPump.is_disabled ? 1 : 0), CabActive, (Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control));
+ SendCtrlToNext("FuelPumpSwitchOff", FuelPump.is_disabled ? 1 : 0, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control);
}
- return (FuelPump.is_disabled != initialstate);
+ return FuelPump.is_disabled != initialstate;
}
// oil pump state toggle
@@ -3478,10 +3475,10 @@ bool TMoverParameters::OilPumpSwitch(bool State, range_t const Notify)
if (Notify != range_t::local)
{
- SendCtrlToNext("OilPumpSwitch", (OilPump.is_enabled ? 1 : 0), CabActive, (Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control));
+ SendCtrlToNext("OilPumpSwitch", OilPump.is_enabled ? 1 : 0, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control);
}
- return (OilPump.is_enabled != initialstate);
+ return OilPump.is_enabled != initialstate;
}
bool TMoverParameters::OilPumpSwitchOff(bool State, range_t const Notify)
@@ -3499,10 +3496,10 @@ bool TMoverParameters::OilPumpSwitchOff(bool State, range_t const Notify)
if (Notify != range_t::local)
{
- SendCtrlToNext("OilPumpSwitchOff", (OilPump.is_disabled ? 1 : 0), CabActive, (Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control));
+ SendCtrlToNext("OilPumpSwitchOff", OilPump.is_disabled ? 1 : 0, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control);
}
- return (OilPump.is_disabled != initialstate);
+ return OilPump.is_disabled != initialstate;
}
bool TMoverParameters::MotorBlowersSwitch(bool State, end const Side, range_t const Notify)
@@ -3510,7 +3507,7 @@ bool TMoverParameters::MotorBlowersSwitch(bool State, end const Side, range_t co
auto &fan{MotorBlowers[Side]};
- if ((fan.start_type != start_t::manual) && (fan.start_type != start_t::manualwithautofallback))
+ if (fan.start_type != start_t::manual && fan.start_type != start_t::manualwithautofallback)
{
// automatic device ignores 'manual' state commands
return false;
@@ -3522,11 +3519,11 @@ bool TMoverParameters::MotorBlowersSwitch(bool State, end const Side, range_t co
if (Notify != range_t::local)
{
- SendCtrlToNext((Side == end::front ? "MotorBlowersFrontSwitch" : "MotorBlowersRearSwitch"), (fan.is_enabled ? 1 : 0), CabActive,
- (Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control));
+ SendCtrlToNext(Side == end::front ? "MotorBlowersFrontSwitch" : "MotorBlowersRearSwitch", fan.is_enabled ? 1 : 0, CabActive,
+ Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control);
}
- return (fan.is_enabled != initialstate);
+ return fan.is_enabled != initialstate;
}
bool TMoverParameters::MotorBlowersSwitchOff(bool State, end const Side, range_t const Notify)
@@ -3534,7 +3531,7 @@ bool TMoverParameters::MotorBlowersSwitchOff(bool State, end const Side, range_t
auto &fan{MotorBlowers[Side]};
- if ((fan.start_type != start_t::manual) && (fan.start_type != start_t::manualwithautofallback))
+ if (fan.start_type != start_t::manual && fan.start_type != start_t::manualwithautofallback)
{
// automatic device ignores 'manual' state commands
return false;
@@ -3546,11 +3543,11 @@ bool TMoverParameters::MotorBlowersSwitchOff(bool State, end const Side, range_t
if (Notify != range_t::local)
{
- SendCtrlToNext((Side == end::front ? "MotorBlowersFrontSwitchOff" : "MotorBlowersRearSwitchOff"), (fan.is_disabled ? 1 : 0), CabActive,
- (Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control));
+ SendCtrlToNext(Side == end::front ? "MotorBlowersFrontSwitchOff" : "MotorBlowersRearSwitchOff", fan.is_disabled ? 1 : 0, CabActive,
+ Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control);
}
- return (fan.is_disabled != initialstate);
+ return fan.is_disabled != initialstate;
}
bool TMoverParameters::CompartmentLightsSwitch(bool State, range_t const Notify)
@@ -3568,10 +3565,10 @@ bool TMoverParameters::CompartmentLightsSwitch(bool State, range_t const Notify)
if (Notify != range_t::local)
{
- SendCtrlToNext("CompartmentLightsSwitch", (CompartmentLights.is_enabled ? 1 : 0), CabActive, (Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control));
+ SendCtrlToNext("CompartmentLightsSwitch", CompartmentLights.is_enabled ? 1 : 0, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control);
}
- return (CompartmentLights.is_enabled != initialstate);
+ return CompartmentLights.is_enabled != initialstate;
}
// water pump state toggle
@@ -3590,10 +3587,10 @@ bool TMoverParameters::CompartmentLightsSwitchOff(bool State, range_t const Noti
if (Notify != range_t::local)
{
- SendCtrlToNext("CompartmentLightsSwitchOff", (CompartmentLights.is_disabled ? 1 : 0), CabActive, (Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control));
+ SendCtrlToNext("CompartmentLightsSwitchOff", CompartmentLights.is_disabled ? 1 : 0, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control);
}
- return (CompartmentLights.is_disabled != initialstate);
+ return CompartmentLights.is_disabled != initialstate;
}
// *************************************************************************************************
@@ -3611,16 +3608,16 @@ bool TMoverParameters::MainSwitch(bool const State, range_t const Notify)
{
// pass the command to other vehicles
// TBD: pass the requested state, or the actual state?
- SendCtrlToNext("MainSwitch", (State ? 1 : 0), CabActive, (Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control));
+ SendCtrlToNext("MainSwitch", State ? 1 : 0, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control);
}
- return ((Mains || dizel_startup) != initialstate);
+ return (Mains || dizel_startup) != initialstate;
}
void TMoverParameters::MainSwitch_(bool const State)
{
- if ((Mains == State) || (MainCtrlPosNo == 0))
+ if (Mains == State || MainCtrlPosNo == 0)
{
// nothing to do
return;
@@ -3628,13 +3625,13 @@ void TMoverParameters::MainSwitch_(bool const State)
bool const initialstate{Mains};
- if ((false == State) || (true == MainSwitchCheck()))
+ if (false == State || true == MainSwitchCheck())
{
if (true == State)
{
// switch on
- if ((EngineType == TEngineType::DieselEngine) || (EngineType == TEngineType::DieselElectric))
+ if (EngineType == TEngineType::DieselEngine || EngineType == TEngineType::DieselElectric)
{
// launch diesel engine startup procedure
dizel_startup = true;
@@ -3680,7 +3677,7 @@ bool TMoverParameters::MainSwitchCheck() const
case TEngineType::ElectricInductionMotor:
{
// TODO: check whether we can simplify this check and skip the outer EngineType switch
- powerisavailable = (EnginePowerSourceVoltage() > 0.5 * EnginePowerSource.MaxVoltage);
+ powerisavailable = EnginePowerSourceVoltage() > 0.5 * EnginePowerSource.MaxVoltage;
break;
}
default:
@@ -3689,10 +3686,12 @@ bool TMoverParameters::MainSwitchCheck() const
}
}
- return ((powerisavailable) && ((ScndCtrlPos == 0) || (EngineType == TEngineType::ElectricInductionMotor)) && (MainsInitTimeCountdown <= 0.0) &&
- ((ConvOvldFlag == false) || (ConverterOverloadRelayOffWhenMainIsOff)) && (true == GroundRelay) && (true == NoVoltRelay) && (true == OvervoltageRelay) && (LastSwitchingTime > CtrlDelay) &&
- (HasCamshaft ? IsMainCtrlActualNoPowerPos() : (LineBreakerClosesOnlyAtNoPowerPos ? IsMainCtrlNoPowerPos() : true)) && (false == TestFlag(DamageFlag, dtrain_out)) &&
- (false == TestFlag(EngDmgFlag, 1)));
+ return powerisavailable && (ScndCtrlPos == 0 || EngineType == TEngineType::ElectricInductionMotor) && MainsInitTimeCountdown <= 0.0 &&
+ (ConvOvldFlag == false || ConverterOverloadRelayOffWhenMainIsOff) && true == GroundRelay && true == NoVoltRelay && true == OvervoltageRelay && LastSwitchingTime > CtrlDelay &&
+ (HasCamshaft ? IsMainCtrlActualNoPowerPos() :
+ LineBreakerClosesOnlyAtNoPowerPos ? IsMainCtrlNoPowerPos() :
+ true) &&
+ false == TestFlag(DamageFlag, dtrain_out) && false == TestFlag(EngDmgFlag, 1);
}
// *************************************************************************************************
@@ -3711,10 +3710,10 @@ bool TMoverParameters::ConverterSwitch(bool State, range_t const Notify)
if (Notify != range_t::local)
{
- SendCtrlToNext("ConverterSwitch", (State ? 1 : 0), CabActive, (Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control));
+ SendCtrlToNext("ConverterSwitch", State ? 1 : 0, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control);
}
- return (ConverterAllow != initialstate);
+ return ConverterAllow != initialstate;
}
// *************************************************************************************************
@@ -3732,17 +3731,17 @@ bool TMoverParameters::CompressorSwitch(bool State, range_t const Notify)
auto const initialstate{CompressorAllow};
- if ((VeselVolume > 0.0) && (CompressorSpeed > 0.0))
+ if (VeselVolume > 0.0 && CompressorSpeed > 0.0)
{
CompressorAllow = State;
}
if (Notify != range_t::local)
{
- SendCtrlToNext("CompressorSwitch", (State ? 1 : 0), CabActive, (Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control));
+ SendCtrlToNext("CompressorSwitch", State ? 1 : 0, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control);
}
- return (CompressorAllow != initialstate);
+ return CompressorAllow != initialstate;
}
bool TMoverParameters::ChangeCompressorPreset(int const State, range_t const Notify)
@@ -3754,10 +3753,10 @@ bool TMoverParameters::ChangeCompressorPreset(int const State, range_t const Not
if (Notify != range_t::local)
{
- SendCtrlToNext("CompressorPreset", State, CabActive, (Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control));
+ SendCtrlToNext("CompressorPreset", State, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control);
}
- return (CompressorListPos != initialstate);
+ return CompressorListPos != initialstate;
}
bool TMoverParameters::HeatingSwitch(bool const State, range_t const Notify)
@@ -3771,10 +3770,10 @@ bool TMoverParameters::HeatingSwitch(bool const State, range_t const Notify)
{
// pass the command to other vehicles
// TBD: pass the requested state, or the actual state?
- SendCtrlToNext("HeatingSwitch", (State ? 1 : 0), CabActive, (Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control));
+ SendCtrlToNext("HeatingSwitch", State ? 1 : 0, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control);
}
- return (HeatingAllow != initialstate);
+ return HeatingAllow != initialstate;
}
void TMoverParameters::HeatingSwitch_(bool const State)
@@ -3788,9 +3787,9 @@ void TMoverParameters::HeatingSwitch_(bool const State)
double TMoverParameters::EnginePowerSourceVoltage() const
{
- return (EnginePowerSource.SourceType == TPowerSource::CurrentCollector ? std::max(GetTrainsetHighVoltage(), PantographVoltage) :
- EnginePowerSource.SourceType == TPowerSource::Accumulator ? Power24vVoltage :
- 0.0);
+ return EnginePowerSource.SourceType == TPowerSource::CurrentCollector ? std::max(GetTrainsetHighVoltage(), PantographVoltage) :
+ EnginePowerSource.SourceType == TPowerSource::Accumulator ? Power24vVoltage :
+ 0.0;
}
// *************************************************************************************************
@@ -3808,7 +3807,7 @@ bool TMoverParameters::IncBrakeLevelOld(void)
++BrakeCtrlPos;
// youBy: EP po nowemu
IBLO = true;
- if ((BrakePressureActual.PipePressureVal < 0) && (BrakePressureTable[BrakeCtrlPos - 1].PipePressureVal > 0))
+ if (BrakePressureActual.PipePressureVal < 0 && BrakePressureTable[BrakeCtrlPos - 1].PipePressureVal > 0)
LimPipePress = PipePress;
}
else
@@ -3830,7 +3829,7 @@ bool TMoverParameters::DecBrakeLevelOld(void)
if (BrakeCtrlPosNo > 0)
{
- if (BrakeCtrlPos > ((BrakeHandle == TBrakeHandle::FV4a) ? -2 : -1))
+ if (BrakeCtrlPos > (BrakeHandle == TBrakeHandle::FV4a ? -2 : -1))
{
--BrakeCtrlPos;
// youBy: EP po nowemu
@@ -3853,7 +3852,7 @@ bool TMoverParameters::DecBrakeLevelOld(void)
bool TMoverParameters::IncLocalBrakeLevel(float const CtrlSpeed)
{
bool IBL;
- if ((LocalBrakePosA < 1.0) /*and (BrakeCtrlPos<1)*/)
+ if (LocalBrakePosA < 1.0 /*and (BrakeCtrlPos<1)*/)
{
LocalBrakePosA = std::min(1.0, LocalBrakePosA + CtrlSpeed / LocalBrakePosNo);
IBL = true;
@@ -3952,7 +3951,7 @@ bool TMoverParameters::DynamicBrakeAvailable(void) const
return true;
}
// strefa wylaczenia jest definiowana przez Vh0 (minimum); powyzej Vh0 ED dziala
- return (Vel >= vh0);
+ return Vel >= vh0;
}
// *************************************************************************************************
@@ -3964,7 +3963,7 @@ bool TMoverParameters::IncManualBrakeLevel(int CtrlSpeed)
bool IMBL;
if (ManualBrakePos < ManualBrakePosNo) /*and (BrakeCtrlPos<1)*/
{
- while ((ManualBrakePos < ManualBrakePosNo) && (CtrlSpeed > 0))
+ while (ManualBrakePos < ManualBrakePosNo && CtrlSpeed > 0)
{
ManualBrakePos++;
CtrlSpeed--;
@@ -3986,7 +3985,7 @@ bool TMoverParameters::DecManualBrakeLevel(int CtrlSpeed)
bool DMBL;
if (ManualBrakePos > 0)
{
- while ((CtrlSpeed > 0) && (ManualBrakePos > 0))
+ while (CtrlSpeed > 0 && ManualBrakePos > 0)
{
ManualBrakePos--;
CtrlSpeed--;
@@ -4006,7 +4005,7 @@ bool TMoverParameters::DynamicBrakeSwitch(bool Switch)
{
bool DBS;
- if ((DynamicBrakeType == dbrake_switch) && (IsMainCtrlNoPowerPos()))
+ if (DynamicBrakeType == dbrake_switch && IsMainCtrlNoPowerPos())
{
DynamicBrakeFlag = Switch;
DBS = true;
@@ -4033,17 +4032,17 @@ bool TMoverParameters::DynamicBrakeSwitch(bool Switch)
bool TMoverParameters::RadiostopSwitch(bool Switch)
{
bool EBS;
- if ((BrakeSystem != TBrakeSystem::Individual) && (BrakeCtrlPosNo > 0))
+ if (BrakeSystem != TBrakeSystem::Individual && BrakeCtrlPosNo > 0)
{
- if ((true == Switch) && (false == RadioStopFlag))
+ if (true == Switch && false == RadioStopFlag)
{
RadioStopFlag = Switch;
EBS = true;
}
else
{
- if ((Switch == false) && (std::abs(V) < 0.1))
+ if (Switch == false && std::abs(V) < 0.1)
{
// odblokowanie hamulca bezpieczenistwa tylko po zatrzymaniu
RadioStopFlag = Switch;
@@ -4102,7 +4101,7 @@ bool TMoverParameters::BrakeReleaser(int state)
if (state != 0)
{
// additional limitations imposed by pressure switch
- if ((false == ControlPressureSwitch) || (false == ReleaserEnabledOnlyAtNoPowerPos) || (true == IsMainCtrlNoPowerPos()))
+ if (false == ControlPressureSwitch || false == ReleaserEnabledOnlyAtNoPowerPos || true == IsMainCtrlNoPowerPos())
{
Hamulec->Releaser(state);
}
@@ -4155,7 +4154,7 @@ bool TMoverParameters::SwitchEPBrake(int state)
bool OK;
OK = false;
- if ((BrakeHandle == TBrakeHandle::St113) && (CabOccupied != 0))
+ if (BrakeHandle == TBrakeHandle::St113 && CabOccupied != 0)
{
if (state > 0)
EpForce = Handle->GetEP(); // TODO: przetlumaczyc
@@ -4178,11 +4177,11 @@ bool TMoverParameters::IncBrakePress(double &brake, double PressLimit, double dp
bool IBP;
// if (DynamicBrakeType<>dbrake_switch) and (DynamicBrakeType<>dbrake_none) and
// ((BrakePress>2.0) or (PipePress<3.7{(LowPipePress+0.5)})) then
- if ((DynamicBrakeType != dbrake_switch) && (DynamicBrakeType != dbrake_none) && (BrakePress > 2.0) && (TrainType != dt_EZT)) // yB radzi nie sprawdzać ciśnienia w przewodzie
+ if (DynamicBrakeType != dbrake_switch && DynamicBrakeType != dbrake_none && BrakePress > 2.0 && TrainType != dt_EZT) // yB radzi nie sprawdzać ciśnienia w przewodzie
// hunter-301211: dla EN57 silnikow nie odlaczamy
{
DynamicBrakeFlag = true; // uruchamianie hamulca ED albo odlaczanie silnikow
- if ((DynamicBrakeType == dbrake_automatic) && (abs(Im) > 60)) // nie napelniaj wiecej, jak na EP09
+ if (DynamicBrakeType == dbrake_automatic && abs(Im) > 60) // nie napelniaj wiecej, jak na EP09
dp = 0.0;
}
if (brake + dp < PressLimit)
@@ -4218,7 +4217,7 @@ bool TMoverParameters::DecBrakePress(double &brake, double PressLimit, double dp
}
// if ((DynamicBrakeType != dbrake_switch) && ((BrakePress < 0.1) && (PipePress > 0.45
// /*(LowPipePress+0.06)*/ )))
- if ((DynamicBrakeType != dbrake_switch) && (BrakePress < 0.1)) // yB radzi nie sprawdzać ciśnienia w przewodzie
+ if (DynamicBrakeType != dbrake_switch && BrakePress < 0.1) // yB radzi nie sprawdzać ciśnienia w przewodzie
DynamicBrakeFlag = false; // wylaczanie hamulca ED i/albo zalaczanie silnikow
return DBP;
@@ -4254,9 +4253,9 @@ bool TMoverParameters::IncBrakeMult(void)
{
bool IBM;
- if ((LoadFlag > 0) && (MBPM < 2) && (LoadFlag < 3))
+ if (LoadFlag > 0 && MBPM < 2 && LoadFlag < 3)
{
- if ((MaxBrakePress[2] > 0) && (LoadFlag == 1))
+ if (MaxBrakePress[2] > 0 && LoadFlag == 1)
LoadFlag = 2;
else
LoadFlag = 3;
@@ -4277,9 +4276,9 @@ bool TMoverParameters::IncBrakeMult(void)
bool TMoverParameters::DecBrakeMult(void)
{
bool DBM;
- if ((LoadFlag > 1) && (MBPM < 2))
+ if (LoadFlag > 1 && MBPM < 2)
{
- if ((MaxBrakePress[2] > 0) && (LoadFlag == 3))
+ if (MaxBrakePress[2] > 0 && LoadFlag == 3)
LoadFlag = 2;
else
LoadFlag = 1;
@@ -4340,7 +4339,7 @@ void TMoverParameters::CompressorCheck(double dt)
}
// EmergencyValve
- EmergencyValveOpen = (Compressor > (EmergencyValveOpen ? EmergencyValveOff : EmergencyValveOn));
+ EmergencyValveOpen = Compressor > (EmergencyValveOpen ? EmergencyValveOff : EmergencyValveOn);
if (EmergencyValveOpen)
{
float dV = PF(0, Compressor, EmergencyValveArea) * dt;
@@ -4359,7 +4358,7 @@ void TMoverParameters::CompressorCheck(double dt)
// checking the impact on the compressor allowance
if (AllowFactor > 0.5)
{
- CompressorAllow = (AllowFactor > 1.5);
+ CompressorAllow = AllowFactor > 1.5;
}
switch (CompressorPower)
@@ -4383,7 +4382,7 @@ void TMoverParameters::CompressorCheck(double dt)
auto const compressorpower{(CompressorPower == 0 ? Mains : CompressorPower == 3 ? Mains : Power110vIsAvailable)};
// TBD: split CompressorAllow into separate enable/disable flags, inherit compressor from basic_device
- auto const compressorenable{(CompressorAllowLocal) && ((CompressorStart == start_t::automatic) || (CompressorAllow))};
+ auto const compressorenable{CompressorAllowLocal && (CompressorStart == start_t::automatic || CompressorAllow)};
auto const compressordisable{false == compressorenable};
auto const pressureistoolow{Compressor < MinCompressorF};
@@ -4391,21 +4390,21 @@ void TMoverParameters::CompressorCheck(double dt)
// TBD, TODO: break the lock with no low voltage power?
auto const governorlockispresent{MaxCompressorF - MinCompressorF > 0.0001};
- CompressorGovernorLock = (governorlockispresent) && (false == pressureistoolow) // unlock if pressure drops below minimal threshold
+ CompressorGovernorLock = governorlockispresent && false == pressureistoolow // unlock if pressure drops below minimal threshold
&& (pressureistoohigh || CompressorGovernorLock); // lock if pressure goes above maximum threshold
// for these multi-unit engines compressors turn off whenever any of them was affected by the governor
// NOTE: this is crude implementation, limited only to adjacent vehicles
// TODO: re-implement when a more elegant/flexible system is in place
auto const coupledgovernorlock{
- ((Couplers[end::rear].Connected != nullptr) && (true == TestFlag(Couplers[end::rear].CouplingFlag, coupling::permanent)) && (Couplers[end::rear].Connected->CompressorGovernorLock)) ||
- ((Couplers[end::front].Connected != nullptr) && (true == TestFlag(Couplers[end::front].CouplingFlag, coupling::permanent)) && (Couplers[end::front].Connected->CompressorGovernorLock))};
+ (Couplers[end::rear].Connected != nullptr && true == TestFlag(Couplers[end::rear].CouplingFlag, coupling::permanent) && Couplers[end::rear].Connected->CompressorGovernorLock) ||
+ (Couplers[end::front].Connected != nullptr && true == TestFlag(Couplers[end::front].CouplingFlag, coupling::permanent) && Couplers[end::front].Connected->CompressorGovernorLock)};
auto const governorlock{CompressorGovernorLock || coupledgovernorlock};
auto const compressorflag{CompressorFlag};
CompressorFlag =
- (compressorpower) && (false == compressordisable) && ((false == governorlock) || (CompressorPower == 3)) && ((CompressorFlag) || ((compressorenable) && (LastSwitchingTime > CtrlDelay)));
+ compressorpower && false == compressordisable && (false == governorlock || CompressorPower == 3) && (CompressorFlag || (compressorenable && LastSwitchingTime > CtrlDelay));
- if ((CompressorFlag) && (CompressorFlag != compressorflag))
+ if (CompressorFlag && CompressorFlag != compressorflag)
{
// jeśli została załączona to trzeba ograniczyć ponowne włączenie
LastSwitchingTime = 0;
@@ -4434,15 +4433,14 @@ void TMoverParameters::CompressorCheck(double dt)
}
}
- if ((pressureistoohigh) && ((false == governorlockispresent) || (CompressorPower == 3)))
+ if (pressureistoohigh && (false == governorlockispresent || CompressorPower == 3))
{
// vent some air out if there's no governor lock to stop the compressor from exceeding acceptable pressure level
SetFlag(SoundFlag, sound::relay | sound::loud);
- CompressedVolume *= (
- false == governorlockispresent ? 0.80 : // arbitrary amount
+ CompressedVolume *= false == governorlockispresent ? 0.80 : // arbitrary amount
CompressorTankValve ? MinCompressorF / MaxCompressorF : // drop to mincompressor level
- 0.999 ); // HACK: drop a tiny bit so the sound doesn't trigger repeatedly
- if ((false == governorlockispresent) || (CompressorTankValve))
+ 0.999; // HACK: drop a tiny bit so the sound doesn't trigger repeatedly
+ if (false == governorlockispresent || CompressorTankValve)
{
CompressorGovernorLock = false;
}
@@ -4478,7 +4476,7 @@ void TMoverParameters::UpdatePipePressure(double dt)
{
if (PipePress > 1.0)
{
- Pipe->Flow(-(PipePress)*AirLeakRate * dt);
+ Pipe->Flow(-PipePress*AirLeakRate * dt);
Pipe->Act();
}
@@ -4497,10 +4495,10 @@ void TMoverParameters::UpdatePipePressure(double dt)
if (BrakeCtrlPosNo > 1)
{
- if ((EngineType != TEngineType::ElectricInductionMotor))
+ if (EngineType != TEngineType::ElectricInductionMotor)
{
double lbpa = LocalBrakePosA;
- if ((EIMCtrlType > 0) && (UniCtrlIntegratedLocalBrakeCtrl))
+ if (EIMCtrlType > 0 && UniCtrlIntegratedLocalBrakeCtrl)
{
lbpa = std::max(0.0, -eimic_real);
}
@@ -4520,11 +4518,11 @@ void TMoverParameters::UpdatePipePressure(double dt)
}
LockPipe = PipePress < (LockPipe ? LockPipeOff : LockPipeOn);
- bool lock_new = (LockPipe && !UnlockPipe && (BrakeCtrlPosR > HandleUnlock)) || ((EmergencyCutsOffHandle) && (EmergencyValveFlow > 0)); // new simple codition based on .fiz
- bool lock_old = ((BrakeHandle == TBrakeHandle::FV4a) // old complex condition based on assumptions
- && ((PipePress < 2.75) && ((Hamulec->GetStatus() & b_rls) == 0)) && (BrakeSubsystem == TBrakeSubSystem::ss_LSt) && (TrainType != dt_EZT) && (!UnlockPipe));
+ bool lock_new = (LockPipe && !UnlockPipe && BrakeCtrlPosR > HandleUnlock) || (EmergencyCutsOffHandle && EmergencyValveFlow > 0); // new simple codition based on .fiz
+ bool lock_old = BrakeHandle == TBrakeHandle::FV4a // old complex condition based on assumptions
+ && PipePress < 2.75 && (Hamulec->GetStatus() & b_rls) == 0 && BrakeSubsystem == TBrakeSubSystem::ss_LSt && TrainType != dt_EZT && !UnlockPipe;
- if ((lock_old) || (lock_new))
+ if (lock_old || lock_new)
{
temp = PipePress + 0.00001;
}
@@ -4534,13 +4532,13 @@ void TMoverParameters::UpdatePipePressure(double dt)
}
Handle->SetReductor(BrakeCtrlPos2);
- if (((BrakeOpModes & bom_PS) == 0) || ((CabOccupied != 0) && (BrakeOpModeFlag != bom_PS)))
+ if ((BrakeOpModes & bom_PS) == 0 || (CabOccupied != 0 && BrakeOpModeFlag != bom_PS))
{
- if ((BrakeOpModeFlag < bom_EP) || ((Handle->GetPos(bh_EB) - 0.5) < BrakeCtrlPosR) || ((BrakeHandle != TBrakeHandle::MHZ_EN57) && (BrakeHandle != TBrakeHandle::MHZ_K8P)))
+ if (BrakeOpModeFlag < bom_EP || Handle->GetPos(bh_EB) - 0.5 < BrakeCtrlPosR || (BrakeHandle != TBrakeHandle::MHZ_EN57 && BrakeHandle != TBrakeHandle::MHZ_K8P))
{
double pos = BrakeCtrlPosR;
- if (SpeedCtrlUnit.IsActive && SpeedCtrlUnit.BrakeIntervention && !SpeedCtrlUnit.Standby && (BrakeCtrlPos != Handle->GetPos(bh_EB)))
+ if (SpeedCtrlUnit.IsActive && SpeedCtrlUnit.BrakeIntervention && !SpeedCtrlUnit.Standby && BrakeCtrlPos != Handle->GetPos(bh_EB))
{
pos = Handle->GetPos(bh_NP);
if (SpeedCtrlUnit.BrakeInterventionBraking)
@@ -4575,14 +4573,14 @@ void TMoverParameters::UpdatePipePressure(double dt)
auto const lowvoltagepower{Power24vIsAvailable || Power110vIsAvailable};
- if (((true == RadioStopFlag) || (true == AlarmChainFlag) || ((true == EIMCtrlEmergency) && (LocalBrakePosA >= 1.0)) || SecuritySystem.is_braking()) ||
- ((SpringBrakeDriveEmergencyVel >= 0) && (Vel > SpringBrakeDriveEmergencyVel) && (SpringBrake.IsActive))
+ if (true == RadioStopFlag || true == AlarmChainFlag || (true == EIMCtrlEmergency && LocalBrakePosA >= 1.0) || SecuritySystem.is_braking() ||
+ (SpringBrakeDriveEmergencyVel >= 0 && Vel > SpringBrakeDriveEmergencyVel && SpringBrake.IsActive)
/*
// NOTE: disabled because 32 is 'load destroyed' flag, what does this have to do with emergency brake?
// (if it's supposed to be broken coupler, such event sets alarmchainflag instead when appropriate)
|| ( true == TestFlag( EngDmgFlag, 32 ) )
*/
- || ((0 == CabActive) && (InactiveCabFlag & activation::emergencybrake)) || ((SpringBrakeDriveEmergencyVel >= 0) && (Vel > SpringBrakeDriveEmergencyVel) && (SpringBrake.IsActive)))
+ || (0 == CabActive && InactiveCabFlag & activation::emergencybrake) || (SpringBrakeDriveEmergencyVel >= 0 && Vel > SpringBrakeDriveEmergencyVel && SpringBrake.IsActive))
{
EmergencyValveFlow = PF(0, PipePress, 0.15) * dt;
}
@@ -4590,7 +4588,7 @@ void TMoverParameters::UpdatePipePressure(double dt)
// 0.2*Spg
Pipe->Flow(-dpMainValve);
- Pipe->Flow(-(PipePress) * 0.001 * dt);
+ Pipe->Flow(-PipePress * 0.001 * dt);
// if Heating then
// Pipe.Flow(PF(PipePress, 0, d2A(7)) * dt);
// if ConverterFlag then
@@ -4630,9 +4628,9 @@ void TMoverParameters::UpdatePipePressure(double dt)
LocBrakePress = LocHandle->GetCP();
for (int b = 0; b < 2; b++)
- if (((TrainType & (dt_ET41 | dt_ET42)) != 0) && (Couplers[b].Connected != nullptr)) // nie podoba mi się to rozwiązanie, chyba trzeba
+ if ((TrainType & (dt_ET41 | dt_ET42)) != 0 && Couplers[b].Connected != nullptr) // nie podoba mi się to rozwiązanie, chyba trzeba
// dodać jakiś wpis do fizyki na to
- if (((Couplers[b].Connected->TrainType & (dt_ET41 | dt_ET42)) != 0) && ((Couplers[b].CouplingFlag & 36) == 36))
+ if ((Couplers[b].Connected->TrainType & (dt_ET41 | dt_ET42)) != 0 && (Couplers[b].CouplingFlag & 36) == 36)
LocBrakePress = std::max(Couplers[b].Connected->LocHandle->GetCP(), LocBrakePress);
// if ((DynamicBrakeFlag) && (EngineType == ElectricInductionMotor))
@@ -4645,7 +4643,7 @@ void TMoverParameters::UpdatePipePressure(double dt)
//(Hamulec as TLSt).SetLBP(LocBrakePress);
Hamulec->SetLBP(LocBrakePress);
- if ((BrakeValve == TBrakeValve::EStED))
+ if (BrakeValve == TBrakeValve::EStED)
if (MBPM < 2)
Hamulec->PLC(MaxBrakePress[LoadFlag]);
else
@@ -4705,20 +4703,20 @@ void TMoverParameters::UpdatePipePressure(double dt)
}
} // switch
- if (((BrakeHandle == TBrakeHandle::FVel6) || (BrakeHandle == TBrakeHandle::FVE408)) && (CabOccupied != 0))
+ if ((BrakeHandle == TBrakeHandle::FVel6 || BrakeHandle == TBrakeHandle::FVE408) && CabOccupied != 0)
{
- if ((Power24vIsAvailable) && (DirActive != 0) && (EpFuse)) // tu powinien byc jeszcze bezpiecznik EP i baterie -
+ if (Power24vIsAvailable && DirActive != 0 && EpFuse) // tu powinien byc jeszcze bezpiecznik EP i baterie -
// temp = (Handle as TFVel6).GetCP
EpForce = Handle->GetEP();
else
EpForce = 0.0;
- DynamicBrakeEMUStatus = (EpForce > 0.001 ? Power110vIsAvailable : true);
+ DynamicBrakeEMUStatus = EpForce > 0.001 ? Power110vIsAvailable : true;
double temp1 = EpForce;
- if ((DCEMUED_EP_max_Vel > 0.001) && (Vel > DCEMUED_EP_max_Vel) && (DynamicBrakeEMUStatus))
+ if (DCEMUED_EP_max_Vel > 0.001 && Vel > DCEMUED_EP_max_Vel && DynamicBrakeEMUStatus)
temp1 = 0;
- if ((DCEMUED_EP_min_Im > 0.001) && (abs(Im) > DCEMUED_EP_min_Im) && (DynamicBrakeEMUStatus))
+ if (DCEMUED_EP_min_Im > 0.001 && abs(Im) > DCEMUED_EP_min_Im && DynamicBrakeEMUStatus)
temp1 = 0;
Hamulec->SetEPS(temp1);
TUHEX_StageActual = EpForce;
@@ -4736,7 +4734,7 @@ void TMoverParameters::UpdatePipePressure(double dt)
Pipe->Flow(temp * Hamulec->GetPF(temp * PipePress, dt, Vel) + GetDVc(dt));
if (ASBType == 128)
- Hamulec->ASB(int(SlippingWheels && (Vel > 1)) * (1 + 2 * int(nrot_eps < -0.01)));
+ Hamulec->ASB(int(SlippingWheels && Vel > 1) * (1 + 2 * int(nrot_eps < -0.01)));
dpPipe = 0;
@@ -4765,7 +4763,7 @@ void TMoverParameters::UpdateScndPipePressure(double dt)
{
if (ScndPipePress > 1.0)
{
- Pipe2->Flow(-(ScndPipePress)*AirLeakRate * dt);
+ Pipe2->Flow(-ScndPipePress*AirLeakRate * dt);
Pipe2->Act();
}
@@ -4798,8 +4796,8 @@ void TMoverParameters::UpdateScndPipePressure(double dt)
c->switch_physics(true);
c->Pipe2->Flow(-dv2);
}
- if ((Couplers[1].Connected != nullptr) && (Couplers[0].Connected != nullptr))
- if ((TestFlag(Couplers[0].CouplingFlag, ctrain_scndpneumatic)) && (TestFlag(Couplers[1].CouplingFlag, ctrain_scndpneumatic)))
+ if (Couplers[1].Connected != nullptr && Couplers[0].Connected != nullptr)
+ if (TestFlag(Couplers[0].CouplingFlag, ctrain_scndpneumatic) && TestFlag(Couplers[1].CouplingFlag, ctrain_scndpneumatic))
{
dV = 0.00025 * dt * PF(Couplers[0].Connected->ScndPipePress, Couplers[1].Connected->ScndPipePress, Spz * 0.25);
Couplers[0].Connected->Pipe2->Flow(+dV);
@@ -4873,7 +4871,7 @@ double TMoverParameters::GetDVc(double dt)
if (TestFlag(Couplers[0].CouplingFlag, ctrain_pneumatic))
{ //*0.85
c = Couplers[0].Connected; // skrot //0.08 //e/D * L/D = e/D^2 * L
- dv1 = 0.5 * dt * PF(PipePress, c->PipePress, (Spg) / (1.0 + 0.015 / Spg * Dim.L));
+ dv1 = 0.5 * dt * PF(PipePress, c->PipePress, Spg / (1.0 + 0.015 / Spg * Dim.L));
if (dv1 * dv1 > 0.00000000000001)
c->switch_physics(true);
c->Pipe->Flow(-dv1);
@@ -4883,7 +4881,7 @@ double TMoverParameters::GetDVc(double dt)
if (TestFlag(Couplers[1].CouplingFlag, ctrain_pneumatic))
{
c = Couplers[1].Connected; // skrot
- dv2 = 0.5 * dt * PF(PipePress, c->PipePress, (Spg) / (1.0 + 0.015 / Spg * Dim.L));
+ dv2 = 0.5 * dt * PF(PipePress, c->PipePress, Spg / (1.0 + 0.015 / Spg * Dim.L));
if (dv2 * dv2 > 0.00000000000001)
c->switch_physics(true);
c->Pipe->Flow(-dv2);
@@ -4933,7 +4931,7 @@ void TMoverParameters::ComputeConstans(void)
}
Ff = TotalMassxg * (BearingF + RollF * V * V / 10.0) / 1000.0;
// dorobic liczenie temperatury lozyska!
- FrictConst1 = (TotalMassxg * RollF) / 10000.0;
+ FrictConst1 = TotalMassxg * RollF / 10000.0;
// drag calculation
{
// NOTE: draft effect of previous vehicle is simplified and doesn't have much to do with reality
@@ -4941,16 +4939,16 @@ void TMoverParameters::ComputeConstans(void)
auto dragarea{Dim.W * Dim.H};
if (previousvehicle)
{
- dragarea = std::max(0.0, dragarea - (0.85 * previousvehicle->Dim.W * previousvehicle->Dim.H));
+ dragarea = std::max(0.0, dragarea - 0.85 * previousvehicle->Dim.W * previousvehicle->Dim.H);
}
FrictConst1 += Cx * dragarea;
}
if (CategoryFlag & 1)
{
- Curvature = (RunningShape.R == 0.0 ? // zero oznacza nieskończony promień
- 0.0 :
- 1.0 / std::abs(RunningShape.R));
+ Curvature = RunningShape.R == 0.0 ? // zero oznacza nieskończony promień
+ 0.0 :
+ 1.0 / std::abs(RunningShape.R);
}
else
{
@@ -4958,8 +4956,8 @@ void TMoverParameters::ComputeConstans(void)
Curvature = 0.0;
}
// opór składu na łuku (youBy): +(500*TrackW/R)*TotalMassxg*0.001 do FrictConst2s/d
- FrictConst2s = (TotalMassxg * ((500.0 * TrackW * Curvature) + 2.5 - HideModifier + 2 * BearingF / dtrain_bearing)) * 0.001;
- FrictConst2d = (TotalMassxg * ((500.0 * TrackW * Curvature) + 2.0 - HideModifier + BearingF / dtrain_bearing)) * 0.001;
+ FrictConst2s = TotalMassxg * (500.0 * TrackW * Curvature + 2.5 - HideModifier + 2 * BearingF / dtrain_bearing) * 0.001;
+ FrictConst2d = TotalMassxg * (500.0 * TrackW * Curvature + 2.0 - HideModifier + BearingF / dtrain_bearing) * 0.001;
}
// *************************************************************************************************
@@ -4986,7 +4984,7 @@ void TMoverParameters::ComputeMass()
else
{
auto const lookup{simulation::Weights.find(LoadType.name)};
- loadtypeunitweight = (lookup != simulation::Weights.end() ? lookup->second : 1000.f); // legacy default unit weight value
+ loadtypeunitweight = lookup != simulation::Weights.end() ? lookup->second : 1000.f; // legacy default unit weight value
}
TotalMass += LoadAmount * loadtypeunitweight;
@@ -5005,13 +5003,13 @@ void TMoverParameters::ComputeTotalForce(double dt)
// McZapkie-031103: sprawdzanie czy warto liczyc fizyke i inne updaty
// ABu 300105: cos tu mieszalem , dziala teraz troche lepiej, wiec zostawiam
{
- auto const vehicleisactive{(CabActive != 0) || (Vel > 0.0001) || (std::abs(AccS) > 0.0001) || (LastSwitchingTime < 5) || (TrainType == dt_EZT) || (TrainType == dt_DMU)};
+ auto const vehicleisactive{CabActive != 0 || Vel > 0.0001 || std::abs(AccS) > 0.0001 || LastSwitchingTime < 5 || TrainType == dt_EZT || TrainType == dt_DMU};
- auto const movingvehicleahead{(Neighbours[end::front].vehicle != nullptr) &&
- ((Neighbours[end::front].vehicle->MoverParameters->Vel > 0.0001) || (std::abs(Neighbours[end::front].vehicle->MoverParameters->AccS) > 0.0001))};
+ auto const movingvehicleahead{Neighbours[end::front].vehicle != nullptr &&
+ (Neighbours[end::front].vehicle->MoverParameters->Vel > 0.0001 || std::abs(Neighbours[end::front].vehicle->MoverParameters->AccS) > 0.0001)};
- auto const movingvehiclebehind{(Neighbours[end::rear].vehicle != nullptr) &&
- ((Neighbours[end::rear].vehicle->MoverParameters->Vel > 0.0001) || (std::abs(Neighbours[end::rear].vehicle->MoverParameters->AccS) > 0.0001))};
+ auto const movingvehiclebehind{Neighbours[end::rear].vehicle != nullptr &&
+ (Neighbours[end::rear].vehicle->MoverParameters->Vel > 0.0001 || std::abs(Neighbours[end::rear].vehicle->MoverParameters->AccS) > 0.0001)};
auto const calculatephysics{vehicleisactive || movingvehicleahead || movingvehiclebehind};
@@ -5034,8 +5032,8 @@ void TMoverParameters::ComputeTotalForce(double dt)
double old_nrot = abs(nrot);
nrot = v2n(); // przeliczenie prędkości liniowej na obrotową
- if ((true == TestFlag(BrakeMethod, bp_MHS)) && (PipePress < 3.0) // ustawione na sztywno na 3 bar
- && (Vel > 45) && (true == TestFlag(BrakeDelayFlag, bdelay_M)))
+ if (true == TestFlag(BrakeMethod, bp_MHS) && PipePress < 3.0 // ustawione na sztywno na 3 bar
+ && Vel > 45 && true == TestFlag(BrakeDelayFlag, bdelay_M))
{
// doliczenie hamowania hamulcem szynowym
FStand += TrackBrakeForce;
@@ -5050,7 +5048,7 @@ void TMoverParameters::ComputeTotalForce(double dt)
if (EngineType == TEngineType::ElectricSeriesMotor) // potem ulepszyc! pantogtrafy!
{ // Ra 2014-03: uwzględnienie kierunku jazdy w napięciu na silnikach, a powinien być zdefiniowany nawrotnik
- EngineVoltage = (Mains ? EnginePowerSourceVoltage() : 0.0);
+ EngineVoltage = Mains ? EnginePowerSourceVoltage() : 0.0;
if (CabActive == 0)
{
EngineVoltage *= DirActive;
@@ -5062,10 +5060,10 @@ void TMoverParameters::ComputeTotalForce(double dt)
} // bo nie dzialalo
else
{
- EngineVoltage = (Power > 1.0 ? std::max(GetTrainsetHighVoltage(), PantographVoltage) : 0.0);
+ EngineVoltage = Power > 1.0 ? std::max(GetTrainsetHighVoltage(), PantographVoltage) : 0.0;
}
- FTrain = (Power > 0 ? TractionForce(dt) : 0);
+ FTrain = Power > 0 ? TractionForce(dt) : 0;
double FT_factor = 1.0;
if (EngineType == TEngineType::ElectricInductionMotor && InvertersRatio > 0.0)
{
@@ -5076,8 +5074,8 @@ void TMoverParameters::ComputeTotalForce(double dt)
Fb = BrakeForce(RunningTrack);
// poslizg
auto Fwheels{FTrain - Fb * Sign(V)};
- if ((Vel > 0.1) // crude trap, to prevent braked stationary vehicles from passing fb > mass * adhesive test
- && (std::abs(Fwheels) > TotalMassxg * Adhesive(RunningTrack.friction)))
+ if (Vel > 0.1 // crude trap, to prevent braked stationary vehicles from passing fb > mass * adhesive test
+ && std::abs(Fwheels) > TotalMassxg * Adhesive(RunningTrack.friction))
{
SlippingWheels = true;
}
@@ -5105,7 +5103,7 @@ void TMoverParameters::ComputeTotalForce(double dt)
}
else
{
- double factor = (FTrain - Fb * Sign(V) != 0 ? Fwheels / (FTrain - Fb * Sign(V)) : 1.0);
+ double factor = FTrain - Fb * Sign(V) != 0 ? Fwheels / (FTrain - Fb * Sign(V)) : 1.0;
Fb *= factor;
FTrain *= factor;
}
@@ -5116,7 +5114,7 @@ void TMoverParameters::ComputeTotalForce(double dt)
nrot = temp_nrot;
}
- nrot_eps = (abs(nrot) - (old_nrot)) / dt;
+ nrot_eps = (abs(nrot) - old_nrot) / dt;
// doliczenie sił z innych pojazdów
for (int end = end::front; end <= end::rear; ++end)
{
@@ -5155,9 +5153,9 @@ double TMoverParameters::BrakeForceR(double ratio, double velocity)
press = MaxBrakePress[3];
if (DynamicBrakeType == dbrake_automatic)
ratio = ratio + (1.5 - ratio) * std::min(1.0, Vel * 0.02);
- if ((BrakeDelayFlag & bdelay_R) && (BrakeMethod % 128 != bp_Cosid) && (BrakeMethod % 128 != bp_D1) && (BrakeMethod % 128 != bp_D2) && (Power < 1) && (velocity < 40))
+ if (BrakeDelayFlag & bdelay_R && BrakeMethod % 128 != bp_Cosid && BrakeMethod % 128 != bp_D1 && BrakeMethod % 128 != bp_D2 && Power < 1 && velocity < 40)
ratio = ratio / 2;
- if ((TrainType == dt_DMU) && (velocity < 30.0))
+ if (TrainType == dt_DMU && velocity < 30.0)
{
ratio -= 0.3;
}
@@ -5169,7 +5167,7 @@ double TMoverParameters::BrakeForceR(double ratio, double velocity)
double TMoverParameters::BrakeForceP(double press, double velocity)
{
double BFP = 0;
- double K = (((press * P2FTrans) - BrakeCylSpring) * BrakeCylMult[0] - BrakeSlckAdj) * BrakeRigEff;
+ double K = ((press * P2FTrans - BrakeCylSpring) * BrakeCylMult[0] - BrakeSlckAdj) * BrakeRigEff;
K *= static_cast(BrakeCylNo) / (NAxles * std::max(1, NBpA));
BFP = Hamulec->GetFC(velocity, K) * K * (NAxles * std::max(1, NBpA)) * 1000;
return BFP;
@@ -5210,12 +5208,12 @@ double TMoverParameters::BrakeForce(TTrackParam const &Track)
if (SpringBrake.IsReady)
K += std::max(0.0, SpringBrake.MinForcePressure - SpringBrake.Cylinder->P()) * SpringBrake.MaxBrakeForce;
- u = ((BrakePress * P2FTrans) - BrakeCylSpring) * BrakeCylMult[0] - BrakeSlckAdj;
+ u = (BrakePress * P2FTrans - BrakeCylSpring) * BrakeCylMult[0] - BrakeSlckAdj;
if (u * BrakeRigEff > Ntotal) // histereza na nacisku klockow
Ntotal = u * BrakeRigEff;
else
{
- u = ((BrakePress * P2FTrans) - BrakeCylSpring) * BrakeCylMult[0] - BrakeSlckAdj;
+ u = (BrakePress * P2FTrans - BrakeCylSpring) * BrakeCylMult[0] - BrakeSlckAdj;
if (u * (2.0 - BrakeRigEff) < Ntotal) // histereza na nacisku klockow
Ntotal = u * (2.0 - BrakeRigEff);
}
@@ -5228,7 +5226,7 @@ double TMoverParameters::BrakeForce(TTrackParam const &Track)
K += Ntotal; // w kN
K *= static_cast(BrakeCylNo) / (NBrakeAxles * static_cast(NBpA)); // w kN na os
}
- if ((BrakeSystem == TBrakeSystem::Pneumatic) || (BrakeSystem == TBrakeSystem::ElectroPneumatic))
+ if (BrakeSystem == TBrakeSystem::Pneumatic || BrakeSystem == TBrakeSystem::ElectroPneumatic)
{
u = Hamulec->GetFC(Vel, K);
UnitBrakeForce = u * K * 1000.0; // sila na jeden klocek w N
@@ -5255,9 +5253,9 @@ double TMoverParameters::FrictionForce() const
double FF = 0;
// ABu 240205: chyba juz ekstremalnie zoptymalizowana funkcja liczaca sily tarcia
if (abs(V) > 0.01)
- FF = (FrictConst1 * V * V) + FrictConst2d;
+ FF = FrictConst1 * V * V + FrictConst2d;
else
- FF = (FrictConst1 * V * V) + FrictConst2s;
+ FF = FrictConst1 * V * V + FrictConst2s;
return FF;
}
@@ -5334,19 +5332,19 @@ double TMoverParameters::CouplerForce(int const End, double dt)
auto const newdistance{initialdistance + 10.0 * distancedelta};
- auto const dV{V - (othervehicle->V * DirPatch(End, otherend))};
+ auto const dV{V - othervehicle->V * DirPatch(End, otherend)};
auto const absdV{std::abs(dV)};
// potentially generate sounds on clash or stretch
- if ((newdistance < 0.0) && (coupler.Dist > newdistance) && (dV < -0.1) && (false == coupler.has_adapter()))
+ if (newdistance < 0.0 && coupler.Dist > newdistance && dV < -0.1 && false == coupler.has_adapter())
{ // HACK: with adapter present we presume buffers won't clash
// 090503: dzwieki pracy zderzakow
- SetFlag(coupler.sounds, (absdV > 5.0 ? (sound::bufferclash | sound::loud) : sound::bufferclash));
+ SetFlag(coupler.sounds, absdV > 5.0 ? sound::bufferclash | sound::loud : sound::bufferclash);
}
- else if ((coupler.CouplingFlag != coupling::faux) && (newdistance > 0.001) && (coupler.Dist <= 0.001) && (absdV > 0.005) && (Vel > 1.0))
+ else if (coupler.CouplingFlag != coupling::faux && newdistance > 0.001 && coupler.Dist <= 0.001 && absdV > 0.005 && Vel > 1.0)
{
// 090503: dzwieki pracy sprzegu
- SetFlag(coupler.sounds, (absdV > 0.035 ? (sound::couplerstretch | sound::loud) : sound::couplerstretch));
+ SetFlag(coupler.sounds, absdV > 0.035 ? sound::couplerstretch | sound::loud : sound::couplerstretch);
}
coupler.CheckCollision = false;
@@ -5354,16 +5352,16 @@ double TMoverParameters::CouplerForce(int const End, double dt)
double CF{0.0};
- if ((coupler.CouplingFlag == coupling::faux) && (initialdistance > 0.05))
+ if (coupler.CouplingFlag == coupling::faux && initialdistance > 0.05)
{ // arbitrary distance
// potentially reset auto coupling lock
coupler.AutomaticCouplingAllowed = true;
}
- if ((coupler.CouplingFlag != coupling::faux) || (initialdistance < 0))
+ if (coupler.CouplingFlag != coupling::faux || initialdistance < 0)
{
- coupler.Dist = std::clamp(newdistance, (coupler.has_adapter() ? 0 : -coupler.DmaxB), coupler.DmaxC);
+ coupler.Dist = std::clamp(newdistance, coupler.has_adapter() ? 0 : -coupler.DmaxB, coupler.DmaxC);
double BetaAvg = 0;
double Fmax = 0;
@@ -5387,14 +5385,14 @@ double TMoverParameters::CouplerForce(int const End, double dt)
if (distDelta > 0)
{
- CF = (-(coupler.SpringKC + othercoupler.SpringKC) * coupler.Dist / 2.0) * DirF(End) - Fmax * dV * BetaAvg;
+ CF = -(coupler.SpringKC + othercoupler.SpringKC) * coupler.Dist / 2.0 * DirF(End) - Fmax * dV * BetaAvg;
}
else
{
- CF = (-(coupler.SpringKC + othercoupler.SpringKC) * coupler.Dist / 2.0) * DirF(End) * BetaAvg - Fmax * dV * BetaAvg;
+ CF = -(coupler.SpringKC + othercoupler.SpringKC) * coupler.Dist / 2.0 * DirF(End) * BetaAvg - Fmax * dV * BetaAvg;
}
// liczenie sily ze sprezystosci sprzegu
- if (newdistance > (coupler.DmaxC + othercoupler.DmaxC))
+ if (newdistance > coupler.DmaxC + othercoupler.DmaxC)
{
// zderzenie
coupler.CheckCollision = true;
@@ -5405,7 +5403,7 @@ double TMoverParameters::CouplerForce(int const End, double dt)
coupler.stretch_duration += dt;
// give coupler 1 sec of leeway to account for simulation glitches, before checking whether it breaks
// (arbitrary) chance to break grows from 10-100% over 10 sec period
- if (Global.crash_damage && (coupler.stretch_duration > 1.f) && (Random() < (coupler.stretch_duration * 0.1f * dt)))
+ if (Global.crash_damage && coupler.stretch_duration > 1.f && Random() < coupler.stretch_duration * 0.1f * dt)
{
damage_coupler(End);
}
@@ -5420,14 +5418,14 @@ double TMoverParameters::CouplerForce(int const End, double dt)
if (distDelta > 0)
{
- CF = (-(coupler.SpringKB + othercoupler.SpringKB) * coupler.Dist / 2.0) * DirF(End) - Fmax * dV * BetaAvg;
+ CF = -(coupler.SpringKB + othercoupler.SpringKB) * coupler.Dist / 2.0 * DirF(End) - Fmax * dV * BetaAvg;
}
else
{
- CF = (-(coupler.SpringKB + othercoupler.SpringKB) * coupler.Dist / 2.0) * DirF(End) * BetaAvg - Fmax * dV * BetaAvg;
+ CF = -(coupler.SpringKB + othercoupler.SpringKB) * coupler.Dist / 2.0 * DirF(End) * BetaAvg - Fmax * dV * BetaAvg;
}
// liczenie sily ze sprezystosci zderzaka
- auto const collisiondistance{((coupler.has_adapter() || othercoupler.has_adapter()) ?
+ auto const collisiondistance{(coupler.has_adapter() || othercoupler.has_adapter() ?
std::min(coupler.DmaxB, othercoupler.DmaxB) : // HACK: only take into account buffering ability of automatic coupler
coupler.DmaxB + othercoupler.DmaxB)};
if (-newdistance > collisiondistance)
@@ -5437,15 +5435,16 @@ double TMoverParameters::CouplerForce(int const End, double dt)
}
if (-newdistance >= std::min(collisiondistance, dEpsilon))
{
- if ((coupler.type() == TCouplerType::Automatic) && (coupler.type() == othercoupler.type()) && (coupler.CouplingFlag == coupling::faux) &&
- (coupler.AutomaticCouplingAllowed && othercoupler.AutomaticCouplingAllowed))
+ if (coupler.type() == TCouplerType::Automatic && coupler.type() == othercoupler.type() && coupler.CouplingFlag == coupling::faux &&
+ coupler.AutomaticCouplingAllowed &&
+ othercoupler.AutomaticCouplingAllowed)
{
// sprzeganie wagonow z samoczynnymi sprzegami
auto couplingtype{coupler.AutomaticCouplingFlag & othercoupler.AutomaticCouplingFlag};
// potentially exclude incompatible control coupling
if (coupler.control_type != othercoupler.control_type)
{
- couplingtype &= ~(coupling::control);
+ couplingtype &= ~coupling::control;
}
if (Attach(End, otherend, othervehicle, couplingtype))
@@ -5489,15 +5488,15 @@ double TMoverParameters::TractionForce(double dt)
{
case TEngineType::DieselElectric:
{
- if ((true == Mains) && (true == FuelPump.is_active))
+ if (true == Mains && true == FuelPump.is_active)
{
if (EIMCtrlType > 0) // sterowanie cyfrowe
- tmp = (DElist[0].RPM + ((DElist[MainCtrlPosNo].RPM - DElist[0].RPM) * std::max(0.0, eimic_real))) / 60.0;
+ tmp = (DElist[0].RPM + (DElist[MainCtrlPosNo].RPM - DElist[0].RPM) * std::max(0.0, eimic_real)) / 60.0;
else
tmp = DElist[(ControlPressureSwitch ? MainCtrlNoPowerPos() : MainCtrlPos)].RPM / 60.0;
- if ((true == HeatingAllow) && (HeatingPower > 0) && (EngineHeatingRPM > 0))
+ if (true == HeatingAllow && HeatingPower > 0 && EngineHeatingRPM > 0)
{
// bump engine revolutions up if needed, when heating is on
tmp = std::max(tmp, std::min(EngineMaxRPM(), EngineHeatingRPM) / 60.0);
@@ -5513,7 +5512,7 @@ double TMoverParameters::TractionForce(double dt)
if (enrot != tmp)
{
- enrot = std::clamp(enrot + (dt / dizel_AIM) * (enrot < tmp ? 1.0 : -1.0 * dizel_RevolutionsDecreaseRate), // NOTE: revolutions typically drop faster than they rise
+ enrot = std::clamp(enrot + dt / dizel_AIM * (enrot < tmp ? 1.0 : -1.0 * dizel_RevolutionsDecreaseRate), // NOTE: revolutions typically drop faster than they rise
0.0, std::max(tmp, enrot));
if (std::abs(tmp - enrot) < 0.001)
{
@@ -5562,7 +5561,7 @@ double TMoverParameters::TractionForce(double dt)
case 1:
{ // manual
- if ((true == RVentForceOn) || ((DirActive != 0) && (RList[MainCtrlActualPos].R > RVentCutOff)))
+ if (true == RVentForceOn || (DirActive != 0 && RList[MainCtrlActualPos].R > RVentCutOff))
{
RventRot += (RVentnmax - RventRot) * RVentSpeed * dt;
}
@@ -5576,12 +5575,12 @@ double TMoverParameters::TractionForce(double dt)
case 2:
{ // automatic
auto const motorcurrent{std::min(ImaxHi, std::abs(Im))};
- if ((std::abs(Itot) > RVentMinI) && (RList[MainCtrlActualPos].R > RVentCutOff))
+ if (std::abs(Itot) > RVentMinI && RList[MainCtrlActualPos].R > RVentCutOff)
{
- RventRot += (RVentnmax * std::min(1.0, ((motorcurrent / NPoweredAxles) / RVentMinI)) * motorcurrent / ImaxLo - RventRot) * RVentSpeed * dt;
+ RventRot += (RVentnmax * std::min(1.0, motorcurrent / NPoweredAxles / RVentMinI) * motorcurrent / ImaxLo - RventRot) * RVentSpeed * dt;
}
- else if ((DynamicBrakeType == dbrake_automatic) && (true == DynamicBrakeFlag))
+ else if (DynamicBrakeType == dbrake_automatic && true == DynamicBrakeFlag)
{
RventRot += (RVentnmax * motorcurrent / ImaxLo - RventRot) * RVentSpeed * dt;
}
@@ -5687,25 +5686,25 @@ double TMoverParameters::TractionForce(double dt)
{
// update the state of voltage relays
auto const voltage{std::max(GetTrainsetHighVoltage(), PantographVoltage)};
- NoVoltRelay = (EnginePowerSource.SourceType != TPowerSource::CurrentCollector) || (voltage >= EnginePowerSource.CollectorParameters.MinV);
+ NoVoltRelay = EnginePowerSource.SourceType != TPowerSource::CurrentCollector || voltage >= EnginePowerSource.CollectorParameters.MinV;
OvervoltageRelay =
- (EnginePowerSource.SourceType != TPowerSource::CurrentCollector) || (voltage <= EnginePowerSource.CollectorParameters.MaxV) || (false == EnginePowerSource.CollectorParameters.OVP);
+ EnginePowerSource.SourceType != TPowerSource::CurrentCollector || voltage <= EnginePowerSource.CollectorParameters.MaxV || false == EnginePowerSource.CollectorParameters.OVP;
// wywalanie szybkiego z powodu niewłaściwego napięcia
- EventFlag |= ((true == Mains) && ((false == NoVoltRelay) || (false == OvervoltageRelay)) &&
- (MainSwitch(false, (TrainType == dt_EZT ? range_t::unit : range_t::local)))); // TODO: check whether we need to send this EMU-wide
+ EventFlag |= true == Mains && (false == NoVoltRelay || false == OvervoltageRelay) &&
+ MainSwitch(false, TrainType == dt_EZT ? range_t::unit : range_t::local); // TODO: check whether we need to send this EMU-wide
break;
}
case TEngineType::ElectricInductionMotor:
{
// TODO: check if we can use instead the code for electricseriesmotor
- if ((Mains))
+ if (Mains)
{
// nie wchodzić w funkcję bez potrzeby
- if ((std::max(GetTrainsetHighVoltage(), PantographVoltage) < EnginePowerSource.CollectorParameters.MinV) ||
- (std::max(GetTrainsetHighVoltage(), PantographVoltage) > EnginePowerSource.CollectorParameters.MaxV + 200))
+ if (std::max(GetTrainsetHighVoltage(), PantographVoltage) < EnginePowerSource.CollectorParameters.MinV ||
+ std::max(GetTrainsetHighVoltage(), PantographVoltage) > EnginePowerSource.CollectorParameters.MaxV + 200)
{
- MainSwitch(false, (TrainType == dt_EZT ? range_t::unit : range_t::local)); // TODO: check whether we need to send this EMU-wide
+ MainSwitch(false, TrainType == dt_EZT ? range_t::unit : range_t::local); // TODO: check whether we need to send this EMU-wide
}
}
break;
@@ -5714,9 +5713,9 @@ double TMoverParameters::TractionForce(double dt)
case TEngineType::DieselElectric:
{
// TODO: move this to the auto relay check when the electric engine code paths are unified
- StLinFlag |= ((Mains) && (false == StLinFlag) && (MainCtrlPowerPos() == 1));
+ StLinFlag |= Mains && false == StLinFlag && MainCtrlPowerPos() == 1;
StLinFlag &= MotorConnectorsCheck();
- StLinFlag &= (MainCtrlPowerPos() > 0);
+ StLinFlag &= MainCtrlPowerPos() > 0;
break;
}
@@ -5732,7 +5731,7 @@ double TMoverParameters::TractionForce(double dt)
{
case TEngineType::Dumb:
{
- if (Mains && (CabActive != 0))
+ if (Mains && CabActive != 0)
{
if (Vel > 0.1)
{
@@ -5771,7 +5770,7 @@ double TMoverParameters::TractionForce(double dt)
{
// enrot:=Transmision.Ratio*nrot;
// yB: szereg dwoch sekcji w ET42
- if ((TrainType == dt_ET42) && (Imax == ImaxHi))
+ if (TrainType == dt_ET42 && Imax == ImaxHi)
EngineVoltage = EngineVoltage / 2.0;
Mm = Momentum(Current(enrot, EngineVoltage)); // oblicza tez prad p/slinik
@@ -5779,10 +5778,10 @@ double TMoverParameters::TractionForce(double dt)
{
if (Imax == ImaxHi)
EngineVoltage = EngineVoltage * 2;
- if ((DynamicBrakeFlag) && (abs(Im) > 300)) // przeiesione do mover.cpp
+ if (DynamicBrakeFlag && abs(Im) > 300) // przeiesione do mover.cpp
FuseOff();
}
- if ((DynamicBrakeType == dbrake_automatic) && (DynamicBrakeFlag))
+ if (DynamicBrakeType == dbrake_automatic && DynamicBrakeFlag)
{
if (TUHEX_Stages > 0) // hamowanie wielostopniowe, nadpisuje wartości domyślne
{
@@ -5800,7 +5799,7 @@ double TMoverParameters::TractionForce(double dt)
break;
case 3:
TUHEX_Sum = TUHEX_Sum3;
- if ((Vadd > 0.99 * TUHEX_MaxIw) && (DynamicBrakeRes == DynamicBrakeRes1))
+ if (Vadd > 0.99 * TUHEX_MaxIw && DynamicBrakeRes == DynamicBrakeRes1)
TUHEX_ResChange = true;
if (TUHEX_ResChange && Vadd < 0.5 * TUHEX_MaxIw)
{
@@ -5814,7 +5813,7 @@ double TMoverParameters::TractionForce(double dt)
break;
}
}
- if (((Vadd + abs(Im)) > TUHEX_Sum + TUHEX_Diff) || (Hamulec->GetEDBCP() < 0.25) || (TUHEX_ResChange) || (TUHEX_StageActual == 0 && TUHEX_Stages > 0))
+ if (Vadd + abs(Im) > TUHEX_Sum + TUHEX_Diff || Hamulec->GetEDBCP() < 0.25 || TUHEX_ResChange || (TUHEX_StageActual == 0 && TUHEX_Stages > 0))
{
Vadd -= 500.0 * dt;
if (Vadd < TUHEX_MinIw)
@@ -5823,7 +5822,7 @@ double TMoverParameters::TractionForce(double dt)
DynamicBrakeFlag = false;
}
}
- else if ((DynamicBrakeFlag) && ((Vadd + abs(Im)) < TUHEX_Sum - TUHEX_Diff))
+ else if (DynamicBrakeFlag && Vadd + abs(Im) < TUHEX_Sum - TUHEX_Diff)
{
Vadd += 70.0 * dt;
Vadd = std::min(std::max(Vadd, TUHEX_MinIw), TUHEX_MaxIw);
@@ -5832,7 +5831,7 @@ double TMoverParameters::TractionForce(double dt)
Mm = MomentumF(Im, Vadd, 0);
}
- if ((TrainType == dt_ET22) && (DelayCtrlFlag)) // szarpanie przy zmianie układu w byku
+ if (TrainType == dt_ET22 && DelayCtrlFlag) // szarpanie przy zmianie układu w byku
Mm = Mm * RList[MainCtrlActualPos].Bn / (RList[MainCtrlActualPos].Bn + 1); // zrobione w momencie, żeby nie dawac elektryki w przeliczaniu sił
if (abs(Im) > Imax)
@@ -5842,9 +5841,9 @@ double TMoverParameters::TractionForce(double dt)
if (Vhyp > CtrlDelay / 2) // jesli czas oddzialywania przekroczony
FuseOff(); // wywalanie bezpiecznika z powodu przetezenia silnikow
- if (((DynamicBrakeType == dbrake_automatic) || (DynamicBrakeType == dbrake_switch)) && (DynamicBrakeFlag))
+ if ((DynamicBrakeType == dbrake_automatic || DynamicBrakeType == dbrake_switch) && DynamicBrakeFlag)
Itot = Im * 2; // 2x2 silniki w EP09
- else if ((TrainType == dt_EZT) && (Imin == IminLo) && (ScndS)) // yBARC - boczniki na szeregu poprawnie
+ else if (TrainType == dt_EZT && Imin == IminLo && ScndS) // yBARC - boczniki na szeregu poprawnie
Itot = Im;
else
Itot = Im * RList[MainCtrlActualPos].Bn; // prad silnika * ilosc galezi
@@ -5857,7 +5856,7 @@ double TMoverParameters::TractionForce(double dt)
case TEngineType::DieselEngine:
{
Mw = dmoment * dtrans * Transmision.Efficiency; // dmoment i dtrans policzone przy okazji enginerotation
- if ((hydro_R) && (hydro_R_Placement == 0))
+ if (hydro_R && hydro_R_Placement == 0)
Mw -= dizel_MomentumRetarder(nrot * Transmision.Ratio, dt) * Transmision.Ratio * Transmision.Efficiency;
Fw = Mw * 2.0 / WheelDiameter / NPoweredAxles;
Ft = Fw * NPoweredAxles; // sila trakcyjna
@@ -5884,11 +5883,11 @@ double TMoverParameters::TractionForce(double dt)
if (true == StLinFlag)
{
- if (tmpV < (Vhyp * tempPmax / DElist[MainCtrlPosNo].GenPower))
+ if (tmpV < Vhyp * tempPmax / DElist[MainCtrlPosNo].GenPower)
{
// czy na czesci prostej, czy na hiperboli
Ft =
- (Ftmax - ((Ftmax - 1000.0 * DElist[MainCtrlPosNo].GenPower / (Vhyp + Vadd)) * (tmpV / Vhyp) / PowerCorRatio)) * eimic_positive; // posratio - bo sila jakos tam sie rozklada
+ (Ftmax - (Ftmax - 1000.0 * DElist[MainCtrlPosNo].GenPower / (Vhyp + Vadd)) * (tmpV / Vhyp) / PowerCorRatio) * eimic_positive; // posratio - bo sila jakos tam sie rozklada
}
else
{
@@ -5906,10 +5905,10 @@ double TMoverParameters::TractionForce(double dt)
{
if (true == StLinFlag)
{
- EngineVoltage = (SST[MainCtrlPos].Umax * AnPos) + (SST[MainCtrlPos].Umin * (1.0 - AnPos));
+ EngineVoltage = SST[MainCtrlPos].Umax * AnPos + SST[MainCtrlPos].Umin * (1.0 - AnPos);
// NOTE: very crude way to approximate power generated at current rpm instead of instant top output
// NOTE, TODO: doesn't take into account potentially increased revolutions if heating is on, fix it
- tmp = EngineRPMRatio() * (SST[MainCtrlPos].Pmax * AnPos) + (SST[MainCtrlPos].Pmin * (1.0 - AnPos));
+ tmp = EngineRPMRatio() * (SST[MainCtrlPos].Pmax * AnPos) + SST[MainCtrlPos].Pmin * (1.0 - AnPos);
Ft = tmp * 1000.0 / (abs(tmpV) + 1.6);
}
else
@@ -5945,10 +5944,10 @@ double TMoverParameters::TractionForce(double dt)
if (true == StLinFlag)
{
- if (tmpV < (Vhyp * power / DElist[MainCtrlPosNo].GenPower))
+ if (tmpV < Vhyp * power / DElist[MainCtrlPosNo].GenPower)
{
// czy na czesci prostej, czy na hiperboli
- Ft = (Ftmax - ((Ftmax - 1000.0 * DElist[MainCtrlPosNo].GenPower / (Vhyp + Vadd)) * (tmpV / Vhyp) / PowerCorRatio)) * PosRatio; // posratio - bo sila jakos tam sie rozklada
+ Ft = (Ftmax - (Ftmax - 1000.0 * DElist[MainCtrlPosNo].GenPower / (Vhyp + Vadd)) * (tmpV / Vhyp) / PowerCorRatio) * PosRatio; // posratio - bo sila jakos tam sie rozklada
}
else
{
@@ -6012,12 +6011,12 @@ double TMoverParameters::TractionForce(double dt)
auto tempMCPN = EIMCtrlType > 0 ? 100 : MainCtrlPosNo;
// charakterystyka pradnicy obcowzbudnej (elipsa) - twierdzenie Pitagorasa
EngineVoltage = std::sqrt(std::abs(square(tempUmax) - square(tempUmax * Im / tempImax))) * (tempMCP - 1) + (1.0 - Im / tempImax) * tempUmax * (tempMCPN - tempMCP);
- EngineVoltage /= (tempMCPN - 1);
- EngineVoltage = std::clamp(EngineVoltage, Im * 0.05, (1000.0 * tmp / std::abs(Im)));
+ EngineVoltage /= tempMCPN - 1;
+ EngineVoltage = std::clamp(EngineVoltage, Im * 0.05, 1000.0 * tmp / std::abs(Im));
}
}
- if ((EngineVoltage > tempUmax) || (Im == 0))
+ if (EngineVoltage > tempUmax || Im == 0)
{
// gdy wychodzi za duze napiecie albo przy biegu jalowym (jest cos takiego?)
EngineVoltage = tempUmax * (ConverterFlag ? 1 : 0);
@@ -6035,13 +6034,13 @@ double TMoverParameters::TractionForce(double dt)
*/
}
- if ((Imax > 1) && (Im > Imax))
+ if (Imax > 1 && Im > Imax)
FuseOff();
if (FuseFlag)
EngineVoltage = 0;
// przekazniki bocznikowania, kazdy inny dla kazdej pozycji
- if ((false == StLinFlag) || (ShuntMode))
+ if (false == StLinFlag || ShuntMode)
{
ScndCtrlPos = 0;
}
@@ -6058,11 +6057,11 @@ double TMoverParameters::TractionForce(double dt)
case 0:
{
- if ((ScndCtrlPos < ScndCtrlPosNo) && (Im <= (MPTRelay[ScndCtrlPos].Iup * PosRatio)))
+ if (ScndCtrlPos < ScndCtrlPosNo && Im <= MPTRelay[ScndCtrlPos].Iup * PosRatio)
{
++ScndCtrlPos;
}
- if ((ScndCtrlPos > 0) && (Im >= (MPTRelay[ScndCtrlPos].Idown * PosRatio)))
+ if (ScndCtrlPos > 0 && Im >= MPTRelay[ScndCtrlPos].Idown * PosRatio)
{
--ScndCtrlPos;
}
@@ -6071,11 +6070,11 @@ double TMoverParameters::TractionForce(double dt)
case 1:
{
- if ((ScndCtrlPos < ScndCtrlPosNo) && (MPTRelay[ScndCtrlPos].Iup < Vel))
+ if (ScndCtrlPos < ScndCtrlPosNo && MPTRelay[ScndCtrlPos].Iup < Vel)
{
++ScndCtrlPos;
}
- if ((ScndCtrlPos > 0) && (MPTRelay[ScndCtrlPos].Idown > Vel))
+ if (ScndCtrlPos > 0 && MPTRelay[ScndCtrlPos].Idown > Vel)
{
--ScndCtrlPos;
}
@@ -6084,11 +6083,11 @@ double TMoverParameters::TractionForce(double dt)
case 2:
{
- if ((ScndCtrlPos < ScndCtrlPosNo) && (MPTRelay[ScndCtrlPos].Iup < Vel) && (EnginePower < (tmp * 0.99)))
+ if (ScndCtrlPos < ScndCtrlPosNo && MPTRelay[ScndCtrlPos].Iup < Vel && EnginePower < tmp * 0.99)
{
++ScndCtrlPos;
}
- if ((ScndCtrlPos > 0) && (MPTRelay[ScndCtrlPos].Idown < Im))
+ if (ScndCtrlPos > 0 && MPTRelay[ScndCtrlPos].Idown < Im)
{
--ScndCtrlPos;
}
@@ -6096,12 +6095,12 @@ double TMoverParameters::TractionForce(double dt)
}
case 41:
{
- if ((ScndCtrlPos < ScndCtrlPosNo) && (MainCtrlPos == MainCtrlPosNo) && (tmpV * 3.6 > MPTRelay[ScndCtrlPos].Iup))
+ if (ScndCtrlPos < ScndCtrlPosNo && MainCtrlPos == MainCtrlPosNo && tmpV * 3.6 > MPTRelay[ScndCtrlPos].Iup)
{
++ScndCtrlPos;
enrot = enrot * 0.73;
}
- if ((ScndCtrlPos > 0) && (Im > MPTRelay[ScndCtrlPos].Idown))
+ if (ScndCtrlPos > 0 && Im > MPTRelay[ScndCtrlPos].Idown)
{
--ScndCtrlPos;
}
@@ -6109,7 +6108,7 @@ double TMoverParameters::TractionForce(double dt)
}
case 45:
{
- if ((ScndCtrlPos < ScndCtrlPosNo) && (MainCtrlPos >= 11))
+ if (ScndCtrlPos < ScndCtrlPosNo && MainCtrlPos >= 11)
{
if (Im < MPTRelay[ScndCtrlPos].Iup)
@@ -6117,13 +6116,13 @@ double TMoverParameters::TractionForce(double dt)
++ScndCtrlPos;
}
// check for cases where the speed drops below threshold for level 2 or 3
- if ((ScndCtrlPos > 1) && (Vel < MPTRelay[ScndCtrlPos - 1].Idown))
+ if (ScndCtrlPos > 1 && Vel < MPTRelay[ScndCtrlPos - 1].Idown)
{
--ScndCtrlPos;
}
}
// malenie
- if ((ScndCtrlPos > 0) && (MainCtrlPos < 11))
+ if (ScndCtrlPos > 0 && MainCtrlPos < 11)
{
if (ScndCtrlPos == 1)
@@ -6163,39 +6162,39 @@ double TMoverParameters::TractionForce(double dt)
case 46:
{
// wzrastanie
- if ((MainCtrlPos >= 12) && (ScndCtrlPos < ScndCtrlPosNo))
+ if (MainCtrlPos >= 12 && ScndCtrlPos < ScndCtrlPosNo)
{
- if ((ScndCtrlPos) % 2 == 0)
+ if (ScndCtrlPos % 2 == 0)
{
- if ((MPTRelay[ScndCtrlPos].Iup > Im))
+ if (MPTRelay[ScndCtrlPos].Iup > Im)
{
++ScndCtrlPos;
}
}
else
{
- if ((MPTRelay[ScndCtrlPos - 1].Iup > Im) && (MPTRelay[ScndCtrlPos].Iup < Vel))
+ if (MPTRelay[ScndCtrlPos - 1].Iup > Im && MPTRelay[ScndCtrlPos].Iup < Vel)
{
++ScndCtrlPos;
}
}
}
// malenie
- if ((MainCtrlPos < 12) && (ScndCtrlPos > 0))
+ if (MainCtrlPos < 12 && ScndCtrlPos > 0)
{
if (Vel < 50.0)
{
// above 50 km/h already active shunt field can be maintained until lower controller setting
- if ((ScndCtrlPos) % 2 == 0)
+ if (ScndCtrlPos % 2 == 0)
{
- if ((MPTRelay[ScndCtrlPos].Idown < Im))
+ if (MPTRelay[ScndCtrlPos].Idown < Im)
{
--ScndCtrlPos;
}
}
else
{
- if ((MPTRelay[ScndCtrlPos + 1].Idown < Im) && (MPTRelay[ScndCtrlPos].Idown > Vel))
+ if (MPTRelay[ScndCtrlPos + 1].Idown < Im && MPTRelay[ScndCtrlPos].Idown > Vel)
{
--ScndCtrlPos;
}
@@ -6220,7 +6219,7 @@ double TMoverParameters::TractionForce(double dt)
if (ScndCtrlPos != shuntfieldstate)
{
- SetFlag(SoundFlag, (sound::relay | sound::shuntfield));
+ SetFlag(SoundFlag, sound::relay | sound::shuntfield);
}
}
}
@@ -6245,7 +6244,7 @@ double TMoverParameters::TractionForce(double dt)
// tempomat
if (ScndCtrlPosNo == 4 && SpeedCtrlTypeTime)
{
- SpeedCtrlUnit.IsActive = (SpeedCtrlValue > 0);
+ SpeedCtrlUnit.IsActive = SpeedCtrlValue > 0;
switch (ScndCtrlPos)
{
case 0:
@@ -6307,26 +6306,26 @@ double TMoverParameters::TractionForce(double dt)
}
}
}
- SpeedCtrlUnit.IsActive = (SpeedCtrlValue > 0);
+ SpeedCtrlUnit.IsActive = SpeedCtrlValue > 0;
}
double edBCP = Hamulec->GetEDBCP();
- auto const localbrakeactive{(CabOccupied != 0) && (LocHandle->GetCP() > 0.25)};
+ auto const localbrakeactive{CabOccupied != 0 && LocHandle->GetCP() > 0.25};
// gdy SplitEDPneumaticBrake jest aktywne, hamulec pomocniczy (LocalBrake) NIE wymusza
// zalaczenia hamulca elektrodynamicznego - ED jest sterowany wlasnym nastawnikiem
- auto const dynbrakectrlactive{SplitEDPneumaticBrake && (DynamicBrakeRatio() > 0.01) && DynamicBrakeAvailable()};
+ auto const dynbrakectrlactive{SplitEDPneumaticBrake && DynamicBrakeRatio() > 0.01 && DynamicBrakeAvailable()};
auto const localbrakeforED{SplitEDPneumaticBrake ? false : localbrakeactive};
- if ((false == Doors.instances[side::left].is_closed) || (false == Doors.instances[side::right].is_closed) ||
+ if (false == Doors.instances[side::left].is_closed || false == Doors.instances[side::right].is_closed ||
(Doors.permit_needed && (Doors.instances[side::left].open_permit || Doors.instances[side::right].open_permit)))
{
DynamicBrakeFlag = true;
}
- else if (((edBCP < 0.25) && (false == localbrakeforED) && (false == dynbrakectrlactive) && (AnPos < 0.01)) ||
- ((edBCP < 0.25) && (ShuntModeAllow) && (false == dynbrakectrlactive) && (LocalBrakePosA < 0.01)))
+ else if ((edBCP < 0.25 && false == localbrakeforED && false == dynbrakectrlactive && AnPos < 0.01) ||
+ (edBCP < 0.25 && ShuntModeAllow && false == dynbrakectrlactive && LocalBrakePosA < 0.01))
DynamicBrakeFlag = false;
- else if ((((BrakePress > 0.25) && (edBCP > 0.25) || localbrakeforED)) || (AnPos > 0.02) || dynbrakectrlactive)
+ else if (BrakePress > 0.25 && edBCP > 0.25 || localbrakeforED || AnPos > 0.02 || dynbrakectrlactive)
DynamicBrakeFlag = true;
edBCP = Hamulec->GetEDBCP() * eimc[eimc_p_abed]; // stala napedu
- if ((DynamicBrakeFlag))
+ if (DynamicBrakeFlag)
{
// ustalanie współczynnika blendingu do luzowania hamulca PN
if (eimv[eimv_Fmax] * Sign(V) * DirAbsolute < -1)
@@ -6343,7 +6342,7 @@ double TMoverParameters::TractionForce(double dt)
PosRatio *= 0.9;
Hamulec->SetED(std::max(0.0, std::min(PosRatio, 1.0))); // ustalenie stopnia zmniejszenia ciśnienia
// ustalanie siły hamowania ED
- if ((Hamulec->GetEDBCP() > 0.25) && (eimc[eimc_p_abed] < 0.001) || (ActiveInverters < InvertersNo)) // jeśli PN wyłącza ED
+ if (Hamulec->GetEDBCP() > 0.25 && eimc[eimc_p_abed] < 0.001 || ActiveInverters < InvertersNo) // jeśli PN wyłącza ED
{
PosRatio = 0;
eimv[eimv_Fzad] = 0;
@@ -6372,7 +6371,7 @@ double TMoverParameters::TractionForce(double dt)
{
PosRatio = std::max(eimic_real, 0.);
eimv[eimv_Fzad] = PosRatio;
- if ((Flat) && (eimc[eimc_p_F0] * eimv[eimv_Fful] > 0))
+ if (Flat && eimc[eimc_p_F0] * eimv[eimv_Fful] > 0)
PosRatio = std::min(PosRatio * eimc[eimc_p_F0] / eimv[eimv_Fful], 1.);
/* if (ScndCtrlActualPos > 0) //speed control
if (Vmax < 250)
@@ -6383,7 +6382,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))
+ if (PosRatio > eimv_pr)
tmp = 4;
else
tmp = 4; // szybkie malenie, powolne wzrastanie
@@ -6391,7 +6390,7 @@ double TMoverParameters::TractionForce(double dt)
dmoment = eimv[eimv_Fful];
// NOTE: the commands to operate the sandbox are likely to conflict with other similar ai decisions
// TODO: gather these in single place so they can be resolved together
- if ((SlippingWheels))
+ if (SlippingWheels)
{
PosRatio = 0;
tmp = 10;
@@ -6408,9 +6407,9 @@ double TMoverParameters::TractionForce(double dt)
eimv_pr = 0;
}
- eimv_pr += std::max(std::min(PosRatio - eimv_pr, 0.02), -0.02) * 12 * (tmp /*2{+4*byte(PosRatio= 0))
- Vadd *= (1.0 - 2.0 * dt);
- else if ((std::abs(EngineVoltage) < EnginePowerSource.CollectorParameters.MaxV))
- Vadd *= (1.0 - dt);
+ if (eimv[eimv_Ipoj] >= 0)
+ Vadd *= 1.0 - 2.0 * dt;
+ else if (std::abs(EngineVoltage) < EnginePowerSource.CollectorParameters.MaxV)
+ Vadd *= 1.0 - dt;
else
Vadd = std::max(Vadd * (1.0 - 0.2 * dt), 0.007 * (std::abs(EngineVoltage) - (EnginePowerSource.CollectorParameters.MaxV - 100)));
Itot = eimv[eimv_Ipoj] * (0.01 + std::min(0.99, 0.99 - Vadd));
@@ -6494,15 +6493,15 @@ double TMoverParameters::TractionForce(double dt)
auto const list = useFFEDList ? FFEDlist : FFlist;
auto const listSize = useFFEDList ? FFEDListSize : FFListSize;
- if ((listSize > 0) && ((std::abs(eimv[eimv_If]) > 1.0) && (tmpV > 0.0001)))
+ if (listSize > 0 && std::abs(eimv[eimv_If]) > 1.0 && tmpV > 0.0001)
{
int i = 0;
- while ((i < listSize - 1) && (list[i + 1].v < tmpV))
+ while (i < listSize - 1 && list[i + 1].v < tmpV)
{
++i;
}
- InverterFrequency = (tmpV - list[i].v) / std::max(1.0, (list[i + 1].v - list[i].v)) * (list[i + 1].freq - list[i].freq) + list[i].freq;
+ InverterFrequency = (tmpV - list[i].v) / std::max(1.0, list[i + 1].v - list[i].v) * (list[i + 1].freq - list[i].freq) + list[i].freq;
}
else
{
@@ -6571,13 +6570,13 @@ double TMoverParameters::TractionForce(double dt)
double TMoverParameters::ComputeRotatingWheel(double WForce, double dt, double n) const
{
double newn = 0, eps = 0;
- if ((n == 0) && (WForce * Sign(V) < 0))
+ if (n == 0 && WForce * Sign(V) < 0)
newn = 0;
else
{
eps = WForce * WheelDiameter / (2.0 * AxleInertialMoment);
newn = n + eps * dt;
- if ((newn * n <= 0) && (eps * n < 0))
+ if (newn * n <= 0 && eps * n < 0)
newn = 0;
}
return newn;
@@ -6609,7 +6608,7 @@ bool TMoverParameters::FuseFlagCheck(void) const
// *************************************************************************************************
bool TMoverParameters::FuseOn(range_t const Notify)
{
- auto const result{RelayReset((relay_t::maincircuitground | relay_t::tractionnmotoroverload), Notify)};
+ auto const result{RelayReset(relay_t::maincircuitground | relay_t::tractionnmotoroverload, Notify)};
return result;
}
@@ -6658,39 +6657,39 @@ bool TMoverParameters::RelayReset(int const Relays, range_t const Notify)
if (TestFlag(Relays, relay_t::maincircuitground))
{
- if (((EngineType == TEngineType::ElectricSeriesMotor) || (EngineType == TEngineType::DieselElectric)) &&
- ((GroundRelayStart == start_t::manual) || (GroundRelayStart == start_t::manualwithautofallback)) && (IsMainCtrlNoPowerPos()) && (ScndCtrlPos == 0) && (DirActive != 0) &&
- (!TestFlag(EngDmgFlag, 1)))
+ if ((EngineType == TEngineType::ElectricSeriesMotor || EngineType == TEngineType::DieselElectric) &&
+ (GroundRelayStart == start_t::manual || GroundRelayStart == start_t::manualwithautofallback) && IsMainCtrlNoPowerPos() && ScndCtrlPos == 0 && DirActive != 0 &&
+ !TestFlag(EngDmgFlag, 1))
{
// NOTE: true means the relay is operational
- reset |= (!GroundRelay && lowvoltagepower);
+ reset |= !GroundRelay && lowvoltagepower;
GroundRelay |= lowvoltagepower;
}
}
if (TestFlag(Relays, relay_t::tractionnmotoroverload))
{
- if (((EngineType == TEngineType::ElectricSeriesMotor) || (EngineType == TEngineType::DieselElectric)) && (IsMainCtrlNoPowerPos()) && (ScndCtrlPos == 0) && (DirActive != 0) &&
- (!TestFlag(EngDmgFlag, 1)))
+ if ((EngineType == TEngineType::ElectricSeriesMotor || EngineType == TEngineType::DieselElectric) && IsMainCtrlNoPowerPos() && ScndCtrlPos == 0 && DirActive != 0 &&
+ !TestFlag(EngDmgFlag, 1))
{
// NOTE: false means the relay is operational
// TODO: cleanup, flip the FuseFlag code to match other relays
// TODO: check whether the power is required, TBD, TODO: make it configurable?
- reset |= (FuseFlag && lowvoltagepower);
+ reset |= FuseFlag && lowvoltagepower;
FuseFlag &= !lowvoltagepower;
}
}
if (TestFlag(Relays, relay_t::primaryconverteroverload))
{
- if ((ConverterOverloadRelayStart == start_t::manual)
+ if (ConverterOverloadRelayStart == start_t::manual
// && ( false == Mains )
- && (false == ConverterAllow))
+ && false == ConverterAllow)
{
// NOTE: false means the relay is operational
// TODO: cleanup, flip the FuseFlag code to match other relays
// TODO: check whether the power is required, TBD, TODO: make it configurable?
- reset |= (ConvOvldFlag && lowvoltagepower);
+ reset |= ConvOvldFlag && lowvoltagepower;
ConvOvldFlag &= !lowvoltagepower;
}
}
@@ -6702,7 +6701,7 @@ bool TMoverParameters::RelayReset(int const Relays, range_t const Notify)
if (Notify != range_t::local)
{
- SendCtrlToNext("RelayReset", Relays, CabActive, (Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control));
+ SendCtrlToNext("RelayReset", Relays, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control);
}
return reset;
@@ -6753,7 +6752,7 @@ double TMoverParameters::Momentum(double I)
SP = RList[MainCtrlActualPos].ScndAct;
// Momentum:=mfi*I*(1-1.0/(Abs(I)/mIsat+1));
- return (MotorParam[SP].mfi * I * (abs(I) / (abs(I) + MotorParam[SP].mIsat) - MotorParam[SP].mfi0));
+ return MotorParam[SP].mfi * I * (abs(I) / (abs(I) + MotorParam[SP].mIsat) - MotorParam[SP].mfi0);
}
// *************************************************************************************************
@@ -6764,7 +6763,7 @@ double TMoverParameters::MomentumF(double I, double Iw, int SCP)
{
// umozliwia dokladne sterowanie wzbudzeniem
- return (MotorParam[SCP].mfi * I * std::max(abs(Iw) / (abs(Iw) + MotorParam[SCP].mIsat) - MotorParam[SCP].mfi0, 0.));
+ return MotorParam[SCP].mfi * I * std::max(abs(Iw) / (abs(Iw) + MotorParam[SCP].mIsat) - MotorParam[SCP].mfi0, 0.);
}
// *************************************************************************************************
@@ -6774,7 +6773,7 @@ double TMoverParameters::MomentumF(double I, double Iw, int SCP)
bool TMoverParameters::CutOffEngine(void)
{
bool COE = false; // Ra: wartość domyślna, sprawdzić to trzeba
- if ((NPoweredAxles > 0) && (CabActive == 0) && (EngineType == TEngineType::ElectricSeriesMotor))
+ if (NPoweredAxles > 0 && CabActive == 0 && EngineType == TEngineType::ElectricSeriesMotor)
{
if (SetFlag(DamageFlag, -dtrain_engine))
{
@@ -6797,7 +6796,7 @@ bool TMoverParameters::MaxCurrentSwitch(bool State, range_t const Notify)
if (Notify != range_t::local)
{
- SendCtrlToNext("MaxCurrentSwitch", (State ? 1 : 0), CabActive, (Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control));
+ SendCtrlToNext("MaxCurrentSwitch", State ? 1 : 0, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control);
}
return State != initialstate;
@@ -6810,17 +6809,17 @@ bool TMoverParameters::MaxCurrentSwitch(bool State, range_t const Notify)
bool TMoverParameters::MinCurrentSwitch(bool State)
{
bool MCS = false;
- if (((EngineType == TEngineType::ElectricSeriesMotor) && (IminHi > IminLo)) || ((TrainType == dt_EZT) && (EngineType != TEngineType::ElectricInductionMotor)))
+ if ((EngineType == TEngineType::ElectricSeriesMotor && IminHi > IminLo) || (TrainType == dt_EZT && EngineType != TEngineType::ElectricInductionMotor))
{
- if (State && (Imin == IminLo))
+ if (State && Imin == IminLo)
{
Imin = IminHi;
MCS = true;
if (CabActive != 0)
SendCtrlToNext("MinCurrentSwitch", 1, CabActive);
}
- if ((!State) && (Imin == IminHi))
+ if (!State && Imin == IminHi)
{
Imin = IminLo;
MCS = true;
@@ -6858,7 +6857,7 @@ bool TMoverParameters::ResistorsFlagCheck(void) const
bool TMoverParameters::AutoRelaySwitch(bool State)
{
bool ARS;
- if ((AutoRelayType == 2) && (AutoRelayFlag != State))
+ if (AutoRelayType == 2 && AutoRelayFlag != State)
{
AutoRelayFlag = State;
ARS = true;
@@ -6884,7 +6883,7 @@ bool TMoverParameters::AutoRelayCheck(void)
// Ra 2014-06: dla SN61 nie działa prawidłowo
// yBARC - rozlaczenie stycznikow liniowych
- if ((motorconnectorsoff) || (HasCamshaft ? IsMainCtrlActualNoPowerPos() : IsMainCtrlNoPowerPos()))
+ if (motorconnectorsoff || (HasCamshaft ? IsMainCtrlActualNoPowerPos() : IsMainCtrlNoPowerPos()))
{
StLinFlag = false;
OK = false;
@@ -6897,9 +6896,9 @@ bool TMoverParameters::AutoRelayCheck(void)
}
// sprawdzenie wszystkich warunkow (AutoRelayFlag, AutoSwitch, Im 0) || (ScndCtrlPos > 0)) && (!(CoupledCtrl) || (RList[MainCtrlActualPos].Relay == MainCtrlPos)))
+ if (RList[MainCtrlActualPos].R == 0 && (ScndCtrlActualPos > 0 || ScndCtrlPos > 0) && (!CoupledCtrl || RList[MainCtrlActualPos].Relay == MainCtrlPos))
{ // zmieniaj scndctrlactualpos
// scnd bez samoczynnego rozruchu
if (ScndCtrlActualPos < ScndCtrlPos)
{
- if ((LastRelayTime > CtrlDelay) && (ARFASI2))
+ if (LastRelayTime > CtrlDelay && ARFASI2)
{
++ScndCtrlActualPos;
SetFlag(SoundFlag, sound::shuntfield);
@@ -6923,7 +6922,7 @@ bool TMoverParameters::AutoRelayCheck(void)
}
else if (ScndCtrlActualPos > ScndCtrlPos)
{
- if ((LastRelayTime > CtrlDownDelay) && (TrainType != dt_EZT))
+ if (LastRelayTime > CtrlDownDelay && TrainType != dt_EZT)
{
--ScndCtrlActualPos;
SetFlag(SoundFlag, sound::shuntfield);
@@ -6935,7 +6934,7 @@ bool TMoverParameters::AutoRelayCheck(void)
}
else
{ // zmieniaj mainctrlactualpos
- if ((DirActive < 0) && (TrainType != dt_PseudoDiesel))
+ if (DirActive < 0 && TrainType != dt_PseudoDiesel)
{
if (RList[MainCtrlActualPos + 1].Bn > BackwardsBranchesAllowed)
{
@@ -6944,18 +6943,18 @@ bool TMoverParameters::AutoRelayCheck(void)
}
}
// main bez samoczynnego rozruchu
- if ((MainCtrlActualPos < (sizeof(RList) / sizeof(TScheme) - 1)) // crude guard against running out of current fixed table
- && ((RList[MainCtrlActualPos].Relay < MainCtrlPos) || ((RList[MainCtrlActualPos + 1].Relay == MainCtrlPos) && (MainCtrlActualPos < RlistSize)) ||
- ((TrainType == dt_ET22) && (DelayCtrlFlag))))
+ if (MainCtrlActualPos < sizeof(RList) / sizeof(TScheme) - 1 // crude guard against running out of current fixed table
+ && (RList[MainCtrlActualPos].Relay < MainCtrlPos || (RList[MainCtrlActualPos + 1].Relay == MainCtrlPos && MainCtrlActualPos < RlistSize) ||
+ (TrainType == dt_ET22 && DelayCtrlFlag)))
{
// prevent switch to parallel mode if motor overload relay is set to high threshold mode
- if ((IsMotorOverloadRelayHighThresholdOn()) && (RList[MainCtrlActualPos + 1].Bn > 1))
+ if (IsMotorOverloadRelayHighThresholdOn() && RList[MainCtrlActualPos + 1].Bn > 1)
{
return false;
}
- if ((RList[MainCtrlPos].R == 0) && (MainCtrlPos > 0) && (MainCtrlPos != MainCtrlPosNo) && (FastSerialCircuit == 1))
+ if (RList[MainCtrlPos].R == 0 && MainCtrlPos > 0 && MainCtrlPos != MainCtrlPosNo && FastSerialCircuit == 1)
{
// szybkie wchodzenie na bezoporowa (303E)
// MainCtrlActualPos:=MainCtrlPos; //hunter-111012:
@@ -6973,11 +6972,11 @@ bool TMoverParameters::AutoRelayCheck(void)
OK = true;
}
}
- else if ((LastRelayTime > CtrlDelay) && (ARFASI))
+ else if (LastRelayTime > CtrlDelay && ARFASI)
{
// WriteLog("LRT = " + FloatToStr(LastRelayTime) + ", " +
// FloatToStr(CtrlDelay));
- if ((TrainType == dt_ET22) && (MainCtrlPos > 1) && ((RList[MainCtrlActualPos].Bn < RList[MainCtrlActualPos + 1].Bn) || (DelayCtrlFlag)))
+ if (TrainType == dt_ET22 && MainCtrlPos > 1 && (RList[MainCtrlActualPos].Bn < RList[MainCtrlActualPos + 1].Bn || DelayCtrlFlag))
{
// et22 z walem grupowym
if (!DelayCtrlFlag) // najpierw przejscie
@@ -7006,12 +7005,12 @@ bool TMoverParameters::AutoRelayCheck(void)
// hunter-111211: poprawki
if (MainCtrlActualPos > 0)
{
- if ((RList[MainCtrlActualPos].R == 0) && (MainCtrlActualPos != MainCtrlPosNo))
+ if (RList[MainCtrlActualPos].R == 0 && MainCtrlActualPos != MainCtrlPosNo)
{
// wejscie na bezoporowa
SetFlag(SoundFlag, sound::parallel | sound::loud);
}
- else if ((RList[MainCtrlActualPos].R > 0) && (RList[MainCtrlActualPos - 1].R == 0))
+ else if (RList[MainCtrlActualPos].R > 0 && RList[MainCtrlActualPos - 1].R == 0)
{
// wejscie na drugi uklad
SetFlag(SoundFlag, sound::parallel);
@@ -7021,7 +7020,7 @@ bool TMoverParameters::AutoRelayCheck(void)
}
else if (RList[MainCtrlActualPos].Relay > MainCtrlPos)
{
- if ((RList[MainCtrlPos].R == 0) && (MainCtrlPos > 0) && (!(MainCtrlPos == MainCtrlPosNo)) && (FastSerialCircuit == 1))
+ if (RList[MainCtrlPos].R == 0 && MainCtrlPos > 0 && !(MainCtrlPos == MainCtrlPosNo) && FastSerialCircuit == 1)
{
// szybkie wchodzenie na bezoporowa (303E)
// MainCtrlActualPos:=MainCtrlPos; //hunter-111012:
@@ -7047,7 +7046,7 @@ bool TMoverParameters::AutoRelayCheck(void)
}
}
}
- else if ((RList[MainCtrlActualPos].R > 0) && (ScndCtrlActualPos > 0))
+ else if (RList[MainCtrlActualPos].R > 0 && ScndCtrlActualPos > 0)
{
if (LastRelayTime > CtrlDownDelay)
{
@@ -7064,7 +7063,7 @@ bool TMoverParameters::AutoRelayCheck(void)
{
OK = false;
// ybARC - zalaczenie stycznikow liniowych
- if ((false == motorconnectorsoff) && (MainCtrlActualPos == 0) && ((TrainType == dt_EZT || HasCamshaft) ? MainCtrlPowerPos() > 0 : MainCtrlPowerPos() == 1))
+ if (false == motorconnectorsoff && MainCtrlActualPos == 0 && (TrainType == dt_EZT || HasCamshaft ? MainCtrlPowerPos() > 0 : MainCtrlPowerPos() == 1))
{
DelayCtrlFlag = true;
@@ -7082,7 +7081,7 @@ bool TMoverParameters::AutoRelayCheck(void)
DelayCtrlFlag = false;
}
- if ((false == StLinFlag) && ((MainCtrlActualPos > 0) || (ScndCtrlActualPos > 0)))
+ if (false == StLinFlag && (MainCtrlActualPos > 0 || ScndCtrlActualPos > 0))
{
if (CoupledCtrl)
@@ -7174,22 +7173,22 @@ bool TMoverParameters::MotorConnectorsCheck()
{
// hunter-111211: wylacznik cisnieniowy
- ControlPressureSwitch = ((HasControlPressureSwitch) && ((BrakePress > 2.0) || (PipePress < 3.6)));
+ ControlPressureSwitch = HasControlPressureSwitch && (BrakePress > 2.0 || PipePress < 3.6);
if (true == ControlPressureSwitch)
{
return false;
}
- auto const connectorsoff{(false == Mains) || (true == FuseFlag) || (true == StLinSwitchOff) || (DirActive == 0)};
+ auto const connectorsoff{false == Mains || true == FuseFlag || true == StLinSwitchOff || DirActive == 0};
- return (false == connectorsoff);
+ return false == connectorsoff;
}
bool TMoverParameters::OperatePantographsValve(operation_t const State, range_t const Notify)
{
- if ((EnginePowerSource.SourceType == TPowerSource::CurrentCollector) && (EnginePowerSource.CollectorParameters.CollectorsNo > 0))
+ if (EnginePowerSource.SourceType == TPowerSource::CurrentCollector && EnginePowerSource.CollectorParameters.CollectorsNo > 0)
{
auto &valve{PantsValve};
@@ -7239,7 +7238,7 @@ bool TMoverParameters::OperatePantographsValve(operation_t const State, range_t
if (Notify != range_t::local)
{
- SendCtrlToNext("PantsValve", static_cast(State), CabActive, (Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control));
+ SendCtrlToNext("PantsValve", static_cast(State), CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control);
}
return true;
@@ -7248,7 +7247,7 @@ bool TMoverParameters::OperatePantographsValve(operation_t const State, range_t
bool TMoverParameters::OperatePantographValve(end const End, operation_t const State, range_t const Notify)
{
- if ((EnginePowerSource.SourceType == TPowerSource::CurrentCollector) && (EnginePowerSource.CollectorParameters.CollectorsNo > 0))
+ if (EnginePowerSource.SourceType == TPowerSource::CurrentCollector && EnginePowerSource.CollectorParameters.CollectorsNo > 0)
{
auto &valve{Pantographs[End].valve};
@@ -7302,7 +7301,7 @@ bool TMoverParameters::OperatePantographValve(end const End, operation_t const S
// HACK: pack the state, pantograph index and sender cab into 8-bit value
// with high bit storing front/rear pantograph, and 7th bit storing sender cab
static_cast(0x80 * (End == end::front ? 0 : 1) + 0x40 * (CabActive != -1 ? 1 : 0) + static_cast(State)), CabActive,
- (Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control));
+ Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control);
}
return true;
@@ -7317,7 +7316,7 @@ bool TMoverParameters::DropAllPantographs(bool const State, range_t const Notify
if (Notify != range_t::local)
{
- SendCtrlToNext("PantAllDown", (State ? 1 : 0), CabActive, (Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control));
+ SendCtrlToNext("PantAllDown", State ? 1 : 0, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control);
}
return State != initialstate;
@@ -7346,15 +7345,15 @@ void TMoverParameters::CheckEIMIC(double dt)
switch (EIMCtrlType)
{
case 0:
- eimic = (brakeDemand > 0.01 ? -brakeDemand : eimic_analog > 0.01 ? eimic_analog : (double)MainCtrlPos / (double)MainCtrlPosNo);
+ eimic = brakeDemand > 0.01 ? -brakeDemand : eimic_analog > 0.01 ? eimic_analog : (double)MainCtrlPos / (double)MainCtrlPosNo;
if (EIMCtrlAdditionalZeros || EIMCtrlEmergency)
{
if (eimic > 0.001)
eimic = std::max(0.002, eimic * (double)MainCtrlPosNo / ((double)MainCtrlPosNo - offset) - offset / ((double)MainCtrlPosNo - offset));
- if ((eimic < -0.001) && (BrakeHandle != TBrakeHandle::MHZ_EN57))
+ if (eimic < -0.001 && BrakeHandle != TBrakeHandle::MHZ_EN57)
eimic = std::min(-0.002, eimic * (double)LocalBrakePosNo / ((double)LocalBrakePosNo - multiplier) + offset / ((double)LocalBrakePosNo - multiplier));
}
- if ((eimic > 0.001) && (SpeedCtrlUnit.IsActive))
+ if (eimic > 0.001 && SpeedCtrlUnit.IsActive)
eimic = std::max(eimic, SpeedCtrlUnit.MinPower);
break;
case 1:
@@ -7388,9 +7387,9 @@ void TMoverParameters::CheckEIMIC(double dt)
eimic = 0;
break;
case 2:
- if ((MainCtrlActualPos != MainCtrlPos) || (LastRelayTime > InitialCtrlDelay))
+ if (MainCtrlActualPos != MainCtrlPos || LastRelayTime > InitialCtrlDelay)
{
- double delta = (MainCtrlActualPos == MainCtrlPos ? dt * CtrlDelay : 0.01);
+ double delta = MainCtrlActualPos == MainCtrlPos ? dt * CtrlDelay : 0.01;
switch (MainCtrlPos)
{
case 0:
@@ -7423,7 +7422,7 @@ void TMoverParameters::CheckEIMIC(double dt)
case 3:
if (UniCtrlIntegratedBrakePNCtrl)
{
- if ((UniCtrlList[MainCtrlPos].mode != BrakeCtrlPos) && (MainCtrlActualPos == MainCtrlPos)) // there was no move of controller, but brake only
+ if (UniCtrlList[MainCtrlPos].mode != BrakeCtrlPos && MainCtrlActualPos == MainCtrlPos) // there was no move of controller, but brake only
{
if (BrakeCtrlPos < UniCtrlList[MainCtrlPosNo].mode)
BrakeLevelSet(UniCtrlList[MainCtrlPosNo].mode); // bottom clamping
@@ -7441,12 +7440,12 @@ void TMoverParameters::CheckEIMIC(double dt)
BrakeLevelSet(UniCtrlList[MainCtrlPos].mode);
}
- if ((MainCtrlActualPos != MainCtrlPos) || (LastRelayTime > InitialCtrlDelay))
+ if (MainCtrlActualPos != MainCtrlPos || LastRelayTime > InitialCtrlDelay)
{
eimic -= std::clamp(-UniCtrlList[MainCtrlPos].SetCtrlVal + eimic, 0.0,
- (MainCtrlActualPos == MainCtrlPos ? dt * UniCtrlList[MainCtrlPos].SpeedDown : sign(UniCtrlList[MainCtrlPos].SpeedDown) * 0.01)); // odejmuj do X
+ MainCtrlActualPos == MainCtrlPos ? dt * UniCtrlList[MainCtrlPos].SpeedDown : sign(UniCtrlList[MainCtrlPos].SpeedDown) * 0.01); // odejmuj do X
eimic += std::clamp(UniCtrlList[MainCtrlPos].SetCtrlVal - eimic, 0.0,
- (MainCtrlActualPos == MainCtrlPos ? dt * UniCtrlList[MainCtrlPos].SpeedUp : sign(UniCtrlList[MainCtrlPos].SpeedUp) * 0.01)); // dodawaj do X
+ MainCtrlActualPos == MainCtrlPos ? dt * UniCtrlList[MainCtrlPos].SpeedUp : sign(UniCtrlList[MainCtrlPos].SpeedUp) * 0.01); // dodawaj do X
eimic = std::clamp(eimic, UniCtrlList[MainCtrlPos].MinCtrlVal, UniCtrlList[MainCtrlPos].MaxCtrlVal);
}
if (MainCtrlActualPos == MainCtrlPos)
@@ -7458,11 +7457,11 @@ void TMoverParameters::CheckEIMIC(double dt)
}
if (Hamulec->GetEDBCP() > 0.3 && eimic < 0 && !UniCtrlIntegratedLocalBrakeCtrl) // when braking with pneumatic brake
eimic = 0; // shut off retarder
- if ((UniCtrlIntegratedBrakeCtrl == false) && (UniCtrlIntegratedLocalBrakeCtrl == false))
+ if (UniCtrlIntegratedBrakeCtrl == false && UniCtrlIntegratedLocalBrakeCtrl == false)
{
// w trybie SplitEDPneumaticBrake hamowanie ED przychodzi z osobnego nastawnika,
// LocalBrake operuje wylacznie pneumatycznym hamulcem lokomotywy
- eimic = (brakeDemand > 0.01 ? -brakeDemand : eimic);
+ eimic = brakeDemand > 0.01 ? -brakeDemand : eimic;
}
}
if (LocHandleTimeTraxx)
@@ -7487,10 +7486,10 @@ void TMoverParameters::CheckEIMIC(double dt)
eimic = 0;
}
- auto const eimicpowerenabled{((true == Mains) || (Power == 0.0)) && (!SpringBrake.IsActive || !SpringBrakeCutsOffDrive) && (!LockPipe) && (DirAbsolute != 0)};
+ auto const eimicpowerenabled{(true == Mains || Power == 0.0) && (!SpringBrake.IsActive || !SpringBrakeCutsOffDrive) && !LockPipe && DirAbsolute != 0};
auto const eimicdoorenabled{(SpringBrake.IsActive && ReleaseParkingBySpringBrakeWhenDoorIsOpen)};
double eimic_max = 0.0;
- if ((Doors.instances[side::left].open_permit == false) && (Doors.instances[side::right].open_permit == false))
+ if (Doors.instances[side::left].open_permit == false && Doors.instances[side::right].open_permit == false)
{
if (eimicpowerenabled)
{
@@ -7530,10 +7529,10 @@ void TMoverParameters::CheckSpeedCtrl(double dt)
}
if (!SpeedCtrlUnit.BrakeIntervention)
{
- if ((Hamulec->GetEDBCP() > 0.4) || (PipePress < (HighPipePress - 0.2)))
+ if (Hamulec->GetEDBCP() > 0.4 || PipePress < HighPipePress - 0.2)
SpeedCtrlUnit.Standby = true;
}
- if ((EIMCtrlType >= 3) && (UniCtrlList[MainCtrlPos].SpeedUp <= 0))
+ if (EIMCtrlType >= 3 && UniCtrlList[MainCtrlPos].SpeedUp <= 0)
{
accfactor = 0.0;
eimicSpeedCtrl = 0;
@@ -7543,23 +7542,23 @@ void TMoverParameters::CheckSpeedCtrl(double dt)
{ // speed control
if (true)
{
- if ((!SpeedCtrlUnit.Standby))
+ if (!SpeedCtrlUnit.Standby)
{
if (SpeedCtrlUnit.ManualStateOverride)
{
if (eimic > 0.0009)
eimic = 1.0;
}
- double error = (std::max(SpeedCtrlValue + SpeedCtrlUnit.Offset, 0.0) - Vel);
+ double error = std::max(SpeedCtrlValue + SpeedCtrlUnit.Offset, 0.0) - Vel;
double factorP = error > 0 ? SpeedCtrlUnit.FactorPpos : SpeedCtrlUnit.FactorPneg;
double eSCP = std::clamp(factorP * error, -1.2, 1.0); // P module
- bool retarder_not_work = (EngineType != TEngineType::DieselEngine) || (Vel < SpeedCtrlUnit.BrakeInterventionVel);
+ bool retarder_not_work = EngineType != TEngineType::DieselEngine || Vel < SpeedCtrlUnit.BrakeInterventionVel;
if (eSCP < -1.0)
{
- SpeedCtrlUnit.BrakeInterventionBraking = (eSCP < -1.1) && retarder_not_work && (eimicSpeedCtrl < -0.99 * SpeedCtrlUnit.DesiredPower);
+ SpeedCtrlUnit.BrakeInterventionBraking = eSCP < -1.1 && retarder_not_work && eimicSpeedCtrl < -0.99 * SpeedCtrlUnit.DesiredPower;
eSCP = -1.0;
}
- SpeedCtrlUnit.BrakeInterventionUnbraking = (eSCP > 0.0) || (Vel == 0.0);
+ SpeedCtrlUnit.BrakeInterventionUnbraking = eSCP > 0.0 || Vel == 0.0;
if (abs(eSCP) < 0.999)
{
// TODO: check how to disable integral part when braking in smart way
@@ -7577,7 +7576,7 @@ void TMoverParameters::CheckSpeedCtrl(double dt)
{
eimicSpeedCtrl = std::min(eimicSpeedCtrl, SpeedCtrlUnit.InitialPower);
}
- if ((Vel < SpeedCtrlUnit.StartVelocity) && (MainCtrlPos < MainCtrlPosNo))
+ if (Vel < SpeedCtrlUnit.StartVelocity && MainCtrlPos < MainCtrlPosNo)
{
eimicSpeedCtrl = 0;
eimic = 0;
@@ -7588,7 +7587,7 @@ void TMoverParameters::CheckSpeedCtrl(double dt)
eimicSpeedCtrl = 0;
eimicSpeedCtrlIntegral = 0;
}
- SpeedCtrlUnit.Parking = (Vel == 0.0) && (eimic <= 0) && (EngineType != TEngineType::ElectricInductionMotor);
+ SpeedCtrlUnit.Parking = Vel == 0.0 && eimic <= 0 && EngineType != TEngineType::ElectricInductionMotor;
SendCtrlToNext("SpeedCtrlUnit.Parking", SpeedCtrlUnit.Parking, CabActive);
}
else
@@ -7598,7 +7597,7 @@ void TMoverParameters::CheckSpeedCtrl(double dt)
else
eimicSpeedCtrl = std::clamp(0.5 * (SpeedCtrlValue * 2 - Vel), -1.0, 1.0);
}
- if (((SpeedCtrlAutoTurnOffFlag & 2) == 2) && (Hamulec->GetEDBCP() > 0.25))
+ if ((SpeedCtrlAutoTurnOffFlag & 2) == 2 && Hamulec->GetEDBCP() > 0.25)
{
DecScndCtrl(2);
SpeedCtrlUnit.IsActive = false;
@@ -7615,7 +7614,7 @@ void TMoverParameters::CheckSpeedCtrl(double dt)
void TMoverParameters::SpeedCtrlButton(int button)
{
- if ((SpeedCtrl) && (ScndCtrlPos > 0))
+ if (SpeedCtrl && ScndCtrlPos > 0)
{
SpeedCtrlValue = SpeedCtrlButtons[button];
}
@@ -7623,7 +7622,7 @@ void TMoverParameters::SpeedCtrlButton(int button)
void TMoverParameters::SpeedCtrlInc()
{
- if ((SpeedCtrl) && (ScndCtrlPos > 0))
+ if (SpeedCtrl && ScndCtrlPos > 0)
{
double x = floor(SpeedCtrlValue / SpeedCtrlUnit.VelocityStep) + 1.0;
SpeedCtrlValue = std::min(x * SpeedCtrlUnit.VelocityStep, SpeedCtrlUnit.MaxVelocity);
@@ -7632,7 +7631,7 @@ void TMoverParameters::SpeedCtrlInc()
void TMoverParameters::SpeedCtrlDec()
{
- if ((SpeedCtrl) && (ScndCtrlPos > 0))
+ if (SpeedCtrl && ScndCtrlPos > 0)
{
double x = ceil(SpeedCtrlValue / SpeedCtrlUnit.VelocityStep) - 1.0;
SpeedCtrlValue = std::max(x * SpeedCtrlUnit.VelocityStep, SpeedCtrlUnit.MinVelocity);
@@ -7669,7 +7668,7 @@ bool TMoverParameters::SpeedCtrlPowerDec()
// *************************************************************************************************
bool TMoverParameters::dizel_EngageSwitch(double state)
{
- if ((EngineType == TEngineType::DieselEngine) && (state <= 1) && (state >= 0) && (state != dizel_engagestate))
+ if (EngineType == TEngineType::DieselEngine && state <= 1 && state >= 0 && state != dizel_engagestate)
{
dizel_engagestate = state;
return true;
@@ -7724,20 +7723,20 @@ bool TMoverParameters::dizel_AutoGearCheck(void)
MotorParam[ScndCtrlActualPos].mfi0 + (MotorParam[ScndCtrlActualPos].mfi - MotorParam[ScndCtrlActualPos].mfi0) * std::max(0.0, eimic_real) :
MotorParam[ScndCtrlActualPos].mfi)};
- auto const VelDown{((MotorParam[ScndCtrlActualPos].fi0 != 0.0) && (eimic_real <= 0.0) ? MotorParam[ScndCtrlActualPos].fi0 : MotorParam[ScndCtrlActualPos].fi)};
+ auto const VelDown{(MotorParam[ScndCtrlActualPos].fi0 != 0.0 && eimic_real <= 0.0 ? MotorParam[ScndCtrlActualPos].fi0 : MotorParam[ScndCtrlActualPos].fi)};
if (MotorParam[ScndCtrlActualPos].AutoSwitch && Mains)
{
- if ((RList[MainCtrlPos].Mn == 0) && (!hydro_TC))
+ if (RList[MainCtrlPos].Mn == 0 && !hydro_TC)
{
if (dizel_engagestate > 0)
dizel_EngageSwitch(0);
- if ((IsMainCtrlNoPowerPos()) && (ScndCtrlActualPos > 0))
+ if (IsMainCtrlNoPowerPos() && ScndCtrlActualPos > 0)
dizel_automaticgearstatus = -1;
}
else
{
- if (MotorParam[ScndCtrlActualPos].AutoSwitch && (dizel_automaticgearstatus == 0)) // sprawdz czy zmienic biegi
+ if (MotorParam[ScndCtrlActualPos].AutoSwitch && dizel_automaticgearstatus == 0) // sprawdz czy zmienic biegi
{
if (Vel > VelUp)
{
@@ -7759,7 +7758,7 @@ bool TMoverParameters::dizel_AutoGearCheck(void)
}
}
}
- if ((dizel_engage < 0.1) && (dizel_automaticgearstatus != 0))
+ if (dizel_engage < 0.1 && dizel_automaticgearstatus != 0)
{
if (dizel_automaticgearstatus == 1)
ScndCtrlActualPos++;
@@ -7777,7 +7776,7 @@ bool TMoverParameters::dizel_AutoGearCheck(void)
{
if (dizel_automaticgearstatus == 0)
{
- if ((hydro_TC && hydro_TC_Fill > 0.01) || (eimic_real > 0.005))
+ if ((hydro_TC && hydro_TC_Fill > 0.01) || eimic_real > 0.005)
dizel_EngageSwitch(1.0);
else if (Vel > hydro_R_EngageVel && hydro_R && hydro_R_Fill > 0.01)
dizel_EngageSwitch(0.5);
@@ -7838,7 +7837,7 @@ bool TMoverParameters::dizel_StartupCheck()
// test the fuel pump
// TODO: add fuel pressure check
- if ((false == FuelPump.is_active) || ((EngineType == TEngineType::DieselEngine) && (RList[MainCtrlPos].R == 0.0)))
+ if (false == FuelPump.is_active || (EngineType == TEngineType::DieselEngine && RList[MainCtrlPos].R == 0.0))
{
engineisready = false;
// if( FuelPump.start_type == start_t::manual ) {
@@ -7847,7 +7846,7 @@ bool TMoverParameters::dizel_StartupCheck()
// }
}
// test the oil pump
- if ((false == OilPump.is_active) || (OilPump.pressure < OilPump.pressure_minimum))
+ if (false == OilPump.is_active || OilPump.pressure < OilPump.pressure_minimum)
{
engineisready = false;
if (OilPump.start_type == start_t::manual)
@@ -7878,12 +7877,12 @@ bool TMoverParameters::dizel_Update(double dt)
WaterHeaterCheck(dt);
OilPumpCheck(dt);
FuelPumpCheck(dt);
- if ((true == dizel_startup) && (true == dizel_StartupCheck()))
+ if (true == dizel_startup && true == dizel_StartupCheck())
{
dizel_ignition = true;
}
- if ((true == dizel_ignition) && (LastSwitchingTime >= InitialCtrlDelay))
+ if (true == dizel_ignition && LastSwitchingTime >= InitialCtrlDelay)
{
dizel_startup = false;
@@ -7897,9 +7896,9 @@ bool TMoverParameters::dizel_Update(double dt)
EngineType == TEngineType::DieselEngine ? dizel_nmin : DElist[0].RPM / 60.0));
}
- dizel_spinup = (dizel_spinup && Mains && (enrot < 0.95 * (EngineType == TEngineType::DieselEngine ? dizel_nmin : DElist[0].RPM / 60.0)));
+ dizel_spinup = dizel_spinup && Mains && enrot < 0.95 * (EngineType == TEngineType::DieselEngine ? dizel_nmin : DElist[0].RPM / 60.0);
- if ((true == Mains) && (false == FuelPump.is_active))
+ if (true == Mains && false == FuelPump.is_active)
{
// knock out the engine if the fuel pump isn't feeding it
// TBD, TODO: grace period before the engine is starved for fuel and knocked out
@@ -7929,10 +7928,10 @@ double TMoverParameters::dizel_fillcheck(int mcp, double dt)
{
auto realfill{0.0};
- if ((true == Mains) && (MainCtrlPosNo > 0) && (true == FuelPump.is_active))
+ if (true == Mains && MainCtrlPosNo > 0 && true == FuelPump.is_active)
{
- if ((true == dizel_ignition) && (LastSwitchingTime >= 0.9 * InitialCtrlDelay))
+ if (true == dizel_ignition && LastSwitchingTime >= 0.9 * InitialCtrlDelay)
{
// wzbogacenie przy rozruchu
// NOTE: ignition flag is reset before this code is executed
@@ -7975,7 +7974,7 @@ double TMoverParameters::dizel_fillcheck(int mcp, double dt)
{
auto nreg{0.0};
if (EIMCtrlType > 0)
- nreg = (eimic_real > 0.005 ? dizel_nreg_max : dizel_nmin);
+ nreg = eimic_real > 0.005 ? dizel_nreg_max : dizel_nmin;
else
switch (RList[MainCtrlPos].Mn)
{
@@ -7984,19 +7983,19 @@ double TMoverParameters::dizel_fillcheck(int mcp, double dt)
nreg = dizel_nmin;
break;
case 2:
- if ((dizel_automaticgearstatus == 0) && (true /*(!hydro_TC) || (dizel_engage>dizel_fill)*/))
+ if (dizel_automaticgearstatus == 0 && true /*(!hydro_TC) || (dizel_engage>dizel_fill)*/)
nreg = dizel_nreg_max;
else
nreg = dizel_nmin;
break;
case 3:
- if ((dizel_automaticgearstatus == 0) && (Vel > dizel_minVelfullengage))
+ if (dizel_automaticgearstatus == 0 && Vel > dizel_minVelfullengage)
nreg = dizel_nreg_max;
else
nreg = dizel_nmin;
break;
case 4:
- if ((dizel_automaticgearstatus == 0) && (Vel > dizel_minVelfullengage))
+ if (dizel_automaticgearstatus == 0 && Vel > dizel_minVelfullengage)
nreg = dizel_nmax;
else
nreg = dizel_nmin * 0.75 + dizel_nreg_max * 0.25;
@@ -8015,7 +8014,7 @@ double TMoverParameters::dizel_fillcheck(int mcp, double dt)
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
+ if (enrot < dizel_nreg_min && RList[mcp].R > 0.001) // jesli ponizej biegu jalowego i niezerowa dawka, to dawaj pelna
realfill = 1;
}
}
@@ -8032,7 +8031,7 @@ double TMoverParameters::dizel_Momentum(double dizel_fill, double n, double dt)
double Moment = 0, enMoment = 0, gearMoment = 0, eps = 0, newn = 0, friction = 0, neps = 0;
double TorqueH = 0, TorqueL = 0, TorqueC = 0;
n = n * CabActive;
- if ((MotorParam[ScndCtrlActualPos].mIsat < 0.001) || (DirActive == 0))
+ if (MotorParam[ScndCtrlActualPos].mIsat < 0.001 || DirActive == 0)
n = enrot;
friction = dizel_engagefriction;
hydro_TC_nIn = enrot; // wal wejsciowy przetwornika momentu
@@ -8052,14 +8051,14 @@ double TMoverParameters::dizel_Momentum(double dizel_fill, double n, double dt)
Mm = Moment;
dizel_FuelConsumptionActual = dizel_FuelConsumption * enrot * dizel_fill;
dizel_FuelConsumptedTotal += dizel_FuelConsumptionActual * dt / 3600.0;
- if ((hydro_R) && (hydro_R_Placement == 2))
+ if (hydro_R && hydro_R_Placement == 2)
Moment -= dizel_MomentumRetarder(enrot, dt);
}
else
{
Moment = -dizel_Mstand;
}
- if ((enrot < dizel_nmin / 10.0) && (eAngle < M_PI_2))
+ if (enrot < dizel_nmin / 10.0 && eAngle < M_PI_2)
{
// wstrzymywanie przy malych obrotach
Moment -= dizel_Mstand;
@@ -8072,23 +8071,23 @@ double TMoverParameters::dizel_Momentum(double dizel_fill, double n, double dt)
if (hydro_TC) // jesli przetwornik momentu
{
// napelnianie przetwornika
- bool IsPower = (EIMCtrlType > 0 ? eimic_real > 0.005 : MainCtrlPowerPos() > 0);
- if ((IsPower) && (Mains) && (enrot > dizel_nmin * 0.9))
+ bool IsPower = EIMCtrlType > 0 ? eimic_real > 0.005 : MainCtrlPowerPos() > 0;
+ if (IsPower && Mains && enrot > dizel_nmin * 0.9)
hydro_TC_Fill += hydro_TC_FillRateInc * dt;
// oproznianie przetwornika
- if (((!IsPower) && (Vel < dizel_maxVelANS)) || (!Mains) || (enrot < dizel_nmin * 0.8))
+ if ((!IsPower && Vel < dizel_maxVelANS) || !Mains || enrot < dizel_nmin * 0.8)
hydro_TC_Fill -= hydro_TC_FillRateDec * dt;
// obcinanie zakresu
hydro_TC_Fill = std::clamp(hydro_TC_Fill, 0.0, 1.0);
// blokowanie sprzegla blokującego
- if ((Vel > hydro_TC_LockupSpeed) && (Mains) && (enrot > 0.9 * dizel_nmin) && (IsPower))
+ if (Vel > hydro_TC_LockupSpeed && Mains && enrot > 0.9 * dizel_nmin && IsPower)
{
hydro_TC_Lockup = true;
hydro_TC_LockupRate += hydro_TC_FillRateInc * dt;
}
// luzowanie sprzegla blokujacego
- if ((Vel < (IsPower ? hydro_TC_LockupSpeed : hydro_TC_UnlockSpeed)) || (!Mains) || (enrot < 0.8 * dizel_nmin))
+ if (Vel < (IsPower ? hydro_TC_LockupSpeed : hydro_TC_UnlockSpeed) || !Mains || enrot < 0.8 * dizel_nmin)
{
hydro_TC_Lockup = false;
hydro_TC_LockupRate -= hydro_TC_FillRateDec * dt;
@@ -8144,7 +8143,7 @@ double TMoverParameters::dizel_Momentum(double dizel_fill, double n, double dt)
}
// sprawdzanie dociskow poszczegolnych sprzegiel
- if (abs(Moment) > std::min(TorqueC, TorqueL + abs(hydro_TC_TorqueIn)) || (abs(dizel_n_old - enrot) > 0.1)) // slizga sie z powodu roznic predkosci albo przekroczenia momentu
+ if (abs(Moment) > std::min(TorqueC, TorqueL + abs(hydro_TC_TorqueIn)) || abs(dizel_n_old - enrot) > 0.1) // slizga sie z powodu roznic predkosci albo przekroczenia momentu
{
dizel_engagedeltaomega = enrot - dizel_n_old;
@@ -8166,14 +8165,14 @@ double TMoverParameters::dizel_Momentum(double dizel_fill, double n, double dt)
else
{
hydro_TC_nOut = enrot;
- gearMoment = (TorqueC)*sign(dizel_engagedeltaomega);
+ gearMoment = TorqueC*sign(dizel_engagedeltaomega);
enMoment = Moment - gearMoment;
}
eps = enMoment / dizel_AIM;
newn = enrot + eps * dt;
- if (((newn - n) * (enrot - dizel_n_old) < 0) && (TorqueC > 0.1)) // przejscie przez zero - slizgalo sie i przestało
+ if ((newn - n) * (enrot - dizel_n_old) < 0 && TorqueC > 0.1) // przejscie przez zero - slizgalo sie i przestało
newn = n;
- if ((newn * enrot <= 0) && (eps * enrot < 0)) // przejscie przez zero obrotow
+ if (newn * enrot <= 0 && eps * enrot < 0) // przejscie przez zero obrotow
newn = 0;
enrot = newn;
}
@@ -8186,10 +8185,10 @@ double TMoverParameters::dizel_Momentum(double dizel_fill, double n, double dt)
double enrot_max = enrot + (std::min(TorqueC, TorqueL + abs(hydro_TC_TorqueIn)) + Moment) / dizel_AIM * dt;
enrot = std::clamp(n, enrot_min, enrot_max);
}
- if ((hydro_R) && (hydro_R_Placement == 1))
+ if (hydro_R && hydro_R_Placement == 1)
gearMoment -= dizel_MomentumRetarder(hydro_TC_nOut, dt);
- if ((enrot <= 0) && (false == dizel_spinup))
+ if (enrot <= 0 && false == dizel_spinup)
{
MainSwitch(false);
enrot = 0;
@@ -8202,18 +8201,18 @@ double TMoverParameters::dizel_Momentum(double dizel_fill, double n, double dt)
double TMoverParameters::dizel_MomentumRetarder(double n, double dt)
{
- double RetarderRequest = (Mains ? std::max(0.0, -eimic_real) : 0);
+ double RetarderRequest = Mains ? std::max(0.0, -eimic_real) : 0;
if (hydro_R_WithIndividual)
RetarderRequest = LocalBrakeRatio();
if (Vel < hydro_R_MinVel)
RetarderRequest = 0;
- if ((hydro_R_Placement == 2) && (enrot < dizel_nmin))
+ if (hydro_R_Placement == 2 && enrot < dizel_nmin)
{
RetarderRequest = 0;
}
- hydro_R_ClutchActive = (!hydro_R_Clutch) || (RetarderRequest > 0);
- if ((!hydro_R_Clutch) || ((hydro_R_ClutchActive) && (hydro_R_ClutchSpeed == 0)))
+ hydro_R_ClutchActive = !hydro_R_Clutch || RetarderRequest > 0;
+ if (!hydro_R_Clutch || (hydro_R_ClutchActive && hydro_R_ClutchSpeed == 0))
{
hydro_R_n = n * 60;
}
@@ -8284,35 +8283,36 @@ void TMoverParameters::dizel_Heat(double const dt)
auto const gw2 = engineon * std::lerp(gwmin2, gwmax2, revolutionsfactor) + waterpump * 1000 + engineoff * 200;
auto const gwO = std::lerp(gwmin, gwmax, revolutionsfactor);
- dizel_heat.water.is_cold = ((dizel_heat.water.config.temp_min > 0) && (dizel_heat.temperatura1 < dizel_heat.water.config.temp_min - (Mains ? 5 : 0)));
- dizel_heat.water.is_hot = ((dizel_heat.water.config.temp_max > 0) && (dizel_heat.temperatura1 > dizel_heat.water.config.temp_max - (dizel_heat.water.is_hot ? 8 : 0)));
- dizel_heat.water_aux.is_cold = ((dizel_heat.water_aux.config.temp_min > 0) && (dizel_heat.temperatura2 < dizel_heat.water_aux.config.temp_min - (Mains ? 5 : 0)));
- dizel_heat.water_aux.is_hot = ((dizel_heat.water_aux.config.temp_max > 0) && (dizel_heat.temperatura2 > dizel_heat.water_aux.config.temp_max - (dizel_heat.water_aux.is_hot ? 8 : 0)));
- dizel_heat.oil.is_cold = ((dizel_heat.oil.config.temp_min > 0) && (dizel_heat.To < dizel_heat.oil.config.temp_min - (Mains ? 5 : 0)));
- dizel_heat.oil.is_hot = ((dizel_heat.oil.config.temp_max > 0) && (dizel_heat.To > dizel_heat.oil.config.temp_max - (dizel_heat.oil.is_hot ? 8 : 0)));
+ dizel_heat.water.is_cold = dizel_heat.water.config.temp_min > 0 && dizel_heat.temperatura1 < dizel_heat.water.config.temp_min - (Mains ? 5 : 0);
+ dizel_heat.water.is_hot = dizel_heat.water.config.temp_max > 0 && dizel_heat.temperatura1 > dizel_heat.water.config.temp_max - (dizel_heat.water.is_hot ? 8 : 0);
+ dizel_heat.water_aux.is_cold = dizel_heat.water_aux.config.temp_min > 0 && dizel_heat.temperatura2 < dizel_heat.water_aux.config.temp_min - (Mains ? 5 : 0);
+ dizel_heat.water_aux.is_hot = dizel_heat.water_aux.config.temp_max > 0 && dizel_heat.temperatura2 > dizel_heat.water_aux.config.temp_max - (dizel_heat.water_aux.is_hot ? 8 : 0);
+ dizel_heat.oil.is_cold = dizel_heat.oil.config.temp_min > 0 && dizel_heat.To < dizel_heat.oil.config.temp_min - (Mains ? 5 : 0);
+ dizel_heat.oil.is_hot = dizel_heat.oil.config.temp_max > 0 && dizel_heat.To > dizel_heat.oil.config.temp_max - (dizel_heat.oil.is_hot ? 8 : 0);
// engine overheat check
- dizel_heat.engine_is_hot = ((dizel_heat.engine_max_temp > 0) && (dizel_heat.Ts > dizel_heat.engine_max_temp - (dizel_heat.engine_is_hot ? 8 : 0)));
+ dizel_heat.engine_is_hot = dizel_heat.engine_max_temp > 0 && dizel_heat.Ts > dizel_heat.engine_max_temp - (dizel_heat.engine_is_hot ? 8 : 0);
- auto const PT = ((false == dizel_heat.water.is_cold) && (false == dizel_heat.water.is_hot) && (false == dizel_heat.water_aux.is_cold) && (false == dizel_heat.water_aux.is_hot) &&
- (false == dizel_heat.oil.is_cold) && (false == dizel_heat.oil.is_hot) && (false == dizel_heat.engine.is_hot) /* && ( false == awaria_termostatow ) */) /* || PTp */;
- auto const PPT = (false == PT) /* && ( false == PPTp ) */;
- dizel_heat.PA = (/* ( ( !zamkniecie or niedomkniecie ) and !WBD ) || */ PPT /* || nurnik || ( woda < 7 ) */) /* && ( !PAp ) */;
+ auto const PT = false == dizel_heat.water.is_cold && false == dizel_heat.water.is_hot && false == dizel_heat.water_aux.is_cold && false == dizel_heat.water_aux.is_hot &&
+ false == dizel_heat.oil.is_cold && false == dizel_heat.oil.is_hot && false == dizel_heat.engine.is_hot /* && ( false == awaria_termostatow ) */
+ /* || PTp */;
+ auto const PPT = false == PT /* && ( false == PPTp ) */;
+ dizel_heat.PA = /* ( ( !zamkniecie or niedomkniecie ) and !WBD ) || */ PPT /* || nurnik || ( woda < 7 ) */;
// engine heat transfers
auto const Ge{engineon * (0.21 * dizel_heat.powerfactor * EnginePower + 12) / 3600};
// TODO: replace fixed heating power cost with more accurate calculation
- auto const obciazenie{engineon * ((dizel_heat.powerfactor * EnginePower / 950) + (Heating ? HeatingPower : 0) + 70)};
+ auto const obciazenie{engineon * (dizel_heat.powerfactor * EnginePower / 950 + (Heating ? HeatingPower : 0) + 70)};
auto const Qd{qs * Ge - obciazenie};
// silnik oddaje czesc ciepla do wody chlodzacej, a takze pewna niewielka czesc do otoczenia, modyfikowane przez okienko
- auto const Qs{(Qd - (dizel_heat.kfs * (dizel_heat.Ts - dizel_heat.Tsr)) - (dizel_heat.kfe * /* ( 0.3 + 0.7 * ( dizel_heat.okienko ? 1 : 0 ) ) * */ (dizel_heat.Ts - dizel_heat.Te)))};
+ auto const Qs{(Qd - dizel_heat.kfs * (dizel_heat.Ts - dizel_heat.Tsr) - dizel_heat.kfe * /* ( 0.3 + 0.7 * ( dizel_heat.okienko ? 1 : 0 ) ) * */ (dizel_heat.Ts - dizel_heat.Te))};
auto const dTss{Qs / Cs};
- dizel_heat.Ts += (dTss * dt);
+ dizel_heat.Ts += dTss * dt;
// oil heat transfers
// olej oddaje cieplo do wody gdy krazy przez wymiennik ciepla == wlaczona pompka lub silnik
- auto const dTo{(dizel_heat.auxiliary_water_circuit ? ((dizel_heat.kfo * (dizel_heat.Ts - dizel_heat.To)) - (dizel_heat.kfo2 * (dizel_heat.To - dizel_heat.Tsr2))) / (gwO * Co) :
- ((dizel_heat.kfo * (dizel_heat.Ts - dizel_heat.To)) - (dizel_heat.kfo2 * (dizel_heat.To - dizel_heat.Tsr))) / (gwO * Co))};
- dizel_heat.To += (dTo * dt);
+ auto const dTo{(dizel_heat.auxiliary_water_circuit ? (dizel_heat.kfo * (dizel_heat.Ts - dizel_heat.To) - dizel_heat.kfo2 * (dizel_heat.To - dizel_heat.Tsr2)) / (gwO * Co) :
+ (dizel_heat.kfo * (dizel_heat.Ts - dizel_heat.To) - dizel_heat.kfo2 * (dizel_heat.To - dizel_heat.Tsr)) / (gwO * Co))};
+ dizel_heat.To += dTo * dt;
// heater
/*
@@ -8320,52 +8320,52 @@ void TMoverParameters::dizel_Heat(double const dt)
Qp = (float)( podgrzewacz and ( true == WaterPump.is_active ) and ( Twy < 55 ) and ( Twy2 < 55 ) ) * 1000;
else
*/
- auto const Qp = (((true == WaterHeater.is_active) && (true == WaterPump.is_active) && (dizel_heat.Twy < 60) && (dizel_heat.Twy2 < 60)) ? 1 : 0) * 1000;
+ auto const Qp = (true == WaterHeater.is_active && true == WaterPump.is_active && dizel_heat.Twy < 60 && dizel_heat.Twy2 < 60 ? 1 : 0) * 1000;
auto const kurek07{1}; // unknown/unimplemented device TBD, TODO: identify and implement?
if (true == dizel_heat.auxiliary_water_circuit)
{
// auxiliary water circuit setup
- dizel_heat.water_aux.is_warm = ((true == dizel_heat.cooling) || ((true == Mains) && (BatteryVoltage > (0.75 * NominalBatteryVoltage)) /* && !bezpompy && !awaria_chlodzenia && !WS10 */
- && (dizel_heat.water_aux.config.temp_cooling > 0) &&
- (dizel_heat.temperatura2 > dizel_heat.water_aux.config.temp_cooling - (dizel_heat.water_aux.is_warm ? 8 : 0))));
+ dizel_heat.water_aux.is_warm = true == dizel_heat.cooling ||
+ (true == Mains && BatteryVoltage > 0.75 * NominalBatteryVoltage /* && !bezpompy && !awaria_chlodzenia && !WS10 */
+ && dizel_heat.water_aux.config.temp_cooling > 0 && dizel_heat.temperatura2 > dizel_heat.water_aux.config.temp_cooling - (dizel_heat.water_aux.is_warm ? 8 : 0));
auto const PTC2{(dizel_heat.water_aux.is_warm /*or PTC2p*/ ? 1 : 0)};
- dizel_heat.rpmwz2 = PTC2 * (dizel_heat.fan_speed >= 0 ? (rpm * dizel_heat.fan_speed) : (dizel_heat.fan_speed * -1));
- dizel_heat.zaluzje2 = (dizel_heat.water_aux.config.shutters ? (PTC2 == 1) : true); // no shutters is an equivalent to having them open
+ dizel_heat.rpmwz2 = PTC2 * (dizel_heat.fan_speed >= 0 ? rpm * dizel_heat.fan_speed : dizel_heat.fan_speed * -1);
+ dizel_heat.zaluzje2 = dizel_heat.water_aux.config.shutters ? PTC2 == 1 : true; // no shutters is an equivalent to having them open
auto const zaluzje2{(dizel_heat.zaluzje2 ? 1 : 0)};
// auxiliary water circuit heat transfer values
- auto const kf2{kurek07 * ((dizel_heat.kw * (0.3 + 0.7 * zaluzje2)) * dizel_heat.rpmw2 + (dizel_heat.kv * (0.3 + 0.7 * zaluzje2) * Vel / 3.6)) + 2};
- auto const dTs2{((dizel_heat.kfo2 * (dizel_heat.To - dizel_heat.Tsr2))) / (gw2 * Cw)};
+ auto const kf2{kurek07 * (dizel_heat.kw * (0.3 + 0.7 * zaluzje2) * dizel_heat.rpmw2 + dizel_heat.kv * (0.3 + 0.7 * zaluzje2) * Vel / 3.6) + 2};
+ auto const dTs2{dizel_heat.kfo2 * (dizel_heat.To - dizel_heat.Tsr2) / (gw2 * Cw)};
// przy otwartym kurku B ma³y obieg jest dogrzewany przez du¿y - stosujemy przy korzystaniu z podgrzewacza oraz w zimie
- auto const Qch2{-kf2 * (dizel_heat.Tsr2 - dizel_heat.Te) + (80 * (true == WaterCircuitsLink ? 1 : 0) * (dizel_heat.Twy - dizel_heat.Tsr2))};
+ auto const Qch2{-kf2 * (dizel_heat.Tsr2 - dizel_heat.Te) + 80 * (true == WaterCircuitsLink ? 1 : 0) * (dizel_heat.Twy - dizel_heat.Tsr2)};
auto const dTch2{Qch2 / (gw2 * Cw)};
// auxiliary water circuit heat transfers finalization
// NOTE: since primary circuit doesn't read data from the auxiliary one, we can pretty safely finalize auxiliary updates before touching the primary circuit
- auto const Twe2{dizel_heat.Twy2 + (dTch2 * dt)};
- dizel_heat.Twy2 = Twe2 + (dTs2 * dt);
+ auto const Twe2{dizel_heat.Twy2 + dTch2 * dt};
+ dizel_heat.Twy2 = Twe2 + dTs2 * dt;
dizel_heat.Tsr2 = 0.5 * (dizel_heat.Twy2 + Twe2);
dizel_heat.temperatura2 = dizel_heat.Twy2;
}
// primary water circuit setup
- dizel_heat.water.is_flowing = ((dizel_heat.water.config.temp_flow < 0) || (dizel_heat.temperatura1 > dizel_heat.water.config.temp_flow - (dizel_heat.water.is_flowing ? 5 : 0)));
+ dizel_heat.water.is_flowing = dizel_heat.water.config.temp_flow < 0 || dizel_heat.temperatura1 > dizel_heat.water.config.temp_flow - (dizel_heat.water.is_flowing ? 5 : 0);
auto const obieg{(dizel_heat.water.is_flowing ? 1 : 0)};
dizel_heat.water.is_warm =
- ((true == dizel_heat.cooling) || ((true == Mains) && (BatteryVoltage > (0.75 * NominalBatteryVoltage)) /* && !bezpompy && !awaria_chlodzenia && !WS10 */
- && (dizel_heat.water.config.temp_cooling > 0) && (dizel_heat.temperatura1 > dizel_heat.water.config.temp_cooling - (dizel_heat.water.is_warm ? 8 : 0))));
+ true == dizel_heat.cooling || (true == Mains && BatteryVoltage > 0.75 * NominalBatteryVoltage /* && !bezpompy && !awaria_chlodzenia && !WS10 */
+ && dizel_heat.water.config.temp_cooling > 0 && dizel_heat.temperatura1 > dizel_heat.water.config.temp_cooling - (dizel_heat.water.is_warm ? 8 : 0));
auto const PTC1{(dizel_heat.water.is_warm /*or PTC1p*/ ? 1 : 0)};
- dizel_heat.rpmwz = PTC1 * (dizel_heat.fan_speed >= 0 ? (rpm * dizel_heat.fan_speed) : (dizel_heat.fan_speed * -1));
- dizel_heat.zaluzje1 = (dizel_heat.water.config.shutters ? (PTC1 == 1) : true); // no shutters is an equivalent to having them open
+ dizel_heat.rpmwz = PTC1 * (dizel_heat.fan_speed >= 0 ? rpm * dizel_heat.fan_speed : dizel_heat.fan_speed * -1);
+ dizel_heat.zaluzje1 = dizel_heat.water.config.shutters ? PTC1 == 1 : true; // no shutters is an equivalent to having them open
auto const zaluzje1{(dizel_heat.zaluzje1 ? 1 : 0)};
// primary water circuit heat transfer values
- auto const kf{obieg * kurek07 * ((dizel_heat.kw * (0.3 + 0.7 * zaluzje1)) * dizel_heat.rpmw + (dizel_heat.kv * (0.3 + 0.7 * zaluzje1) * Vel / 3.6) + 3) + 2};
- auto const dTs{(dizel_heat.auxiliary_water_circuit ? ((dizel_heat.kfs * (dizel_heat.Ts - dizel_heat.Tsr))) / (gw * Cw) :
- ((dizel_heat.kfs * (dizel_heat.Ts - dizel_heat.Tsr)) + (dizel_heat.kfo2 * (dizel_heat.To - dizel_heat.Tsr))) / (gw * Cw))};
+ auto const kf{obieg * kurek07 * (dizel_heat.kw * (0.3 + 0.7 * zaluzje1) * dizel_heat.rpmw + dizel_heat.kv * (0.3 + 0.7 * zaluzje1) * Vel / 3.6 + 3) + 2};
+ auto const dTs{(dizel_heat.auxiliary_water_circuit ? dizel_heat.kfs * (dizel_heat.Ts - dizel_heat.Tsr) / (gw * Cw) :
+ (dizel_heat.kfs * (dizel_heat.Ts - dizel_heat.Tsr) + dizel_heat.kfo2 * (dizel_heat.To - dizel_heat.Tsr)) / (gw * Cw))};
auto const Qch{-kf * (dizel_heat.Tsr - dizel_heat.Te) + Qp};
auto const dTch{Qch / (gw * Cw)};
// primary water circuit heat transfers finalization
- auto const Twe{dizel_heat.Twy + (dTch * dt)};
- dizel_heat.Twy = Twe + (dTs * dt);
+ auto const Twe{dizel_heat.Twy + dTch * dt};
+ dizel_heat.Twy = Twe + dTs * dt;
dizel_heat.Tsr = 0.5 * (dizel_heat.Twy + Twe);
dizel_heat.temperatura1 = dizel_heat.Twy;
/*
@@ -8423,11 +8423,11 @@ bool TMoverParameters::AssignLoad(std::string const &Name, float const Amount)
{
// wartość niby "pantstate" - nazwa dla formalności, ważna jest ilość
auto const pantographsetup{static_cast(Amount)};
- if (pantographsetup & (1 << 2))
+ if (pantographsetup & 1 << 2)
{
DoubleTr = -1;
}
- if (pantographsetup & (1 << 0))
+ if (pantographsetup & 1 << 0)
{
if (DoubleTr == 1)
{
@@ -8438,7 +8438,7 @@ bool TMoverParameters::AssignLoad(std::string const &Name, float const Amount)
OperatePantographValve(end::rear, operation_t::enable, range_t::local);
}
}
- if (pantographsetup & (1 << 1))
+ if (pantographsetup & 1 << 1)
{
if (DoubleTr == 1)
{
@@ -8460,13 +8460,13 @@ bool TMoverParameters::AssignLoad(std::string const &Name, float const Amount)
if (Name.empty())
{
// empty the vehicle if requested
- LoadTypeChange = (LoadType.name != Name);
+ LoadTypeChange = LoadType.name != Name;
LoadType = load_attributes();
LoadAmount = 0.f;
return true;
}
// can't mix load types, at least for the time being
- if ((LoadAmount > 0) && (LoadType.name != Name))
+ if (LoadAmount > 0 && LoadType.name != Name)
{
return false;
}
@@ -8475,7 +8475,7 @@ bool TMoverParameters::AssignLoad(std::string const &Name, float const Amount)
{
if (Name == loadattributes.name)
{
- LoadTypeChange = (LoadType.name != Name);
+ LoadTypeChange = LoadType.name != Name;
LoadType = loadattributes;
LoadAmount = std::clamp(Amount, 0.f, MaxLoad);
ComputeMass();
@@ -8502,11 +8502,11 @@ bool TMoverParameters::LoadingDone(double const LSpeed, std::string const &Loadn
if (Loadname.empty())
{
- return (LoadStatus >= 4);
+ return LoadStatus >= 4;
}
if (Loadname != LoadType.name)
{
- return (LoadStatus >= 4);
+ return LoadStatus >= 4;
}
// test zakończenia załadunku/rozładunku
@@ -8522,7 +8522,7 @@ bool TMoverParameters::LoadingDone(double const LSpeed, std::string const &Loadn
LastLoadChangeTime = 0; // naliczony czas został zużyty
LoadAmount -= loadchange; // zmniejszenie ilości ładunku
CommandIn.Value1 -= loadchange; // zmniejszenie ilości do rozładowania
- if ((LoadAmount <= 0) || (CommandIn.Value1 <= 0))
+ if (LoadAmount <= 0 || CommandIn.Value1 <= 0)
{
// pusto lub rozładowano żądaną ilość
LoadStatus = 4; // skończony rozładunek
@@ -8544,7 +8544,7 @@ bool TMoverParameters::LoadingDone(double const LSpeed, std::string const &Loadn
LastLoadChangeTime = 0; // naliczony czas został zużyty
LoadAmount += loadchange; // zwiększenie ładunku
CommandIn.Value1 -= loadchange;
- if ((LoadAmount >= MaxLoad * (1.0 + OverLoadFactor)) || (CommandIn.Value1 <= 0))
+ if (LoadAmount >= MaxLoad * (1.0 + OverLoadFactor) || CommandIn.Value1 <= 0)
{
LoadStatus = 4; // skończony załadunek
LoadAmount = std::min(MaxLoad * (1.0 + OverLoadFactor), LoadAmount);
@@ -8553,7 +8553,7 @@ bool TMoverParameters::LoadingDone(double const LSpeed, std::string const &Loadn
}
}
- return (LoadStatus >= 4);
+ return LoadStatus >= 4;
}
bool TMoverParameters::ChangeDoorPermitPreset(int const Change, range_t const Notify)
@@ -8569,11 +8569,11 @@ bool TMoverParameters::ChangeDoorPermitPreset(int const Change, range_t const No
auto const permitleft{((doors & 1) != 0)};
auto const permitright{((doors & 2) != 0)};
- PermitDoors((CabActive > 0 ? side::left : side::right), permitleft, Notify);
- PermitDoors((CabActive > 0 ? side::right : side::left), permitright, Notify);
+ PermitDoors(CabActive > 0 ? side::left : side::right, permitleft, Notify);
+ PermitDoors(CabActive > 0 ? side::right : side::left, permitright, Notify);
}
- return (Doors.permit_preset != initialstate);
+ return Doors.permit_preset != initialstate;
}
bool TMoverParameters::PermitDoorStep(bool const State, range_t const Notify)
@@ -8585,10 +8585,10 @@ bool TMoverParameters::PermitDoorStep(bool const State, range_t const Notify)
if (Notify != range_t::local)
{
// wysłanie wyłączenia do pozostałych?
- SendCtrlToNext("DoorStep", (State == true ? 1 : 0), CabActive, (Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control));
+ SendCtrlToNext("DoorStep", State == true ? 1 : 0, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control);
}
- return (Doors.step_enabled != initialstate);
+ return Doors.step_enabled != initialstate;
}
bool TMoverParameters::PermitDoors(side const Door, bool const State, range_t const Notify)
@@ -8606,16 +8606,16 @@ bool TMoverParameters::PermitDoors(side const Door, bool const State, range_t co
* (Door == (CabActive > 0 ? side::left : side::right) ? // 1=lewe, 2=prawe (swap if reversed)
1 :
2),
- CabActive, (Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control));
+ CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control);
}
- return (Doors.instances[Door].open_permit != initialstate);
+ return Doors.instances[Door].open_permit != initialstate;
}
void TMoverParameters::PermitDoors_(side const Door, bool const State)
{
- if ((State) && (State != Doors.instances[Door].open_permit))
+ if (State && State != Doors.instances[Door].open_permit)
{
SetFlag(SoundFlag, sound::doorpermit);
}
@@ -8631,7 +8631,7 @@ bool TMoverParameters::ChangeDoorControlMode(bool const State, range_t const Not
if (Notify != range_t::local)
{
// wysłanie wyłączenia do pozostałych?
- SendCtrlToNext("DoorMode", (State == true ? 1 : 0), CabActive, (Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control));
+ SendCtrlToNext("DoorMode", State == true ? 1 : 0, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control);
}
if (true == State)
@@ -8642,7 +8642,7 @@ bool TMoverParameters::ChangeDoorControlMode(bool const State, range_t const Not
OperateDoors(side::right, true);
}
- return (Doors.remote_only != initialstate);
+ return Doors.remote_only != initialstate;
}
bool TMoverParameters::OperateDoors(side const Door, bool const State, range_t const Notify)
@@ -8661,16 +8661,16 @@ bool TMoverParameters::OperateDoors(side const Door, bool const State, range_t c
if (Notify == range_t::local)
{
door.local_open = State;
- door.local_close = (false == State);
+ door.local_close = false == State;
result = true;
}
else
{
// remote door operation signals require power to propagate
- if ((Power24vIsAvailable || Power110vIsAvailable))
+ if (Power24vIsAvailable || Power110vIsAvailable)
{
door.remote_open = State;
- door.remote_close = (false == State);
+ door.remote_close = false == State;
result = true;
}
}
@@ -8678,11 +8678,11 @@ bool TMoverParameters::OperateDoors(side const Door, bool const State, range_t c
if (Notify != range_t::local)
{
- SendCtrlToNext((State == true ? "DoorOpen" : "DoorClose"),
- (Door == (CabActive > 0 ? side::left : side::right) ? // 1=lewe, 2=prawe (swap if reversed)
- 1 :
- 2),
- CabActive, (Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control));
+ SendCtrlToNext(State == true ? "DoorOpen" : "DoorClose",
+ Door == (CabActive > 0 ? side::left : side::right) ? // 1=lewe, 2=prawe (swap if reversed)
+ 1 :
+ 2,
+ CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control);
}
return result;
@@ -8698,10 +8698,10 @@ bool TMoverParameters::LockDoors(bool const State, range_t const Notify)
if (Notify != range_t::local)
{
// wysłanie wyłączenia do pozostałych?
- SendCtrlToNext("DoorLock", (State == true ? 1 : 0), CabActive, (Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control));
+ SendCtrlToNext("DoorLock", State == true ? 1 : 0, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control);
}
- return (Doors.lock_enabled != initialstate);
+ return Doors.lock_enabled != initialstate;
}
// toggles departure warning
@@ -8718,7 +8718,7 @@ bool TMoverParameters::signal_departure(bool const State, range_t const Notify)
if (Notify != range_t::local)
{
// wysłanie wyłączenia do pozostałych?
- SendCtrlToNext("DepartureSignal", (State == true ? 1 : 0), CabActive, (Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control));
+ SendCtrlToNext("DepartureSignal", State == true ? 1 : 0, CabActive, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control);
}
return true;
@@ -8734,57 +8734,57 @@ void TMoverParameters::update_doors(double const Deltatime)
} // HACK: crude way to distinguish vehicles with actual doors
// NBMX Obsluga drzwi, MC: zuniwersalnione
- auto const localopencontrol{(false == Doors.remote_only) && ((Doors.open_control == control_t::passenger) || (Doors.open_control == control_t::mixed))};
- auto const remoteopencontrol{(Doors.open_control == control_t::driver) || (Doors.open_control == control_t::conductor) || (Doors.open_control == control_t::mixed)};
- auto const localclosecontrol{(false == Doors.remote_only) && ((Doors.close_control == control_t::passenger) || (Doors.close_control == control_t::mixed))};
- auto const remoteclosecontrol{(Doors.close_control == control_t::driver) || (Doors.close_control == control_t::conductor) || (Doors.close_control == control_t::mixed)};
+ auto const localopencontrol{false == Doors.remote_only && (Doors.open_control == control_t::passenger || Doors.open_control == control_t::mixed)};
+ auto const remoteopencontrol{Doors.open_control == control_t::driver || Doors.open_control == control_t::conductor || Doors.open_control == control_t::mixed};
+ auto const localclosecontrol{false == Doors.remote_only && (Doors.close_control == control_t::passenger || Doors.close_control == control_t::mixed)};
+ auto const remoteclosecontrol{Doors.close_control == control_t::driver || Doors.close_control == control_t::conductor || Doors.close_control == control_t::mixed};
- Doors.is_locked = (true == Doors.has_lock) && (true == Doors.lock_enabled) && (Vel >= Doors.doorLockSpeed);
+ Doors.is_locked = true == Doors.has_lock && true == Doors.lock_enabled && Vel >= Doors.doorLockSpeed;
for (auto &door : Doors.instances)
{
// revoke permit if...
- door.open_permit = (true == door.open_permit) // ...we already have one...
- && ((false == Doors.permit_presets.empty()) // ...there's no preset switch controlling permit state...
- || ((false == Doors.is_locked) // ...and the door lock is engaged...
- && (false == door.remote_close))); // ...or the door is about to be closed
+ door.open_permit = true == door.open_permit // ...we already have one...
+ && (false == Doors.permit_presets.empty() // ...there's no preset switch controlling permit state...
+ || (false == Doors.is_locked // ...and the door lock is engaged...
+ && false == door.remote_close)); // ...or the door is about to be closed
- door.is_open = (door.position >= Doors.range) && ((false == Doors.step_enabled) || (door.step_position >= (Doors.step_range != 0.f ? 1.f : 0.f)));
- door.is_closed = (door.position <= 0.f) && (door.step_position <= 0.f);
- door.is_door_closed = (door.position <= 0.f);
+ door.is_open = door.position >= Doors.range && (false == Doors.step_enabled || door.step_position >= (Doors.step_range != 0.f ? 1.f : 0.f));
+ door.is_closed = door.position <= 0.f && door.step_position <= 0.f;
+ door.is_door_closed = door.position <= 0.f;
- door.local_open = door.local_open && (false == door.is_open) && ((false == Doors.permit_needed) || door.open_permit);
- door.remote_open = (door.remote_open || Doors.remote_only) && (false == door.is_open) && ((false == Doors.permit_needed) || door.open_permit);
- door.local_close = door.local_close && (false == door.is_closed) && ((false == remoteopencontrol) || (false == door.remote_open));
- door.remote_close = door.remote_close && (false == door.is_closed) && ((false == localopencontrol) || (false == door.local_open));
+ door.local_open = door.local_open && false == door.is_open && (false == Doors.permit_needed || door.open_permit);
+ door.remote_open = (door.remote_open || Doors.remote_only) && false == door.is_open && (false == Doors.permit_needed || door.open_permit);
+ door.local_close = door.local_close && false == door.is_closed && (false == remoteopencontrol || false == door.remote_open);
+ door.remote_close = door.remote_close && false == door.is_closed && (false == localopencontrol || false == door.local_open);
- auto const autoopenrequest{(Doors.open_control == control_t::autonomous) && ((false == Doors.permit_needed) || door.open_permit)};
- auto const openrequest{(localopencontrol && door.local_open) || (remoteopencontrol && door.remote_open) || (autoopenrequest && (false == door.is_open))};
+ auto const autoopenrequest{Doors.open_control == control_t::autonomous && (false == Doors.permit_needed || door.open_permit)};
+ auto const openrequest{(localopencontrol && door.local_open) || (remoteopencontrol && door.remote_open) || (autoopenrequest && false == door.is_open)};
- auto const autocloserequest{((Doors.auto_velocity != -1.f) && (Vel > Doors.auto_velocity)) || ((door.auto_timer != -1.f) && (door.auto_timer <= 0.f)) ||
- ((Doors.permit_needed) && (false == door.open_permit))};
+ auto const autocloserequest{(Doors.auto_velocity != -1.f && Vel > Doors.auto_velocity) || (door.auto_timer != -1.f && door.auto_timer <= 0.f) ||
+ (Doors.permit_needed && false == door.open_permit)};
auto const closerequest{(door.remote_close && remoteclosecontrol) || (door.local_close && localclosecontrol) || (autocloserequest && door.is_open)};
- auto const ispowered{(Doors.voltage == 0 ? true : Doors.voltage == 24 ? (Power24vIsAvailable || Power110vIsAvailable) : Doors.voltage == 110 ? Power110vIsAvailable : false)};
+ auto const ispowered{(Doors.voltage == 0 ? true : Doors.voltage == 24 ? Power24vIsAvailable || Power110vIsAvailable : Doors.voltage == 110 ? Power110vIsAvailable : false)};
- door.is_opening = (false == door.is_open) && (true == ispowered) && (false == closerequest) && ((true == door.is_opening) || ((true == openrequest) && (false == Doors.is_locked)));
- door.is_closing = (false == door.is_closed) && (true == ispowered) && (false == openrequest) && (door.is_closing || closerequest);
- door.step_unfolding = ((Doors.step_range != 0.f) && (Doors.step_enabled) && (false == Doors.is_locked) && (door.step_position < 1.f) && (door.is_opening));
- door.step_folding = ((door.step_position > 0.f) // is unfolded
- && ((false == Doors.step_enabled) // we lost permission to stay open or our door is calling the shots
- || (Doors.permit_needed ? (false == door.open_permit) : door.is_closing)) &&
- ((door.close_delay > Doors.close_delay) || door.position <= 0.f)); // door is about to close, or already done
+ door.is_opening = false == door.is_open && true == ispowered && false == closerequest && (true == door.is_opening || (true == openrequest && false == Doors.is_locked));
+ door.is_closing = false == door.is_closed && true == ispowered && false == openrequest && (door.is_closing || closerequest);
+ door.step_unfolding = Doors.step_range != 0.f && Doors.step_enabled && false == Doors.is_locked && door.step_position < 1.f && door.is_opening;
+ door.step_folding = door.step_position > 0.f // is unfolded
+ && (false == Doors.step_enabled // we lost permission to stay open or our door is calling the shots
+ || (Doors.permit_needed ? false == door.open_permit : door.is_closing)) &&
+ (door.close_delay > Doors.close_delay || door.position <= 0.f); // door is about to close, or already done
if (true == door.is_opening)
{
- door.auto_timer = ((localopencontrol && door.local_open) ? Doors.auto_duration : (remoteopencontrol && door.remote_open && Doors.auto_include_remote) ? Doors.auto_duration : -1.f);
+ door.auto_timer = localopencontrol && door.local_open ? Doors.auto_duration : remoteopencontrol && door.remote_open && Doors.auto_include_remote ? Doors.auto_duration : -1.f;
}
// doors
if (true == door.is_opening)
{
// open door
- if ((false == door.step_unfolding) // no wait if no doorstep
- || (Doors.step_type == 2))
+ if (false == door.step_unfolding // no wait if no doorstep
+ || Doors.step_type == 2)
{ // no wait for rotating doorstep
door.open_delay += Deltatime;
if (door.open_delay > Doors.open_delay)
@@ -8813,7 +8813,7 @@ void TMoverParameters::update_doors(double const Deltatime)
if (door.step_folding)
{
// fold left doorstep
- if ((TrainType == dt_EZT) || (TrainType == dt_DMU))
+ if (TrainType == dt_EZT || TrainType == dt_DMU)
{
// multi-unit vehicles typically fold the doorstep only after closing the door
if (door.position <= 0.f)
@@ -8828,7 +8828,7 @@ void TMoverParameters::update_doors(double const Deltatime)
}
}
- if ((false == Doors.instances[side::right].is_open) && (false == Doors.instances[side::left].is_open))
+ if (false == Doors.instances[side::right].is_open && false == Doors.instances[side::left].is_open)
{
return;
}
@@ -8849,7 +8849,7 @@ void TMoverParameters::update_doors(double const Deltatime)
door.auto_timer -= Deltatime;
}
// if there's load exchange in progress, reset the timer(s) for already open doors
- if ((door.auto_timer != -1.f) && ((LoadStatus & (2 | 1)) != 0))
+ if (door.auto_timer != -1.f && (LoadStatus & (2 | 1)) != 0)
{
door.auto_timer = Doors.auto_duration;
}
@@ -8882,7 +8882,7 @@ bool TMoverParameters::ChangeOffsetH(double DeltaOffset)
{
OffsetTrackH = OffsetTrackH + DeltaOffset;
// if (abs(OffsetTrackH) > (RunningTrack.Width / 1.95 - TrackW / 2.0))
- if (abs(OffsetTrackH) > (0.5 * (RunningTrack.Width - Dim.W) - 0.05)) // Ra: może pół pojazdu od brzegu?
+ if (abs(OffsetTrackH) > 0.5 * (RunningTrack.Width - Dim.W) - 0.05) // Ra: może pół pojazdu od brzegu?
COH = false; // kola na granicy drogi
else
COH = true;
@@ -8917,7 +8917,7 @@ std::string TMoverParameters::EngineDescription(int what) const
else
outstr = "Load shifted";
}
- if ((WheelFlat > 5.0) || (TestFlag(DamageFlag, dtrain_wheelwear)))
+ if (WheelFlat > 5.0 || TestFlag(DamageFlag, dtrain_wheelwear))
{
outstr = "Wheel wear";
}
@@ -8983,11 +8983,11 @@ double TMoverParameters::GetTrainsetVoltage(int const Coupling) const
{
continue;
}
- auto *connectedpowercoupling = ((Coupling & (coupling::highvoltage | coupling::heating)) != 0 ? &coupler.Connected->Couplers[coupler.ConnectedNr].power_high :
- (Coupling & coupling::power110v) != 0 ? &coupler.Connected->Couplers[coupler.ConnectedNr].power_110v :
- (Coupling & coupling::power24v) != 0 ? &coupler.Connected->Couplers[coupler.ConnectedNr].power_24v :
- nullptr);
- if ((connectedpowercoupling != nullptr) && (connectedpowercoupling->is_live))
+ auto *connectedpowercoupling = (Coupling & (coupling::highvoltage | coupling::heating)) != 0 ? &coupler.Connected->Couplers[coupler.ConnectedNr].power_high :
+ (Coupling & coupling::power110v) != 0 ? &coupler.Connected->Couplers[coupler.ConnectedNr].power_110v :
+ (Coupling & coupling::power24v) != 0 ? &coupler.Connected->Couplers[coupler.ConnectedNr].power_24v :
+ nullptr;
+ if (connectedpowercoupling != nullptr && connectedpowercoupling->is_live)
{
voltages[end] = connectedpowercoupling->voltage;
}
@@ -8998,7 +8998,7 @@ double TMoverParameters::GetTrainsetVoltage(int const Coupling) const
double TMoverParameters::GetTrainsetHighVoltage() const
{
- return std::max(GetTrainsetVoltage(coupling::highvoltage), (HeatingAllow ? GetTrainsetVoltage(coupling::heating) : 0.0));
+ return std::max(GetTrainsetVoltage(coupling::highvoltage), HeatingAllow ? GetTrainsetVoltage(coupling::heating) : 0.0);
}
// *************************************************************************************************
@@ -9035,7 +9035,7 @@ int LISTLINE;
bool issection(std::string const &Name, std::string const &Input)
{
- return (Input.compare(0, Name.size(), Name) == 0);
+ return Input.compare(0, Name.size(), Name) == 0;
}
int s2NPW(std::string s)
@@ -9095,7 +9095,7 @@ bool TMoverParameters::readMPT0(std::string const &line)
{
int autoswitch;
parser >> autoswitch;
- MotorParam[idx].AutoSwitch = (autoswitch == 1);
+ MotorParam[idx].AutoSwitch = autoswitch == 1;
}
else
{
@@ -9147,7 +9147,7 @@ bool TMoverParameters::readMPTElectricSeries(std::string const &line)
{
int autoswitch;
parser >> autoswitch;
- MotorParam[idx].AutoSwitch = (autoswitch == 1);
+ MotorParam[idx].AutoSwitch = autoswitch == 1;
}
else
{
@@ -9188,7 +9188,7 @@ bool TMoverParameters::readMPTDieselEngine(std::string const &line)
{
int autoswitch;
parser >> autoswitch;
- MotorParam[idx].AutoSwitch = (autoswitch == 1);
+ MotorParam[idx].AutoSwitch = autoswitch == 1;
}
else
{
@@ -9554,7 +9554,7 @@ void TMoverParameters::BrakeValveDecode(std::string const &Valve)
auto lookup = valvetypes.find(Valve);
BrakeValve = lookup != valvetypes.end() ? lookup->second : TBrakeValve::Other;
- if ((BrakeValve == TBrakeValve::Other) && (contains(Valve, "ESt")))
+ if (BrakeValve == TBrakeValve::Other && contains(Valve, "ESt"))
{
BrakeValve = TBrakeValve::ESt3;
@@ -10257,7 +10257,7 @@ void TMoverParameters::LoadFIZ_Param(std::string const &line)
std::string category;
extract_value(category, "Category", line, "none");
auto lookup = categories.find(category);
- CategoryFlag = (lookup != categories.end() ? lookup->second : 0);
+ CategoryFlag = lookup != categories.end() ? lookup->second : 0;
if (CategoryFlag == 0)
{
ErrorLog("Unknown vehicle category: \"" + category + "\".");
@@ -10281,7 +10281,7 @@ void TMoverParameters::LoadFIZ_Param(std::string const &line)
std::string type;
extract_value(type, "Type", line, "none");
auto lookup = types.find(ToLower(type));
- TrainType = (lookup != types.end() ? lookup->second : dt_Default);
+ TrainType = lookup != types.end() ? lookup->second : dt_Default;
}
if (TrainType == dt_EZT)
@@ -10374,7 +10374,7 @@ void TMoverParameters::LoadFIZ_Wheels(std::string const &line)
NPoweredAxles = s2NPW(AxleArangement);
NAxles = NPoweredAxles + s2NNW(AxleArangement);
- BearingType = (extract_value("BearingType", line) == "Roll") ? 1 : 0;
+ BearingType = extract_value("BearingType", line) == "Roll" ? 1 : 0;
extract_value(ADist, "Ad", line, "");
extract_value(BDist, "Bd", line, "");
@@ -10437,7 +10437,7 @@ void TMoverParameters::LoadFIZ_Brake(std::string const &line)
P2FTrans = 100 * M_PI * std::pow(BrakeCylRadius, 2); // w kN/bar
- if ((BrakeCylMult[1] > 0.0) || (MaxBrakePress[1] > 0.0))
+ if (BrakeCylMult[1] > 0.0 || MaxBrakePress[1] > 0.0)
{
LoadFlag = 1;
}
@@ -10512,7 +10512,7 @@ void TMoverParameters::LoadFIZ_Brake(std::string const &line)
AirLeakRate *= 0.01;
}
- extract_value(ReleaserEnabledOnlyAtNoPowerPos, "ReleaserPowerPosLock", line, ((EngineType == TEngineType::DieselEngine) || (EngineType == TEngineType::DieselElectric)) ? "yes" : "no");
+ extract_value(ReleaserEnabledOnlyAtNoPowerPos, "ReleaserPowerPosLock", line, EngineType == TEngineType::DieselEngine || EngineType == TEngineType::DieselElectric ? "yes" : "no");
if (MinCompressor_cabB > 0.0)
{
@@ -10594,9 +10594,9 @@ void TMoverParameters::LoadFIZ_Doors(std::string const &line)
extract_value(Doors.has_lock, "DoorBlocked", line, "");
extract_value(Doors.doorLockSpeed, "DoorLockSpeed", line, "");
{
- auto const remotedoorcontrol{(Doors.open_control == control_t::driver) || (Doors.open_control == control_t::conductor) || (Doors.open_control == control_t::mixed)};
+ auto const remotedoorcontrol{Doors.open_control == control_t::driver || Doors.open_control == control_t::conductor || Doors.open_control == control_t::mixed};
- extract_value(Doors.voltage, "DoorVoltage", line, (remotedoorcontrol ? "24" : "0"));
+ extract_value(Doors.voltage, "DoorVoltage", line, remotedoorcontrol ? "24" : "0");
}
extract_value(Doors.step_rate, "PlatformSpeed", line, "");
@@ -10633,7 +10633,7 @@ void TMoverParameters::LoadFIZ_BuffCoupl(std::string const &line, int const Inde
{"Automatic", TCouplerType::Automatic}, {"Screw", TCouplerType::Screw}, {"Chain", TCouplerType::Chain}, {"Bare", TCouplerType::Bare}, {"Articulated", TCouplerType::Articulated},
};
auto lookup = couplertypes.find(extract_value("CType", line));
- coupler->CouplerType = (lookup != couplertypes.end() ? lookup->second : TCouplerType::NoCoupler);
+ coupler->CouplerType = lookup != couplertypes.end() ? lookup->second : TCouplerType::NoCoupler;
extract_value(coupler->SpringKC, "kC", line, "");
extract_value(coupler->DmaxC, "DmaxC", line, "");
@@ -10646,13 +10646,13 @@ void TMoverParameters::LoadFIZ_BuffCoupl(std::string const &line, int const Inde
extract_value(coupler->AllowedFlag, "AllowedFlag", line, "");
if (coupler->AllowedFlag < 0)
{
- coupler->AllowedFlag = ((-coupler->AllowedFlag) | coupling::permanent);
+ coupler->AllowedFlag = -coupler->AllowedFlag | coupling::permanent;
}
extract_value(coupler->PowerCoupling, "PowerCoupling", line, "");
extract_value(coupler->PowerFlag, "PowerFlag", line, "");
extract_value(coupler->control_type, "ControlType", line, "");
- if ((coupler->CouplerType != TCouplerType::NoCoupler) && (coupler->CouplerType != TCouplerType::Bare) && (coupler->CouplerType != TCouplerType::Articulated))
+ if (coupler->CouplerType != TCouplerType::NoCoupler && coupler->CouplerType != TCouplerType::Bare && coupler->CouplerType != TCouplerType::Articulated)
{
coupler->SpringKC *= 1000;
@@ -10869,7 +10869,7 @@ void TMoverParameters::LoadFIZ_Cntrl(std::string const &line)
extract_value(CtrlDownDelay, "SCDDelay", line, "");
// hunter-111012: dla siodemek 303E
- FastSerialCircuit = (ToLower(extract_value("FSCircuit", line)) == "yes") ? 1 : 0;
+ FastSerialCircuit = ToLower(extract_value("FSCircuit", line)) == "yes" ? 1 : 0;
extract_value(BackwardsBranchesAllowed, "BackwardsBranchesAllowed", line, "");
extract_value(AutomaticCabActivation, "AutomaticCabActivation", line, "");
@@ -10910,7 +10910,7 @@ void TMoverParameters::LoadFIZ_Cntrl(std::string const &line)
ConverterStart = lookup != starts.end() ? lookup->second : start_t::manual;
}
extract_value(ConverterStartDelay, "ConverterStartDelay", line, "");
- extract_value(ConverterOverloadRelayOffWhenMainIsOff, "ConverterOverloadWhenMainIsOff", line, (TrainType == dt_EZT ? "yes" : "no"));
+ extract_value(ConverterOverloadRelayOffWhenMainIsOff, "ConverterOverloadWhenMainIsOff", line, TrainType == dt_EZT ? "yes" : "no");
// compressor
{
auto lookup = starts.find(extract_value("CompressorStart", line));
@@ -10922,7 +10922,7 @@ void TMoverParameters::LoadFIZ_Cntrl(std::string const &line)
PantographCompressorStart = lookup != starts.end() ? lookup->second : start_t::manual;
}
// pantograph compressor valve
- PantAutoValve = (TrainType == dt_EZT); // legacy code behaviour, automatic valve was initially installed in all EMUs
+ PantAutoValve = TrainType == dt_EZT; // legacy code behaviour, automatic valve was initially installed in all EMUs
extract_value(PantAutoValve, "PantAutoValve", line, "");
// pantographs valve
{
@@ -10973,14 +10973,14 @@ void TMoverParameters::LoadFIZ_Cntrl(std::string const &line)
// ground relay
{
auto lookup = starts.find(extract_value("GroundRelayStart", line));
- GroundRelayStart = (lookup != starts.end() ? lookup->second : (TrainType == dt_EZT ? start_t::automatic : start_t::manual));
+ GroundRelayStart = lookup != starts.end() ? lookup->second : TrainType == dt_EZT ? start_t::automatic : start_t::manual;
}
// converter overload relay
{
auto lookup = starts.find(extract_value("ConverterOverloadRelayStart", line));
- ConverterOverloadRelayStart = (lookup != starts.end() ? lookup->second :
- (TrainType == dt_EZT ? start_t::converter : // relay activates when converter is switched off
- start_t::manual));
+ ConverterOverloadRelayStart = lookup != starts.end() ? lookup->second :
+ TrainType == dt_EZT ? start_t::converter : // relay activates when converter is switched off
+ start_t::manual;
}
}
@@ -11081,10 +11081,10 @@ void TMoverParameters::LoadFIZ_SpeedControl(std::string const &Line)
{
// speed control
extract_value(SpeedCtrl, "SpeedCtrl", Line, "");
- if ((!SpeedCtrl) && (EngineType == TEngineType::ElectricInductionMotor) && (ScndCtrlPosNo > 0)) // backward compatibility
+ if (!SpeedCtrl && EngineType == TEngineType::ElectricInductionMotor && ScndCtrlPosNo > 0) // backward compatibility
SpeedCtrl = true;
extract_value(SpeedCtrlDelay, "SpeedCtrlDelay", Line, "");
- SpeedCtrlTypeTime = (extract_value("SpeedCtrlType", Line) == "Time") ? true : false;
+ SpeedCtrlTypeTime = extract_value("SpeedCtrlType", Line) == "Time" ? true : false;
extract_value(SpeedCtrlAutoTurnOffFlag, "SpeedCtrlATOF", Line, "");
auto speedpresets = Split(extract_value("SpeedButtons", Line), '|');
@@ -11249,7 +11249,7 @@ void TMoverParameters::LoadFIZ_Engine(std::string const &Input)
{ // youBy
extract_value(Ftmax, "Ftmax", Input, "");
- Flat = (extract_value("Flat", Input) == "1");
+ Flat = extract_value("Flat", Input) == "1";
extract_value(Vhyp, "Vhyp", Input, "");
Vhyp /= 3.6;
extract_value(Vadd, "Vadd", Input, "");
@@ -11324,7 +11324,7 @@ void TMoverParameters::LoadFIZ_Engine(std::string const &Input)
} // engine type
// NOTE: elements shared by both diesel engine variants; crude but, eh
- if ((EngineType == TEngineType::DieselEngine) || (EngineType == TEngineType::DieselElectric))
+ if (EngineType == TEngineType::DieselEngine || EngineType == TEngineType::DieselElectric)
{
// oil pump
extract_value(OilPump.pressure_minimum, "OilMinPressure", Input, "");
@@ -11365,7 +11365,7 @@ void TMoverParameters::LoadFIZ_Engine(std::string const &Input)
extract_value(MotorBlowers[end::front].min_start_velocity, "MotorBlowersStartVelocity", Input, "");
MotorBlowers[end::rear] = MotorBlowers[end::front];
// pressure switch
- extract_value(HasControlPressureSwitch, "PressureSwitch", Input, (TrainType != dt_EZT ? "yes" : "no"));
+ extract_value(HasControlPressureSwitch, "PressureSwitch", Input, TrainType != dt_EZT ? "yes" : "no");
}
void TMoverParameters::LoadFIZ_Switches(std::string const &Input)
@@ -11455,7 +11455,7 @@ void TMoverParameters::LoadFIZ_RList(std::string const &Input)
else
{
- RVentType = (venttype == "yes" ? 1 : 0);
+ RVentType = venttype == "yes" ? 1 : 0;
}
if (RVentType > 0)
@@ -11656,7 +11656,7 @@ void TMoverParameters::LoadFIZ_PowerParamsDecode(TPowerParameters &Powerparamete
default:; // nothing here
}
- if ((Powerparameters.SourceType != TPowerSource::Heater) && (Powerparameters.SourceType != TPowerSource::InternalSource))
+ if (Powerparameters.SourceType != TPowerSource::Heater && Powerparameters.SourceType != TPowerSource::InternalSource)
{
extract_value(Powerparameters.MaxVoltage, Prefix + "MaxVoltage", Line, "");
@@ -11712,7 +11712,7 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir)
int b;
bool OK = true;
- AutoRelayFlag = (AutoRelayType == 1);
+ AutoRelayFlag = AutoRelayType == 1;
if (NominalBatteryVoltage == 0.0)
{
@@ -11722,17 +11722,17 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir)
Sand = SandCapacity;
// NOTE: for diesel-powered vehicles we automatically convert legacy "main" power source to more accurate "engine"
- if ((CompressorPower == 0) && ((EngineType == TEngineType::DieselEngine) || (EngineType == TEngineType::DieselElectric)))
+ if (CompressorPower == 0 && (EngineType == TEngineType::DieselEngine || EngineType == TEngineType::DieselElectric))
{
CompressorPower = 3;
}
// WriteLog("aa = " + AxleArangement + " " + std::string( Pos("o", AxleArangement)) );
- if ((contains(AxleArangement, "o")) && (EngineType == TEngineType::ElectricSeriesMotor))
+ if (contains(AxleArangement, "o") && EngineType == TEngineType::ElectricSeriesMotor)
{
// test poprawnosci ilosci osi indywidualnie napedzanych
- OK = ((RList[1].Bn * RList[1].Mn) == NPoweredAxles);
+ OK = RList[1].Bn * RList[1].Mn == NPoweredAxles;
// WriteLogSS("aa ok", BoolToYN(OK));
}
@@ -11740,7 +11740,7 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir)
if (BrakeSubsystem != TBrakeSubSystem::ss_None)
OK = false; //!
- if ((BrakeVVolume == 0) && (MaxBrakePress[3] > 0) && (BrakeSystem != TBrakeSystem::Individual))
+ if (BrakeVVolume == 0 && MaxBrakePress[3] > 0 && BrakeSystem != TBrakeSystem::Individual)
{
BrakeVVolume = MaxBrakePress[3] / (5.0 - MaxBrakePress[3]) * (BrakeCylRadius * BrakeCylRadius * BrakeCylDist * BrakeCylNo * M_PI) * 1000;
}
@@ -11906,7 +11906,7 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir)
LocHandle = std::make_shared();
}
- if ((true == TestFlag(BrakeDelays, bdelay_G)) && ((false == TestFlag(BrakeDelays, bdelay_R)) || (Power > 1.0))) // ustalanie srednicy przewodu glownego (lokomotywa lub napędowy
+ if (true == TestFlag(BrakeDelays, bdelay_G) && (false == TestFlag(BrakeDelays, bdelay_R) || Power > 1.0)) // ustalanie srednicy przewodu glownego (lokomotywa lub napędowy
Spg = 0.792;
else
Spg = 0.507;
@@ -11932,11 +11932,11 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir)
CompressorListPos = CompressorListDefPos;
// NOTE: legacy compatibility behaviour for vehicles without defined heating power source
- if ((EnginePowerSource.SourceType == TPowerSource::CurrentCollector) && (HeatingPowerSource.SourceType == TPowerSource::NotDefined))
+ if (EnginePowerSource.SourceType == TPowerSource::CurrentCollector && HeatingPowerSource.SourceType == TPowerSource::NotDefined)
{
HeatingPowerSource.SourceType = TPowerSource::Main;
}
- if ((HeatingPowerSource.SourceType == TPowerSource::NotDefined) && (HeatingPower > 0))
+ if (HeatingPowerSource.SourceType == TPowerSource::NotDefined && HeatingPower > 0)
{
HeatingPowerSource.SourceType = TPowerSource::PowerCable;
HeatingPowerSource.PowerType = TPowerType::ElectricPower;
@@ -11947,11 +11947,11 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir)
if (ReadyFlag) // gotowy do drogi
{
WriteLog("Ready to depart");
- CompressedVolume = VeselVolume * MinCompressor * (9.8) / 10.0;
- ScndPipePress = (VeselVolume > 0.0 ? CompressedVolume / VeselVolume :
- (Couplers[end::front].AllowedFlag & coupling::mainhose) != 0 ? 5.0 :
- (Couplers[end::rear].AllowedFlag & coupling::mainhose) != 0 ? 5.0 :
- 0.0);
+ CompressedVolume = VeselVolume * MinCompressor * 9.8 / 10.0;
+ ScndPipePress = VeselVolume > 0.0 ? CompressedVolume / VeselVolume :
+ (Couplers[end::front].AllowedFlag & coupling::mainhose) != 0 ? 5.0 :
+ (Couplers[end::rear].AllowedFlag & coupling::mainhose) != 0 ? 5.0 :
+ 0.0;
PipePress = CntrlPipePress;
BrakePress = 0.0;
LocalBrakePosA = 0.0;
@@ -11970,7 +11970,7 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir)
DirAbsolute = DirActive * CabActive; // kierunek jazdy względem sprzęgów
LimPipePress = CntrlPipePress;
- Battery = (BatteryStart != start_t::disabled);
+ Battery = BatteryStart != start_t::disabled;
}
else
{ // zahamowany}
@@ -11980,17 +11980,17 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir)
/*
ScndPipePress = 5.1;
*/
- ScndPipePress = (VeselVolume > 0.0 ? CompressedVolume / VeselVolume :
- (Couplers[end::front].AllowedFlag & coupling::mainhose) != 0 ? 5.1 :
- (Couplers[end::rear].AllowedFlag & coupling::mainhose) != 0 ? 5.1 :
- 0.0);
+ ScndPipePress = VeselVolume > 0.0 ? CompressedVolume / VeselVolume :
+ (Couplers[end::front].AllowedFlag & coupling::mainhose) != 0 ? 5.1 :
+ (Couplers[end::rear].AllowedFlag & coupling::mainhose) != 0 ? 5.1 :
+ 0.0;
PipePress = LowPipePress;
PipeBrakePress = MaxBrakePress[3] * 0.5;
BrakePress = MaxBrakePress[3] * 0.5;
LocalBrakePosA = 0.0;
BrakeCtrlPos = static_cast(Handle->GetPos(bh_NP));
LimPipePress = LowPipePress;
- if ((LocalBrake == TLocalBrake::ManualBrake) || (MBrake == true))
+ if (LocalBrake == TLocalBrake::ManualBrake || MBrake == true)
{
IncManualBrakeLevel(ManualBrakePosNo);
}
@@ -12038,9 +12038,9 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir)
// taki mini automat - powinno byc ladnie dobrze :)
BrakeDelayFlag = bdelay_P;
- if ((TestFlag(BrakeDelays, bdelay_G)) && !(TestFlag(BrakeDelays, bdelay_R)))
+ if (TestFlag(BrakeDelays, bdelay_G) && !TestFlag(BrakeDelays, bdelay_R))
BrakeDelayFlag = bdelay_G;
- if ((TestFlag(BrakeDelays, bdelay_R)) && !(TestFlag(BrakeDelays, bdelay_G)))
+ if (TestFlag(BrakeDelays, bdelay_R) && !TestFlag(BrakeDelays, bdelay_G))
BrakeDelayFlag = bdelay_R;
/*
// disabled, as test mode is used in specific situations and not really a default
@@ -12073,7 +12073,7 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir)
{
if (UniCtrlList[idx].MaxCtrlVal > 0.0)
{
- UniCtrlNoPowerPos = std::max(0, (idx - 1));
+ UniCtrlNoPowerPos = std::max(0, idx - 1);
break;
}
}
@@ -12122,7 +12122,7 @@ double TMoverParameters::GetExternalCommand(std::string &Command)
bool TMoverParameters::SetInternalCommand(std::string NewCommand, double NewValue1, double NewValue2, int const Couplertype)
{
bool SIC;
- if ((CommandIn.Command == NewCommand) && (CommandIn.Value1 == NewValue1) && (CommandIn.Value2 == NewValue2) && (CommandIn.Coupling == Couplertype))
+ if (CommandIn.Command == NewCommand && CommandIn.Value1 == NewValue1 && CommandIn.Value2 == NewValue2 && CommandIn.Coupling == Couplertype)
SIC = false;
else
{
@@ -12153,20 +12153,20 @@ bool TMoverParameters::SendCtrlToNext(std::string const CtrlCommand, double cons
if (OK)
{
// musi być wybrana niezerowa kabina
- if ((Couplers[d].Connected != nullptr) && (TestFlag(Couplers[d].CouplingFlag, Couplertype)))
+ if (Couplers[d].Connected != nullptr && TestFlag(Couplers[d].CouplingFlag, Couplertype))
{
if (Couplers[d].ConnectedNr != d)
{
// jeśli ten nastpęny jest zgodny z aktualnym
if (Couplers[d].Connected->SetInternalCommand(CtrlCommand, ctrlvalue, dir, Couplertype))
- OK = (Couplers[d].Connected->RunInternalCommand() && OK); // tu jest rekurencja
+ OK = Couplers[d].Connected->RunInternalCommand() && OK; // tu jest rekurencja
}
else
{
// jeśli następny jest ustawiony przeciwnie, zmieniamy kierunek
if (Couplers[d].Connected->SetInternalCommand(CtrlCommand, ctrlvalue, -dir, Couplertype))
- OK = (Couplers[d].Connected->RunInternalCommand() && OK); // tu jest rekurencja
+ OK = Couplers[d].Connected->RunInternalCommand() && OK; // tu jest rekurencja
}
}
}
@@ -12195,7 +12195,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
MainCtrlPos = static_cast(floor(CValue1));
if (DelayCtrlFlag)
{
- if ((LastRelayTime >= InitialCtrlDelay) && (MainCtrlPos == 1))
+ if (LastRelayTime >= InitialCtrlDelay && MainCtrlPos == 1)
LastRelayTime = 0;
}
else if (LastRelayTime > CtrlDelay)
@@ -12231,9 +12231,9 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
if (CValue1 < 0.001)
DynamicBrakeEMUStatus = true;
double temp1 = CValue1;
- if ((DCEMUED_EP_max_Vel > 0.001) && (Vel > DCEMUED_EP_max_Vel) && (DynamicBrakeEMUStatus))
+ if (DCEMUED_EP_max_Vel > 0.001 && Vel > DCEMUED_EP_max_Vel && DynamicBrakeEMUStatus)
temp1 = 0;
- if ((DCEMUED_EP_min_Im > 0.001) && (abs(Im) > DCEMUED_EP_min_Im) && (DynamicBrakeEMUStatus))
+ if (DCEMUED_EP_min_Im > 0.001 && abs(Im) > DCEMUED_EP_min_Im && DynamicBrakeEMUStatus)
temp1 = 0;
Hamulec->SetEPS(temp1);
TUHEX_StageActual = CValue1;
@@ -12255,7 +12255,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
if( FuelPump.start_type != start::automatic ) {
// automatic fuel pump ignores 'manual' state commands
*/
- WaterPump.breaker = (CValue1 == 1);
+ WaterPump.breaker = CValue1 == 1;
/*
}
*/
@@ -12267,7 +12267,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
if (WaterPump.start_type != start_t::battery)
{
// automatic fuel pump ignores 'manual' state commands
- WaterPump.is_enabled = (CValue1 == 1);
+ WaterPump.is_enabled = CValue1 == 1;
}
OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype);
}
@@ -12277,7 +12277,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
if (WaterPump.start_type != start_t::battery)
{
// automatic fuel pump ignores 'manual' state commands
- WaterPump.is_disabled = (CValue1 == 1);
+ WaterPump.is_disabled = CValue1 == 1;
}
OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype);
}
@@ -12287,7 +12287,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
if( FuelPump.start_type != start::automatic ) {
// automatic fuel pump ignores 'manual' state commands
*/
- WaterHeater.breaker = (CValue1 == 1);
+ WaterHeater.breaker = CValue1 == 1;
/*
}
*/
@@ -12299,7 +12299,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
if( FuelPump.start_type != start::automatic ) {
// automatic fuel pump ignores 'manual' state commands
*/
- WaterHeater.is_enabled = (CValue1 == 1);
+ WaterHeater.is_enabled = CValue1 == 1;
/*
}
*/
@@ -12310,7 +12310,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
if (true == dizel_heat.auxiliary_water_circuit)
{
// can only link circuits if the vehicle has more than one of them
- WaterCircuitsLink = (CValue1 == 1);
+ WaterCircuitsLink = CValue1 == 1;
}
OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype);
}
@@ -12319,7 +12319,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
if (FuelPump.start_type != start_t::automatic)
{
// automatic fuel pump ignores 'manual' state commands
- FuelPump.is_enabled = (CValue1 == 1);
+ FuelPump.is_enabled = CValue1 == 1;
}
OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype);
}
@@ -12328,7 +12328,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
if (FuelPump.start_type != start_t::automatic)
{
// automatic fuel pump ignores 'manual' state commands
- FuelPump.is_disabled = (CValue1 == 1);
+ FuelPump.is_disabled = CValue1 == 1;
}
OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype);
}
@@ -12337,7 +12337,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
if (OilPump.start_type != start_t::automatic)
{
// automatic pump ignores 'manual' state commands
- OilPump.is_enabled = (CValue1 == 1);
+ OilPump.is_enabled = CValue1 == 1;
}
OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype);
}
@@ -12346,43 +12346,43 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
if (OilPump.start_type != start_t::automatic)
{
// automatic pump ignores 'manual' state commands
- OilPump.is_disabled = (CValue1 == 1);
+ OilPump.is_disabled = CValue1 == 1;
}
OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype);
}
else if (Command == "MotorBlowersFrontSwitch")
{
- if ((MotorBlowers[end::front].start_type != start_t::manual) && (MotorBlowers[end::front].start_type != start_t::manualwithautofallback))
+ if (MotorBlowers[end::front].start_type != start_t::manual && MotorBlowers[end::front].start_type != start_t::manualwithautofallback)
{
// automatic device ignores 'manual' state commands
- MotorBlowers[end::front].is_enabled = (CValue1 == 1);
+ MotorBlowers[end::front].is_enabled = CValue1 == 1;
}
OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype);
}
else if (Command == "MotorBlowersFrontSwitchOff")
{
- if ((MotorBlowers[end::front].start_type != start_t::manual) && (MotorBlowers[end::front].start_type != start_t::manualwithautofallback))
+ if (MotorBlowers[end::front].start_type != start_t::manual && MotorBlowers[end::front].start_type != start_t::manualwithautofallback)
{
// automatic device ignores 'manual' state commands
- MotorBlowers[end::front].is_disabled = (CValue1 == 1);
+ MotorBlowers[end::front].is_disabled = CValue1 == 1;
}
OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype);
}
else if (Command == "MotorBlowersRearSwitch")
{
- if ((MotorBlowers[end::rear].start_type != start_t::manual) && (MotorBlowers[end::rear].start_type != start_t::manualwithautofallback))
+ if (MotorBlowers[end::rear].start_type != start_t::manual && MotorBlowers[end::rear].start_type != start_t::manualwithautofallback)
{
// automatic device ignores 'manual' state commands
- MotorBlowers[end::rear].is_enabled = (CValue1 == 1);
+ MotorBlowers[end::rear].is_enabled = CValue1 == 1;
}
OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype);
}
else if (Command == "MotorBlowersRearSwitchOff")
{
- if ((MotorBlowers[end::rear].start_type != start_t::manual) && (MotorBlowers[end::rear].start_type != start_t::manualwithautofallback))
+ if (MotorBlowers[end::rear].start_type != start_t::manual && MotorBlowers[end::rear].start_type != start_t::manualwithautofallback)
{
// automatic device ignores 'manual' state commands
- MotorBlowers[end::rear].is_disabled = (CValue1 == 1);
+ MotorBlowers[end::rear].is_disabled = CValue1 == 1;
}
OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype);
}
@@ -12392,7 +12392,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
if (CompartmentLights.start_type != start_t::automatic)
{
// automatic lights ignore 'manual' state commands
- CompartmentLights.is_enabled = (CValue1 == 1);
+ CompartmentLights.is_enabled = CValue1 == 1;
}
OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype);
}
@@ -12402,7 +12402,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
if (CompartmentLights.start_type != start_t::automatic)
{
// automatic lights ignore 'manual' state commands
- CompartmentLights.is_disabled = (CValue1 == 1);
+ CompartmentLights.is_disabled = CValue1 == 1;
}
OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype);
}
@@ -12449,7 +12449,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
}
else if (Command == "AutoRelaySwitch")
{
- if ((CValue1 == 1) && (AutoRelayType == 2))
+ if (CValue1 == 1 && AutoRelayType == 2)
AutoRelayFlag = true;
else
AutoRelayFlag = false;
@@ -12464,7 +12464,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
{
if (ConverterStart == start_t::manual)
{
- ConverterAllow = (CValue1 > 0.0);
+ ConverterAllow = CValue1 > 0.0;
}
OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype);
}
@@ -12472,7 +12472,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
{
if (BatteryStart == start_t::manual)
{
- Battery = (CValue1 > 0.0);
+ Battery = CValue1 > 0.0;
}
OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype);
}
@@ -12484,7 +12484,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
// end
else if (Command == "CompressorSwitch") /*NBMX*/
{
- CompressorSwitch((CValue1 == 1), range_t::local);
+ CompressorSwitch(CValue1 == 1, range_t::local);
OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype);
}
else if (Command == "CompressorPreset")
@@ -12500,18 +12500,18 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
if (std::abs(static_cast(CValue1)) & right)
{
- PermitDoors_(side::right, (CValue1 > 0));
+ PermitDoors_(side::right, CValue1 > 0);
}
if (std::abs(static_cast(CValue1)) & left)
{
- PermitDoors_(side::left, (CValue1 > 0));
+ PermitDoors_(side::left, CValue1 > 0);
}
OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype);
}
else if (Command == "DoorOpen") /*NBMX*/
{ // Ra: uwzględnić trzeba jeszcze zgodność sprzęgów
- if ((Doors.open_control == control_t::conductor) || (Doors.open_control == control_t::driver) || (Doors.open_control == control_t::mixed))
+ if (Doors.open_control == control_t::conductor || Doors.open_control == control_t::driver || Doors.open_control == control_t::mixed)
{
// ignore remote command if the door is only operated locally
if (Power24vIsAvailable || Power110vIsAvailable)
@@ -12536,7 +12536,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
}
else if (Command == "DoorClose") /*NBMX*/
{ // Ra: uwzględnić trzeba jeszcze zgodność sprzęgów
- if ((Doors.close_control == control_t::conductor) || (Doors.close_control == control_t::driver) || (Doors.close_control == control_t::mixed))
+ if (Doors.close_control == control_t::conductor || Doors.close_control == control_t::driver || Doors.close_control == control_t::mixed)
{
// ignore remote command if the door is only operated locally
if (Power24vIsAvailable || Power110vIsAvailable)
@@ -12561,22 +12561,22 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
}
else if (Command == "DoorLock")
{
- Doors.lock_enabled = (CValue1 == 1 ? true : false);
+ Doors.lock_enabled = CValue1 == 1 ? true : false;
OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype);
}
else if (Command == "DoorStep")
{
- Doors.step_enabled = (CValue1 == 1 ? true : false);
+ Doors.step_enabled = CValue1 == 1 ? true : false;
OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype);
}
else if (Command == "DoorMode")
{
- Doors.remote_only = (CValue1 == 1 ? true : false);
+ Doors.remote_only = CValue1 == 1 ? true : false;
OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype);
}
else if (Command == "DepartureSignal")
{
- DepartureSignal = (CValue1 == 1 ? true : false);
+ DepartureSignal = CValue1 == 1 ? true : false;
OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype);
}
else if (Command == "PantValve") // Winger 160204
@@ -12584,8 +12584,8 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
auto const inputend{(static_cast(CValue1) & 0x80) != 0 ? 1 : 0};
auto const inputcab{(static_cast(CValue1) & 0x40) != 0 ? 1 : 0};
auto const inputoperation{static_cast(CValue1) & ~(0x80 | 0x40)};
- auto const noswap{(TrainType == dt_EZT) || (TrainType == dt_ET41)};
- auto swap{(false == noswap) && (TestFlag(Couplers[(CValue2 == -1 ? end::rear : end::front)].CouplingFlag, coupling::control))};
+ auto const noswap{TrainType == dt_EZT || TrainType == dt_ET41};
+ auto swap{false == noswap && TestFlag(Couplers[(CValue2 == -1 ? end::rear : end::front)].CouplingFlag, coupling::control)};
auto const reversed{inputcab != (CabActive != -1 ? 1 : 0)};
if (reversed)
{
@@ -12658,8 +12658,8 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
else if (issection("Load=", Command))
{
OK = false; // będzie powtarzane aż się załaduje
- if ((Vel < 0.1) // tolerance margin for small vehicle movements in the consist
- && (MaxLoad > 0) && (LoadAmount < MaxLoad * (1.0 + OverLoadFactor)) && (Distance(Loc, CommandIn.Location, Dim, Dim) < (CValue2 > 1.0 ? CValue2 : 10.0)))
+ if (Vel < 0.1 // tolerance margin for small vehicle movements in the consist
+ && MaxLoad > 0 && LoadAmount < MaxLoad * (1.0 + OverLoadFactor) && Distance(Loc, CommandIn.Location, Dim, Dim) < (CValue2 > 1.0 ? CValue2 : 10.0))
{ // ten peron/rampa
auto const loadname{ToLower(extract_value("Load", Command))};
@@ -12679,9 +12679,9 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
else if (issection("UnLoad=", Command))
{
OK = false; // będzie powtarzane aż się rozładuje
- if ((Vel < 0.1) // tolerance margin for small vehicle movements in the consist
- && (LoadAmount > 0) // czy jest co rozladowac?
- && (Distance(Loc, CommandIn.Location, Dim, Dim) < (CValue2 > 1.0 ? CValue2 : 10.0)))
+ if (Vel < 0.1 // tolerance margin for small vehicle movements in the consist
+ && LoadAmount > 0 // czy jest co rozladowac?
+ && Distance(Loc, CommandIn.Location, Dim, Dim) < (CValue2 > 1.0 ? CValue2 : 10.0))
{ // ten peron
/*mozna to rozladowac*/
OK = LoadingDone(-1.f * LoadSpeed, ToLower(extract_value("UnLoad", Command)));
@@ -12694,7 +12694,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
}
else if (Command == "SpeedCntrl")
{
- if ((EngineType == TEngineType::ElectricInductionMotor) || (SpeedCtrl))
+ if (EngineType == TEngineType::ElectricInductionMotor || SpeedCtrl)
SpeedCtrlValue = static_cast(round(CValue1));
OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype);
}
@@ -12756,16 +12756,16 @@ double TMoverParameters::ShowCurrentP(int AmpN) const
bool Grupowy;
// ClearPendingExceptions;
- Grupowy = ((DelayCtrlFlag) && (TrainType == dt_ET22)); // przerzucanie walu grupowego w ET22;
+ Grupowy = DelayCtrlFlag && TrainType == dt_ET22; // przerzucanie walu grupowego w ET22;
Bn = RList[MainCtrlActualPos].Bn; // ile równoległych gałęzi silników
- if ((DynamicBrakeType == dbrake_automatic) && (DynamicBrakeFlag))
+ if (DynamicBrakeType == dbrake_automatic && DynamicBrakeFlag)
Bn = DynamicBrakeAmpmeters;
if (Power > 0.01)
{
if (AmpN > 0) // podać prąd w gałęzi
{
- if ((Bn < AmpN) || ((Grupowy) && (AmpN == Bn - 1)))
+ if (Bn < AmpN || (Grupowy && AmpN == Bn - 1))
return 0;
else // normalne podawanie pradu
return floor(abs(Im));
diff --git a/McZapkie/Oerlikon_ESt.cpp b/McZapkie/Oerlikon_ESt.cpp
index e5761ef6..1df5fe81 100644
--- a/McZapkie/Oerlikon_ESt.cpp
+++ b/McZapkie/Oerlikon_ESt.cpp
@@ -18,7 +18,7 @@ Copyright (C) 2007-2014 Maciej Cierniak
double d2A( double const d )
{
- return (d * d) * 0.7854 / 1000.0;
+ return d * d * 0.7854 / 1000.0;
}
// ------ RURA ------
@@ -115,9 +115,9 @@ void TRapid::Update(double dt)
ActMult = 1.0;
}
- if ((BCP * RapidMult) > (P() * ActMult))
+ if (BCP * RapidMult > P() * ActMult)
dV = -PFVd(BCP, 0, DL, P() * ActMult / RapidMult) * dt;
- else if ((BCP * RapidMult) < (P() * ActMult))
+ else if (BCP * RapidMult < P() * ActMult)
dV = PFVa(BVP, BCP, DN, P() * ActMult / RapidMult) * dt;
else
dV = 0.0;
@@ -140,9 +140,9 @@ void TPrzekCiagly::Update(double dt)
double const BCP{ Next->P() };
double dV;
- if ( BCP > (P() * Mult))
+ if ( BCP > P() * Mult)
dV = -PFVd(BCP, 0, d2A(8.0), P() * Mult) * dt;
- else if (BCP < (P() * Mult))
+ else if (BCP < P() * Mult)
dV = PFVa(BVP, BCP, d2A(8.0), P() * Mult) * dt;
else
dV = 0.0;
@@ -226,7 +226,7 @@ double TNESt3::GetPF( double const PP, double const dt, double const Vel ) // pr
dV = 0.0;
// BrakeCyl.Flow(-dV);
Przekladniki[1]->Flow(-dV);
- if ( ((BrakeStatus & b_on) == b_on) && (Przekladniki[1]->P() * HBG300 < MaxBP) )
+ if ( (BrakeStatus & b_on) == b_on && Przekladniki[1]->P() * HBG300 < MaxBP )
dV =
PF( BVP, BCP, Nozzles[dTN] * (nastG + 2.0 * (BCP < Podskok ? 1.0 : 0.0)) + Nozzles[dON] * (1.0 - nastG) )
* dt * (0.1 + 4.9 * std::min( 0.2, (CVP - 0.05 - VVP) * BVM - BCP ) );
@@ -241,10 +241,7 @@ double TNESt3::GetPF( double const PP, double const dt, double const Vel ) // pr
Przekladniki[i]->Update(dt);
if (typeid(*Przekladniki[i]) == typeid(TRapid))
{
- RapidStatus = ( ( ( BrakeDelayFlag & bdelay_R ) == bdelay_R )
- && ( ( std::abs( Vel ) > 70.0 )
- || ( ( std::abs( Vel ) > 50.0 ) && ( RapidStatus ) )
- || ( RapidStaly ) ) );
+ RapidStatus = (BrakeDelayFlag & bdelay_R) == bdelay_R && (std::abs(Vel) > 70.0 || (std::abs(Vel) > 50.0 && RapidStatus) || RapidStaly);
Przekladniki[i]->SetRapidStatus(RapidStatus);
}
else if( typeid( *Przekladniki[i] ) == typeid( TPrzeciwposlizg ) )
@@ -263,7 +260,7 @@ double TNESt3::GetPF( double const PP, double const dt, double const Vel ) // pr
// przeplyw testowy miedzypojemnosci
dV = PF(MPP, VVP, BVs(BCP)) + PF(MPP, CVP, CVs(BCP));
- if ((MPP - 0.05) > BVP)
+ if (MPP - 0.05 > BVP)
dV += PF(MPP - 0.05, BVP, Nozzles[dPT] * nastG + (1.0 - nastG) * Nozzles[dPO]);
if (MPP > VVP)
dV += PF(MPP, VVP, d2A(5.0));
@@ -277,7 +274,7 @@ double TNESt3::GetPF( double const PP, double const dt, double const Vel ) // pr
dV1 += 0.98 * dV;
// przeplyw ZP <-> MPJ
- if ((MPP - 0.05) > BVP)
+ if (MPP - 0.05 > BVP)
dV = PF(BVP, MPP - 0.05, Nozzles[dPT] * nastG + (1.0 - nastG) * Nozzles[dPO]) * dt;
else
dV = 0.0;
@@ -312,7 +309,7 @@ void TNESt3::Init( double const PP, double const HPP, double const LPP, double c
CntrlRes = std::make_shared();
CntrlRes->CreateCap(15.0);
CntrlRes->CreatePress(HPP);
- BrakeStatus = (BP > 1.0 ? 1 : 0);
+ BrakeStatus = BP > 1.0 ? 1 : 0;
Miedzypoj = std::make_shared();
Miedzypoj->CreateCap(5.0);
Miedzypoj->CreatePress(PP);
@@ -323,7 +320,7 @@ void TNESt3::Init( double const PP, double const HPP, double const LPP, double c
Zamykajacy = false;
- if ( (typeid(*FM) == typeid(TDisk1)) || (typeid(*FM) == typeid(TDisk2)) ) // jesli zeliwo to schodz
+ if ( typeid(*FM) == typeid(TDisk1) || typeid(*FM) == typeid(TDisk2) ) // jesli zeliwo to schodz
RapidStaly = true;
else
RapidStaly = false;
@@ -343,24 +340,24 @@ void TNESt3::CheckState(double const BCP, double &dV1) // glowny przyrzad rozrza
double const CVP{ CntrlRes->P() };
double const MPP{ Miedzypoj->P() };
- if ((BCP < 0.25) && (VVP + 0.08 > CVP))
+ if (BCP < 0.25 && VVP + 0.08 > CVP)
Przys_blok = false;
// sprawdzanie stanu
// if ((BrakeStatus and 1)=1)and(BCP>0.25)then
- if (((VVP + 0.01 + BCP / BVM) < (CVP - 0.05)) && (Przys_blok))
- BrakeStatus |= ( b_on | b_hld ); // hamowanie stopniowe;
- else if ((VVP - 0.01 + (BCP - 0.1) / BVM) > (CVP - 0.05))
+ if (VVP + 0.01 + BCP / BVM < CVP - 0.05 && Przys_blok)
+ BrakeStatus |= b_on | b_hld; // hamowanie stopniowe;
+ else if (VVP - 0.01 + (BCP - 0.1) / BVM > CVP - 0.05)
BrakeStatus &= ~( b_on | b_hld ); // luzowanie;
- else if ((VVP + BCP / BVM) > (CVP - 0.05))
+ else if (VVP + BCP / BVM > CVP - 0.05)
BrakeStatus &= ~b_on; // zatrzymanie napelaniania;
- else if (((VVP + (BCP - 0.1) / BVM) < (CVP - 0.05)) && (BCP > 0.25)) // zatrzymanie luzowania
+ else if (VVP + (BCP - 0.1) / BVM < CVP - 0.05 && BCP > 0.25) // zatrzymanie luzowania
BrakeStatus |= b_hld;
if( ( BrakeStatus & b_hld ) == 0 )
SoundFlag |= sf_CylU;
- if (((VVP + 0.10) < CVP) && (BCP < 0.25)) // poczatek hamowania
+ if (VVP + 0.10 < CVP && BCP < 0.25) // poczatek hamowania
if (false == Przys_blok)
{
ValveRes->CreatePress(0.1 * VVP);
@@ -371,7 +368,7 @@ void TNESt3::CheckState(double const BCP, double &dV1) // glowny przyrzad rozrza
if (BCP > 0.5)
Zamykajacy = true;
- else if ((VVP - 0.6) < MPP)
+ else if (VVP - 0.6 < MPP)
Zamykajacy = false;
}
@@ -384,7 +381,7 @@ void TNESt3::CheckReleaser(double const dt) // odluzniacz
if ((BrakeStatus & b_rls) == b_rls)
{
CntrlRes->Flow(PF(CVP, 0, 0.02) * dt);
- if ((CVP < (VVP + 0.3)) || (false == autom))
+ if (CVP < VVP + 0.3 || false == autom)
BrakeStatus &= ~b_rls;
}
}
@@ -395,9 +392,9 @@ double TNESt3::CVs(double const BP) // napelniacz sterujacego
double const MPP{ Miedzypoj->P() };
// przeplyw ZS <-> PG
- if (MPP < (CVP - 0.17))
+ if (MPP < CVP - 0.17)
return 0.0;
- else if (MPP > (CVP - 0.08))
+ else if (MPP > CVP - 0.08)
return Nozzles[dSd];
else
return Nozzles[dSm];
@@ -409,7 +406,7 @@ double TNESt3::BVs(double const BCP) // napelniacz pomocniczego
double const MPP{ Miedzypoj->P() };
// przeplyw ZP <-> rozdzielacz
- if (MPP < (CVP - 0.3))
+ if (MPP < CVP - 0.3)
return Nozzles[dP];
else if( BCP < 0.5 ) {
if( true == Zamykajacy )
@@ -425,7 +422,7 @@ void TNESt3::PLC(double const mass)
{
LoadC = 1.0 +
( mass < LoadM ?
- ( (TareBP + (MaxBP - TareBP) * (mass - TareM) / (LoadM - TareM) ) / MaxBP - 1.0 ) :
+ (TareBP + (MaxBP - TareBP) * (mass - TareM) / (LoadM - TareM)) / MaxBP - 1.0 :
0.0 );
}
@@ -490,13 +487,13 @@ void TNESt3::SetSize( int const size, std::string const ¶ms ) // ustawianie
else
Przekladniki[2] = std::make_shared();
- if( ( contains( params, "3d" ) )
- || ( contains( params, "4d" ) ) ) {
+ if( contains(params, "3d")
+ || contains(params, "4d") ) {
autom = false;
}
else
autom = true;
- if ((contains( params,"HBG300")))
+ if (contains(params, "HBG300"))
HBG300 = 1.0;
else
HBG300 = 0.0;
diff --git a/McZapkie/friction.cpp b/McZapkie/friction.cpp
index f3eca234..6ecf5a06 100644
--- a/McZapkie/friction.cpp
+++ b/McZapkie/friction.cpp
@@ -60,7 +60,7 @@ double TP10yBg::GetFC(double N, double Vel)
C = 0.353 - A * 0.029;
u0 = 0.41 - C;
V0 = 25.7 + 20 * A;
- return (u0 + C * exp(-Vel * 1.0 / V0));
+ return u0 + C * exp(-Vel * 1.0 / V0);
}
double TP10yBgu::GetFC(double N, double Vel)
@@ -74,7 +74,7 @@ double TP10yBgu::GetFC(double N, double Vel)
C = 0.353 - A * 0.044;
u0 = 0.41 - C;
V0 = 25.7 + 21 * A;
- return (u0 + C * exp(-Vel * 1.0 / V0));
+ return u0 + C * exp(-Vel * 1.0 / V0);
}
double TP10::GetFC(double N, double Vel)
diff --git a/McZapkie/hamulce.cpp b/McZapkie/hamulce.cpp
index a957dc79..44e8be4b 100644
--- a/McZapkie/hamulce.cpp
+++ b/McZapkie/hamulce.cpp
@@ -63,7 +63,7 @@ double PF_old(double P1, double P2, double S)
double PL = P1 + P2 - PH + 2;
if (PH - PL < 0.0001)
return 0;
- else if ((PH - PL) < 0.05)
+ else if (PH - PL < 0.05)
return 20 * (PH - PL) * (PH + 1) * 222 * S * (P2 - P1) / (1.13 * PH - PL);
else
return (PH + 1) * 222 * S * (P2 - P1) / (1.13 * PH - PL);
@@ -86,11 +86,11 @@ double PF(double const P1, double const P2, double const S, double const DP)
double const sg = PL / PH; // bezwymiarowy stosunek cisnien
double const FM = PH * 197.0 * S * Sign(P2 - P1); // najwyzszy mozliwy przeplyw, wraz z kierunkiem
if (sg > 0.5) // jesli ponizej stosunku krytycznego
- if ((PH - PL) < DP) // niewielka roznica cisnien
- return (1.0 - sg) / DPL * FM * 2.0 * std::sqrt((DP) * (PH - DP));
+ if (PH - PL < DP) // niewielka roznica cisnien
+ return (1.0 - sg) / DPL * FM * 2.0 * std::sqrt(DP * (PH - DP));
// return 1/DPL*(PH-PL)*fm*2*SQRT((sg)*(1-sg));
else
- return FM * 2.0 * std::sqrt((sg) * (1.0 - sg));
+ return FM * 2.0 * std::sqrt(sg * (1.0 - sg));
else // powyzej stosunku krytycznego
return FM;
}
@@ -113,9 +113,9 @@ double PF1(double const P1, double const P2, double const S)
double const FM = PH * 197.0 * S * Sign(P2 - P1); // najwyzszy mozliwy przeplyw, wraz z kierunkiem
if (sg > 0.5) // jesli ponizej stosunku krytycznego
if (sg < DPS) // niewielka roznica cisnien
- return (1.0 - sg) / DPS * FM * 2.0 * std::sqrt((DPS) * (1.0 - DPS));
+ return (1.0 - sg) / DPS * FM * 2.0 * std::sqrt(DPS * (1.0 - DPS));
else
- return FM * 2.0 * std::sqrt((sg) * (1.0 - sg));
+ return FM * 2.0 * std::sqrt(sg * (1.0 - sg));
else // powyzej stosunku krytycznego
return FM;
}
@@ -141,13 +141,13 @@ double PFVa(double PH, double PL, double const S, double LIM, double const DP)
PL = PL + 1; // nizsze cisnienie absolutne
double sg = std::min(1.0, PL / PH); // bezwymiarowy stosunek cisnien. NOTE: sg is capped at 1 to prevent calculations from going awry. TODO, TBD: log these as errors?
double FM = PH * 197 * S; // najwyzszy mozliwy przeplyw, wraz z kierunkiem
- if ((LIM - PL) < DP)
+ if (LIM - PL < DP)
FM = FM * (LIM - PL) / DP; // jesli jestesmy przy nastawieniu, to zawor sie przymyka
- if ((sg > 0.5)) // jesli ponizej stosunku krytycznego
- if ((PH - PL) < DPL) // niewielka roznica cisnien
- return (PH - PL) / DPL * FM * 2 * std::sqrt((sg) * (1 - sg)); // BUG: (1-sg) can be < 0, leading to sqrt(-x)
+ if (sg > 0.5) // jesli ponizej stosunku krytycznego
+ if (PH - PL < DPL) // niewielka roznica cisnien
+ return (PH - PL) / DPL * FM * 2 * std::sqrt(sg * (1 - sg)); // BUG: (1-sg) can be < 0, leading to sqrt(-x)
else
- return FM * 2 * std::sqrt((sg) * (1 - sg)); // BUG: (1-sg) can be < 0, leading to sqrt(-x)
+ return FM * 2 * std::sqrt(sg * (1 - sg)); // BUG: (1-sg) can be < 0, leading to sqrt(-x)
else // powyzej stosunku krytycznego
return FM;
}
@@ -175,13 +175,13 @@ double PFVd(double PH, double PL, double const S, double LIM, double const DP)
PL = PL + 1.0; // nizsze cisnienie absolutne
double sg = std::min(1.0, PL / PH); // bezwymiarowy stosunek cisnien
double FM = PH * 197.0 * S; // najwyzszy mozliwy przeplyw, wraz z kierunkiem
- if ((PH - LIM) < 0.1)
+ if (PH - LIM < 0.1)
FM = FM * (PH - LIM) / DP; // jesli jestesmy przy nastawieniu, to zawor sie przymyka
- if ((sg > 0.5)) // jesli ponizej stosunku krytycznego
- if ((PH - PL) < DPL) // niewielka roznica cisnien
- return (PH - PL) / DPL * FM * 2.0 * std::sqrt((sg) * (1.0 - sg));
+ if (sg > 0.5) // jesli ponizej stosunku krytycznego
+ if (PH - PL < DPL) // niewielka roznica cisnien
+ return (PH - PL) / DPL * FM * 2.0 * std::sqrt(sg * (1.0 - sg));
else
- return FM * 2.0 * std::sqrt((sg) * (1.0 - sg));
+ return FM * 2.0 * std::sqrt(sg * (1.0 - sg));
else // powyzej stosunku krytycznego
return FM;
}
@@ -198,7 +198,7 @@ double PFVd(double PH, double PL, double const S, double LIM, double const DP)
/// True if pos is within ±0.5 of i_pos.
bool is_EQ(double pos, double i_pos)
{
- return (pos <= i_pos + 0.5) && (pos > i_pos - 0.5);
+ return pos <= i_pos + 0.5 && pos > i_pos - 0.5;
}
//---ZBIORNIKI---
@@ -302,7 +302,7 @@ double TBrakeCyl::P()
static double const cD = 1;
static double const pD = VD - cD;
- double VtoC = (Cap > 0.0 ? Vol / Cap : 0.0); // stosunek cisnienia do objetosci.
+ double VtoC = Cap > 0.0 ? Vol / Cap : 0.0; // stosunek cisnienia do objetosci.
// Added div/0 trap for vehicles with incomplete definitions (cars etc)
// P:=VtoC;
if (VtoC < VS)
@@ -384,7 +384,7 @@ TBrake::TBrake(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn
ValveRes->CreateCap(0.25);
// materialy cierne
- i_mat = i_mat & (255 - bp_MHS);
+ i_mat = i_mat & 255 - bp_MHS;
switch (i_mat)
{
case bp_P10Bg:
@@ -530,7 +530,7 @@ double TBrake::GetBCF()
/// True on accepted change, false otherwise.
bool TBrake::SetBDF(int const nBDF)
{
- if (((nBDF & BrakeDelays) == nBDF) && (nBDF != BrakeDelayFlag))
+ if ((nBDF & BrakeDelays) == nBDF && nBDF != BrakeDelayFlag)
{
BrakeDelayFlag = nBDF;
return true;
@@ -543,14 +543,14 @@ bool TBrake::SetBDF(int const nBDF)
/// 1 to engage, 0 to disengage.
void TBrake::Releaser(int const state)
{
- BrakeStatus = (BrakeStatus & ~b_rls) | (state * b_rls);
+ BrakeStatus = BrakeStatus & ~b_rls | state * b_rls;
}
/// Returns true if the releaser flag is currently set in BrakeStatus.
bool TBrake::Releaser() const
{
- return ((BrakeStatus & b_rls) == b_rls);
+ return (BrakeStatus & b_rls) == b_rls;
}
///
@@ -567,8 +567,8 @@ void TBrake::SetEPS(double const nEPS) {}
/// Two-bit ASB request.
void TBrake::ASB(int const state)
{ // 255-b_asb(32)
- BrakeStatus = (BrakeStatus & ~b_asb) | ((state / 2) * b_asb);
- BrakeStatus = (BrakeStatus & ~b_asb_unbrake) | ((state % 2) * b_asb_unbrake);
+ BrakeStatus = BrakeStatus & ~b_asb | state / 2 * b_asb;
+ BrakeStatus = BrakeStatus & ~b_asb_unbrake | state % 2 * b_asb_unbrake;
}
/// Returns the raw BrakeStatus bitfield.
@@ -674,24 +674,24 @@ double TWest::GetPF(double const PP, double const dt, double const Vel)
BCP = BrakeCyl->P();
if ((BrakeStatus & b_hld) == b_hld)
- if ((VVP + 0.03 < BVP))
+ if (VVP + 0.03 < BVP)
BrakeStatus |= b_on;
- else if ((VVP > BVP + 0.1))
+ else if (VVP > BVP + 0.1)
BrakeStatus &= ~(b_on | b_hld);
- else if ((VVP > BVP))
+ else if (VVP > BVP)
BrakeStatus &= ~b_on;
else
;
- else if ((VVP + 0.25 < BVP))
- BrakeStatus |= (b_on | b_hld);
+ else if (VVP + 0.25 < BVP)
+ BrakeStatus |= b_on | b_hld;
- if (((BrakeStatus & b_hld) == b_off) && (!DCV))
+ if ((BrakeStatus & b_hld) == b_off && !DCV)
dv = PF(0, CVP, 0.0068 * SizeBC) * dt;
else
dv = 0;
BrakeCyl->Flow(-dv);
- if ((BCP > LBP + 0.01) && (DCV))
+ if (BCP > LBP + 0.01 && DCV)
dv = PF(0, CVP, 0.1 * SizeBC) * dt;
else
dv = 0;
@@ -710,8 +710,8 @@ double TWest::GetPF(double const PP, double const dt, double const Vel)
dv = 0;
// przeplyw ZP <-> silowniki
- if (((BrakeStatus & b_on) == b_on) && ((TareBP < 0.1) || (BCP < MaxBP * LoadC)))
- if ((BVP > LBP))
+ if ((BrakeStatus & b_on) == b_on && (TareBP < 0.1 || BCP < MaxBP * LoadC))
+ if (BVP > LBP)
{
DCV = false;
dv = PF(BVP, CVP, 0.017 * SizeBC) * dt;
@@ -722,15 +722,15 @@ double TWest::GetPF(double const PP, double const dt, double const Vel)
dv = 0;
BrakeRes->Flow(dv);
BrakeCyl->Flow(-dv);
- if ((DCV))
+ if (DCV)
dVP = PF(LBP, BCP, 0.01 * SizeBC) * dt;
else
dVP = 0;
BrakeCyl->Flow(-dVP);
- if ((dVP > 0))
+ if (dVP > 0)
dVP = 0;
// przeplyw ZP <-> rozdzielacz
- if (((BrakeStatus & b_hld) == b_off))
+ if ((BrakeStatus & b_hld) == b_off)
dv = PF(BVP, VVP, 0.0011 * SizeBR) * dt;
else
dv = 0;
@@ -788,11 +788,11 @@ void TWest::SetEPS(double const nEPS)
DCV = true;
else if (nEPS == 0)
{
- if ((EPS != 0))
+ if (EPS != 0)
{
- if ((LBP > 0.4))
+ if (LBP > 0.4)
LBP = BrakeCyl->P();
- if ((LBP < 0.15))
+ if (LBP < 0.15)
LBP = 0;
}
}
@@ -838,7 +838,7 @@ void TESt::CheckReleaser(double const dt)
// odluzniacz
if ((BrakeStatus & b_rls) == b_rls)
- if ((CVP - VVP < 0))
+ if (CVP - VVP < 0)
BrakeStatus &= ~b_rls;
else
{
@@ -868,19 +868,19 @@ void TESt::CheckState(double const BCP, double &dV1)
if ((BrakeStatus & b_hld) == b_hld)
{
- if ((VVP + 0.003 + BCP / BVM) < CVP)
+ if (VVP + 0.003 + BCP / BVM < CVP)
{
// hamowanie stopniowe
BrakeStatus |= b_on;
}
else
{
- if ((VVP + BCP / BVM) > CVP)
+ if (VVP + BCP / BVM > CVP)
{
// zatrzymanie napelaniania
BrakeStatus &= ~b_on;
}
- if ((VVP - 0.003 + (BCP - 0.1) / BVM) > CVP)
+ if (VVP - 0.003 + (BCP - 0.1) / BVM > CVP)
{
// luzowanie
BrakeStatus &= ~(b_on | b_hld);
@@ -890,7 +890,7 @@ void TESt::CheckState(double const BCP, double &dV1)
else
{
- if ((VVP + BCP / BVM < CVP) && ((CVP - VVP) * BVM > 0.25))
+ if (VVP + BCP / BVM < CVP && (CVP - VVP) * BVM > 0.25)
{
// zatrzymanie luzowanie
BrakeStatus |= b_hld;
@@ -910,7 +910,7 @@ void TESt::CheckState(double const BCP, double &dV1)
SoundFlag |= sf_Acc;
ValveRes->Act();
}
- BrakeStatus |= (b_on | b_hld);
+ BrakeStatus |= b_on | b_hld;
}
}
@@ -938,14 +938,14 @@ double TESt::CVs(double const BP)
VVP = ValveRes->P();
// przeplyw ZS <-> PG
- if ((VVP < CVP - 0.12) || (BVP < CVP - 0.3) || (BP > 0.4))
+ if (VVP < CVP - 0.12 || BVP < CVP - 0.3 || BP > 0.4)
return 0;
- else if ((VVP > CVP + 0.4))
- if ((BVP > CVP + 0.2))
+ else if (VVP > CVP + 0.4)
+ if (BVP > CVP + 0.2)
return 0.23;
else
return 0.05;
- else if ((BVP > CVP - 0.1))
+ else if (BVP > CVP - 0.1)
return 1;
else
return 0.3;
@@ -969,10 +969,10 @@ double TESt::BVs(double const BCP)
VVP = ValveRes->P();
// przeplyw ZP <-> rozdzielacz
- if ((BVP < CVP - 0.3))
+ if (BVP < CVP - 0.3)
return 0.6;
- else if ((BCP < 0.5))
- if ((VVP > CVP + 0.4))
+ else if (BCP < 0.5)
+ if (VVP > CVP + 0.4)
return 0.1;
else
return 0.3;
@@ -1038,7 +1038,7 @@ double TESt::GetPF(double const PP, double const dt, double const Vel)
// przeplyw ZP <-> rozdzielacz
temp = BVs(BCP);
// if(BrakeStatus and b_hld)=b_off then
- if ((VVP - 0.05 > BVP))
+ if (VVP - 0.05 > BVP)
dv = PF(BVP, VVP, 0.02 * SizeBR * temp / 1.87) * dt;
else
dv = 0;
@@ -1167,16 +1167,16 @@ double TEStEP2::GetPF(double const PP, double const dt, double const Vel)
CheckReleaser(dt);
// sprawdzanie stanu
- if (((BrakeStatus & b_hld) == b_hld) && (BCP > 0.25))
- if ((VVP + 0.003 + BCP / BVM < CVP - 0.12))
+ if ((BrakeStatus & b_hld) == b_hld && BCP > 0.25)
+ if (VVP + 0.003 + BCP / BVM < CVP - 0.12)
BrakeStatus |= b_on; // hamowanie stopniowe;
- else if ((VVP - 0.003 + BCP / BVM > CVP - 0.12))
+ else if (VVP - 0.003 + BCP / BVM > CVP - 0.12)
BrakeStatus &= ~(b_on | b_hld); // luzowanie;
- else if ((VVP + BCP / BVM > CVP - 0.12))
+ else if (VVP + BCP / BVM > CVP - 0.12)
BrakeStatus &= ~b_on; // zatrzymanie napelaniania;
else
;
- else if ((VVP + 0.10 < CVP - 0.12) && (BCP < 0.25)) // poczatek hamowania
+ else if (VVP + 0.10 < CVP - 0.12 && BCP < 0.25) // poczatek hamowania
{
// if ((BrakeStatus & 1) == 0)
//{
@@ -1184,9 +1184,9 @@ double TEStEP2::GetPF(double const PP, double const dt, double const Vel)
// // SoundFlag:=SoundFlag or sf_Acc;
// // ValveRes.Act;
//}
- BrakeStatus |= (b_on | b_hld);
+ BrakeStatus |= b_on | b_hld;
}
- else if ((VVP + BCP / BVM < CVP - 0.12) && (BCP > 0.25)) // zatrzymanie luzowanie
+ else if (VVP + BCP / BVM < CVP - 0.12 && BCP > 0.25) // zatrzymanie luzowanie
BrakeStatus |= b_hld;
if ((BrakeStatus & b_hld) == 0)
@@ -1195,9 +1195,9 @@ double TEStEP2::GetPF(double const PP, double const dt, double const Vel)
}
// przeplyw ZS <-> PG
- if ((BVP < CVP - 0.2) || (BrakeStatus != b_off) || (BCP > 0.25))
+ if (BVP < CVP - 0.2 || BrakeStatus != b_off || BCP > 0.25)
temp = 0;
- else if ((VVP > CVP + 0.4))
+ else if (VVP > CVP + 0.4)
temp = 0.1;
else
temp = 0.5;
@@ -1217,7 +1217,7 @@ double TEStEP2::GetPF(double const PP, double const dt, double const Vel)
dv = 0;
ImplsRes->Flow(-dv);
// przeplyw ZP <-> KI
- if (((BrakeStatus & b_on) == b_on) && (BCP < MaxBP * LoadC))
+ if ((BrakeStatus & b_on) == b_on && BCP < MaxBP * LoadC)
dv = PF(BVP, BCP, 0.0006) * dt;
else
dv = 0;
@@ -1231,17 +1231,17 @@ double TEStEP2::GetPF(double const PP, double const dt, double const Vel)
temp = std::max(BCP, LBP);
- if ((ImplsRes->P() > LBP + 0.01))
+ if (ImplsRes->P() > LBP + 0.01)
LBP = 0;
// luzowanie CH
- if ((BrakeCyl->P() > temp + 0.005) || (std::max(ImplsRes->P(), 8 * LBP) < 0.05))
+ if (BrakeCyl->P() > temp + 0.005 || std::max(ImplsRes->P(), 8 * LBP) < 0.05)
dv = PF(0, BrakeCyl->P(), 0.25 * SizeBC * (0.01 + (BrakeCyl->P() - temp))) * dt;
else
dv = 0;
BrakeCyl->Flow(-dv);
// przeplyw ZP <-> CH
- if ((BrakeCyl->P() < temp - 0.005) && (std::max(ImplsRes->P(), 8 * LBP) > 0.10) && (std::max(BCP, LBP) < MaxBP * LoadC))
+ if (BrakeCyl->P() < temp - 0.005 && std::max(ImplsRes->P(), 8 * LBP) > 0.10 && std::max(BCP, LBP) < MaxBP * LoadC)
dv = PF(BVP, BrakeCyl->P(), 0.35 * SizeBC * (0.01 - (BrakeCyl->P() - temp))) * dt;
else
dv = 0;
@@ -1275,7 +1275,7 @@ void TEStEP2::PLC(double const mass)
void TEStEP2::SetEPS(double const nEPS)
{
EPS = nEPS;
- if ((EPS > 0) && (LBP + 0.01 < BrakeCyl->P()))
+ if (EPS > 0 && LBP + 0.01 < BrakeCyl->P())
LBP = BrakeCyl->P();
}
@@ -1315,7 +1315,7 @@ void TEStEP1::EPCalc(double dt)
double temp = EPS - std::floor(EPS); // część ułamkowa jest hamulcem EP
double LBPLim = std::min(MaxBP * LoadC * temp, BrakeRes->P()); // do czego dążymy
double S = 10 * std::clamp(LBPLim - LBP, -0.1, 0.1); // przymykanie zaworku
- double dv = PF((S > 0 ? BrakeRes->P() : 0), LBP, abs(S) * (0.00053 + 0.00060 * int(S < 0))) * dt; // przepływ
+ double dv = PF(S > 0 ? BrakeRes->P() : 0, LBP, abs(S) * (0.00053 + 0.00060 * int(S < 0))) * dt; // przepływ
LBP = LBP - dv;
}
@@ -1371,14 +1371,14 @@ double TESt3::GetPF(double const PP, double const dt, double const Vel)
BrakeCyl->Flow(-dv);
// przeplyw ZP <-> silowniki
if ((BrakeStatus & b_on) == b_on)
- dv = PF(BVP, BCP, 0.017 * (1.00 + (((BCP < 0.58) && (BrakeDelayFlag == bdelay_G)) ? 1.0 : 0.0)) * (1.13 - (((BCP > 0.60) && (BrakeDelayFlag == bdelay_G)) ? 1.0 : 0.0)) * SizeBC) * dt;
+ dv = PF(BVP, BCP, 0.017 * (1.00 + (BCP < 0.58 && BrakeDelayFlag == bdelay_G ? 1.0 : 0.0)) * (1.13 - (BCP > 0.60 && BrakeDelayFlag == bdelay_G ? 1.0 : 0.0)) * SizeBC) * dt;
else
dv = 0;
BrakeRes->Flow(dv);
BrakeCyl->Flow(-dv);
// przeplyw ZP <-> rozdzielacz
temp = BVs(BCP);
- if ((VVP - 0.05 > BVP))
+ if (VVP - 0.05 > BVP)
dv = PF(BVP, VVP, 0.02 * SizeBR * temp / 1.87) * dt;
else
dv = 0;
@@ -1455,7 +1455,7 @@ double TESt4R::GetPF(double const PP, double const dt, double const Vel)
ImplsRes->Flow(-dv);
// przeplyw ZP <-> rozdzielacz
temp = BVs(BCP);
- if ((BVP < VVP - 0.05)) // or((PP 55) && (RapidStatus == true)) || (Vel > 70));
+ RapidStatus = BrakeDelayFlag == bdelay_R && ((Vel > 55 && RapidStatus == true) || Vel > 70);
RapidTemp = RapidTemp + (0.9 * int(RapidStatus) - RapidTemp) * dt / 2;
temp = 1.9 - RapidTemp;
- if (((BrakeStatus & b_asb) == b_asb))
+ if ((BrakeStatus & b_asb) == b_asb)
temp = 1000;
// luzowanie CH
- if ((BrakeCyl->P() * temp > ImplsRes->P() + 0.005) || (ImplsRes->P() < 0.25))
- if (((BrakeStatus & b_asb) == b_asb))
+ if (BrakeCyl->P() * temp > ImplsRes->P() + 0.005 || ImplsRes->P() < 0.25)
+ if ((BrakeStatus & b_asb) == b_asb)
dv = PFVd(BrakeCyl->P(), 0, 0.115 * SizeBC * 4, ImplsRes->P() / temp) * dt;
else
dv = PFVd(BrakeCyl->P(), 0, 0.115 * SizeBC, ImplsRes->P() / temp) * dt;
@@ -1486,7 +1486,7 @@ double TESt4R::GetPF(double const PP, double const dt, double const Vel)
dv = 0;
BrakeCyl->Flow(-dv);
// przeplyw ZP <-> CH
- if ((BrakeCyl->P() * temp < ImplsRes->P() - 0.005) && (ImplsRes->P() > 0.3))
+ if (BrakeCyl->P() * temp < ImplsRes->P() - 0.005 && ImplsRes->P() > 0.3)
// dV:=PFVa(BVP,BrakeCyl.P,0.020*sizeBC,ImplsRes.P/temp)*dt
dv = PFVa(BVP, BrakeCyl->P(), 0.60 * SizeBC, ImplsRes->P() / temp) * dt;
else
@@ -1569,15 +1569,15 @@ double TESt3AL2::GetPF(double const PP, double const dt, double const Vel)
dv = 0;
ImplsRes->Flow(-dv);
// przeplyw ZP <-> KI
- if (((BrakeStatus & b_on) == b_on) && (BCP < MaxBP))
- dv = PF(BVP, BCP, 0.0008 * (1 + int((BCP < 0.58) && (BrakeDelayFlag == bdelay_G))) * (1.13 - int((BCP > 0.6) && (BrakeDelayFlag == bdelay_G)))) * dt;
+ if ((BrakeStatus & b_on) == b_on && BCP < MaxBP)
+ dv = PF(BVP, BCP, 0.0008 * (1 + int(BCP < 0.58 && BrakeDelayFlag == bdelay_G)) * (1.13 - int(BCP > 0.6 && BrakeDelayFlag == bdelay_G))) * dt;
else
dv = 0;
BrakeRes->Flow(dv);
ImplsRes->Flow(-dv);
// przeplyw ZP <-> rozdzielacz
temp = BVs(BCP);
- if ((VVP - 0.05 > BVP))
+ if (VVP - 0.05 > BVP)
dv = PF(BVP, VVP, 0.02 * SizeBR * temp / 1.87) * dt;
else
dv = 0;
@@ -1590,14 +1590,14 @@ double TESt3AL2::GetPF(double const PP, double const dt, double const Vel)
result = dv - dV1;
// luzowanie CH
- if ((BrakeCyl->P() > ImplsRes->P() * LoadC + 0.005) || (ImplsRes->P() < 0.15))
+ if (BrakeCyl->P() > ImplsRes->P() * LoadC + 0.005 || ImplsRes->P() < 0.15)
dv = PF(0, BrakeCyl->P(), 0.015 * SizeBC) * dt;
else
dv = 0;
BrakeCyl->Flow(-dv);
// przeplyw ZP <-> CH
- if ((BrakeCyl->P() < ImplsRes->P() * LoadC - 0.005) && (ImplsRes->P() > 0.15))
+ if (BrakeCyl->P() < ImplsRes->P() * LoadC - 0.005 && ImplsRes->P() > 0.15)
dv = PF(BVP, BrakeCyl->P(), 0.020 * SizeBC) * dt;
else
dv = 0;
@@ -1678,34 +1678,34 @@ double TLSt::GetPF(double const PP, double const dt, double const Vel)
// sprawdzanie stanu
// NOTE: partial copypaste from checkstate() of base class
// TODO: clean inheritance for checkstate() and checkreleaser() and reuse these instead of manual copypaste
- if (((BrakeStatus & b_hld) == b_hld) && (BCP > 0.25))
+ if ((BrakeStatus & b_hld) == b_hld && BCP > 0.25)
{
- if ((VVP + 0.003 + BCP / BVM < CVP))
+ if (VVP + 0.003 + BCP / BVM < CVP)
{
// hamowanie stopniowe
BrakeStatus |= b_on;
}
- else if ((VVP - 0.003 + (BCP - 0.1) / BVM > CVP))
+ else if (VVP - 0.003 + (BCP - 0.1) / BVM > CVP)
{
// luzowanie
BrakeStatus &= ~(b_on | b_hld);
}
- else if ((VVP + BCP / BVM > CVP))
+ else if (VVP + BCP / BVM > CVP)
{
// zatrzymanie napelaniania
BrakeStatus &= ~b_on;
}
}
- else if ((VVP + 0.10 < CVP) && (BCP < 0.25))
+ else if (VVP + 0.10 < CVP && BCP < 0.25)
{
// poczatek hamowania
if ((BrakeStatus & b_hld) == b_off)
{
SoundFlag |= sf_Acc;
}
- BrakeStatus |= (b_on | b_hld);
+ BrakeStatus |= b_on | b_hld;
}
- else if ((VVP + (BCP - 0.1) / BVM < CVP) && ((CVP - VVP) * BVM > 0.25) && (BCP > 0.25))
+ else if (VVP + (BCP - 0.1) / BVM < CVP && (CVP - VVP) * BVM > 0.25 && BCP > 0.25)
{
// zatrzymanie luzowanie
BrakeStatus |= b_hld;
@@ -1715,7 +1715,7 @@ double TLSt::GetPF(double const PP, double const dt, double const Vel)
SoundFlag |= sf_CylU;
}
// equivalent of checkreleaser() in the base class?
- bool is_releasing = ((BrakeStatus & b_rls) || (UniversalFlag & TUniversalBrake::ub_Release));
+ bool is_releasing = BrakeStatus & b_rls || UniversalFlag & TUniversalBrake::ub_Release;
if (is_releasing)
{
if (CVP < 0.0)
@@ -1731,9 +1731,9 @@ double TLSt::GetPF(double const PP, double const dt, double const Vel)
// przeplyw ZS <-> PG
double temp;
- if (((CVP - BCP) * BVM > 0.5))
+ if ((CVP - BCP) * BVM > 0.5)
temp = 0.0;
- else if ((VVP > CVP + 0.4))
+ else if (VVP > CVP + 0.4)
temp = 0.5;
else
temp = 0.5;
@@ -1752,11 +1752,11 @@ double TLSt::GetPF(double const PP, double const dt, double const Vel)
/*P*/
if (VVP > BCP)
{
- dV = PF(VVP, BCP, 0.00043 * (1.5 - (true == (((CVP - BCP) * BVM > 1.0) && (BrakeDelayFlag == bdelay_G)) ? 1.0 : 0.0)), 0.1) * dt;
+ dV = PF(VVP, BCP, 0.00043 * (1.5 - (true == ((CVP - BCP) * BVM > 1.0 && BrakeDelayFlag == bdelay_G) ? 1.0 : 0.0)), 0.1) * dt;
}
- else if ((CVP - BCP) < 1.5)
+ else if (CVP - BCP < 1.5)
{
- dV = PF(VVP, BCP, 0.001472 * (1.36 - (true == (((CVP - BCP) * BVM > 1.0) && (BrakeDelayFlag == bdelay_G)) ? 1.0 : 0.0)), 0.1) * dt;
+ dV = PF(VVP, BCP, 0.001472 * (1.36 - (true == ((CVP - BCP) * BVM > 1.0 && BrakeDelayFlag == bdelay_G) ? 1.0 : 0.0)), 0.1) * dt;
}
else
{
@@ -1774,17 +1774,17 @@ double TLSt::GetPF(double const PP, double const dt, double const Vel)
// if Vel>55 then temp:=0.72 else
// temp:=1;{R}
// cisnienie PP
- RapidTemp = RapidTemp + (RM * int((Vel > 55) && (BrakeDelayFlag == bdelay_R)) - RapidTemp) * dt / 2;
+ RapidTemp = RapidTemp + (RM * int(Vel > 55 && BrakeDelayFlag == bdelay_R) - RapidTemp) * dt / 2;
temp = 1 - RapidTemp;
if (EDFlag > 0.2)
temp = 10000;
double tempasb = 0;
- if (((UniversalFlag & TUniversalBrake::ub_AntiSlipBrake) > 0) || ((BrakeStatus & b_asb_unbrake) == b_asb_unbrake))
+ if ((UniversalFlag & TUniversalBrake::ub_AntiSlipBrake) > 0 || (BrakeStatus & b_asb_unbrake) == b_asb_unbrake)
tempasb = ASBP;
// powtarzacz — podwojny zawor zwrotny
temp = std::max(((CVP - BCP) * BVM + tempasb) / temp, LBP);
// luzowanie CH
- if ((BrakeCyl->P() > temp + 0.005) || (temp < 0.28))
+ if (BrakeCyl->P() > temp + 0.005 || temp < 0.28)
// dV:=PF(0,BrakeCyl->P(),0.0015*3*sizeBC)*dt
// dV:=PF(0,BrakeCyl->P(),0.005*3*sizeBC)*dt
dV = PFVd(BrakeCyl->P(), 0, 0.005 * 7 * SizeBC, temp) * dt;
@@ -1792,7 +1792,7 @@ double TLSt::GetPF(double const PP, double const dt, double const Vel)
dV = 0;
BrakeCyl->Flow(-dV);
// przeplyw ZP <-> CH
- if ((BrakeCyl->P() < temp - 0.005) && (temp > 0.29))
+ if (BrakeCyl->P() < temp - 0.005 && temp > 0.29)
// dV:=PF(BVP,BrakeCyl->P(),0.002*3*sizeBC*2)*dt
dV = -PFVa(BVP, BrakeCyl->P(), 0.002 * 7 * SizeBC * 2, temp) * dt;
else
@@ -1918,24 +1918,24 @@ double TEStED::GetPF(double const PP, double const dt, double const Vel)
MPP = Miedzypoj->P();
dV1 = 0;
- nastG = (BrakeDelayFlag & bdelay_G);
+ nastG = BrakeDelayFlag & bdelay_G;
// sprawdzanie stanu
- if ((BCP < 0.25) && (VVP + 0.08 > CVP))
+ if (BCP < 0.25 && VVP + 0.08 > CVP)
Przys_blok = false;
// sprawdzanie stanu
- if ((VVP + 0.002 + BCP / BVM < CVP - 0.05) && (Przys_blok))
- BrakeStatus |= (b_on | b_hld); // hamowanie stopniowe;
- else if ((VVP - 0.002 + (BCP - 0.1) / BVM > CVP - 0.05))
+ if (VVP + 0.002 + BCP / BVM < CVP - 0.05 && Przys_blok)
+ BrakeStatus |= b_on | b_hld; // hamowanie stopniowe;
+ else if (VVP - 0.002 + (BCP - 0.1) / BVM > CVP - 0.05)
BrakeStatus &= ~(b_on | b_hld); // luzowanie;
- else if ((VVP + BCP / BVM > CVP - 0.05))
+ else if (VVP + BCP / BVM > CVP - 0.05)
BrakeStatus &= ~b_on; // zatrzymanie napelaniania;
- else if ((VVP + (BCP - 0.1) / BVM < CVP - 0.05) && (BCP > 0.25)) // zatrzymanie luzowania
+ else if (VVP + (BCP - 0.1) / BVM < CVP - 0.05 && BCP > 0.25) // zatrzymanie luzowania
BrakeStatus |= b_hld;
- if ((VVP + 0.10 < CVP) && (BCP < 0.25)) // poczatek hamowania
- if ((!Przys_blok))
+ if (VVP + 0.10 < CVP && BCP < 0.25) // poczatek hamowania
+ if (!Przys_blok)
{
ValveRes->CreatePress(0.75 * VVP);
SoundFlag |= sf_Acc;
@@ -1943,9 +1943,9 @@ double TEStED::GetPF(double const PP, double const dt, double const Vel)
Przys_blok = true;
}
- if ((BCP > 0.5))
+ if (BCP > 0.5)
Zamykajacy = true;
- else if ((VVP - 0.6 < MPP))
+ else if (VVP - 0.6 < MPP)
Zamykajacy = false;
if ((BrakeStatus & b_rls) == b_rls)
@@ -1960,7 +1960,7 @@ double TEStED::GetPF(double const PP, double const dt, double const Vel)
else
dv = 0;
ImplsRes->Flow(-dv);
- if (((BrakeStatus & b_on) == b_on) && (BCP < MaxBP))
+ if ((BrakeStatus & b_on) == b_on && BCP < MaxBP)
dv = PF(BVP, BCP, Nozzles[2] * (nastG + 2 * int(BCP < 0.8)) + Nozzles[0] * (1 - nastG)) * dt;
else
dv = 0;
@@ -1968,10 +1968,10 @@ double TEStED::GetPF(double const PP, double const dt, double const Vel)
BrakeRes->Flow(dv);
// przeplyw testowy miedzypojemnosci
- if ((MPP < CVP - 0.3))
+ if (MPP < CVP - 0.3)
temp = Nozzles[4];
- else if ((BCP < 0.5))
- if ((Zamykajacy))
+ else if (BCP < 0.5)
+ if (Zamykajacy)
temp = Nozzles[8]; // 1.25;
else
temp = Nozzles[7];
@@ -1979,21 +1979,21 @@ double TEStED::GetPF(double const PP, double const dt, double const Vel)
temp = 0;
dv = PF(MPP, VVP, temp);
- if ((MPP < CVP - 0.17))
+ if (MPP < CVP - 0.17)
temp = 0;
- else if ((MPP > CVP - 0.08))
+ else if (MPP > CVP - 0.08)
temp = Nozzles[5];
else
temp = Nozzles[6];
dv = dv + PF(MPP, CVP, temp);
- if ((MPP - 0.05 > BVP))
+ if (MPP - 0.05 > BVP)
dv = dv + PF(MPP - 0.05, BVP, Nozzles[10] * nastG + (1 - nastG) * Nozzles[9]);
if (MPP > VVP)
dv = dv + PF(MPP, VVP, 0.02);
Miedzypoj->Flow(dv * dt * 0.15);
- RapidTemp = RapidTemp + (RM * int((Vel > RV) && (BrakeDelayFlag == bdelay_R)) - RapidTemp) * dt / 2;
+ RapidTemp = RapidTemp + (RM * int(Vel > RV && BrakeDelayFlag == bdelay_R) - RapidTemp) * dt / 2;
temp = std::max(1 - RapidTemp, 0.001);
// if EDFlag then temp:=1000;
// temp:=temp/(1-);
@@ -2005,15 +2005,15 @@ double TEStED::GetPF(double const PP, double const dt, double const Vel)
temp = std::max(temp, ASBP);
double speed = 1;
- if ((ASBP < 0.1) && ((BrakeStatus & b_asb_unbrake) == b_asb_unbrake))
+ if (ASBP < 0.1 && (BrakeStatus & b_asb_unbrake) == b_asb_unbrake)
{
temp = 0;
speed = 3;
}
- if ((BrakeCyl->P() > temp))
+ if (BrakeCyl->P() > temp)
dv = -PFVd(BrakeCyl->P(), 0, 0.05 * SizeBC * speed, temp) * dt;
- else if ((BrakeCyl->P() < temp) && ((BrakeStatus & b_asb) == 0))
+ else if (BrakeCyl->P() < temp && (BrakeStatus & b_asb) == 0)
dv = PFVa(BVP, BrakeCyl->P(), 0.05 * SizeBC, temp) * dt;
else
dv = 0;
@@ -2023,9 +2023,9 @@ double TEStED::GetPF(double const PP, double const dt, double const Vel)
BrakeRes->Flow(-dv);
// przeplyw ZS <-> PG
- if ((MPP < CVP - 0.17))
+ if (MPP < CVP - 0.17)
temp = 0;
- else if ((MPP > CVP - 0.08))
+ else if (MPP > CVP - 0.08)
temp = Nozzles[5];
else
temp = Nozzles[6];
@@ -2035,7 +2035,7 @@ double TEStED::GetPF(double const PP, double const dt, double const Vel)
dV1 = dV1 + 0.98 * dv;
// przeplyw ZP <-> MPJ
- if ((MPP - 0.05 > BVP))
+ if (MPP - 0.05 > BVP)
dv = PF(BVP, MPP - 0.05, Nozzles[10] * nastG + (1 - nastG) * Nozzles[9]) * dt;
else
dv = 0;
@@ -2078,7 +2078,7 @@ void TEStED::Init(double const PP, double const HPP, double const LPP, double co
// CntrlRes.CreateCap(15);
// CntrlRes.CreatePress(1*HPP);
- BrakeStatus = (BP > 1.0) ? 1 : 0;
+ BrakeStatus = BP > 1.0 ? 1 : 0;
Miedzypoj->CreateCap(5);
Miedzypoj->CreatePress(PP);
@@ -2160,25 +2160,25 @@ void TCV1::CheckState(double const BCP, double &dV1)
CVP = CntrlRes->P();
// odluzniacz
- if (((BrakeStatus & b_rls) == b_rls) && (CVP - VVP < 0))
+ if ((BrakeStatus & b_rls) == b_rls && CVP - VVP < 0)
BrakeStatus &= ~b_rls;
// sprawdzanie stanu
if ((BrakeStatus & b_hld) == b_hld)
- if ((VVP + 0.003 + BCP / BVM < CVP))
+ if (VVP + 0.003 + BCP / BVM < CVP)
BrakeStatus |= b_on; // hamowanie stopniowe;
- else if ((VVP - 0.003 + BCP * 1.0 / BVM > CVP))
+ else if (VVP - 0.003 + BCP * 1.0 / BVM > CVP)
BrakeStatus &= ~(b_on | b_hld); // luzowanie;
- else if ((VVP + BCP * 1.0 / BVM > CVP))
+ else if (VVP + BCP * 1.0 / BVM > CVP)
BrakeStatus &= ~b_on; // zatrzymanie napelaniania;
else
;
- else if ((VVP + 0.10 < CVP) && (BCP < 0.1)) // poczatek hamowania
+ else if (VVP + 0.10 < CVP && BCP < 0.1) // poczatek hamowania
{
- BrakeStatus |= (b_on | b_hld);
+ BrakeStatus |= b_on | b_hld;
dV1 = 1.25;
}
- else if ((VVP + BCP / BVM < CVP) && (BCP > 0.25)) // zatrzymanie luzowanie
+ else if (VVP + BCP / BVM < CVP && BCP > 0.25) // zatrzymanie luzowanie
BrakeStatus |= b_hld;
}
@@ -2191,7 +2191,7 @@ void TCV1::CheckState(double const BCP, double &dV1)
double TCV1::CVs(double const BP)
{
// przeplyw ZS <-> PG
- if ((BP > 0.05))
+ if (BP > 0.05)
return 0;
else
return 0.23;
@@ -2215,9 +2215,9 @@ double TCV1::BVs(double const BCP)
VVP = ValveRes->P();
// przeplyw ZP <-> rozdzielacz
- if ((BVP < CVP - 0.1))
+ if (BVP < CVP - 0.1)
return 1;
- else if ((BCP > 0.05))
+ else if (BCP > 0.05)
return 0;
else
return 0.2 * (1.5 - int(BVP > VVP));
@@ -2270,7 +2270,7 @@ double TCV1::GetPF(double const PP, double const dt, double const Vel)
// przeplyw ZP <-> silowniki
if ((BrakeStatus & b_on) == b_on)
- dv = PF(BVP, BCP, 0.017 * (1 + int((BCP < 0.58) && (BrakeDelayFlag == bdelay_G))) * (1.13 - int((BCP > 0.6) && (BrakeDelayFlag == bdelay_G))) * SizeBC) * dt;
+ dv = PF(BVP, BCP, 0.017 * (1 + int(BCP < 0.58 && BrakeDelayFlag == bdelay_G)) * (1.13 - int(BCP > 0.6 && BrakeDelayFlag == bdelay_G)) * SizeBC) * dt;
else
dv = 0;
BrakeRes->Flow(dv);
@@ -2278,7 +2278,7 @@ double TCV1::GetPF(double const PP, double const dt, double const Vel)
// przeplyw ZP <-> rozdzielacz
temp = BVs(BCP);
- if ((VVP + 0.05 > BVP))
+ if (VVP + 0.05 > BVP)
dv = PF(BVP, VVP, 0.02 * SizeBR * temp / 1.87) * dt;
else
dv = 0;
@@ -2427,8 +2427,8 @@ double TCV1L_TR::GetPF(double const PP, double const dt, double const Vel)
dv = 0;
ImplsRes->Flow(-dv);
// przeplyw ZP <-> KI
- if (((BrakeStatus & b_on) == b_on) && (BCP < MaxBP))
- dv = PF(BVP, BCP, 0.002 * (1 + int((BCP < 0.58) && (BrakeDelayFlag == bdelay_G))) * (1.13 - int((BCP > 0.6) && (BrakeDelayFlag == bdelay_G)))) * dt;
+ if ((BrakeStatus & b_on) == b_on && BCP < MaxBP)
+ dv = PF(BVP, BCP, 0.002 * (1 + int(BCP < 0.58 && BrakeDelayFlag == bdelay_G)) * (1.13 - int(BCP > 0.6 && BrakeDelayFlag == bdelay_G))) * dt;
else
dv = 0;
BrakeRes->Flow(dv);
@@ -2436,7 +2436,7 @@ double TCV1L_TR::GetPF(double const PP, double const dt, double const Vel)
// przeplyw ZP <-> rozdzielacz
temp = BVs(BCP);
- if ((VVP + 0.05 > BVP))
+ if (VVP + 0.05 > BVP)
dv = PF(BVP, VVP, 0.02 * SizeBR * temp / 1.87) * dt;
else
dv = 0;
@@ -2450,14 +2450,14 @@ double TCV1L_TR::GetPF(double const PP, double const dt, double const Vel)
temp = std::max(BCP, LBP);
// luzowanie CH
- if ((BrakeCyl->P() > temp + 0.005) || (std::max(ImplsRes->P(), 8 * LBP) < 0.25))
+ if (BrakeCyl->P() > temp + 0.005 || std::max(ImplsRes->P(), 8 * LBP) < 0.25)
dv = PF(0, BrakeCyl->P(), 0.015 * SizeBC) * dt;
else
dv = 0;
BrakeCyl->Flow(-dv);
// przeplyw ZP <-> CH
- if ((BrakeCyl->P() < temp - 0.005) && (std::max(ImplsRes->P(), 8 * LBP) > 0.3) && (std::max(BCP, LBP) < MaxBP))
+ if (BrakeCyl->P() < temp - 0.005 && std::max(ImplsRes->P(), 8 * LBP) > 0.3 && std::max(BCP, LBP) < MaxBP)
dv = PF(BVP, BrakeCyl->P(), 0.020 * SizeBC) * dt;
else
dv = 0;
@@ -2488,7 +2488,7 @@ void TKE::CheckReleaser(double const dt)
// odluzniacz
if (true == ((BrakeStatus & b_rls) == b_rls))
- if ((CVP - VVP < 0))
+ if (CVP - VVP < 0)
BrakeStatus &= ~b_rls;
else
CntrlRes->Flow(+PF(CVP, 0, 0.1) * dt);
@@ -2519,19 +2519,19 @@ void TKE::CheckState(double const BCP, double &dV1)
if ((BrakeStatus & b_hld) == b_hld)
{
- if ((VVP + 0.003 + BCP / BVM) < CVP)
+ if (VVP + 0.003 + BCP / BVM < CVP)
{
// hamowanie stopniowe;
BrakeStatus |= b_on;
}
else
{
- if ((VVP + BCP / BVM) > CVP)
+ if (VVP + BCP / BVM > CVP)
{
// zatrzymanie napelaniania;
BrakeStatus &= ~b_on;
}
- if ((VVP - 0.003 + BCP / BVM) > CVP)
+ if (VVP - 0.003 + BCP / BVM > CVP)
{
// luzowanie;
BrakeStatus &= ~(b_on | b_hld);
@@ -2541,7 +2541,7 @@ void TKE::CheckState(double const BCP, double &dV1)
else
{
- if ((VVP + BCP / BVM < CVP) && ((CVP - VVP) * BVM > 0.25))
+ if (VVP + BCP / BVM < CVP && (CVP - VVP) * BVM > 0.25)
{
// zatrzymanie luzowanie
BrakeStatus |= b_hld;
@@ -2561,7 +2561,7 @@ void TKE::CheckState(double const BCP, double &dV1)
SoundFlag |= sf_Acc;
ValveRes->Act();
}
- BrakeStatus |= (b_on | b_hld);
+ BrakeStatus |= b_on | b_hld;
}
}
@@ -2589,9 +2589,9 @@ double TKE::CVs(double const BP)
VVP = ValveRes->P();
// przeplyw ZS <-> PG
- if ((BP > 0.2))
+ if (BP > 0.2)
return 0;
- else if ((VVP > CVP + 0.4))
+ else if (VVP > CVP + 0.4)
return 0.05;
else
return 0.23;
@@ -2615,9 +2615,9 @@ double TKE::BVs(double const BCP)
VVP = ValveRes->P();
// przeplyw ZP <-> rozdzielacz
- if ((BVP > VVP))
+ if (BVP > VVP)
return 0;
- else if ((BVP < CVP - 0.3))
+ else if (BVP < CVP - 0.3)
return 0.6;
else
return 0.13;
@@ -2668,7 +2668,7 @@ double TKE::GetPF(double const PP, double const dt, double const Vel)
// luzowanie
if ((BrakeStatus & b_hld) == b_off)
{
- if (((BrakeDelayFlag & bdelay_G) == 0))
+ if ((BrakeDelayFlag & bdelay_G) == 0)
temp = 0.283 + 0.139;
else
temp = 0.139;
@@ -2679,12 +2679,12 @@ double TKE::GetPF(double const PP, double const dt, double const Vel)
ImplsRes->Flow(-dv);
// przeplyw ZP <-> silowniki
- if (((BrakeStatus & b_on) == b_on) && (IMP < MaxBP))
+ if ((BrakeStatus & b_on) == b_on && IMP < MaxBP)
{
temp = 0.113;
- if (((BrakeDelayFlag & bdelay_G) == 0))
+ if ((BrakeDelayFlag & bdelay_G) == 0)
temp = temp + 0.636;
- if ((BCP < 0.5))
+ if (BCP < 0.5)
temp = temp + 0.785;
dv = PF(BVP, IMP, 0.001 * temp) * dt;
}
@@ -2694,15 +2694,15 @@ double TKE::GetPF(double const PP, double const dt, double const Vel)
ImplsRes->Flow(-dv);
// rapid
- if (!((typeid(*FM) == typeid(TDisk1)) || (typeid(*FM) == typeid(TDisk2)))) // jesli zeliwo to schodz
- RapidStatus = ((BrakeDelayFlag & bdelay_R) == bdelay_R) && ((RV < 0) || ((Vel > RV) && (RapidStatus)) || (Vel > (RV + 20)));
+ if (!(typeid(*FM) == typeid(TDisk1) || typeid(*FM) == typeid(TDisk2))) // jesli zeliwo to schodz
+ RapidStatus = (BrakeDelayFlag & bdelay_R) == bdelay_R && (RV < 0 || (Vel > RV && RapidStatus) || Vel > RV + 20);
else // jesli tarczowki, to zostan
- RapidStatus = ((BrakeDelayFlag & bdelay_R) == bdelay_R);
+ RapidStatus = (BrakeDelayFlag & bdelay_R) == bdelay_R;
// temp:=1.9-0.9*int(RapidStatus);
- if ((RM * RM > 0.001)) // jesli jest rapid
- if ((RM > 0)) // jesli dodatni (naddatek);
+ if (RM * RM > 0.001) // jesli jest rapid
+ if (RM > 0) // jesli dodatni (naddatek);
temp = 1 - RM * int(RapidStatus);
else
temp = 1 - RM * (1 - int(RapidStatus));
@@ -2712,15 +2712,15 @@ double TKE::GetPF(double const PP, double const dt, double const Vel)
// luzowanie CH
// temp:=std::max(BCP,LBP);
IMP = std::max(IMP / temp, std::max(LBP, ASBP * int((BrakeStatus & b_asb) == b_asb)));
- if ((ASBP < 0.1) && ((BrakeStatus & b_asb) == b_asb))
+ if (ASBP < 0.1 && (BrakeStatus & b_asb) == b_asb)
IMP = 0;
// luzowanie CH
- if ((BCP > IMP + 0.005) || (std::max(ImplsRes->P(), 8 * LBP) < 0.25))
+ if (BCP > IMP + 0.005 || std::max(ImplsRes->P(), 8 * LBP) < 0.25)
dv = PFVd(BCP, 0, 0.05, IMP) * dt;
else
dv = 0;
BrakeCyl->Flow(-dv);
- if ((BCP < IMP - 0.005) && (std::max(ImplsRes->P(), 8 * LBP) > 0.3))
+ if (BCP < IMP - 0.005 && std::max(ImplsRes->P(), 8 * LBP) > 0.3)
dv = PFVa(BVP, BCP, 0.05, IMP) * dt;
else
dv = 0;
@@ -2730,7 +2730,7 @@ double TKE::GetPF(double const PP, double const dt, double const Vel)
// przeplyw ZP <-> rozdzielacz
temp = BVs(IMP);
// if(BrakeStatus and b_hld)=b_off then
- if ((IMP < 0.25) || (VVP + 0.05 > BVP))
+ if (IMP < 0.25 || VVP + 0.05 > BVP)
dv = PF(BVP, VVP, 0.02 * SizeBR * temp / 1.87) * dt;
else
dv = 0;
@@ -2951,7 +2951,7 @@ double TFV4a::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
double LimPP = std::min(BPT[std::lround(i_bcp) + 2][1], HP);
double ActFlowSpeed = BPT[std::lround(i_bcp) + 2][0];
- if ((i_bcp == i_bcpno))
+ if (i_bcp == i_bcpno)
LimPP = 2.9;
CP = CP + 20 * std::min(std::abs(LimPP - CP), 0.05) * PR(CP, LimPP) * dt / 1;
@@ -2961,39 +2961,39 @@ double TFV4a::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
double dpPipe = std::min(HP, LimPP);
double dpMainValve = PF(dpPipe, PP, ActFlowSpeed / LBDelay) * dt;
- if ((CP > RP + 0.05))
+ if (CP > RP + 0.05)
dpMainValve = PF(std::min(CP + 0.1, HP), PP, 1.1 * ActFlowSpeed / LBDelay) * dt;
- if ((CP < RP - 0.05))
+ if (CP < RP - 0.05)
dpMainValve = PF(CP - 0.1, PP, 1.1 * ActFlowSpeed / LBDelay) * dt;
if (lround(i_bcp) == -1)
{
CP = CP + 5 * std::min(std::abs(LimPP - CP), 0.2) * PR(CP, LimPP) * dt / 2;
- if ((CP < RP + 0.03))
- if ((TP < 5))
+ if (CP < RP + 0.03)
+ if (TP < 5)
TP = TP + dt;
// if(cp+0.03<5.4)then
- if ((RP + 0.03 < 5.4) || (CP + 0.03 < 5.4)) // fala
+ if (RP + 0.03 < 5.4 || CP + 0.03 < 5.4) // fala
dpMainValve = PF(std::min(HP, 17.1), PP, ActFlowSpeed / LBDelay) * dt;
// dpMainValve:=20*std::min(abs(ep-7.1),0.05)*PF(HP,pp,ActFlowSpeed/LBDelay)*dt;
else
{
RP = 5.45;
- if ((CP < PP - 0.01)) //: /34*9
+ if (CP < PP - 0.01) //: /34*9
dpMainValve = PF(dpPipe, PP, ActFlowSpeed / 34 * 9 / LBDelay) * dt;
else
dpMainValve = PF(dpPipe, PP, ActFlowSpeed / LBDelay) * dt;
}
}
- if ((lround(i_bcp) == 0))
+ if (lround(i_bcp) == 0)
{
- if ((TP > 0.1))
+ if (TP > 0.1)
{
CP = 5 + (TP - 0.1) * 0.08;
TP = TP - dt / 12 / 2;
}
- if ((CP > RP + 0.1) && (CP <= 5))
+ if (CP > RP + 0.1 && CP <= 5)
dpMainValve = PF(std::min(CP + 0.25, HP), PP, 2 * ActFlowSpeed / LBDelay) * dt;
else if (CP > 5)
dpMainValve = PF(std::min(CP, HP), PP, 2 * ActFlowSpeed / LBDelay) * dt;
@@ -3001,7 +3001,7 @@ double TFV4a::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
dpMainValve = PF(dpPipe, PP, ActFlowSpeed / LBDelay) * dt;
}
- if ((lround(i_bcp) == i_bcpno))
+ if (lround(i_bcp) == i_bcpno)
{
dpMainValve = PF(0, PP, ActFlowSpeed / LBDelay) * dt;
}
@@ -3037,7 +3037,7 @@ double TFV4aM::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
int const LBDelay{100};
double const xpM{0.3}; // mnoznik membrany komory pod
- ep = (PP / 2.0) * 1.5 + (ep / 2.0) * 0.5; // SPKS!!
+ ep = PP / 2.0 * 1.5 + ep / 2.0 * 0.5; // SPKS!!
for (int idx = 0; idx < 5; ++idx)
{
@@ -3119,7 +3119,7 @@ double TFV4aM::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
double const ActFlowSpeed = BPT[std::lround(i_bcp) + 2][0];
- double dpMainValve = (dpPipe > PP ? -PFVa(HP, PP, ActFlowSpeed / LBDelay, dpPipe, 0.4) : PFVd(PP, 0, ActFlowSpeed / LBDelay, dpPipe, 0.4));
+ double dpMainValve = dpPipe > PP ? -PFVa(HP, PP, ActFlowSpeed / LBDelay, dpPipe, 0.4) : PFVd(PP, 0, ActFlowSpeed / LBDelay, dpPipe, 0.4);
if (EQ(i_bcp, -1))
{
@@ -3144,7 +3144,7 @@ double TFV4aM::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
}
ep = dpPipe;
- if ((EQ(i_bcp, 0) || (RP > ep)))
+ if (EQ(i_bcp, 0) || RP > ep)
{
// powolne wzrastanie, ale szybsze na jezdzie;
RP += PF(RP, ep, 0.0007) * dt;
@@ -3155,14 +3155,14 @@ double TFV4aM::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
RP += PF(RP, ep, 0.000093 / 2 * 2) * dt;
}
// jednak trzeba wydluzyc, bo obecnie zle dziala
- if ((RP < ep) && (RP < BPT[std::lround(i_bcpno) + 2][1]))
+ if (RP < ep && RP < BPT[std::lround(i_bcpno) + 2][1])
{
// jesli jestesmy ponizej cisnienia w sterujacym (2.9 bar)
// przypisz cisnienie w PG - wydluzanie napelniania o czas potrzebny do napelnienia PG
RP += PF(RP, CP, 0.005) * dt;
}
- if ((EQ(i_bcp, i_bcpno)) || (EQ(i_bcp, -2)))
+ if (EQ(i_bcp, i_bcpno) || EQ(i_bcp, -2))
{
DP = PF(0.0, PP, ActFlowSpeed / LBDelay);
@@ -3243,14 +3243,14 @@ double TFV4aM::LPP_RP(double pos) // cisnienie z zaokraglonej pozycji;
{
int const i_pos = 2 + std::floor(pos); // zaokraglone w dol
- return BPT[i_pos][1] + (BPT[i_pos + 1][1] - BPT[i_pos][1]) * ((pos + 2) - i_pos); // interpolacja liniowa
+ return BPT[i_pos][1] + (BPT[i_pos + 1][1] - BPT[i_pos][1]) * (pos + 2 - i_pos); // interpolacja liniowa
}
/// Returns true if pos is within ±0.5 of i_pos (detent test).
/// Continuous handle position.
/// Detent centre.
bool TFV4aM::EQ(double pos, double i_pos)
{
- return (pos <= i_pos + 0.5) && (pos > i_pos - 0.5);
+ return pos <= i_pos + 0.5 && pos > i_pos - 0.5;
}
//---MHZ_EN57--- manipulator hamulca zespolonego do EN57
@@ -3288,7 +3288,7 @@ double TMHZ_EN57::GetPF(double i_bcp, double PP, double HP, double dt, double ep
i_bcp = std::clamp(i_bcp, -0.999, 9.999); // na wszelki wypadek, zeby nie wyszlo poza zakres
- if ((TP > 0) && (CP > 4.9))
+ if (TP > 0 && CP > 4.9)
{
DP = OverloadPressureDecrease;
if (EQ(i_bcp, 0))
@@ -3304,16 +3304,16 @@ double TMHZ_EN57::GetPF(double i_bcp, double PP, double HP, double dt, double ep
ActFlowSpeed = 4;
double uop = UnbrakeOverPressure; // unbrake over pressure in actual state
- ManualOvrldActive = (UniversalFlag & TUniversalBrake::ub_HighPressure); // button is pressed
+ ManualOvrldActive = UniversalFlag & TUniversalBrake::ub_HighPressure; // button is pressed
if (ManualOvrld && !ManualOvrldActive) // no overpressure for not pressed button if it does not exists
uop = 0;
- if ((EQ(i_bcp, -1)) && (uop > 0))
+ if (EQ(i_bcp, -1) && uop > 0)
pom = std::min(HP, 5.4 + RedAdj + uop);
else
pom = std::min(CP, HP);
- if ((LimPP > CP)) // podwyzszanie szybkie
+ if (LimPP > CP) // podwyzszanie szybkie
CP = CP + 60 * std::min(abs(LimPP - CP), 0.05) * PR(CP, LimPP) * dt; // zbiornik sterujacy;
else
CP = CP + 13 * std::min(abs(LimPP - CP), 0.05) * PR(CP, LimPP) * dt; // zbiornik sterujacy
@@ -3329,15 +3329,15 @@ double TMHZ_EN57::GetPF(double i_bcp, double PP, double HP, double dt, double ep
else
dpMainValve = PFVd(PP, 0, ActFlowSpeed / LBDelay, dpPipe, 0.4);
- if ((EQ(i_bcp, -1) && (AutoOvrld)) || (i_bcp < 0.5 && (UniversalFlag & TUniversalBrake::ub_Overload)))
+ if ((EQ(i_bcp, -1) && AutoOvrld) || (i_bcp < 0.5 && UniversalFlag & TUniversalBrake::ub_Overload))
{
- if ((TP < 5))
+ if (TP < 5)
TP = TP + dt; // 5/10
- if ((TP < OverloadMaxPressure))
+ if (TP < OverloadMaxPressure)
TP = TP - 0.5 * dt; // 5/10
}
- if ((EQ(i_bcp, 10)) || (EQ(i_bcp, -2)))
+ if (EQ(i_bcp, 10) || EQ(i_bcp, -2))
{
DP = PF(0, PP, 2 * ActFlowSpeed / LBDelay);
dpMainValve = DP;
@@ -3354,7 +3354,7 @@ double TMHZ_EN57::GetPF(double i_bcp, double PP, double HP, double dt, double ep
Sounds[s_fv4a_u] = -dpMainValve;
}
- if ((i_bcp < 1.5))
+ if (i_bcp < 1.5)
RP = std::max(0., 0.125 * i_bcp);
else
RP = std::min(1., 0.125 * i_bcp - 0.125);
@@ -3450,7 +3450,7 @@ void TMHZ_EN57::SetParams(bool AO, bool MO, double OverP, double, double OMP, do
AutoOvrld = AO;
ManualOvrld = MO;
UnbrakeOverPressure = std::max(0.0, OverP);
- Fala = (OverP > 0.01);
+ Fala = OverP > 0.01;
OverloadMaxPressure = OMP;
OverloadPressureDecrease = OPD;
}
@@ -3458,7 +3458,7 @@ void TMHZ_EN57::SetParams(bool AO, bool MO, double OverP, double, double OMP, do
/// Returns true if pos is within ±0.5 of i_pos (detent test).
bool TMHZ_EN57::EQ(double pos, double i_pos)
{
- return (pos <= i_pos + 0.5) && (pos > i_pos - 0.5);
+ return pos <= i_pos + 0.5 && pos > i_pos - 0.5;
}
//---MHZ_K5P--- manipulator hamulca zespolonego Knorr 5-ciopozycyjny
@@ -3495,7 +3495,7 @@ double TMHZ_K5P::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
i_bcp = std::clamp(i_bcp, -0.999, 2.999); // na wszelki wypadek, zeby nie wyszlo poza zakres
- if ((TP > 0) && (CP > 4.9))
+ if (TP > 0 && CP > 4.9)
{
DP = OverloadPressureDecrease;
TP = TP - DP * dt;
@@ -3516,13 +3516,13 @@ 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
+ 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
double uop = UnbrakeOverPressure; // unbrake over pressure in actual state
- ManualOvrldActive = (UniversalFlag & TUniversalBrake::ub_HighPressure); // button is pressed
+ ManualOvrldActive = UniversalFlag & TUniversalBrake::ub_HighPressure; // button is pressed
if (ManualOvrld && !ManualOvrldActive) // no overpressure for not pressed button if it does not exists
uop = 0;
@@ -3546,9 +3546,9 @@ double TMHZ_K5P::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
else
dpMainValve = PFVd(PP, 0, ActFlowSpeed / LBDelay, dpPipe, 0.4);
- if ((EQ(i_bcp, -1) && (AutoOvrld)) || ((i_bcp < 0.5) && (UniversalFlag & TUniversalBrake::ub_Overload)))
+ if ((EQ(i_bcp, -1) && AutoOvrld) || (i_bcp < 0.5 && UniversalFlag & TUniversalBrake::ub_Overload))
{
- if ((TP < OverloadMaxPressure))
+ if (TP < OverloadMaxPressure)
TP = TP + 0.03 * dt;
}
@@ -3633,7 +3633,7 @@ void TMHZ_K5P::SetParams(bool AO, bool MO, double OverP, double FSF, double OMP,
AutoOvrld = AO;
ManualOvrld = MO;
UnbrakeOverPressure = std::max(0.0, OverP);
- Fala = (OverP > 0.01);
+ Fala = OverP > 0.01;
OverloadMaxPressure = OMP;
OverloadPressureDecrease = OPD;
FillingStrokeFactor = 1 + FSF;
@@ -3642,7 +3642,7 @@ void TMHZ_K5P::SetParams(bool AO, bool MO, double OverP, double FSF, double OMP,
/// Returns true if pos is within ±0.5 of i_pos (detent test).
bool TMHZ_K5P::EQ(double pos, double i_pos)
{
- return (pos <= i_pos + 0.5) && (pos > i_pos - 0.5);
+ return pos <= i_pos + 0.5 && pos > i_pos - 0.5;
}
//---MHZ_6P--- manipulator hamulca zespolonego 6-ciopozycyjny
@@ -3678,7 +3678,7 @@ double TMHZ_6P::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
i_bcp = std::clamp(i_bcp, -0.999, 3.999); // na wszelki wypadek, zeby nie wyszlo poza zakres
- if ((TP > 0) && (CP > 4.9))
+ if (TP > 0 && CP > 4.9)
{
DP = OverloadPressureDecrease;
TP = TP - DP * dt;
@@ -3699,7 +3699,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
+ 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
@@ -3707,7 +3707,7 @@ double TMHZ_6P::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
dpPipe = std::min(HP, CP + TP + RedAdj);
double uop = UnbrakeOverPressure; // unbrake over pressure in actual state
- ManualOvrldActive = (UniversalFlag & TUniversalBrake::ub_HighPressure); // button is pressed
+ ManualOvrldActive = UniversalFlag & TUniversalBrake::ub_HighPressure; // button is pressed
if (ManualOvrld && !ManualOvrldActive) // no overpressure for not pressed button if it does not exists
uop = 0;
@@ -3729,9 +3729,9 @@ double TMHZ_6P::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
else
dpMainValve = PFVd(PP, 0, ActFlowSpeed / LBDelay, dpPipe, 0.4);
- if ((EQ(i_bcp, -1) && (AutoOvrld)) || ((i_bcp < 0.5) && (UniversalFlag & TUniversalBrake::ub_Overload)))
+ if ((EQ(i_bcp, -1) && AutoOvrld) || (i_bcp < 0.5 && UniversalFlag & TUniversalBrake::ub_Overload))
{
- if ((TP < OverloadMaxPressure))
+ if (TP < OverloadMaxPressure)
TP = TP + 0.03 * dt;
}
@@ -3816,7 +3816,7 @@ void TMHZ_6P::SetParams(bool AO, bool MO, double OverP, double FSF, double OMP,
AutoOvrld = AO;
ManualOvrld = MO;
UnbrakeOverPressure = std::max(0.0, OverP);
- Fala = (OverP > 0.01);
+ Fala = OverP > 0.01;
OverloadMaxPressure = OMP;
OverloadPressureDecrease = OPD;
FillingStrokeFactor = 1 + FSF;
@@ -3825,7 +3825,7 @@ void TMHZ_6P::SetParams(bool AO, bool MO, double OverP, double FSF, double OMP,
/// Returns true if pos is within ±0.5 of i_pos (detent test).
bool TMHZ_6P::EQ(double pos, double i_pos)
{
- return (pos <= i_pos + 0.5) && (pos > i_pos - 0.5);
+ return pos <= i_pos + 0.5 && pos > i_pos - 0.5;
}
//---M394--- Matrosow
@@ -3858,11 +3858,11 @@ double TM394::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
LimPP = std::min(BPT_394[BCP + 1][1], HP);
ActFlowSpeed = BPT_394[BCP + 1][0];
- if ((BCP == 1) || (BCP == i_bcpno))
+ if (BCP == 1 || BCP == i_bcpno)
LimPP = PP;
- if ((BCP == 0))
+ if (BCP == 0)
LimPP = LimPP + RedAdj;
- if ((BCP != 2))
+ if (BCP != 2)
if (CP < LimPP)
CP = CP + 4 * std::min(abs(LimPP - CP), 0.05) * PR(CP, LimPP) * dt; // zbiornik sterujacy
// cp:=cp+6*(2+int(bcp<0))*std::min(abs(Limpp-cp),0.05)*PR(cp,Limpp)*dt //zbiornik
@@ -3972,9 +3972,9 @@ double TH14K1::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
if (BCP == -1)
dpMainValve = PF(HP, PP, ActFlowSpeed / LBDelay) * dt;
- if ((BCP == 0))
+ if (BCP == 0)
dpMainValve = -PFVa(HP, PP, ActFlowSpeed / LBDelay, NomPress + RedAdj) * dt;
- if ((BCP > 1) && (PP > CP))
+ if (BCP > 1 && PP > CP)
dpMainValve = PFVd(PP, 0, ActFlowSpeed / LBDelay, CP) * dt;
if (BCP == i_bcpno)
dpMainValve = PF(0, PP, ActFlowSpeed / LBDelay) * dt;
@@ -4066,9 +4066,9 @@ double TSt113::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
if (BCP == -1)
dpMainValve = PF(HP, PP, ActFlowSpeed / LBDelay) * dt;
- if ((BCP == 0))
+ if (BCP == 0)
dpMainValve = -PFVa(HP, PP, ActFlowSpeed / LBDelay, NomPress + RedAdj) * dt;
- if ((BCP > 1) && (PP > CP))
+ if (BCP > 1 && PP > CP)
dpMainValve = PFVd(PP, 0, ActFlowSpeed / LBDelay, CP) * dt;
if (BCP == i_bcpno)
dpMainValve = PF(0, PP, ActFlowSpeed / LBDelay) * dt;
@@ -4134,10 +4134,10 @@ double Ttest::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
LimPP = BPT[lround(i_bcp) + 2][1];
ActFlowSpeed = BPT[lround(i_bcp) + 2][0];
- if ((i_bcp == i_bcpno))
+ if (i_bcp == i_bcpno)
LimPP = 0.0;
- if ((i_bcp == -1))
+ if (i_bcp == -1)
LimPP = 7;
CP = CP + 20 * std::min(abs(LimPP - CP), 0.05) * PR(CP, LimPP) * dt / 1;
@@ -4147,7 +4147,7 @@ double Ttest::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
dpMainValve = PF(dpPipe, PP, ActFlowSpeed / LBDelay) * dt;
- if ((lround(i_bcp) == i_bcpno))
+ if (lround(i_bcp) == i_bcpno)
{
dpMainValve = PF(0, PP, ActFlowSpeed / LBDelay) * dt;
}
@@ -4286,11 +4286,11 @@ double TFVel6::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
CP = PP;
LimPP = std::min(5. * int(i_bcp < 3.5), HP);
- if ((i_bcp >= 3.5) && ((i_bcp < 4.3) || (i_bcp > 5.5)))
+ if (i_bcp >= 3.5 && (i_bcp < 4.3 || i_bcp > 5.5))
ActFlowSpeed = 0;
- else if ((i_bcp > 4.3) && (i_bcp < 4.8))
+ else if (i_bcp > 4.3 && i_bcp < 4.8)
ActFlowSpeed = 4 * (i_bcp - 4.3); // konsultacje wawa1 - bylo 8;
- else if ((i_bcp < 4))
+ else if (i_bcp < 4)
ActFlowSpeed = 2;
else
ActFlowSpeed = 4;
@@ -4299,16 +4299,16 @@ double TFVel6::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
Sounds[s_fv4a_e] = 0;
Sounds[s_fv4a_u] = 0;
Sounds[s_fv4a_b] = 0;
- if ((i_bcp < 3.5))
+ if (i_bcp < 3.5)
Sounds[s_fv4a_u] = -dpMainValve;
- else if ((i_bcp < 4.8))
+ else if (i_bcp < 4.8)
Sounds[s_fv4a_b] = dpMainValve;
- else if ((i_bcp < 5.5))
+ else if (i_bcp < 5.5)
Sounds[s_fv4a_e] = dpMainValve;
- if ((i_bcp < -0.5))
+ if (i_bcp < -0.5)
EPS = -1;
- else if ((i_bcp > 0.5) && (i_bcp < 4.7))
+ else if (i_bcp > 0.5 && i_bcp < 4.7)
EPS = 1;
else
EPS = 0;
@@ -4383,11 +4383,11 @@ double TFVE408::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
CP = PP;
LimPP = std::min(5. * int(i_bcp < 6.5), HP);
- if ((i_bcp >= 6.5) && ((i_bcp < 7.5) || (i_bcp > 9.5)))
+ if (i_bcp >= 6.5 && (i_bcp < 7.5 || i_bcp > 9.5))
ActFlowSpeed = 0;
- else if ((i_bcp > 7.5) && (i_bcp < 8.5))
+ else if (i_bcp > 7.5 && i_bcp < 8.5)
ActFlowSpeed = 2; // konsultacje wawa1 - bylo 8;
- else if ((i_bcp < 6.5))
+ else if (i_bcp < 6.5)
ActFlowSpeed = 2;
else
ActFlowSpeed = 4;
@@ -4396,11 +4396,11 @@ double TFVE408::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
Sounds[s_fv4a_e] = 0;
Sounds[s_fv4a_u] = 0;
Sounds[s_fv4a_b] = 0;
- if ((i_bcp < 6.5))
+ if (i_bcp < 6.5)
Sounds[s_fv4a_u] = -dpMainValve;
- else if ((i_bcp < 8.5))
+ else if (i_bcp < 8.5)
Sounds[s_fv4a_b] = dpMainValve;
- else if ((i_bcp < 9.5))
+ else if (i_bcp < 9.5)
Sounds[s_fv4a_e] = dpMainValve;
if (is_EQ(i_bcp, 1))
diff --git a/McZapkie/hamulce.h b/McZapkie/hamulce.h
index 4e3e888e..a05a3635 100644
--- a/McZapkie/hamulce.h
+++ b/McZapkie/hamulce.h
@@ -1399,7 +1399,7 @@ class TH14K1 : public TDriverHandle
private:
/// Position table for the H14K1 (range -1..4): {flow speed, target multiplier}.
- static double const BPT_K[/*?*/ /*-1..4*/ (4) - (-1) + 1][2];
+ static double const BPT_K[/*?*/ /*-1..4*/ 4 - -1 + 1][2];
/// Lookup of bh_* function codes to handle position values.
static double const pos_table[11]; // = {-1, 4, -1, 0, 1, 2, 3, 4, 0, 0, 0};
@@ -1440,9 +1440,9 @@ class TSt113 : public TH14K1
/// Current EP intensity reported by the handle.
double EPS = 0.0;
/// Position table (override of H14K1's, with adjusted parameters).
- static double const BPT_K[/*?*/ /*-1..4*/ (4) - (-1) + 1][2];
+ static double const BPT_K[/*?*/ /*-1..4*/ 4 - -1 + 1][2];
/// EP table — EP intensity per handle position (range -1..5).
- static double const BEP_K[/*?*/ /*-1..5*/ (5) - (-1) + 1];
+ static double const BEP_K[/*?*/ /*-1..5*/ 5 - -1 + 1];
/// Lookup of bh_* function codes to handle position values.
static double const pos_table[11]; // = {-1, 5, -1, 0, 2, 3, 4, 5, 0, 0, 1};
/// Local control pressure (mirrors PP).
diff --git a/application/application.cpp b/application/application.cpp
index 0d6d5041..7fd121d5 100644
--- a/application/application.cpp
+++ b/application/application.cpp
@@ -446,13 +446,13 @@ void eu07_application::queue_quit(bool direct)
bool eu07_application::is_server() const
{
- return (m_network && m_network->servers);
+ return m_network && m_network->servers;
}
bool eu07_application::is_client() const
{
- return (m_network && m_network->client);
+ return m_network && m_network->client;
}
int eu07_application::run()
@@ -649,7 +649,7 @@ bool eu07_application::request(python_taskqueue::task_request const &Task)
{
auto const result{m_taskqueue.insert(Task)};
- if ((false == result) && (Task.input != nullptr))
+ if (false == result && Task.input != nullptr)
{
// clean up allocated resources since the worker won't
}
@@ -913,7 +913,7 @@ GLFWwindow *eu07_application::window(int const Windowindex, bool visible, int wi
if (Windowindex >= 0)
{
- return (Windowindex < m_windows.size() ? m_windows[Windowindex] : nullptr);
+ return Windowindex < m_windows.size() ? m_windows[Windowindex] : nullptr;
}
// for index -1 create a new child window
@@ -1005,7 +1005,7 @@ void eu07_application::init_console()
{
#ifdef _WIN32
HWND consoleWnd = ::GetConsoleWindow();
- const bool hadConsole = (consoleWnd != nullptr);
+ const bool hadConsole = consoleWnd != nullptr;
if (Global.ShowSystemConsole)
{
@@ -1279,7 +1279,7 @@ int eu07_application::init_glfw()
Global.bFullScreen = true;
}
- auto *mainwindow = window(-1, true, Global.window_size.x, Global.window_size.y, (Global.bFullScreen ? monitor : nullptr), true, false);
+ auto *mainwindow = window(-1, true, Global.window_size.x, Global.window_size.y, Global.bFullScreen ? monitor : nullptr, true, false);
if (mainwindow == nullptr)
{
@@ -1480,7 +1480,7 @@ bool eu07_application::init_network()
tmp = std::gmtime(&utc_now);
memcpy(&tm_utc, tmp, sizeof(tm));
- int64_t offset = (tm_local.tm_hour * 3600 + tm_local.tm_min * 60 + tm_local.tm_sec) - (tm_utc.tm_hour * 3600 + tm_utc.tm_min * 60 + tm_utc.tm_sec);
+ int64_t offset = tm_local.tm_hour * 3600 + tm_local.tm_min * 60 + tm_local.tm_sec - (tm_utc.tm_hour * 3600 + tm_utc.tm_min * 60 + tm_utc.tm_sec);
Global.starting_timestamp = utc_now + offset;
Global.ready_to_load = true;
diff --git a/application/driverhints.cpp b/application/driverhints.cpp
index fd1e6e05..afa654cf 100644
--- a/application/driverhints.cpp
+++ b/application/driverhints.cpp
@@ -31,7 +31,7 @@ TController::update_hints() {
m_hints.remove_if(
[]( auto const &Hint ) {
- return ( std::get( Hint )( std::get( Hint ) ) ); } );
+ return std::get(Hint)(std::get(Hint)); } );
}
void
@@ -39,7 +39,7 @@ TController::remove_hint( driver_hint const Value ) {
m_hints.remove_if(
[=]( auto const &Hint ) {
- return ( std::get( Hint ) == Value ); } );
+ return std::get(Hint) == Value; } );
}
void
@@ -88,7 +88,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( ( mvOccupied->BatteryStart != start_t::manual ) || ( mvOccupied->Power24vIsAvailable == true ) ); } );
+ return mvOccupied->BatteryStart != start_t::manual || mvOccupied->Power24vIsAvailable == true; } );
break;
}
case driver_hint::batteryoff: {
@@ -99,7 +99,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( ( mvOccupied->BatteryStart != start_t::manual ) || ( mvOccupied->Power24vIsAvailable == false ) ); } );
+ return mvOccupied->BatteryStart != start_t::manual || mvOccupied->Power24vIsAvailable == false; } );
break;
}
// battery
@@ -112,7 +112,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( ( mvOccupied->AutomaticCabActivation ) || ( mvOccupied->IsCabMaster() ) ); } );
+ return mvOccupied->AutomaticCabActivation || mvOccupied->IsCabMaster(); } );
break;
}
case driver_hint::cabdeactivation: {
@@ -123,7 +123,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( ( mvOccupied->AutomaticCabActivation ) || ( ( mvOccupied->CabMaster == false ) && ( mvOccupied->CabActive == 0 ) ) ); } );
+ return mvOccupied->AutomaticCabActivation || (mvOccupied->CabMaster == false && mvOccupied->CabActive == 0); } );
break;
}
// radio
@@ -135,7 +135,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( mvOccupied->Radio == true ); } );
+ return mvOccupied->Radio == true; } );
break;
}
case driver_hint::radiochannel: {
@@ -145,7 +145,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( iRadioChannel == static_cast( Parameter ) ); },
+ return iRadioChannel == static_cast(Parameter); },
Actionparameter );
break;
}
@@ -157,7 +157,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( mvOccupied->Radio == false ); } );
+ return mvOccupied->Radio == false; } );
break;
}
// oil pump
@@ -170,7 +170,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
Action,
[this](float const Parameter) -> bool {
auto const &device { mvOccupied->OilPump };
- return ( ( device.start_type != start_t::manual ) || ( device.is_enabled == true ) || ( device.is_active == true ) || ( mvOccupied->Mains ) ); } );
+ return device.start_type != start_t::manual || device.is_enabled == true || device.is_active == true || mvOccupied->Mains; } );
break;
}
case driver_hint::oilpumpoff: {
@@ -182,7 +182,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
Action,
[this](float const Parameter) -> bool {
auto const &device { mvOccupied->OilPump };
- return ( ( device.start_type != start_t::manual ) || ( ( device.is_enabled == false ) && ( device.is_active == false ) ) ); } );
+ return device.start_type != start_t::manual || (device.is_enabled == false && device.is_active == false); } );
break;
}
// fuel pump
@@ -195,7 +195,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
Action,
[this](float const Parameter) -> bool {
auto const &device { mvOccupied->FuelPump };
- return ( ( device.start_type != start_t::manual ) || ( device.is_enabled == true ) || ( device.is_active == true ) ); } );
+ return device.start_type != start_t::manual || device.is_enabled == true || device.is_active == true; } );
break;
}
case driver_hint::fuelpumpoff: {
@@ -207,7 +207,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
Action,
[this](float const Parameter) -> bool {
auto const &device { mvOccupied->FuelPump };
- return ( ( device.start_type != start_t::manual ) || ( ( device.is_enabled == false ) && ( device.is_active == false ) ) ); } );
+ return device.start_type != start_t::manual || (device.is_enabled == false && device.is_active == false); } );
break;
}
// pantographs
@@ -219,7 +219,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( mvPantographUnit->bPantKurek3 == true ); } );
+ return mvPantographUnit->bPantKurek3 == true; } );
break;
}
case driver_hint::pantographairsourcesetauxiliary: {
@@ -230,7 +230,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( mvPantographUnit->bPantKurek3 == false ); } );
+ return mvPantographUnit->bPantKurek3 == false; } );
break;
}
case driver_hint::pantographcompressoron: {
@@ -241,7 +241,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( mvPantographUnit->PantCompFlag == true ); } );
+ return mvPantographUnit->PantCompFlag == true; } );
break;
}
case driver_hint::pantographcompressoroff: {
@@ -252,7 +252,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( mvPantographUnit->PantCompFlag == false ); } );
+ return mvPantographUnit->PantCompFlag == false; } );
break;
}
case driver_hint::pantographsvalveon: {
@@ -263,7 +263,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( mvPantographUnit->PantsValve.is_active == true ); } );
+ return mvPantographUnit->PantsValve.is_active == true; } );
break;
}
case driver_hint::frontpantographvalveon: {
@@ -274,7 +274,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[ this ]( float const Parameter ) -> bool {
- return ( ( mvPantographUnit->Pantographs[ end::front ].valve.is_active == true ) || ( ( Parameter > 0 ) && ( mvOccupied->Vel > Parameter ) ) ); },
+ return mvPantographUnit->Pantographs[end::front].valve.is_active == true || (Parameter > 0 && mvOccupied->Vel > Parameter); },
Actionparameter );
break;
}
@@ -286,7 +286,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( mvPantographUnit->Pantographs[ end::front ].valve.is_active == false ); } );
+ return mvPantographUnit->Pantographs[end::front].valve.is_active == false; } );
break;
}
case driver_hint::rearpantographvalveon: {
@@ -297,7 +297,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[ this ]( float const Parameter ) -> bool {
- return ( ( mvPantographUnit->Pantographs[ end::rear ].valve.is_active == true ) || ( ( Parameter > 0 ) && ( mvOccupied->Vel > Parameter ) ) ); },
+ return mvPantographUnit->Pantographs[end::rear].valve.is_active == true || (Parameter > 0 && mvOccupied->Vel > Parameter); },
Actionparameter );
break;
}
@@ -309,7 +309,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( mvPantographUnit->Pantographs[ end::rear ].valve.is_active == false ); } );
+ return mvPantographUnit->Pantographs[end::rear].valve.is_active == false; } );
break;
}
// converter
@@ -321,7 +321,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( IsAnyConverterEnabled == true ); } );
+ return IsAnyConverterEnabled == true; } );
break;
}
case driver_hint::converteroff: {
@@ -332,7 +332,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( IsAnyConverterExplicitlyEnabled == false ); } );
+ return IsAnyConverterExplicitlyEnabled == false; } );
break;
}
// relays
@@ -343,7 +343,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( ( mvOccupied->ConverterOverloadRelayStart != start_t::manual ) || ( mvOccupied->ConvOvldFlag == false ) ); } );
+ return mvOccupied->ConverterOverloadRelayStart != start_t::manual || mvOccupied->ConvOvldFlag == false; } );
break;
}
case driver_hint::maincircuitgroundreset: {
@@ -353,7 +353,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( ( mvOccupied->GroundRelayStart != start_t::manual ) || ( mvOccupied->GroundRelay == true ) ); } );
+ return mvOccupied->GroundRelayStart != start_t::manual || mvOccupied->GroundRelay == true; } );
break;
}
case driver_hint::tractionnmotoroverloadreset: {
@@ -363,7 +363,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( mvOccupied->FuseFlag == false ); } );
+ return mvOccupied->FuseFlag == false; } );
break;
}
// line breaker
@@ -375,7 +375,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( IsAnyLineBreakerOpen == false ); } );
+ return IsAnyLineBreakerOpen == false; } );
break;
}
case driver_hint::linebreakeropen: {
@@ -387,7 +387,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
Action,
[this](float const Parameter) -> bool {
// TBD, TODO: replace with consist-wide flag set true if any line breaker is closed?
- return ( mvControlling->Mains == false ); } );
+ return mvControlling->Mains == false; } );
break;
}
// compressor
@@ -399,7 +399,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( IsAnyCompressorEnabled == true ); } );
+ return IsAnyCompressorEnabled == true; } );
break;
}
case driver_hint::compressoroff: {
@@ -410,7 +410,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( IsAnyCompressorExplicitlyEnabled == false ); } );
+ return IsAnyCompressorExplicitlyEnabled == false; } );
break;
}
case driver_hint::frontmotorblowerson: {
@@ -423,7 +423,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
Action,
[this]( float const Parameter ) -> bool {
auto const &device { mvOccupied->MotorBlowers[ end::front ] };
- return ( ( device.start_type != start_t::manual ) || ( ( device.is_enabled == true ) && ( device.is_disabled == false ) ) ); } );
+ return device.start_type != start_t::manual || (device.is_enabled == true && device.is_disabled == false); } );
break;
}
case driver_hint::rearmotorblowerson: {
@@ -436,7 +436,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
Action,
[this]( float const Parameter ) -> bool {
auto const &device { mvOccupied->MotorBlowers[ end::rear ] };
- return ( ( device.start_type != start_t::manual ) || ( ( device.is_enabled == true ) && ( device.is_disabled == false ) ) ); } );
+ return device.start_type != start_t::manual || (device.is_enabled == true && device.is_disabled == false); } );
break;
}
// spring brake
@@ -448,7 +448,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this]( float const Parameter ) -> bool {
- return ( mvOccupied->SpringBrake.Activate == true ); } );
+ return mvOccupied->SpringBrake.Activate == true; } );
break;
}
case driver_hint::springbrakeoff: {
@@ -459,7 +459,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this]( float const Parameter ) -> bool {
- return ( mvOccupied->SpringBrake.Activate == false ); } );
+ return mvOccupied->SpringBrake.Activate == false; } );
break;
}
// manual brake
@@ -471,7 +471,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this]( float const Parameter ) -> bool {
- return ( ( mvOccupied->LocalBrake != TLocalBrake::ManualBrake ) || ( mvOccupied->MBrake == false ) || ( mvOccupied->ManualBrakePos == ManualBrakePosNo ) ); } );
+ return mvOccupied->LocalBrake != TLocalBrake::ManualBrake || mvOccupied->MBrake == false || mvOccupied->ManualBrakePos == ManualBrakePosNo; } );
break;
}
case driver_hint::manualbrakoff: {
@@ -482,14 +482,14 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this]( float const Parameter ) -> bool {
- return ( ( mvOccupied->LocalBrake != TLocalBrake::ManualBrake ) || ( mvOccupied->MBrake == false ) || ( mvOccupied->ManualBrakePos == 0 ) ); } );
+ return mvOccupied->LocalBrake != TLocalBrake::ManualBrake || mvOccupied->MBrake == false || mvOccupied->ManualBrakePos == 0; } );
break;
}
// master controller
case driver_hint::mastercontrollersetidle: {
if( AIControllFlag ) {
- while( ( mvControlling->RList[ mvControlling->MainCtrlPos ].Mn == 0 )
- && ( mvControlling->IncMainCtrl( 1 ) ) ) {
+ while( mvControlling->RList[mvControlling->MainCtrlPos].Mn == 0
+ && mvControlling->IncMainCtrl(1) ) {
;
}
}
@@ -497,7 +497,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this]( float const Parameter ) -> bool {
- return ( mvControlling->RList[ mvControlling->MainCtrlPos ].Mn > 0 ); } );
+ return mvControlling->RList[mvControlling->MainCtrlPos].Mn > 0; } );
break;
}
case driver_hint::mastercontrollersetseriesmode: {
@@ -507,8 +507,8 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
if( mvControlling->ScndCtrlPos ) {
mvControlling->DecScndCtrl( 2 );
}
- while( ( mvControlling->RList[ mvControlling->MainCtrlPos ].Bn > 1 )
- && ( mvControlling->DecMainCtrl( 1 ) ) ) {
+ while( mvControlling->RList[mvControlling->MainCtrlPos].Bn > 1
+ && mvControlling->DecMainCtrl(1) ) {
; // all work is performed in the header
}
}
@@ -517,7 +517,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this]( float const Parameter ) -> bool {
- return ( mvControlling->RList[ mvControlling->MainCtrlPos ].Bn < 2 ); } );
+ return mvControlling->RList[mvControlling->MainCtrlPos].Bn < 2; } );
break;
}
case driver_hint::mastercontrollersetzerospeed: {
@@ -528,13 +528,13 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( ( mvControlling->IsMainCtrlNoPowerPos() ) && ( mvControlling->IsScndCtrlNoPowerPos() ) ); } );
+ return mvControlling->IsMainCtrlNoPowerPos() && mvControlling->IsScndCtrlNoPowerPos(); } );
break;
}
case driver_hint::mastercontrollersetreverserunlock: {
if( AIControllFlag ) {
- while( ( false == mvControlling->EIMDirectionChangeAllow() )
- && ( mvControlling->DecMainCtrl( 1 ) ) ) {
+ while( false == mvControlling->EIMDirectionChangeAllow()
+ && mvControlling->DecMainCtrl(1) ) {
;
}
}
@@ -542,7 +542,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( mvControlling->EIMDirectionChangeAllow() ); },
+ return mvControlling->EIMDirectionChangeAllow(); },
mvControlling->MainCtrlMaxDirChangePos );
break;
}
@@ -554,7 +554,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( std::abs( mvControlling->Ft ) <= Parameter ); },
+ return std::abs(mvControlling->Ft) <= Parameter; },
std::min(
0.0,
std::max(
@@ -576,12 +576,8 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( ( AccDesired <= EU07_AI_NOACCELERATION )
- || ( ( false == Ready ) && ( false == mvOccupied->ShuntMode ) )
- || ( AccDesired - AbsAccS <= 0.05 )
- || ( mvOccupied->EIMCtrlType > 0 ?
- ( mvControlling->eimic_real >= 1.0 ) :
- ( ( mvControlling->IsScndCtrlMaxPowerPos() ) && ( mvControlling->IsMainCtrlMaxPowerPos() ) ) ) ); } );
+ return AccDesired <= EU07_AI_NOACCELERATION || (false == Ready && false == mvOccupied->ShuntMode) || AccDesired - AbsAccS <= 0.05 ||
+ (mvOccupied->EIMCtrlType > 0 ? mvControlling->eimic_real >= 1.0 : mvControlling->IsScndCtrlMaxPowerPos() && mvControlling->IsMainCtrlMaxPowerPos()); } );
break;
}
case driver_hint::bufferscompress: {
@@ -594,7 +590,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( ( std::abs( mvControlling->Ft ) > 30.0 ) || ( ( OrderCurrentGet() & Disconnect ) == 0 ) ); } );
+ return std::abs(mvControlling->Ft) > 30.0 || (OrderCurrentGet() & Disconnect) == 0; } );
break;
}
@@ -606,7 +602,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( mvControlling->IsScndCtrlNoPowerPos() ); } );
+ return mvControlling->IsScndCtrlNoPowerPos(); } );
break;
}
@@ -619,7 +615,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
Action,
[this](float const Parameter) -> bool {
auto const &device { mvControlling->WaterPump };
- return ( ( device.start_type != start_t::manual ) || ( ( device.is_enabled == true ) && ( device.is_disabled == false ) ) || ( device.is_active == true ) ); } );
+ return device.start_type != start_t::manual || (device.is_enabled == true && device.is_disabled == false) || device.is_active == true; } );
break;
}
case driver_hint::waterpumpoff: {
@@ -631,7 +627,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
Action,
[this](float const Parameter) -> bool {
auto const &device { mvControlling->WaterPump };
- return ( ( device.start_type != start_t::manual ) || ( ( device.is_enabled == false ) && ( device.is_active == false ) ) ); } );
+ return device.start_type != start_t::manual || (device.is_enabled == false && device.is_active == false); } );
break;
}
case driver_hint::waterpumpbreakeron: {
@@ -643,7 +639,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
Action,
[this](float const Parameter) -> bool {
auto const &device { mvControlling->WaterPump };
- return ( device.breaker == true ); } );
+ return device.breaker == true; } );
break;
}
case driver_hint::waterpumpbreakeroff: {
@@ -655,7 +651,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
Action,
[this](float const Parameter) -> bool {
auto const &device { mvControlling->WaterPump };
- return ( device.breaker == false ); } );
+ return device.breaker == false; } );
break;
}
case driver_hint::waterheateron: {
@@ -667,7 +663,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
Action,
[this](float const Parameter) -> bool {
auto const &device { mvControlling->WaterHeater };
- return ( device.is_enabled == true ); } );
+ return device.is_enabled == true; } );
break;
}
case driver_hint::waterheateroff: {
@@ -679,7 +675,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
Action,
[this](float const Parameter) -> bool {
auto const &device { mvControlling->WaterHeater };
- return ( device.is_enabled == false ); } );
+ return device.is_enabled == false; } );
break;
}
case driver_hint::waterheaterbreakeron: {
@@ -691,7 +687,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
Action,
[this](float const Parameter) -> bool {
auto const &device { mvControlling->WaterHeater };
- return ( device.breaker == true ); } );
+ return device.breaker == true; } );
break;
}
case driver_hint::waterheaterbreakeroff: {
@@ -703,7 +699,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
Action,
[this](float const Parameter) -> bool {
auto const &device { mvControlling->WaterHeater };
- return ( device.breaker == false ); } );
+ return device.breaker == false; } );
break;
}
case driver_hint::watercircuitslinkon: {
@@ -714,7 +710,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( ( mvControlling->dizel_heat.auxiliary_water_circuit == false ) || ( mvControlling->WaterCircuitsLink == true ) ); } );
+ return mvControlling->dizel_heat.auxiliary_water_circuit == false || mvControlling->WaterCircuitsLink == true; } );
break;
}
case driver_hint::watercircuitslinkoff: {
@@ -725,7 +721,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( ( mvControlling->dizel_heat.auxiliary_water_circuit == false ) || ( mvControlling->WaterCircuitsLink == false ) ); } );
+ return mvControlling->dizel_heat.auxiliary_water_circuit == false || mvControlling->WaterCircuitsLink == false; } );
break;
}
case driver_hint::waittemperaturetoolow: {
@@ -733,7 +729,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( false == IsHeatingTemperatureTooLow ); } );
+ return false == IsHeatingTemperatureTooLow; } );
break;
}
case driver_hint::waitpressuretoolow: {
@@ -741,7 +737,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( ( mvControlling->ScndPipePress > 4.5 ) || ( mvControlling->VeselVolume == 0.0 ) ); } );
+ return mvControlling->ScndPipePress > 4.5 || mvControlling->VeselVolume == 0.0; } );
break;
}
case driver_hint::waitpantographpressuretoolow: {
@@ -749,7 +745,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( mvPantographUnit->PantPress >= ( is_emu() ? ( mvPantographUnit->PantPressLockActive ? 4.6 : 2.6 ) : 4.2 ) ); } );
+ return mvPantographUnit->PantPress >= (is_emu() ? (mvPantographUnit->PantPressLockActive ? 4.6 : 2.6) : 4.2); } );
break;
}
case driver_hint::waitloadexchange: {
@@ -757,7 +753,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( ExchangeTime <= 0 ); } );
+ return ExchangeTime <= 0; } );
break;
}
case driver_hint::waitdeparturetime: {
@@ -765,7 +761,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( IsAtPassengerStop == false ); } );
+ return IsAtPassengerStop == false; } );
break;
}
@@ -779,8 +775,8 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
case driver_hint::trainbrakesetpipeunlock: {
if( AIControllFlag ) {
if( mvOccupied->HandleUnlock != -3 ) {
- while( ( BrakeCtrlPosition >= mvOccupied->HandleUnlock )
- && ( BrakeLevelAdd( -1 ) ) ) {
+ while( BrakeCtrlPosition >= mvOccupied->HandleUnlock
+ && BrakeLevelAdd(-1) ) {
// all work is done in the header
;
}
@@ -790,7 +786,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( ( mvOccupied->HandleUnlock == -3 ) || ( BrakeCtrlPosition == mvOccupied->HandleUnlock ) ); } );
+ return mvOccupied->HandleUnlock == -3 || BrakeCtrlPosition == mvOccupied->HandleUnlock; } );
break;
}
case driver_hint::trainbrakerelease: {
@@ -802,15 +798,14 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( is_equal( mvOccupied->fBrakeCtrlPos, mvOccupied->Handle->GetPos( bh_RP ), 0.2 )
- || ( mvOccupied->Handle->Time && ( mvOccupied->Handle->GetCP() > mvOccupied->HighPipePress - 0.05) ) ); } );
+ return is_equal(mvOccupied->fBrakeCtrlPos, mvOccupied->Handle->GetPos(bh_RP), 0.2) || (mvOccupied->Handle->Time && mvOccupied->Handle->GetCP() > mvOccupied->HighPipePress - 0.05); } );
// return ( BrakeCtrlPosition == gbh_RP ); } );
break;
}
case driver_hint::trainbrakeapply: {
if( AIControllFlag ) {
// za radą yB ustawiamy pozycję 3 kranu (ruszanie kranem w innych miejscach powino zostać wyłączone)
- if( ( BrakeSystem == TBrakeSystem::ElectroPneumatic ) && ( false == ForcePNBrake ) ) {
+ if( BrakeSystem == TBrakeSystem::ElectroPneumatic && false == ForcePNBrake ) {
mvOccupied->BrakeLevelSet( mvOccupied->Handle->GetPos( bh_EPB ) );
}
else {
@@ -821,14 +816,14 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( IsConsistBraked /*|| ( ( OrderCurrentGet() & Disconnect ) == 0 ) */ ); } );
+ return IsConsistBraked /*|| ( ( OrderCurrentGet() & Disconnect ) == 0 ) */; } );
break;
}
case driver_hint::brakingforcedecrease: {
if( AIControllFlag ) {
auto const brakingcontrolschange { DecBrake() };
// set optional delay between brake adjustments
- if( ( brakingcontrolschange ) && ( Actionparameter > 0 ) ) {
+ if( brakingcontrolschange && Actionparameter > 0 ) {
fBrakeTime = Actionparameter;
}
}
@@ -836,7 +831,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( std::abs( mvControlling->Fb ) <= Parameter ); },
+ return std::abs(mvControlling->Fb) <= Parameter; },
std::min( 0.0, 0.95 * std::abs( mvControlling->Fb ) ) ); // keep hint until 5% decrease
break;
}
@@ -844,7 +839,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
if( AIControllFlag ) {
auto const brakingcontrolschange { IncBrake() };
// set optional delay between brake adjustments
- if( ( brakingcontrolschange ) && ( Actionparameter > 0 ) ) {
+ if( brakingcontrolschange && Actionparameter > 0 ) {
fBrakeTime = Actionparameter;
}
}
@@ -852,7 +847,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( ( std::abs( mvControlling->Fb ) > Parameter ) || ( is_equal( mvOccupied->fBrakeCtrlPos, mvOccupied->Handle->GetPos( bh_EB ), 0.2 ) ) ); },
+ return std::abs(mvControlling->Fb) > Parameter || is_equal(mvOccupied->fBrakeCtrlPos, mvOccupied->Handle->GetPos(bh_EB), 0.2); },
std::max(
0.0,
std::max(
@@ -868,7 +863,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( ( Ready ) && ( fReady < 0.4 ) && ( is_equal( mvOccupied->fBrakeCtrlPos, mvOccupied->Handle->GetPos( bh_RP ), 0.2 ) ) ); } );
+ return Ready && fReady < 0.4 && is_equal(mvOccupied->fBrakeCtrlPos, mvOccupied->Handle->GetPos(bh_RP), 0.2); } );
break;
}
case driver_hint::brakingforcelap: {
@@ -894,7 +889,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( mvOccupied->LocalBrakePosA >= Parameter ); },
+ return mvOccupied->LocalBrakePosA >= Parameter; },
( LocalBrakePosNo - ( mvOccupied->EIMCtrlEmergency ? 1 : 0 ) ) / LocalBrakePosNo );
break;
}
@@ -906,7 +901,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( mvOccupied->LocalBrakePosA < 0.05 ); } );
+ return mvOccupied->LocalBrakePosA < 0.05; } );
break;
}
// reverser
@@ -918,7 +913,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( mvOccupied->DirActive * mvOccupied->CabActive > 0 ); } );
+ return mvOccupied->DirActive * mvOccupied->CabActive > 0; } );
break;
}
case driver_hint::directionbackward: {
@@ -929,7 +924,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( mvOccupied->DirActive * mvOccupied->CabActive < 0 ); } );
+ return mvOccupied->DirActive * mvOccupied->CabActive < 0; } );
break;
}
case driver_hint::directionother: {
@@ -942,7 +937,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( iDirection == iDirectionOrder ); } );
+ return iDirection == iDirectionOrder; } );
break;
}
case driver_hint::directionnone: {
@@ -953,7 +948,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( mvOccupied->DirActive == 0 ); } );
+ return mvOccupied->DirActive == 0; } );
break;
}
// anti-slip systems
@@ -965,7 +960,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( ( mvControlling->Sand == 0 ) || ( mvControlling->SandDose == true ) || ( mvControlling->SlippingWheels == false ) ); } );
+ return mvControlling->Sand == 0 || mvControlling->SandDose == true || mvControlling->SlippingWheels == false; } );
break;
}
case driver_hint::sandingoff: {
@@ -976,7 +971,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( ( mvControlling->Sand == 0 ) || ( mvControlling->SandDose == false ) ); } );
+ return mvControlling->Sand == 0 || mvControlling->SandDose == false; } );
break;
}
case driver_hint::antislip: {
@@ -986,7 +981,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( ( mvControlling->ASBType != 1 ) || ( ( mvControlling->Hamulec->GetBrakeStatus() & b_asb ) != 0 ) || ( mvControlling->SlippingWheels == false ) ); } );
+ return mvControlling->ASBType != 1 || (mvControlling->Hamulec->GetBrakeStatus() & b_asb) != 0 || mvControlling->SlippingWheels == false; } );
break;
}
// horns
@@ -999,7 +994,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
Action,
[this](float const Parameter) -> bool {
// NOTE: we provide slightly larger horn activation window for human driver
- return ( ( fWarningDuration + 5.0 < 0.05 ) || ( mvOccupied->WarningSignal != 0 ) ); } );
+ return fWarningDuration + 5.0 < 0.05 || mvOccupied->WarningSignal != 0; } );
break;
}
case driver_hint::hornoff: {
@@ -1025,7 +1020,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( ( mvOccupied->Doors.has_lock == false ) || ( mvOccupied->Doors.lock_enabled == true ) ); } );
+ return mvOccupied->Doors.has_lock == false || mvOccupied->Doors.lock_enabled == true; } );
break;
}
// departure signal
@@ -1037,7 +1032,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( ( mvOccupied->Doors.has_warning == false ) || ( mvOccupied->Doors.has_autowarning == true ) || ( mvOccupied->DepartureSignal == true ) || mvOccupied->Vel > 5.0 ); } );
+ return mvOccupied->Doors.has_warning == false || mvOccupied->Doors.has_autowarning == true || mvOccupied->DepartureSignal == true || mvOccupied->Vel > 5.0; } );
break;
}
case driver_hint::departuresignaloff: {
@@ -1048,56 +1043,56 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( ( mvOccupied->Doors.has_warning == false ) || ( mvOccupied->Doors.has_autowarning == true ) || ( mvOccupied->DepartureSignal == false ) ); } );
+ return mvOccupied->Doors.has_warning == false || mvOccupied->Doors.has_autowarning == true || mvOccupied->DepartureSignal == false; } );
break;
}
// consist doors
case driver_hint::doorrightopen: {
- if( ( AIControllFlag )
- || ( pVehicle->MoverParameters->Doors.open_control == control_t::conductor ) ) {
+ if( AIControllFlag
+ || pVehicle->MoverParameters->Doors.open_control == control_t::conductor ) {
pVehicle->MoverParameters->OperateDoors( side::right, true );
}
remove_hint( driver_hint::doorrightclose );
hint(
Action,
[this](float const Parameter) -> bool {
- return ( IsAnyDoorOpen[ side::right ] == true ); } );
+ return IsAnyDoorOpen[side::right] == true; } );
break;
}
case driver_hint::doorrightclose: {
- if( ( AIControllFlag )
- || ( pVehicle->MoverParameters->Doors.open_control == control_t::conductor ) ) {
+ if( AIControllFlag
+ || pVehicle->MoverParameters->Doors.open_control == control_t::conductor ) {
pVehicle->MoverParameters->OperateDoors( side::right, false );
}
remove_hint( driver_hint::doorrightopen );
hint(
Action,
[this](float const Parameter) -> bool {
- return ( IsAnyDoorOpen[ side::right ] == false ); } );
+ return IsAnyDoorOpen[side::right] == false; } );
break;
}
case driver_hint::doorleftopen: {
- if( ( AIControllFlag )
- || ( pVehicle->MoverParameters->Doors.open_control == control_t::conductor ) ) {
+ if( AIControllFlag
+ || pVehicle->MoverParameters->Doors.open_control == control_t::conductor ) {
pVehicle->MoverParameters->OperateDoors( side::left, true );
}
remove_hint( driver_hint::doorleftclose );
hint(
Action,
[this](float const Parameter) -> bool {
- return ( IsAnyDoorOpen[ side::left ] == true ); } );
+ return IsAnyDoorOpen[side::left] == true; } );
break;
}
case driver_hint::doorleftclose: {
- if( ( AIControllFlag )
- || ( pVehicle->MoverParameters->Doors.open_control == control_t::conductor ) ) {
+ if( AIControllFlag
+ || pVehicle->MoverParameters->Doors.open_control == control_t::conductor ) {
pVehicle->MoverParameters->OperateDoors( side::left, false );
}
remove_hint( driver_hint::doorleftopen );
hint(
Action,
[this](float const Parameter) -> bool {
- return ( IsAnyDoorOpen[ side::left ] == false ); } );
+ return IsAnyDoorOpen[side::left] == false; } );
break;
}
case driver_hint::doorrightpermiton: {
@@ -1108,7 +1103,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( IsAnyDoorPermitActive[ side::right ] == true ); } );
+ return IsAnyDoorPermitActive[side::right] == true; } );
break;
}
case driver_hint::doorrightpermitoff: {
@@ -1119,7 +1114,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( IsAnyDoorPermitActive[ side::right ] == false ); } );
+ return IsAnyDoorPermitActive[side::right] == false; } );
break;
}
case driver_hint::doorleftpermiton: {
@@ -1130,7 +1125,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( IsAnyDoorPermitActive[ side::left ] == true ); } );
+ return IsAnyDoorPermitActive[side::left] == true; } );
break;
}
case driver_hint::doorleftpermitoff: {
@@ -1141,7 +1136,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( IsAnyDoorPermitActive[ side::left ] == false ); } );
+ return IsAnyDoorPermitActive[side::left] == false; } );
break;
}
// consist lights
@@ -1155,7 +1150,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
Action,
[this](float const Parameter) -> bool {
auto const &device { mvOccupied->CompartmentLights };
- return ( ( Global.fLuminance * ConsistShade > 0.40 ) || ( device.start_type != start_t::manual ) || ( ( device.is_enabled == true ) && ( device.is_disabled == false ) ) || ( device.is_active == true ) ); } );
+ return Global.fLuminance * ConsistShade > 0.40 || device.start_type != start_t::manual || (device.is_enabled == true && device.is_disabled == false) || device.is_active == true; } );
break;
}
case driver_hint::consistlightsoff: {
@@ -1168,7 +1163,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
Action,
[this](float const Parameter) -> bool {
auto const &device { mvOccupied->CompartmentLights };
- return ( ( Global.fLuminance * ConsistShade < 0.35 ) || ( device.start_type != start_t::manual ) || ( ( device.is_enabled == false ) && ( device.is_active == false ) ) ); } );
+ return Global.fLuminance * ConsistShade < 0.35 || device.start_type != start_t::manual || (device.is_enabled == false && device.is_active == false); } );
break;
}
// consist heating
@@ -1180,7 +1175,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( mvOccupied->HeatingAllow == true ); } );
+ return mvOccupied->HeatingAllow == true; } );
break;
}
case driver_hint::consistheatingoff: {
@@ -1191,7 +1186,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( mvOccupied->HeatingAllow == false ); } );
+ return mvOccupied->HeatingAllow == false; } );
break;
}
@@ -1226,7 +1221,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
Action,
[this](float const Parameter) -> bool {
auto const &device { pVehicles[ end::front ]->MoverParameters->Couplers[ static_cast( Parameter ) ] };
- return ( device.type() == TCouplerType::Automatic ); } );
+ return device.type() == TCouplerType::Automatic; } );
break;
}
case driver_hint::couplingadapterremove: {
@@ -1237,7 +1232,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
Action,
[this](float const Parameter) -> bool {
auto const &device { pVehicles[ end::front ]->MoverParameters->Couplers[ static_cast( Parameter ) ] };
- return ( false == device.has_adapter() ); } );
+ return false == device.has_adapter(); } );
break;
}
// lights
@@ -1251,7 +1246,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( pVehicles[ end::front ]->has_signal_pc1_on() ); } );
+ return pVehicles[end::front]->has_signal_pc1_on(); } );
break;
}
case driver_hint::headcodepc2: {
@@ -1264,7 +1259,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( pVehicles[ end::front ]->has_signal_pc2_on() ); } );
+ return pVehicles[end::front]->has_signal_pc2_on(); } );
break;
}
case driver_hint::headcodetb1: {
@@ -1283,14 +1278,12 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
[this](float const Parameter) -> bool {
auto const activeend { mvOccupied->CabActive >= 0 ? end::front : end::rear };
auto const consistfront { mvOccupied->DirActive >= 0 ? end::front : end::rear };
- return (
- pVehicles[ consistfront ]->has_signal_on( activeend, light::headlight_right )
- && pVehicles[ 1 - consistfront ]->has_signal_on( 1 - activeend, light::headlight_left ) ); } );
+ return pVehicles[consistfront]->has_signal_on(activeend, light::headlight_right) && pVehicles[1 - consistfront]->has_signal_on(1 - activeend, light::headlight_left); } );
break;
}
case driver_hint::headcodepc5: {
- if( ( AIControllFlag )
- || ( Global.AITrainman && ( false == pVehicles[ end::rear ]->is_connected( pVehicle, coupling::control ) ) ) ) {
+ if( AIControllFlag
+ || ( Global.AITrainman && false == pVehicles[end::rear]->is_connected(pVehicle, coupling::control) ) ) {
pVehicles[ end::rear ]->RaLightsSet( -1, light::redmarker_left | light::redmarker_right | light::rearendsignals );
}
remove_hint( driver_hint::headcodetb1 );
@@ -1298,7 +1291,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( pVehicles[ end::rear ]->has_signal_pc5_on() ); } );
+ return pVehicles[end::rear]->has_signal_pc5_on(); } );
break;
}
case driver_hint::lightsoff: {
@@ -1314,9 +1307,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
[this](float const Parameter) -> bool {
auto const activeend { mvOccupied->CabActive >= 0 ? end::front : end::rear };
auto const consistfront { mvOccupied->DirActive >= 0 ? end::front : end::rear };
- return (
- pVehicles[ consistfront ]->has_signal_on( activeend, 0 )
- && pVehicles[ 1 - consistfront ]->has_signal_on( 1 - activeend, 0 ) ); } );
+ return pVehicles[consistfront]->has_signal_on(activeend, 0) && pVehicles[1 - consistfront]->has_signal_on(1 - activeend, 0); } );
break;
}
// releaser
@@ -1328,7 +1319,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( true == mvOccupied->Hamulec->Releaser() ); } );
+ return true == mvOccupied->Hamulec->Releaser(); } );
break;
}
case driver_hint::releaseroff: {
@@ -1339,7 +1330,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) -> bool {
- return ( false == mvOccupied->Hamulec->Releaser() ); } );
+ return false == mvOccupied->Hamulec->Releaser(); } );
break;
}
diff --git a/application/drivermode.cpp b/application/drivermode.cpp
index 19aece2e..e9b07b42 100644
--- a/application/drivermode.cpp
+++ b/application/drivermode.cpp
@@ -74,7 +74,7 @@ bool driver_mode::drivermode_input::init()
{
// initialize input devices
- auto result = (keyboard.init() && mouse.init());
+ auto result = keyboard.init() && mouse.init();
if (true == Global.InputGamepad)
{
gamepad.init();
@@ -268,7 +268,7 @@ bool driver_mode::update()
}
}
- if ((simulation::Train == nullptr) && (false == FreeFlyModeFlag))
+ if (simulation::Train == nullptr && false == FreeFlyModeFlag)
{
// intercept cases when the driven train got removed after entering portal
InOutKey();
@@ -344,7 +344,7 @@ bool driver_mode::update()
// tooltip update
set_tooltip("");
auto const *train{simulation::Train};
- if ((train != nullptr) && (false == FreeFlyModeFlag))
+ if (train != nullptr && false == FreeFlyModeFlag)
{
if (false == DebugModeFlag)
{
@@ -378,7 +378,7 @@ bool driver_mode::update()
{
// in debug mode show names of submodels, to help with cab setup and/or debugging
auto const cabcontrol = GfxRenderer->Pick_Control();
- set_tooltip((cabcontrol ? cabcontrol->pName : ""));
+ set_tooltip(cabcontrol ? cabcontrol->pName : "");
}
}
if (Global.ControlPicking && FreeFlyModeFlag && DebugModeFlag)
@@ -410,7 +410,7 @@ bool driver_mode::update()
GfxRenderer->Update(deltarealtime);
- simulation::is_ready = simulation::is_ready || ((simulation::Train != nullptr) && (simulation::Train->is_cab_initialized)) || (Global.local_start_vehicle == "ghostview");
+ simulation::is_ready = simulation::is_ready || (simulation::Train != nullptr && simulation::Train->is_cab_initialized) || Global.local_start_vehicle == "ghostview";
return true;
}
@@ -419,7 +419,7 @@ bool driver_mode::update()
void driver_mode::enter()
{
- TDynamicObject *nPlayerTrain{((Global.local_start_vehicle != "ghostview") ? simulation::Vehicles.find(Global.local_start_vehicle) : nullptr)};
+ TDynamicObject *nPlayerTrain{(Global.local_start_vehicle != "ghostview" ? simulation::Vehicles.find(Global.local_start_vehicle) : nullptr)};
Camera.Init(Global.FreeCameraInit[0], Global.FreeCameraInitAngle[0], nullptr);
Global.pCamera = Camera;
@@ -467,9 +467,9 @@ void driver_mode::on_key(int const Key, int const Scancode, int const Action, in
{
#ifndef __unix__
- Global.shiftState = (Mods & GLFW_MOD_SHIFT) ? true : false;
- Global.ctrlState = (Mods & GLFW_MOD_CONTROL) ? true : false;
- Global.altState = (Mods & GLFW_MOD_ALT) ? true : false;
+ Global.shiftState = Mods & GLFW_MOD_SHIFT ? true : false;
+ Global.ctrlState = Mods & GLFW_MOD_CONTROL ? true : false;
+ Global.altState = Mods & GLFW_MOD_ALT ? true : false;
#endif
bool anyModifier = Mods & (GLFW_MOD_SHIFT | GLFW_MOD_CONTROL | GLFW_MOD_ALT);
@@ -479,7 +479,7 @@ void driver_mode::on_key(int const Key, int const Scancode, int const Action, in
{
return;
}
- if (Key == (GLFW_KEY_F12) && Global.shiftState && Action == GLFW_PRESS)
+ if (Key == GLFW_KEY_F12 && Global.shiftState && Action == GLFW_PRESS)
{
m_userinterface->showDebugUI();
return;
@@ -490,13 +490,13 @@ void driver_mode::on_key(int const Key, int const Scancode, int const Action, in
return;
}
- if ((true == Global.InputMouse) && ((Key == GLFW_KEY_LEFT_ALT) || (Key == GLFW_KEY_RIGHT_ALT)))
+ if (true == Global.InputMouse && (Key == GLFW_KEY_LEFT_ALT || Key == GLFW_KEY_RIGHT_ALT))
{
// if the alt key was pressed toggle control picking mode and set matching cursor behaviour
if (Action == GLFW_PRESS)
{
// toggle picking mode
- set_picking(Global.shiftState ? true : (Global.ctrlState ? false : !Global.ControlPicking));
+ set_picking(Global.shiftState ? true : Global.ctrlState ? false : !Global.ControlPicking);
}
}
@@ -558,7 +558,7 @@ bool driver_mode::is_command_processor() const
void driver_mode::update_camera(double const Deltatime)
{
- auto *controlled = (simulation::Train ? simulation::Train->Dynamic() : nullptr);
+ auto *controlled = simulation::Train ? simulation::Train->Dynamic() : nullptr;
if (false == Global.ControlPicking)
{
@@ -626,7 +626,7 @@ void driver_mode::update_camera(double const Deltatime)
if (false == DebugCameraFlag)
{
// regular camera
- if ((simulation::Train != nullptr) && (false == FreeFlyModeFlag) && (false == Global.CabWindowOpen))
+ if (simulation::Train != nullptr && false == FreeFlyModeFlag && false == Global.CabWindowOpen)
{
// if in cab potentially alter camera placement based on changes in train object
Camera.m_owneroffset = simulation::Train->pMechOffset;
@@ -636,20 +636,20 @@ void driver_mode::update_camera(double const Deltatime)
Camera.Update();
- if ((simulation::Train != nullptr) && (false == FreeFlyModeFlag))
+ if (simulation::Train != nullptr && false == FreeFlyModeFlag)
{
// keep the camera within cab boundaries
Camera.m_owneroffset = simulation::Train->clamp_inside(Camera.m_owneroffset);
}
- if ((simulation::Train != nullptr) && (false == FreeFlyModeFlag) && (false == Global.CabWindowOpen))
+ if (simulation::Train != nullptr && false == FreeFlyModeFlag && false == Global.CabWindowOpen)
{
// cache cab camera in case of view type switch
simulation::Train->pMechViewAngle = {Camera.Angle.x, Camera.Angle.y};
simulation::Train->pMechOffset = Camera.m_owneroffset;
}
- if ((true == FreeFlyModeFlag) && (Camera.m_owner != nullptr))
+ if (true == FreeFlyModeFlag && Camera.m_owner != nullptr)
{
// cache external view config
auto &externalviewconfig{m_externalviewconfigs[m_externalviewmode]};
@@ -667,14 +667,14 @@ void driver_mode::update_camera(double const Deltatime)
// reset window state, it'll be set again if applicable in a check below
Global.CabWindowOpen = false;
- if ((simulation::Train != nullptr) && (Camera.m_owner != nullptr) && (false == DebugCameraFlag))
+ if (simulation::Train != nullptr && Camera.m_owner != nullptr && false == DebugCameraFlag)
{
// jeśli jazda w kabinie, przeliczyć trzeba parametry kamery
/*
auto tempangle = controlled->VectorFront() * ( controlled->MoverParameters->CabOccupied == -1 ? -1 : 1 );
double modelrotate = atan2( -tempangle.x, tempangle.z );
*/
- if ((false == FreeFlyModeFlag) && (true == Global.ctrlState) && ((m_input.keyboard.key(GLFW_KEY_LEFT) != GLFW_RELEASE) || (m_input.keyboard.key(GLFW_KEY_RIGHT) != GLFW_RELEASE)))
+ if (false == FreeFlyModeFlag && true == Global.ctrlState && (m_input.keyboard.key(GLFW_KEY_LEFT) != GLFW_RELEASE || m_input.keyboard.key(GLFW_KEY_RIGHT) != GLFW_RELEASE))
{
// jeśli lusterko lewe albo prawe (bez rzucania na razie)
Global.CabWindowOpen = true;
@@ -722,8 +722,8 @@ void driver_mode::update_camera(double const Deltatime)
auto shakencamerapos{Camera.m_owneroffset +
shakescale * glm::vec3(1.5 * Camera.m_owner->ShakeState.offset.x, 2.0 * Camera.m_owner->ShakeState.offset.y, 1.5 * Camera.m_owner->ShakeState.offset.z)};
- Camera.Pos = (Camera.m_owner->GetWorldPosition(FreeFlyModeFlag ? glm::dvec3(shakencamerapos) : // TODO: vehicle collision box for the external vehicle camera
- simulation::Train->clamp_inside(shakencamerapos)));
+ Camera.Pos = Camera.m_owner->GetWorldPosition(FreeFlyModeFlag ? glm::dvec3(shakencamerapos) : // TODO: vehicle collision box for the external vehicle camera
+ simulation::Train->clamp_inside(shakencamerapos));
if (!Global.iPause)
{
@@ -902,15 +902,15 @@ void driver_mode::OnKeyDown(int cKey)
// actual key processing
// TODO: redo the input system
- if ((cKey >= GLFW_KEY_0) && (cKey <= GLFW_KEY_9))
+ if (cKey >= GLFW_KEY_0 && cKey <= GLFW_KEY_9)
{
// klawisze cyfrowe
int i = cKey - GLFW_KEY_0; // numer klawisza
if (Global.shiftState)
{
// z [Shift] uruchomienie eventu
- if ((Global.iPause == 0) // podczas pauzy klawisze nie działają
- && (KeyEvents[i] != nullptr))
+ if (Global.iPause == 0 // podczas pauzy klawisze nie działają
+ && KeyEvents[i] != nullptr)
{
m_relay.post(user_command::queueevent, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &KeyEvents[i]->name());
}
@@ -921,7 +921,7 @@ void driver_mode::OnKeyDown(int cKey)
if (FreeFlyModeFlag)
{
// w trybie latania można przeskakiwać do ustawionych kamer
- if ((Global.FreeCameraInit[i].x == 0.0) && (Global.FreeCameraInit[i].y == 0.0) && (Global.FreeCameraInit[i].z == 0.0))
+ if (Global.FreeCameraInit[i].x == 0.0 && Global.FreeCameraInit[i].y == 0.0 && Global.FreeCameraInit[i].z == 0.0)
{
// jeśli kamera jest w punkcie zerowym, zapamiętanie współrzędnych i kątów
Global.FreeCameraInit[i] = Camera.Pos;
@@ -966,7 +966,7 @@ void driver_mode::OnKeyDown(int cKey)
TDynamicObject *dynamic = std::get(simulation::Region->find_vehicle(Global.pCamera.Pos, 50, false, false));
if (dynamic)
{
- m_relay.post(user_command::entervehicle, (Global.ctrlState ? GLFW_MOD_CONTROL : 0), (simulation::Train ? simulation::Train->id() : 0), GLFW_PRESS, 0, dynamic->GetPosition(),
+ m_relay.post(user_command::entervehicle, Global.ctrlState ? GLFW_MOD_CONTROL : 0, simulation::Train ? simulation::Train->id() : 0, GLFW_PRESS, 0, dynamic->GetPosition(),
&dynamic->name());
change_train = dynamic->name();
@@ -982,11 +982,11 @@ void driver_mode::OnKeyDown(int cKey)
if (Global.ctrlState)
{
- Global.fTimeSpeed = (Global.shiftState ? 60.0 : 20.0);
+ Global.fTimeSpeed = Global.shiftState ? 60.0 : 20.0;
}
else
{
- Global.fTimeSpeed = (Global.shiftState ? 5.0 : Global.default_timespeed);
+ Global.fTimeSpeed = Global.shiftState ? 5.0 : Global.default_timespeed;
}
}
break;
@@ -1024,7 +1024,7 @@ void driver_mode::OnKeyDown(int cKey)
case GLFW_KEY_F11:
{
// editor mode
- if ((false == Global.ctrlState) && (false == Global.shiftState))
+ if (false == Global.ctrlState && false == Global.shiftState)
{
Application.push_mode(eu07_application::mode::editor);
}
@@ -1044,14 +1044,14 @@ void driver_mode::OnKeyDown(int cKey)
void driver_mode::DistantView(bool const Near)
{
- TDynamicObject const *vehicle = {((simulation::Train != nullptr) ? simulation::Train->Dynamic() : pDynamicNearest)};
+ TDynamicObject const *vehicle = {(simulation::Train != nullptr ? simulation::Train->Dynamic() : pDynamicNearest)};
if (vehicle == nullptr)
{
return;
}
- auto const cab = (vehicle->MoverParameters->CabOccupied == 0 ? 1 : vehicle->MoverParameters->CabOccupied);
+ auto const cab = vehicle->MoverParameters->CabOccupied == 0 ? 1 : vehicle->MoverParameters->CabOccupied;
auto const left = vehicle->VectorLeft() * (double)cab;
if (true == Near)
@@ -1119,7 +1119,7 @@ void driver_mode::ExternalView()
Camera.m_owneroffset = {1.5 * owner->MoverParameters->Dim.W * offsetflip, std::max(5.0, 1.25 * owner->MoverParameters->Dim.H), -0.4 * owner->MoverParameters->Dim.L * offsetflip};
- Camera.Angle.y = glm::radians((vehicle->MoverParameters->DirActive < 0 ? 180.0 : 0.0));
+ Camera.Angle.y = glm::radians(vehicle->MoverParameters->DirActive < 0 ? 180.0 : 0.0);
}
auto const shakeangles{owner->shake_angles()};
Camera.Angle.x -= 0.5 * shakeangles.second; // hustanie kamery przod tyl
@@ -1149,7 +1149,7 @@ void driver_mode::ExternalView()
Camera.m_owneroffset = {1.5 * owner->MoverParameters->Dim.W * offsetflip, std::max(5.0, 1.25 * owner->MoverParameters->Dim.H), 0.2 * owner->MoverParameters->Dim.L * offsetflip};
- Camera.Angle.y = glm::radians((vehicle->MoverParameters->DirActive < 0 ? 0.0 : 180.0));
+ Camera.Angle.y = glm::radians(vehicle->MoverParameters->DirActive < 0 ? 0.0 : 180.0);
}
auto const shakeangles{owner->shake_angles()};
Camera.Angle.x -= 0.5 * shakeangles.second; // hustanie kamery przod tyl
@@ -1177,7 +1177,7 @@ void driver_mode::ExternalView()
Camera.m_owneroffset = {-0.65 * owner->MoverParameters->Dim.W * offsetflip, 0.90, 0.15 * owner->MoverParameters->Dim.L * offsetflip};
- Camera.Angle.y = glm::radians((vehicle->MoverParameters->DirActive < 0 ? 180.0 : 0.0));
+ Camera.Angle.y = glm::radians(vehicle->MoverParameters->DirActive < 0 ? 180.0 : 0.0);
}
auto const shakeangles{owner->shake_angles()};
Camera.Angle.x -= 0.5 * shakeangles.second; // hustanie kamery przod tyl
diff --git a/application/driveruilayer.cpp b/application/driveruilayer.cpp
index a89f19fd..0b8463f8 100644
--- a/application/driveruilayer.cpp
+++ b/application/driveruilayer.cpp
@@ -112,7 +112,7 @@ bool driver_ui::on_key(int const Key, int const Action)
case GLFW_KEY_F12:
{ // ui mode selectors
- if ((true == Global.ctrlState) || (true == Global.shiftState))
+ if (true == Global.ctrlState || true == Global.shiftState)
{
// only react to keys without modifiers
return false;
@@ -143,11 +143,11 @@ bool driver_ui::on_key(int const Key, int const Action)
case GLFW_KEY_F1:
{
// basic consist info
- auto state = ((m_aidpanel.is_open == false) ? 0 : (m_aidpanel.is_expanded == false) ? 1 : 2);
+ auto state = m_aidpanel.is_open == false ? 0 : m_aidpanel.is_expanded == false ? 1 : 2;
state = clamp_circular(++state, 3);
- m_aidpanel.is_open = (state > 0);
- m_aidpanel.is_expanded = (state > 1);
+ m_aidpanel.is_open = state > 0;
+ m_aidpanel.is_expanded = state > 1;
return true;
}
@@ -155,11 +155,11 @@ bool driver_ui::on_key(int const Key, int const Action)
case GLFW_KEY_F2:
{
// timetable
- auto state = ((m_timetablepanel.is_open == false) ? 0 : (m_timetablepanel.is_expanded == false) ? 1 : 2);
+ auto state = m_timetablepanel.is_open == false ? 0 : m_timetablepanel.is_expanded == false ? 1 : 2;
state = clamp_circular(++state, 3);
- m_timetablepanel.is_open = (state > 0);
- m_timetablepanel.is_expanded = (state > 1);
+ m_timetablepanel.is_open = state > 0;
+ m_timetablepanel.is_expanded = state > 1;
return true;
}
@@ -209,8 +209,8 @@ void driver_ui::update()
{
auto const pausemask{1 | 2};
- auto ispaused{(false == DebugModeFlag) && ((Global.iPause & pausemask) != 0)};
- if ((ispaused != m_paused) && (false == Global.ControlPicking))
+ auto ispaused{false == DebugModeFlag && (Global.iPause & pausemask) != 0};
+ if (ispaused != m_paused && false == Global.ControlPicking)
{
set_cursor(ispaused);
}
@@ -252,7 +252,7 @@ void driver_ui::render_()
ImGui::SetNextWindowSize(ImVec2(-1, -1));
if (ImGui::BeginPopupModal(popupheader, nullptr, 0))
{
- if ((ImGui::Button(STR_C("Resume"), ImVec2(150, 0))) || (ImGui::IsKeyReleased(ImGui::GetKeyIndex(ImGuiKey_Escape))))
+ if (ImGui::Button(STR_C("Resume"), ImVec2(150, 0)) || ImGui::IsKeyReleased(ImGui::GetKeyIndex(ImGuiKey_Escape)))
{
m_relay.post(user_command::pausetoggle, 0.0, 0.0, GLFW_RELEASE, 0);
}
diff --git a/application/driveruipanels.cpp b/application/driveruipanels.cpp
index f316f175..729b854c 100644
--- a/application/driveruipanels.cpp
+++ b/application/driveruipanels.cpp
@@ -48,12 +48,12 @@ drivingaid_panel::update() {
auto const *train { simulation::Train };
auto const *controlled { ( train ? train->Dynamic() : nullptr ) };
- if( ( controlled == nullptr )
- || ( controlled->Mechanik == nullptr ) ) { return; }
+ if( controlled == nullptr
+ || controlled->Mechanik == nullptr ) { return; }
auto const *mover = controlled->MoverParameters;
auto const *driver = controlled->Mechanik;
- auto const *owner = ( controlled->ctOwner != nullptr ? controlled->ctOwner : controlled->Mechanik );
+ auto const *owner = controlled->ctOwner != nullptr ? controlled->ctOwner : controlled->Mechanik;
{ // throttle, velocity, speed limits and grade
std::string expandedtext;
@@ -76,8 +76,8 @@ drivingaid_panel::update() {
if( speedlimit != 0 ) { // if we aren't allowed to move then any next speed limit is irrelevant
// nie przekraczać rozkladowej
auto const schedulespeedlimit { (
- ( ( owner->OrderCurrentGet() & ( Obey_train | Bank ) ) != 0 ) && ( owner->TrainParams.TTVmax > 0.0 ) ? static_cast( owner->TrainParams.TTVmax ) :
- ( ( owner->OrderCurrentGet() & ( Obey_train | Bank ) ) == 0 ) ? static_cast( owner->fShuntVelocity ) :
+ (owner->OrderCurrentGet() & (Obey_train | Bank)) != 0 && owner->TrainParams.TTVmax > 0.0 ? static_cast( owner->TrainParams.TTVmax ) :
+ (owner->OrderCurrentGet() & (Obey_train | Bank)) == 0 ? static_cast( owner->fShuntVelocity ) :
-1 ) };
// first take note of any speed change which should occur after passing potential current speed limit
if( owner->VelLimitLastDist.second > 0 ) {
@@ -142,9 +142,12 @@ drivingaid_panel::update() {
std::snprintf(
m_buffer.data(), m_buffer.size(),
STR_C("Throttle: %3d+%d %c%s"),
- ( mover->EIMCtrlType > 0 ? std::max( 0, static_cast( 100.4 * mover->eimic_real ) ) : driver->Controlling()->MainCtrlPos ),
- ( mover->EIMCtrlType > 0 ? driver->Controlling()->MainCtrlPos : driver->Controlling()->ScndCtrlPos ),
- ( mover->SpeedCtrlUnit.IsActive ? 'T' : mover->DirActive > 0 ? 'D' : mover->DirActive < 0 ? 'R' : 'N' ),
+ mover->EIMCtrlType > 0 ? std::max(0, static_cast(100.4 * mover->eimic_real)) : driver->Controlling()->MainCtrlPos,
+ mover->EIMCtrlType > 0 ? driver->Controlling()->MainCtrlPos : driver->Controlling()->ScndCtrlPos,
+ mover->SpeedCtrlUnit.IsActive ? 'T' :
+ mover->DirActive > 0 ? 'D' :
+ mover->DirActive < 0 ? 'R' :
+ 'N',
expandedtext.c_str());
text_lines.emplace_back( m_buffer.data(), Global.UITextColor );
@@ -166,9 +169,9 @@ drivingaid_panel::update() {
m_buffer.data(), m_buffer.size(),
STR_C("Brakes: %5.1f+%-2.0f%c%s"),
// ( mover->EIMCtrlType == 0 ? basicbraking : mover->EIMCtrlType == 3 ? ( mover->UniCtrlIntegratedBrakeCtrl ? eimicbraking : basicbraking ) : eimicbraking ),
- ( mover->UniCtrlIntegratedBrakeCtrl ? eimicbraking : basicbraking ),
+ mover->UniCtrlIntegratedBrakeCtrl ? eimicbraking : basicbraking,
mover->LocalBrakePosA * LocalBrakePosNo,
- ( mover->SlippingWheels ? '!' : ' ' ),
+ mover->SlippingWheels ? '!' : ' ',
expandedtext.c_str() );
text_lines.emplace_back( m_buffer.data(), Global.UITextColor );
@@ -197,13 +200,9 @@ drivingaid_panel::update() {
}
}
std::string textline =
- ( (mover->SecuritySystem.is_vigilance_blinking() && (train != nullptr ? (train->fBlinkTimer > 0) : true)) ?
- STR("!ALERTER! ") :
- " " );
+ mover->SecuritySystem.is_vigilance_blinking() && (train != nullptr ? train->fBlinkTimer > 0 : true) ? STR("!ALERTER! ") : " ";
textline +=
- ( mover->SecuritySystem.is_cabsignal_blinking() ?
- STR("!SHP!") :
- " " );
+ mover->SecuritySystem.is_cabsignal_blinking() ? STR("!SHP!") : " ";
text_lines.emplace_back( textline + " " + expandedtext, Global.UITextColor );
}
@@ -219,13 +218,12 @@ scenario_panel::update() {
auto const *train { simulation::Train };
auto const *controlled { ( train ? train->Dynamic() : nullptr ) };
auto const &camera { Global.pCamera };
- m_nearest = (
- false == FreeFlyModeFlag ? controlled :
- camera.m_owner != nullptr ? camera.m_owner :
- std::get( simulation::Region->find_vehicle( camera.Pos, 20, false, false ) ) ); // w trybie latania lokalizujemy wg mapy
+ m_nearest = false == FreeFlyModeFlag ? controlled :
+ camera.m_owner != nullptr ? camera.m_owner :
+ std::get(simulation::Region->find_vehicle(camera.Pos, 20, false, false)); // w trybie latania lokalizujemy wg mapy
if( m_nearest == nullptr ) { return; }
auto const *owner { (
- ( ( m_nearest->Mechanik != nullptr ) && ( m_nearest->Mechanik->primary() ) ) ?
+ m_nearest->Mechanik != nullptr && m_nearest->Mechanik->primary() ?
m_nearest->Mechanik :
m_nearest->ctOwner ) };
if( owner == nullptr ) { return; }
@@ -263,13 +261,13 @@ scenario_panel::render() {
if( true == ImGui::Begin( panelname.c_str(), &is_open, flags ) ) {
// potential assignment section
auto const *owner { (
- ( ( m_nearest->Mechanik != nullptr ) && ( m_nearest->Mechanik->primary() ) ) ?
+ m_nearest->Mechanik != nullptr && m_nearest->Mechanik->primary() ?
m_nearest->Mechanik :
m_nearest->ctOwner ) };
if( owner != nullptr ) {
auto const assignmentheader { STR("Assignment") };
- if( ( false == owner->assignment().empty() )
- && ( true == ImGui::CollapsingHeader( assignmentheader.c_str() ) ) ) {
+ if( false == owner->assignment().empty()
+ && true == ImGui::CollapsingHeader(assignmentheader.c_str()) ) {
ImGui::TextWrapped( "%s", owner->assignment().c_str() );
ImGui::Separator();
}
@@ -330,10 +328,7 @@ timetable_panel::update() {
if( vehicle == nullptr ) { return; }
// if the nearest located vehicle doesn't have a direct driver, try to query its owner
- auto const *owner = (
- ( ( vehicle->Mechanik != nullptr ) && ( vehicle->Mechanik->primary() ) ) ?
- vehicle->Mechanik :
- vehicle->ctOwner );
+ auto const *owner = vehicle->Mechanik != nullptr && vehicle->Mechanik->primary() ? vehicle->Mechanik : vehicle->ctOwner;
if( owner == nullptr ) { return; }
auto const &table = owner->TrainTimetable();
@@ -364,8 +359,8 @@ timetable_panel::update() {
// consist data
auto consistmass { owner->fMass };
auto consistlength { owner->fLength };
- if( ( false == owner->is_dmu() )
- && ( false == owner->is_emu() ) ) {
+ if( false == owner->is_dmu()
+ && false == owner->is_emu() ) {
//odejmij lokomotywy czynne, a przynajmniej aktualną
consistmass -= owner->pVehicle->MoverParameters->TotalMass;
// subtract potential other half of a two-part vehicle
@@ -429,29 +424,27 @@ timetable_panel::update() {
std::to_string( int( 100 + tableline->Dh ) ).substr( 1, 2 ) + ":" + to_minutes_str( tableline->Dm, true, 3 ) :
U8(" │ ") ) };
auto const candepart { (
- ( table.StationStart < table.StationIndex )
- && ( i < table.StationIndex )
- && ( ( tableline->Ah < 0 ) // pass-through, always valid
- || ( tableline->is_maintenance ) // maintenance stop, always valid
- || ( time.wHour * 60 + time.wMinute + time.wSecond * 0.0167 >= tableline->Dh * 60 + tableline->Dm ) ) ) };
- auto const loadchangeinprogress { ( ( static_cast( std::ceil( -1.0 * owner->fStopTime ) ) ) > 0 ) };
- auto const isatpassengerstop { ( true == owner->IsAtPassengerStop ) && ( vehicle->MoverParameters->Vel < 1.0 ) };
+ table.StationStart < table.StationIndex
+ && i < table.StationIndex
+ && ( tableline->Ah < 0 // pass-through, always valid
+ || tableline->is_maintenance // maintenance stop, always valid
+ || time.wHour * 60 + time.wMinute + time.wSecond * 0.0167 >= tableline->Dh * 60 + tableline->Dm ) ) };
+ auto const loadchangeinprogress { ( static_cast(std::ceil(-1.0 * owner->fStopTime)) > 0 ) };
+ auto const isatpassengerstop { true == owner->IsAtPassengerStop && vehicle->MoverParameters->Vel < 1.0 };
auto const traveltime { (
i < 2 ? " " :
tableline->Ah >= 0 ? to_minutes_str( CompareTime( table.TimeTable[ i - 1 ].Dh, table.TimeTable[ i - 1 ].Dm, tableline->Ah, tableline->Am ), false, 3 ) :
to_minutes_str( std::max( 0.0, CompareTime( table.TimeTable[ i - 1 ].Dh, table.TimeTable[ i - 1 ].Dm, tableline->Dh, tableline->Dm ) - 0.5 ), false, 3 ) ) };
auto const linecolor { (
- ( i != table.StationStart ) ? Global.UITextColor :
+ i != table.StationStart ? Global.UITextColor :
loadchangeinprogress ? colors::uitextred :
candepart ? colors::uitextgreen : // czas minął i odjazd był, to nazwa stacji będzie na zielono
isatpassengerstop ? colors::uitextorange :
Global.UITextColor ) };
std::string const trackcount{ ( tableline->TrackNo == 1 ? U8(" ┃ ") : U8(" ║ " )) };
- m_tablelines.emplace_back(
- ( U8("│ ") + vmax + U8(" │ ") + station + trackcount + arrival + U8(" │ ") + traveltime + U8(" │") ),
+ m_tablelines.emplace_back(U8("│ ") + vmax + U8(" │ ") + station + trackcount + arrival + U8(" │ ") + traveltime + U8(" │"),
linecolor );
- m_tablelines.emplace_back(
- ( U8("│ │ ") + location + tableline->StationWare + trackcount + departure + U8(" │ │") ),
+ m_tablelines.emplace_back(U8("│ │ ") + location + tableline->StationWare + trackcount + departure + U8(" │ │"),
linecolor );
// divider/footer
if( i < table.StationCount ) {
@@ -522,20 +515,14 @@ void debug_panel::update()
// input item bindings
m_input.train = simulation::Train;
- m_input.controlled = ( m_input.train ? m_input.train->Dynamic() : nullptr );
- m_input.camera = &( Global.pCamera );
- m_input.vehicle = (
- false == FreeFlyModeFlag ? m_input.controlled :
- m_input.camera->m_owner != nullptr ? m_input.camera->m_owner :
- std::get( simulation::Region->find_vehicle( m_input.camera->Pos, 20, false, false ) ) ); // w trybie latania lokalizujemy wg mapy
+ m_input.controlled = m_input.train ? m_input.train->Dynamic() : nullptr;
+ m_input.camera = &Global.pCamera;
+ m_input.vehicle = false == FreeFlyModeFlag ? m_input.controlled :
+ m_input.camera->m_owner != nullptr ? m_input.camera->m_owner :
+ std::get(simulation::Region->find_vehicle(m_input.camera->Pos, 20, false, false)); // w trybie latania lokalizujemy wg mapy
m_input.mover =
- ( m_input.vehicle != nullptr ?
- m_input.vehicle->MoverParameters :
- nullptr );
- m_input.mechanik = (
- m_input.vehicle != nullptr ?
- m_input.vehicle->Mechanik :
- nullptr );
+ m_input.vehicle != nullptr ? m_input.vehicle->MoverParameters : nullptr;
+ m_input.mechanik = m_input.vehicle != nullptr ? m_input.vehicle->Mechanik : nullptr;
// header section
text_lines.clear();
@@ -602,7 +589,7 @@ debug_panel::render() {
// sections
ImGui::Separator();
if( true == render_section( "Vehicle", m_vehiclelines ) ) {
- if( DebugModeFlag && ( m_input.mover ) && ( m_input.mover->DamageFlag != 0 ) ) {
+ if( DebugModeFlag && m_input.mover && m_input.mover->DamageFlag != 0 ) {
if( true == ImGui::Button( "Stop and repair consist" ) ) {
command_relay relay;
relay.post(user_command::resetconsist, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &m_input.vehicle->name());
@@ -738,7 +725,7 @@ debug_panel::render_section_scenario() {
{
auto timerate { ( Global.fTimeSpeed == 60 ? 4 : Global.fTimeSpeed == 20 ? 3 : Global.fTimeSpeed == 5 ? 2 : 1 ) };
if( ImGui::SliderInt( ( "x " + to_string( Global.fTimeSpeed, 0 ) + "###timeacceleration" ).c_str(), &timerate, 1, 4, "Time acceleration" ) ) {
- Global.fTimeSpeed = ( timerate == 4 ? 60 : timerate == 3 ? 20 : timerate == 2 ? 5 : 1 );
+ Global.fTimeSpeed = timerate == 4 ? 60 : timerate == 3 ? 20 : timerate == 2 ? 5 : 1;
}
}
// base draw range slider
@@ -780,8 +767,8 @@ debug_panel::update_section_vehicle( std::vector &Output ) {
auto const &vehicle { *m_input.vehicle };
auto const &mover { *m_input.mover };
- auto const isowned { /* ( vehicle.Mechanik == nullptr ) && */ ( vehicle.ctOwner != nullptr ) && ( vehicle.ctOwner->Vehicle() != m_input.vehicle ) };
- auto const isdieselenginepowered { ( mover.EngineType == TEngineType::DieselElectric ) || ( mover.EngineType == TEngineType::DieselEngine ) };
+ auto const isowned { /* ( vehicle.Mechanik == nullptr ) && */ vehicle.ctOwner != nullptr && vehicle.ctOwner->Vehicle() != m_input.vehicle };
+ auto const isdieselenginepowered { mover.EngineType == TEngineType::DieselElectric || mover.EngineType == TEngineType::DieselEngine };
auto const isdieselinshuntmode { mover.ShuntMode && mover.EngineType == TEngineType::DieselElectric };
std::snprintf(
@@ -803,24 +790,52 @@ debug_panel::update_section_vehicle( std::vector &Output ) {
m_buffer.data(), m_buffer.size(),
STR_C("Devices: %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%s%s\nPower transfers: %.0f@%.0f%s[%.0f]%s%.0f@%.0f :: %.0f@%.0f%s[%.0f]%s%.0f@%.0f"),
// devices
- ( mover.Battery ? 'B' : '.' ),
- ( mover.PantsValve.is_active ? '+' : '.' ),
- ( mover.Pantographs[ end::rear ].valve.is_active ? 'O' : ( mover.Pantographs[ end::rear ].valve.is_enabled ? 'o' : '.' ) ),
- ( mover.Pantographs[ end::front ].valve.is_active ? 'P' : ( mover.Pantographs[ end::front ].valve.is_enabled ? 'p' : '.' ) ),
- ( mover.PantPressLockActive ? '!' : ( mover.PantPressSwitchActive ? '*' : '.' ) ),
- ( mover.WaterPump.is_active ? 'W' : ( false == mover.WaterPump.breaker ? '-' : ( mover.WaterPump.is_enabled ? 'w' : '.' ) ) ),
- ( mover.WaterHeater.is_damaged ? '!' : ( mover.WaterHeater.is_active ? 'H' : ( false == mover.WaterHeater.breaker ? '-' : ( mover.WaterHeater.is_enabled ? 'h' : '.' ) ) ) ),
- ( mover.FuelPump.is_active ? 'F' : ( mover.FuelPump.is_enabled ? 'f' : '.' ) ),
- ( mover.OilPump.is_active ? 'O' : ( mover.OilPump.is_enabled ? 'o' : '.' ) ),
- ( mover.Mains ? 'M' : '.' ),
- ( mover.FuseFlag ? '!' : '.' ),
- ( mover.ConverterFlag ? 'X' : ( false == mover.ConverterAllowLocal ? '-' : ( mover.ConverterAllow ? 'x' : '.' ) ) ),
- ( mover.ConvOvldFlag ? '!' : '.' ),
- ( mover.CompressorFlag ? 'C' : ( false == mover.CompressorAllowLocal ? '-' : ( ( mover.CompressorAllow || ( mover.CompressorStart == start_t::automatic && mover.CompressorSpeed > 0.0 ) ) ? 'c' : '.' ) ) ),
- ( mover.CompressorGovernorLock ? '!' : '.' ),
- ( mover.StLinSwitchOff ? '-' : ( mover.ControlPressureSwitch ? '!' : ( mover.StLinFlag ? '+' : '.' ) ) ),
- ( mover.Heating ? 'H' : ( mover.HeatingAllow ? 'h' : '.' ) ),
- ( mover.Hamulec->Releaser() ? '^' : '.' ),
+ mover.Battery ? 'B' : '.',
+ mover.PantsValve.is_active ? '+' : '.',
+ mover.Pantographs[end::rear].valve.is_active ? 'O' :
+ mover.Pantographs[end::rear].valve.is_enabled ? 'o' :
+ '.',
+ mover.Pantographs[end::front].valve.is_active ? 'P' :
+ mover.Pantographs[end::front].valve.is_enabled ? 'p' :
+ '.',
+ mover.PantPressLockActive ? '!' :
+ mover.PantPressSwitchActive ? '*' :
+ '.',
+ mover.WaterPump.is_active ? 'W' :
+ false == mover.WaterPump.breaker ? '-' :
+ mover.WaterPump.is_enabled ? 'w' :
+ '.',
+ mover.WaterHeater.is_damaged ? '!' :
+ mover.WaterHeater.is_active ? 'H' :
+ false == mover.WaterHeater.breaker ? '-' :
+ mover.WaterHeater.is_enabled ? 'h' :
+ '.',
+ mover.FuelPump.is_active ? 'F' :
+ mover.FuelPump.is_enabled ? 'f' :
+ '.',
+ mover.OilPump.is_active ? 'O' :
+ mover.OilPump.is_enabled ? 'o' :
+ '.',
+ mover.Mains ? 'M' : '.',
+ mover.FuseFlag ? '!' : '.',
+ mover.ConverterFlag ? 'X' :
+ false == mover.ConverterAllowLocal ? '-' :
+ mover.ConverterAllow ? 'x' :
+ '.',
+ mover.ConvOvldFlag ? '!' : '.',
+ mover.CompressorFlag ? 'C' :
+ false == mover.CompressorAllowLocal ? '-' :
+ mover.CompressorAllow || (mover.CompressorStart == start_t::automatic && mover.CompressorSpeed > 0.0) ? 'c' :
+ '.',
+ mover.CompressorGovernorLock ? '!' : '.',
+ mover.StLinSwitchOff ? '-' :
+ mover.ControlPressureSwitch ? '!' :
+ mover.StLinFlag ? '+' :
+ '.',
+ mover.Heating ? 'H' :
+ mover.HeatingAllow ? 'h' :
+ '.',
+ mover.Hamulec->Releaser() ? '^' : '.',
std::string( m_input.mechanik ? STR(" R") + ( mover.Radio ? std::to_string( m_input.mechanik->iRadioChannel ) : "-" ) : "" ).c_str(),
std::string( isdieselenginepowered ? STR(" oil pressure: ") + to_string( mover.OilPump.pressure, 2 ) : "" ).c_str(),
// power transfers
@@ -871,7 +886,7 @@ debug_panel::update_section_vehicle( std::vector &Output ) {
mover.dizel_heat.Ts,
mover.dizel_heat.To,
mover.dizel_heat.temperatura1,
- ( mover.WaterCircuitsLink ? '-' : '|' ),
+ mover.WaterCircuitsLink ? '-' : '|',
mover.dizel_heat.temperatura2 );
textline += m_buffer.data();
}
@@ -888,8 +903,8 @@ debug_panel::update_section_vehicle( std::vector &Output ) {
mover.LoadFlag,
mover.LocalBrakePosA,
mover.LocalBrakePosAEIM,
- ( mover.ManualBrakePos / static_cast( ManualBrakePosNo ) ),
- ( mover.SpringBrake.Activate ? 1.f : 0.f ),
+ mover.ManualBrakePos / static_cast(ManualBrakePosNo),
+ mover.SpringBrake.Activate ? 1.f : 0.f,
// cylinders
mover.BrakePress,
mover.LocBrakePress,
@@ -911,7 +926,7 @@ debug_panel::update_section_vehicle( std::vector &Output ) {
m_buffer.data(), m_buffer.size(),
STR_C(" pantograph: %.2f%cMT"),
mover.PantPress,
- ( mover.bPantKurek3 ? '-' : '|' ) );
+ mover.bPantKurek3 ? '-' : '|' );
textline += m_buffer.data();
}
@@ -924,7 +939,7 @@ debug_panel::update_section_vehicle( std::vector &Output ) {
mover.Ft * 0.001f * ( mover.CabOccupied ? mover.CabOccupied : vehicle.ctOwner ? vehicle.ctOwner->Controlling()->CabOccupied : 1 ) + 0.001f,
mover.Fb * 0.001f,
mover.FrictionForce() * 0.001f,
- ( mover.SlippingWheels ? " (!)" : "" ),
+ mover.SlippingWheels ? " (!)" : "",
// acceleration
mover.AccSVBased,
mover.AccN + 0.001f,
@@ -994,7 +1009,7 @@ void debug_panel::graph_data::render() {
std::string
debug_panel::update_vehicle_coupler( int const Side ) {
// NOTE: mover and vehicle are guaranteed to be valid by the caller
- auto const &mover { *( m_input.mover ) };
+ auto const &mover { *m_input.mover };
std::string const controltype{ ( mover.Couplers[ Side ].control_type.empty() ? "[*]" : "[" + mover.Couplers[ Side ].control_type + "]" ) };
std::string couplerstatus { STR("none") };
@@ -1022,7 +1037,7 @@ debug_panel::update_vehicle_coupler( int const Side ) {
std::string
debug_panel::update_vehicle_brake() const {
// NOTE: mover is guaranteed to be valid by the caller
- auto const &mover { *( m_input.mover ) };
+ auto const &mover { *m_input.mover };
std::string brakedelay;
@@ -1063,9 +1078,7 @@ debug_panel::update_section_engine( std::vector &Output ) {
if( i < 10 ) {
parameters +=
- ( ( m_input.train != nullptr ) && ( m_input.train->Dynamic() == m_input.vehicle ) ?
- " | " + TTrain::fPress_labels[ i ] + to_string( m_input.train->fPress[ i ][ 0 ], 2, 9 ) :
- "" );
+ m_input.train != nullptr && m_input.train->Dynamic() == m_input.vehicle ? " | " + TTrain::fPress_labels[i] + to_string(m_input.train->fPress[i][0], 2, 9) : "";
}
else if( i == 12 ) {
parameters += " med:";
@@ -1147,8 +1160,8 @@ debug_panel::update_section_ai( std::vector &Output ) {
Output.emplace_back( textline, Global.UITextColor );
- if( ( mechanik.VelNext == 0.0 )
- && ( mechanik.eSignNext ) ) {
+ if( mechanik.VelNext == 0.0
+ && mechanik.eSignNext ) {
// jeśli ma zapamiętany event semafora, nazwa eventu semafora
Output.emplace_back( "Current signal: " + Bezogonkow( mechanik.eSignNext->m_name ), Global.UITextColor );
}
@@ -1210,7 +1223,8 @@ debug_panel::update_section_ai( std::vector &Output ) {
"Acceleration:\n desired: " + to_string( mechanik.AccDesired, 2 )
+ ", corrected: " + to_string( mechanik.AccDesired * mechanik.BrakeAccFactor(), 2 )
+ "\n current: " + to_string( mechanik.AbsAccS + 0.001f, 2 )
- + ", slope: " + to_string( mechanik.fAccGravity + 0.001f, 2 ) + " (" + ( mechanik.fAccGravity > 0.01 ? "\\" : ( mechanik.fAccGravity < -0.01 ? "/" : "-" ) ) + ")"
+ + ", slope: " + to_string( mechanik.fAccGravity + 0.001f, 2 ) + " (" + ( mechanik.fAccGravity > 0.01 ? "\\" : mechanik.fAccGravity < -0.01 ? "/" :
+ "-" ) + ")"
+ "\n desired diesel percentage: " + std::to_string(mechanik.DizelPercentage)
+ "/" + std::to_string(mechanik.DizelPercentage_Speed)
+ "/" + to_string(100.4*mechanik.mvControlling->eimic_real, 0);
@@ -1331,18 +1345,18 @@ debug_panel::update_section_eventqueue( std::vector &Output ) {
Output.emplace_back( "Delay: Event:", Global.UITextColor );
- while( ( event != nullptr )
- && ( Output.size() < 30 ) ) {
+ while( event != nullptr
+ && Output.size() < 30 ) {
- if( ( false == event->m_ignored )
- && ( false == event->m_passive )
- && ( ( false == m_eventqueueactivevehicleonly )
- || ( event->m_activator == m_input.vehicle ) ) ) {
+ if( false == event->m_ignored
+ && false == event->m_passive
+ && ( false == m_eventqueueactivevehicleonly
+ || event->m_activator == m_input.vehicle ) ) {
auto const label { event->m_name + ( event->m_activator ? " (by: " + event->m_activator->asName + ")" : "" ) };
- if( ( false == searchfilter.empty() )
- && ( false == contains( label, searchfilter ) ) ) {
+ if( false == searchfilter.empty()
+ && false == contains(label, searchfilter) ) {
event = event->m_next;
continue;
}
@@ -1359,10 +1373,7 @@ debug_panel::update_section_eventqueue( std::vector &Output ) {
}
if( Output.size() == 1 ) {
// event queue can be empty either because no event got through active filters, or because it is genuinely empty
- Output.front().data = (
- simulation::Events.begin() == nullptr ?
- "(no queued events)" :
- "(no matching events)" );
+ Output.front().data = simulation::Events.begin() == nullptr ? "(no queued events)" : "(no matching events)";
}
}
@@ -1398,9 +1409,9 @@ debug_panel::update_section_powergrid( std::vector &Output ) {
Output.emplace_back(
textline,
- ( ( powerstation->FastFuse || powerstation->SlowFuse ) ? nopowercolor :
- powerstation->OutputVoltage < ( 0.8 * powerstation->NominalVoltage ) ? lowpowercolor :
- Global.UITextColor ) );
+ powerstation->FastFuse || powerstation->SlowFuse ? nopowercolor :
+ powerstation->OutputVoltage < 0.8 * powerstation->NominalVoltage ? lowpowercolor :
+ Global.UITextColor );
}
if( Output.size() == 1 ) {
diff --git a/application/editormode.cpp b/application/editormode.cpp
index 08acb959..46a8edad 100644
--- a/application/editormode.cpp
+++ b/application/editormode.cpp
@@ -71,7 +71,7 @@ namespace
return false; // degenerate or vertical triangle, no defined height
double const s = (wx * vz - vx * wz) / den;
double const t = (ux * wz - wx * uz) / den;
- if (s < 0.0 || t < 0.0 || (s + t) > 1.0)
+ if (s < 0.0 || t < 0.0 || s + t > 1.0)
return false;
OutY = a.y + s * (b.y - a.y) + t * (c.y - a.y);
return true;
@@ -86,7 +86,7 @@ namespace
for (TSubModel *sub = Submodel; sub != nullptr; sub = sub->Next)
{
glm::dmat4 mlocal = M;
- if ((sub->iFlags & 0xC000) && (sub->GetMatrix() != nullptr))
+ if (sub->iFlags & 0xC000 && sub->GetMatrix() != nullptr)
mlocal = M * glm::dmat4(glm::make_mat4(sub->GetMatrix()->readArray()));
if (sub->eType < TP_ROTATOR) // a drawable mesh, not a rotator/light/etc.
@@ -121,7 +121,7 @@ namespace
bool editor_mode::editormode_input::init()
{
- return (mouse.init() && keyboard.init());
+ return mouse.init() && keyboard.init();
}
void editor_mode::editormode_input::poll()
@@ -172,14 +172,14 @@ void editor_mode::start_focus(scene::basic_node *node, double duration)
// distance that frames the object's bounding sphere within the vertical FOV, with some margin
double const radius = std::max(1.0, static_cast(node->radius()));
double const fovy = glm::radians(static_cast(Global.FieldOfView) / std::max(0.01, static_cast(Global.ZoomFactor)));
- double distance = (radius / std::tan(fovy * 0.5)) * 1.6;
+ double distance = radius / std::tan(fovy * 0.5) * 1.6;
distance = std::clamp(distance, radius * 1.5, static_cast(kMaxPlacementDistance));
// keep the camera on the side it currently views from, so the move turns toward the object
// rather than flying around it; fall back to a pleasant 3/4 direction when sitting on top of it
glm::dvec3 dir = Camera.Pos - center;
double const len = glm::length(dir);
- dir = (len > 1e-3) ? dir / len : glm::normalize(glm::dvec3(1.0, 0.5, 1.0));
+ dir = len > 1e-3 ? dir / len : glm::normalize(glm::dvec3(1.0, 0.5, 1.0));
m_focus_start_pos = Camera.Pos;
m_focus_start_angle = Camera.Angle;
@@ -354,7 +354,7 @@ scene::basic_node* editor_mode::find_in_hierarchy(const std::string &uuid_str)
{
if (uuid_str.empty()) return nullptr;
auto it = scene::Hierarchy.find(uuid_str);
- return (it != scene::Hierarchy.end()) ? it->second : nullptr;
+ return it != scene::Hierarchy.end() ? it->second : nullptr;
}
scene::basic_node* editor_mode::find_node_by_any(scene::basic_node *node_ptr, const std::string &uuid_str, const std::string &name)
@@ -726,7 +726,7 @@ void editor_mode::render_settings()
ImGui::TextUnformatted("Camera movement");
const char *schemes[] = {"WSAD (new)", "Arrows (legacy)"};
- int current = (EditorSettings.movement() == editorSettings::movement_scheme::legacy) ? 1 : 0;
+ int current = EditorSettings.movement() == editorSettings::movement_scheme::legacy ? 1 : 0;
if (ImGui::Combo("##movement_scheme", ¤t, schemes, IM_ARRAYSIZE(schemes)))
{
EditorSettings.movement(current == 1 ? editorSettings::movement_scheme::legacy
@@ -983,8 +983,8 @@ void editor_mode::handle_chunk_edit_click(bool DeleteMode)
// if the clicked cell holds a chunk, target the neighbour nearest the clicked edge (the empty
// side); otherwise fill the clicked cell
bool const occupied = streaming
- ? (m_streamer.terrain_at(world.x, world.z) != nullptr)
- : (m_grid_chunks.count({cx, cz}) > 0);
+ ? m_streamer.terrain_at(world.x, world.z) != nullptr
+ : m_grid_chunks.count({cx, cz}) > 0;
int tcx = cx, tcz = cz;
if (occupied)
{
@@ -1081,7 +1081,7 @@ void editor_mode::handle_terrain_sculpt(double Deltatime)
return;
double const rate = m_terrain_brush_strength * Deltatime; // metres applied this frame
- double const signedrate = (Global.shiftState ? -rate : rate);
+ double const signedrate = Global.shiftState ? -rate : rate;
// apply to every chunk the brush touches; each patch clips to its own bounds, so a stroke
// crossing a chunk boundary edits both and shared-edge vertices stay in sync
for (editor_terrain *terrain : active_terrains())
@@ -1227,7 +1227,7 @@ void editor_mode::render_gizmo()
// doesn't expect; rebuild a clean, standard perspective that matches the rendered view.
// for the main viewport the engine uses a symmetric frustum with this exact fov/aspect.
float const fovy = glm::radians(Global.FieldOfView / Global.ZoomFactor);
- float const aspect = (io.DisplaySize.y > 0.0f) ? (io.DisplaySize.x / io.DisplaySize.y) : 1.0f;
+ float const aspect = io.DisplaySize.y > 0.0f ? io.DisplaySize.x / io.DisplaySize.y : 1.0f;
glm::mat4 const projection = glm::perspective(fovy, aspect, 0.1f, 10000.0f);
// rotation/scale are only meaningful for instanced models; other node types translate only
@@ -1267,7 +1267,7 @@ void editor_mode::render_gizmo()
snapvalue = glm::vec3(5.0f);
else
snapvalue = glm::vec3(0.1f);
- float const *snap = (Global.ctrlState && snapvalue.x > 0.0f) ? glm::value_ptr(snapvalue) : nullptr;
+ float const *snap = Global.ctrlState && snapvalue.x > 0.0f ? glm::value_ptr(snapvalue) : nullptr;
ImGuizmo::Manipulate(glm::value_ptr(view), glm::value_ptr(projection),
operation, mode, glm::value_ptr(matrix), nullptr, snap);
@@ -1316,7 +1316,7 @@ void editor_mode::update_camera(double const Deltatime)
if (m_focus_active)
{
m_focus_time += Deltatime;
- double t = m_focus_duration > 0.0 ? (m_focus_time / m_focus_duration) : 1.0;
+ double t = m_focus_duration > 0.0 ? m_focus_time / m_focus_duration : 1.0;
if (t >= 1.0)
t = 1.0;
// smoothstep easing
@@ -1356,7 +1356,7 @@ void editor_mode::enter()
auto const *vehicle = Camera.m_owner;
if (vehicle)
{
- const int cab = (vehicle->MoverParameters->CabOccupied == 0 ? 1 : vehicle->MoverParameters->CabOccupied);
+ const int cab = vehicle->MoverParameters->CabOccupied == 0 ? 1 : vehicle->MoverParameters->CabOccupied;
const glm::dvec3 left = vehicle->VectorLeft() * (double)cab;
Camera.Pos = glm::dvec3(Camera.Pos.x, vehicle->GetPosition().y, Camera.Pos.z) + left * vehicle->GetWidth() + glm::dvec3(1.25f * left.x, 1.6f, 1.25f * left.z);
Camera.m_owner = nullptr;
@@ -1387,7 +1387,7 @@ void editor_mode::exit()
m_gizmo_using = false;
ui()->set_node(nullptr);
- Application.set_cursor((Global.ControlPicking ? GLFW_CURSOR_NORMAL : GLFW_CURSOR_DISABLED));
+ Application.set_cursor(Global.ControlPicking ? GLFW_CURSOR_NORMAL : GLFW_CURSOR_DISABLED);
if (!Global.ControlPicking)
{
@@ -1398,9 +1398,9 @@ void editor_mode::exit()
void editor_mode::on_key(int const Key, int const Scancode, int const Action, int const Mods)
{
#ifndef __unix__
- Global.shiftState = (Mods & GLFW_MOD_SHIFT) ? true : false;
- Global.ctrlState = (Mods & GLFW_MOD_CONTROL) ? true : false;
- Global.altState = (Mods & GLFW_MOD_ALT) ? true : false;
+ Global.shiftState = Mods & GLFW_MOD_SHIFT ? true : false;
+ Global.ctrlState = Mods & GLFW_MOD_CONTROL ? true : false;
+ Global.altState = Mods & GLFW_MOD_ALT ? true : false;
#endif
bool anyModifier = Mods & (GLFW_MOD_SHIFT | GLFW_MOD_CONTROL | GLFW_MOD_ALT);
@@ -1678,11 +1678,11 @@ void editor_mode::render_change_history(){
auto &s = m_history[i];
char buf[256];
std::snprintf(buf, sizeof(buf), "%3d: %s %s pos=(%.1f,%.1f,%.1f)", i,
- (s.action == EditorSnapshot::Action::Add) ? "ADD" :
- (s.action == EditorSnapshot::Action::Delete) ? "DEL" :
- (s.action == EditorSnapshot::Action::Move) ? "MOV" :
- (s.action == EditorSnapshot::Action::Rotate) ? "ROT" :
- (s.action == EditorSnapshot::Action::Scale) ? "SCA" : "OTH",
+ s.action == EditorSnapshot::Action::Add ? "ADD" :
+ s.action == EditorSnapshot::Action::Delete ? "DEL" :
+ s.action == EditorSnapshot::Action::Move ? "MOV" :
+ s.action == EditorSnapshot::Action::Rotate ? "ROT" :
+ s.action == EditorSnapshot::Action::Scale ? "SCA" : "OTH",
s.node_name.empty() ? "(noname)" : s.node_name.c_str(),
s.position.x, s.position.y, s.position.z);
@@ -1722,7 +1722,7 @@ void editor_mode::on_event_poll()
// game-engine style camera: WSAD/EQ only fly the camera while the right mouse button is held.
// when it's released the keyboard is free for gizmo shortcuts, and we flush a zero-movement
// command once so the camera doesn't keep coasting on the last velocity it was given.
- bool const flying = (m_input.mouse.button(GLFW_MOUSE_BUTTON_RIGHT) == GLFW_PRESS);
+ bool const flying = m_input.mouse.button(GLFW_MOUSE_BUTTON_RIGHT) == GLFW_PRESS;
if (flying)
{
m_input.poll();
diff --git a/application/editoruipanels.cpp b/application/editoruipanels.cpp
index 2afcaa36..f15f791e 100644
--- a/application/editoruipanels.cpp
+++ b/application/editoruipanels.cpp
@@ -95,14 +95,14 @@ void itemproperties_panel::update(scene::basic_node *Node)
text_lines.emplace_back(textline, Global.UITextColor);
// 3d shape
- auto modelfile{((subnode->pModel != nullptr) ? subnode->pModel->NameGet() : "(none)")};
+ auto modelfile{(subnode->pModel != nullptr ? subnode->pModel->NameGet() : "(none)")};
if (modelfile.find(paths::models) == 0)
{
// don't include 'models/' in the path
modelfile.erase(0, std::string{paths::models}.size());
}
// texture
- auto texturefile{((subnode->Material()->replacable_skins[1] != null_handle) ? GfxRenderer->Material(subnode->Material()->replacable_skins[1])->GetName() : "(none)")};
+ auto texturefile{(subnode->Material()->replacable_skins[1] != null_handle ? GfxRenderer->Material(subnode->Material()->replacable_skins[1])->GetName() : "(none)")};
if (texturefile.find(paths::textures) == 0)
{
// don't include 'textures/' in the path
@@ -129,12 +129,12 @@ void itemproperties_panel::update(scene::basic_node *Node)
"\nwidth: " + std::to_string(subnode->fTrackWidth) + " m" + "\nfriction: " + to_string(subnode->fFriction, 2) + "\nquality: " + std::to_string(subnode->iQualityFlag);
text_lines.emplace_back(textline, Global.UITextColor);
// textures
- auto texturefile{((subnode->m_material1 != null_handle) ? GfxRenderer->Material(subnode->m_material1)->GetName() : "(none)")};
+ auto texturefile{(subnode->m_material1 != null_handle ? GfxRenderer->Material(subnode->m_material1)->GetName() : "(none)")};
if (texturefile.find(paths::textures) == 0)
{
texturefile.erase(0, std::string{paths::textures}.size());
}
- auto texturefile2{((subnode->m_material2 != null_handle) ? GfxRenderer->Material(subnode->m_material2)->GetName() : "(none)")};
+ auto texturefile2{(subnode->m_material2 != null_handle ? GfxRenderer->Material(subnode->m_material2)->GetName() : "(none)")};
if (texturefile2.find(paths::textures) == 0)
{
texturefile2.erase(0, std::string{paths::textures}.size());
@@ -166,13 +166,13 @@ void itemproperties_panel::update(scene::basic_node *Node)
}
textline += (textline.empty() ? "" : "\n") + eventsequence.first + ": [";
- for (auto const &event : *(eventsequence.second))
+ for (auto const &event : *eventsequence.second)
{
if (textline.back() != '[')
{
textline += ", ";
}
- textline += (event.second != nullptr ? Bezogonkow(event.second->m_name) : event.first + " (missing)");
+ textline += event.second != nullptr ? Bezogonkow(event.second->m_name) : event.first + " (missing)";
}
textline += "] ";
}
@@ -472,9 +472,9 @@ nodebank_panel::nodebank_panel(std::string const &Name, bool const Isopen) : ui_
auto groupend{groupbegin};
while (groupbegin != m_nodebank.end())
{
- groupbegin = std::find_if(groupend, m_nodebank.end(), [](auto const &Entry) { return (false == Entry.second->empty()); });
- groupend = std::find_if(groupbegin, m_nodebank.end(), [](auto const &Entry) { return (Entry.second->empty()); });
- std::sort(groupbegin, groupend, [](auto const &Left, auto const &Right) { return (Left.first < Right.first); });
+ groupbegin = std::find_if(groupend, m_nodebank.end(), [](auto const &Entry) { return false == Entry.second->empty(); });
+ groupend = std::find_if(groupbegin, m_nodebank.end(), [](auto const &Entry) { return Entry.second->empty(); });
+ std::sort(groupbegin, groupend, [](auto const &Left, auto const &Right) { return Left.first < Right.first; });
}
}
void nodebank_panel::nodebank_reload()
@@ -500,9 +500,9 @@ void nodebank_panel::nodebank_reload()
auto groupend{groupbegin};
while (groupbegin != m_nodebank.end())
{
- groupbegin = std::find_if(groupend, m_nodebank.end(), [](auto const &Entry) { return (false == Entry.second->empty()); });
- groupend = std::find_if(groupbegin, m_nodebank.end(), [](auto const &Entry) { return (Entry.second->empty()); });
- std::sort(groupbegin, groupend, [](auto const &Left, auto const &Right) { return (Left.first < Right.first); });
+ groupbegin = std::find_if(groupend, m_nodebank.end(), [](auto const &Entry) { return false == Entry.second->empty(); });
+ groupend = std::find_if(groupbegin, m_nodebank.end(), [](auto const &Entry) { return Entry.second->empty(); });
+ std::sort(groupbegin, groupend, [](auto const &Left, auto const &Right) { return Left.first < Right.first; });
}
}
@@ -566,7 +566,7 @@ void nodebank_panel::render()
{
continue;
}
- if ((false == searchfilter.empty()) && (false == contains(entry.first, searchfilter)))
+ if (false == searchfilter.empty() && false == contains(entry.first, searchfilter))
{
continue;
}
@@ -609,7 +609,7 @@ std::string nodebank_panel::generate_node_label(std::string Input) const
replace_slashes(model);
erase_extension(model);
replace_slashes(texture);
- return (texture == "none" ? model : model + " (" + texture + ")");
+ return texture == "none" ? model : model + " (" + texture + ")";
}
void functions_panel::update(scene::basic_node const *Node)
diff --git a/application/scenarioloadermode.cpp b/application/scenarioloadermode.cpp
index e49493c4..f05c3869 100644
--- a/application/scenarioloadermode.cpp
+++ b/application/scenarioloadermode.cpp
@@ -56,7 +56,7 @@ bool scenarioloader_mode::update() {
Application.pop_mode();
}
- WriteLog( "Scenario loading time: " + std::to_string( std::chrono::duration_cast( ( std::chrono::system_clock::now() - timestart ) ).count() ) + " seconds" );
+ WriteLog( "Scenario loading time: " + std::to_string( std::chrono::duration_cast( std::chrono::system_clock::now() - timestart ).count() ) + " seconds" );
// TODO: implement and use next mode cue
Application.pop_mode();
diff --git a/application/uilayer.cpp b/application/uilayer.cpp
index 0f93bddc..8dd993ed 100644
--- a/application/uilayer.cpp
+++ b/application/uilayer.cpp
@@ -474,7 +474,7 @@ void ui_layer::render_hierarchy(){
void ui_layer::set_cursor(int const Mode)
{
glfwSetInputMode(m_window, GLFW_CURSOR, Mode);
- m_cursorvisible = (Mode != GLFW_CURSOR_DISABLED);
+ m_cursorvisible = Mode != GLFW_CURSOR_DISABLED;
}
void ui_layer::set_progress(std::string const &Text)
@@ -614,7 +614,7 @@ void ui_layer::render_background()
float tex_h = (float)tex.get_height();
// skalowanie "cover" – wypełnia cały ekran, zachowując proporcje
- float scale_factor = (display_size.x / display_size.y) > (tex_w / tex_h) ? display_size.x / tex_w : display_size.y / tex_h;
+ float scale_factor = display_size.x / display_size.y > tex_w / tex_h ? display_size.x / tex_w : display_size.y / tex_h;
ImVec2 image_size(tex_w * scale_factor, tex_h * scale_factor);
diff --git a/audio/audio.cpp b/audio/audio.cpp
index e04e11cd..1c72d1bc 100644
--- a/audio/audio.cpp
+++ b/audio/audio.cpp
@@ -97,7 +97,7 @@ buffer_manager::~buffer_manager() {
for( auto &buffer : m_buffers ) {
if( buffer.id != null_resource ) {
- ::alDeleteBuffers( 1, &( buffer.id ) );
+ ::alDeleteBuffers( 1, &buffer.id );
}
}
}
diff --git a/audio/audio.h b/audio/audio.h
index 613c62c7..9d6285ec 100644
--- a/audio/audio.h
+++ b/audio/audio.h
@@ -19,7 +19,7 @@ http://mozilla.org/MPL/2.0/.
namespace audio {
-ALuint const null_resource{ ~( ALuint { 0 } ) };
+ALuint const null_resource{ ~ALuint{0} };
// wrapper for audio sample
struct openal_buffer {
diff --git a/audio/audiorenderer.cpp b/audio/audiorenderer.cpp
index 20f7a64c..bd0a0e49 100644
--- a/audio/audiorenderer.cpp
+++ b/audio/audiorenderer.cpp
@@ -32,10 +32,7 @@ limit_velocity( glm::vec3 const &Velocity ) {
auto const ratio { glm::length( Velocity ) / EU07_SOUND_VELOCITYLIMIT };
- return (
- ratio > 1.f ?
- Velocity / ratio :
- Velocity );
+ return ratio > 1.f ? Velocity / ratio : Velocity;
}
// starts playback of queued buffers
@@ -48,7 +45,7 @@ openal_source::play() {
ALint state;
::alGetSourcei( id, AL_SOURCE_STATE, &state );
- is_playing = ( state == AL_PLAYING );
+ is_playing = state == AL_PLAYING;
}
// stops the playback
@@ -90,14 +87,14 @@ openal_source::update( double const Deltatime, glm::vec3 const &Listenervelocity
// for multipart sounds trim away processed buffers until only one remains, the last one may be set to looping by the controller
// TBD, TODO: instead of change flag move processed buffer ids to separate queue, for accurate tracking of longer buffer sequences
ALuint discard;
- while( ( sound_index > 0 )
- && ( sounds.size() > 1 ) ) {
+ while( sound_index > 0
+ && sounds.size() > 1 ) {
::alSourceUnqueueBuffers( id, 1, &discard );
sounds.erase( std::begin( sounds ) );
--sound_index;
sound_change = true;
// potentially adjust starting point of the last buffer (to reduce chance of reverb effect with multiple, looping copies playing)
- if( ( controller->start() > 0.f ) && ( sounds.size() == 1 ) ) {
+ if( controller->start() > 0.f && sounds.size() == 1 ) {
ALint bufferid;
::alGetSourcei(
id,
@@ -114,7 +111,7 @@ openal_source::update( double const Deltatime, glm::vec3 const &Listenervelocity
int state;
::alGetSourcei( id, AL_SOURCE_STATE, &state );
- is_playing = ( state == AL_PLAYING );
+ is_playing = state == AL_PLAYING;
}
// request instructions from the controller
@@ -131,9 +128,9 @@ openal_source::sync_with( sound_properties const &State ) {
return;
}
// velocity
- if( ( update_deltatime > 0.0 )
- && ( sound_range >= 0 )
- && ( properties.location != glm::dvec3() ) ) {
+ if( update_deltatime > 0.0
+ && sound_range >= 0
+ && properties.location != glm::dvec3() ) {
// after sound position was initialized we can start velocity calculations
sound_velocity = limit_velocity( ( State.location - properties.location ) / update_deltatime );
}
@@ -145,10 +142,8 @@ openal_source::sync_with( sound_properties const &State ) {
if( sound_range != -1 ) {
// range cutoff check for songs other than 'unlimited'
// NOTE: since we're comparing squared distances we can ignore that sound range can be negative
- auto const cutoffrange = (
- is_multipart ?
- EU07_SOUND_CUTOFFRANGE : // we keep multi-part sounds around longer, to minimize restarts as the sounds get out and back in range
- sound_range * 7.5f );
+ auto const cutoffrange = is_multipart ? EU07_SOUND_CUTOFFRANGE : // we keep multi-part sounds around longer, to minimize restarts as the sounds get out and back in range
+ sound_range * 7.5f;
if( glm::length2( sound_distance ) > std::min( sq(cutoffrange), sq(EU07_SOUND_CUTOFFRANGE) ) ) {
stop();
sync = sync_state::bad_distance; // flag sync failure for the controller
@@ -170,9 +165,9 @@ openal_source::sync_with( sound_properties const &State ) {
State.category == sound_category::local ? Global.EnvironmentPositionalVolume :
State.category == sound_category::ambient ? Global.EnvironmentAmbientVolume :
1.f ) };
- if( ( State.gain != properties.gain )
- || ( State.soundproofing_stamp != properties.soundproofing_stamp )
- || ( audio::event_volume_change ) ) {
+ if( State.gain != properties.gain
+ || State.soundproofing_stamp != properties.soundproofing_stamp
+ || audio::event_volume_change ) {
// gain value has changed
::alSourcef( id, AL_GAIN, gain );
auto const range { (
@@ -184,8 +179,8 @@ openal_source::sync_with( sound_properties const &State ) {
if( sound_range != -1 ) {
auto const rangesquared { sound_range * sound_range };
auto const distancesquared { glm::length2( sound_distance ) };
- if( ( distancesquared > rangesquared )
- || ( false == is_in_range ) ) {
+ if( distancesquared > rangesquared
+ || false == is_in_range ) {
// if the emitter is outside of its nominal hearing range or was outside of it during last check
// adjust the volume to a suitable fraction of nominal value
auto const fadedistance { sound_range * 0.75f };
@@ -196,7 +191,7 @@ openal_source::sync_with( sound_properties const &State ) {
0.f, 1.f ) ) };
::alSourcef( id, AL_GAIN, gain * rangefactor );
}
- is_in_range = ( distancesquared <= rangesquared );
+ is_in_range = distancesquared <= rangesquared;
}
// pitch
if( State.pitch != properties.pitch ) {
@@ -245,9 +240,7 @@ openal_source::loop( bool const State ) {
::alSourcei(
id,
AL_LOOPING,
- ( State ?
- AL_TRUE :
- AL_FALSE ) );
+ State ? AL_TRUE : AL_FALSE);
}
// releases bound buffers and resets state of the class variables
@@ -376,7 +369,7 @@ openal_renderer::update( double const Deltatime ) {
// orientation
glm::dmat4 cameramatrix;
Global.pCamera.SetMatrix( cameramatrix );
- auto cameraposition = Global.pCamera.Pos + glm::dvec3((Global.viewport_move * glm::mat3(cameramatrix)));
+ auto cameraposition = Global.pCamera.Pos + glm::dvec3(Global.viewport_move * glm::mat3(cameramatrix));
cameramatrix = glm::dmat4(glm::inverse(Global.viewport_rotate)) * cameramatrix;
auto rotationmatrix { glm::mat3{ cameramatrix } };
glm::vec3 const orientation[] = {
@@ -399,7 +392,7 @@ openal_renderer::update( double const Deltatime ) {
cameramove = glm::dvec3{ 0.0 };
}
// ... from cab change
- if( ( simulation::Train != nullptr ) && ( simulation::Train->iCabn != m_activecab ) ) {
+ if( simulation::Train != nullptr && simulation::Train->iCabn != m_activecab ) {
m_activecab = simulation::Train->iCabn;
cameramove = glm::dvec3{ 0.0 };
}
@@ -454,7 +447,7 @@ openal_renderer::fetch_source() {
}
if( newsource.id == audio::null_resource ) {
// if there's no source to reuse, try to generate a new one
- ::alGenSources( 1, &( newsource.id ) );
+ ::alGenSources( 1, &newsource.id );
}
if( newsource.id == audio::null_resource ) {
alGetError();
@@ -467,23 +460,23 @@ openal_renderer::fetch_source() {
for( auto source { std::begin( m_sources ) }; source != std::cend( m_sources ); ++source ) {
- if( ( source->id == audio::null_resource )
- || ( true == source->is_multipart )
- || ( false == source->is_playing ) ) {
+ if( source->id == audio::null_resource
+ || true == source->is_multipart
+ || false == source->is_playing ) {
continue;
}
auto const sourceweight { (
source->sound_range != -1 ?
- ( source->sound_range * source->sound_range ) / ( glm::length2( source->sound_distance ) + 1 ) :
+ source->sound_range * source->sound_range / ( glm::length2( source->sound_distance ) + 1 ) :
std::numeric_limits::max() ) };
if( sourceweight < leastimportantweight ) {
leastimportantsource = source;
leastimportantweight = sourceweight;
}
}
- if( ( leastimportantsource != std::end( m_sources ) )
- && ( leastimportantweight < 1.f ) ) {
+ if( leastimportantsource != std::end(m_sources)
+ && leastimportantweight < 1.f ) {
// only accept the candidate if it's outside of its nominal hearing range
leastimportantsource->stop();
// HACK: dt of 0 is a roundabout way to notify the controller its emitter has stopped
@@ -516,11 +509,11 @@ openal_renderer::init_caps() {
auto const
*device { devices },
*next { devices + 1 };
- while( (device) && (*device != '\0') && (next) && (*next != '\0') ) {
+ while( device && *device != '\0' && next && *next != '\0' ) {
WriteLog( { device } );
auto const len { std::strlen( device ) };
- device += ( len + 1 );
- next += ( len + 2 );
+ device += len + 1;
+ next += len + 2;
}
}
diff --git a/audio/audiorenderer.h b/audio/audiorenderer.h
index 763279ce..13978fd0 100644
--- a/audio/audiorenderer.h
+++ b/audio/audiorenderer.h
@@ -34,7 +34,7 @@ struct sound_properties {
sound_category category { sound_category::unknown };
float gain { 1.f };
float soundproofing { 1.f };
- std::uintptr_t soundproofing_stamp { ~( std::uintptr_t{ 0 } ) };
+ std::uintptr_t soundproofing_stamp { ~std::uintptr_t{0} };
};
enum class sync_state {
diff --git a/audio/audiorenderer_extra.h b/audio/audiorenderer_extra.h
index 69bc2a34..430f594b 100644
--- a/audio/audiorenderer_extra.h
+++ b/audio/audiorenderer_extra.h
@@ -15,7 +15,7 @@ openal_source::bind( sound_source *Controller, uint32_sequence Sounds, Iterator_
auto const &buffer { audio::renderer.buffer( bufferhandle ) };
if (buffer.id != null_resource) buffers.emplace_back( buffer.id ); } );
- is_multipart = ( buffers.size() > 1 );
+ is_multipart = buffers.size() > 1;
if( id != audio::null_resource && !buffers.empty()) {
::alSourceQueueBuffers( id, static_cast( buffers.size() ), buffers.data() );
diff --git a/audio/sound.cpp b/audio/sound.cpp
index 59130232..0ff2eff9 100644
--- a/audio/sound.cpp
+++ b/audio/sound.cpp
@@ -55,7 +55,7 @@ sound_source::deserialize( cParser &Input, sound_type const Legacytype, int cons
std::sort(
std::begin( m_soundchunks ), std::end( m_soundchunks ),
[]( soundchunk_pair const &Left, soundchunk_pair const &Right ) {
- return ( Left.second.threshold < Right.second.threshold ); } );
+ return Left.second.threshold < Right.second.threshold; } );
// calculate and cache full range points for each chunk, including crossfade sections:
// on the far end the crossfade section extends to the threshold point of the next chunk...
for( std::size_t idx = 0; idx < m_soundchunks.size() - 1; ++idx ) {
@@ -157,7 +157,7 @@ sound_source::deserialize_mapping( cParser &Input ) {
// token can be a key or block end
std::string const key { Input.getToken( true, "\n\r\t ,;[]" ) };
- if( ( true == key.empty() ) || ( key == "}" ) ) { return false; }
+ if( true == key.empty() || key == "}" ) { return false; }
// if not block end then the key is followed by assigned value or sub-block
if( key == "soundmain:" ) {
@@ -210,10 +210,7 @@ sound_source::deserialize_mapping( cParser &Input ) {
Input.getToken( false, "\n\r\t ,;" ),
0.0f, 1.0f )
* 100.0f / 2.0f };
- m_pitchvariation = (
- variation == 0.0f ?
- 1.0f :
- 0.01f * static_cast( LocalRandom( 100.0 - variation, 100.0 + variation ) ) );
+ m_pitchvariation = variation == 0.0f ? 1.0f : 0.01f * static_cast(LocalRandom(100.0 - variation, 100.0 + variation));
}
else if( key == "startoffset:" ) {
m_startoffset =
@@ -230,7 +227,7 @@ sound_source::deserialize_mapping( cParser &Input ) {
auto const pitch { Input.getToken( false, "\n\r\t ,;" ) };
for( auto &chunk : m_soundchunks ) {
if( chunk.second.threshold == index ) {
- chunk.second.pitch = ( pitch > 0.f ? pitch : 1.f );
+ chunk.second.pitch = pitch > 0.f ? pitch : 1.f;
break;
}
}
@@ -352,8 +349,8 @@ sound_source::copy_sounds( sound_source const &Source ) {
void
sound_source::play( int const Flags ) {
- if( ( false == Global.bSoundEnabled )
- || ( true == empty() ) ) {
+ if( false == Global.bSoundEnabled
+ || true == empty() ) {
// if the sound is disabled altogether or nothing can be emitted from this source, no point wasting time
return;
}
@@ -384,10 +381,7 @@ sound_source::play( int const Flags ) {
*/
// determine sound category
// TBD, TODO: user-configurable
- m_properties.category = (
- m_owner ? sound_category::vehicle :
- m_range < 0 ? sound_category::ambient :
- sound_category::local );
+ m_properties.category = m_owner ? sound_category::vehicle : m_range < 0 ? sound_category::ambient : sound_category::local;
if( sound( sound_id::main ).buffer != null_handle ) {
// basic variant: single main sound, with optional bookends
@@ -404,8 +398,8 @@ sound_source::play_basic() {
if( false == is_playing() ) {
// dispatch appropriate sound
- if( ( true == m_playbeginning )
- && ( sound( sound_id::begin ).buffer != null_handle ) ) {
+ if( true == m_playbeginning
+ && sound(sound_id::begin).buffer != null_handle) {
std::vector sounds { sound_id::begin, sound_id::main };
insert( std::begin( sounds ), std::end( sounds ) );
m_playbeginning = false;
@@ -416,8 +410,8 @@ sound_source::play_basic() {
}
else {
// for single part non-looping samples we allow spawning multiple instances, if not prevented by set flags
- if( ( ( m_flags & ( sound_flags::exclusive | sound_flags::looping ) ) == 0 )
- && ( sound( sound_id::begin ).buffer == null_handle ) ) {
+ if( (m_flags & (sound_flags::exclusive | sound_flags::looping)) == 0
+ && sound(sound_id::begin).buffer == null_handle) {
insert( sound_id::main );
}
}
@@ -436,9 +430,8 @@ sound_source::play_combined() {
if( soundpoint < soundchunk.second.fadein ) { break; }
if( soundpoint >= soundchunk.second.fadeout ) { continue; }
- if( ( soundchunk.first.buffer == null_handle )
- || ( ( ( m_flags & ( sound_flags::exclusive | sound_flags::looping ) ) != 0 )
- && ( soundchunk.first.playing > 0 ) ) ) {
+ if( soundchunk.first.buffer == null_handle || ( (m_flags & (sound_flags::exclusive | sound_flags::looping)) != 0
+ && soundchunk.first.playing > 0 ) ) {
// combined sounds only play looped, single copy of each activated chunk
continue;
}
@@ -489,7 +482,7 @@ sound_source::compute_combined_point() const {
void
sound_source::play_event() {
- if( true == TestFlag( m_flags, ( sound_flags::event | sound_flags::looping ) ) ) {
+ if( true == TestFlag( m_flags, sound_flags::event | sound_flags::looping ) ) {
// events can potentially start scenery sounds out of the sound's audible range
// such sounds are stopped on renderer side, but unless stopped by the simulation keep their activation flags
// we use this to discern event-started sounds which should be re-activated if the listener gets close enough
@@ -510,10 +503,10 @@ sound_source::stop( bool const Skipend ) {
m_stop = true;
- if( ( false == Skipend )
- && ( sound( sound_id::end ).buffer != null_handle )
-/* && ( sound( sound_id::end ).buffer != sound( sound_id::main ).buffer ) */ // end == main can happen in malformed legacy cases
- && ( sound( sound_id::end ).playing < 2 ) ) { // allows potential single extra instance to account for longer overlapping sounds
+ if( false == Skipend
+ && sound(sound_id::end).buffer != null_handle
+ /* && ( sound( sound_id::end ).buffer != sound( sound_id::main ).buffer ) */ // end == main can happen in malformed legacy cases
+ && sound(sound_id::end).playing < 2 ) { // allows potential single extra instance to account for longer overlapping sounds
// spawn potentially defined sound end sample, if the emitter is currently active
insert( sound_id::end );
}
@@ -523,8 +516,8 @@ sound_source::stop( bool const Skipend ) {
void
sound_source::update( audio::openal_source &Source ) {
- if( ( m_owner != nullptr )
- && ( false == m_owner->bEnabled ) ) {
+ if( m_owner != nullptr
+ && false == m_owner->bEnabled ) {
// terminate the sound if the owner is gone
// TBD, TODO: replace with a listener pattern to receive vehicle removal and cab change events and such?
m_stop = true;
@@ -558,15 +551,12 @@ sound_source::update_basic( audio::openal_source &Source ) {
update_counter( sound_id::begin, -1 );
}
update_counter( soundhandle, 1 );
- Source.loop( (
- soundhandle == sound_id::main ?
- TestFlag( m_flags, sound_flags::looping ) :
- false ) );
+ Source.loop( soundhandle == sound_id::main ? TestFlag(m_flags, sound_flags::looping) : false );
}
}
- if( ( true == m_stop )
- && ( soundhandle != sound_id::end ) ) {
+ if( true == m_stop
+ && soundhandle != sound_id::end ) {
// kill the sound if stop was requested, unless it's sound bookend sample
update_counter( soundhandle, -1 );
Source.stop();
@@ -603,10 +593,7 @@ sound_source::update_basic( audio::openal_source &Source ) {
auto const soundhandle { Source.sounds[ Source.sound_index ] };
// emitter initialization
// main sample can be optionally set to loop
- Source.loop( (
- soundhandle == sound_id::main ?
- TestFlag( m_flags, sound_flags::looping ) :
- false ) );
+ Source.loop( soundhandle == sound_id::main ? TestFlag(m_flags, sound_flags::looping) : false );
Source.range( m_range );
Source.pitch( m_pitchvariation );
update_location();
@@ -662,8 +649,8 @@ sound_source::update_combined( audio::openal_source &Source ) {
}
}
- if( ( true == m_stop )
- && ( soundhandle != sound_id::end ) ) {
+ if( true == m_stop
+ && soundhandle != sound_id::end ) {
// kill the sound if stop was requested, unless it's sound bookend sample
Source.stop();
update_counter( soundhandle, -1 );
@@ -689,8 +676,8 @@ sound_source::update_combined( audio::openal_source &Source ) {
if( ( m_flags & ( sound_flags::exclusive | sound_flags::looping ) ) != 0 ) {
auto const soundpoint { compute_combined_point() };
auto const &soundchunk { m_soundchunks[ soundhandle ^ sound_id::chunk ] };
- if( ( soundpoint < soundchunk.second.fadein )
- || ( soundpoint >= soundchunk.second.fadeout ) ) {
+ if( soundpoint < soundchunk.second.fadein
+ || soundpoint >= soundchunk.second.fadeout ) {
Source.stop();
update_counter( soundhandle, -1 );
return;
@@ -722,9 +709,9 @@ sound_source::update_combined( audio::openal_source &Source ) {
// the emitter wasn't yet started
auto const soundhandle { Source.sounds[ Source.sound_index ] };
// emitter initialization
- if( ( soundhandle != sound_id::begin )
- && ( soundhandle != sound_id::end )
- && ( true == TestFlag( m_flags, sound_flags::looping ) ) ) {
+ if( soundhandle != sound_id::begin
+ && soundhandle != sound_id::end
+ && true == TestFlag(m_flags, sound_flags::looping) ) {
// main sample can be optionally set to loop
Source.loop( true );
}
@@ -791,7 +778,7 @@ sound_source::update_crossfade( sound_handle const Chunk ) {
}
else {
- if( chunkindex < ( m_soundchunks.size() - 1 ) ) {
+ if( chunkindex < m_soundchunks.size() - 1 ) {
// interpolate between this chunk's base pitch and the pitch of next chunk
// based on how far the current soundpoint is in the range of this chunk
auto const &nextchunkdata { m_soundchunks[ chunkindex + 1 ].second };
@@ -823,11 +810,11 @@ sound_source::update_crossfade( sound_handle const Chunk ) {
0.f, 1.f ) );
m_properties.gain *=
lineargain /
- (1 + (1 - lineargain) * (-0.57)); // approximation of logarytmic fade in
+ (1 + (1 - lineargain) * -0.57); // approximation of logarytmic fade in
return;
}
}
- if( chunkindex < ( m_soundchunks.size() - 1 ) ) {
+ if( chunkindex < m_soundchunks.size() - 1 ) {
// chunks other than the last can have fadeout
// TODO: cache widths in the chunk data struct?
// fadeout point of this chunk and activation threshold of the next are the same
@@ -842,7 +829,7 @@ sound_source::update_crossfade( sound_handle const Chunk ) {
( soundpoint - fadeoutstart ) / fadeoutwidth,
0.f, 1.f ) );
m_properties.gain *= (-lineargain + 1) /
- (1 + lineargain * (-0.57)); // approximation of logarytmic fade out
+ (1 + lineargain * -0.57); // approximation of logarytmic fade out
return;
}
}
@@ -875,16 +862,16 @@ bool
sound_source::empty() const {
// NOTE: we test only the main sound, won't bother playing potential bookends if this is missing
- return ( ( sound( sound_id::main ).buffer == null_handle ) && ( m_soundchunksempty ) );
+ return sound(sound_id::main).buffer == null_handle && m_soundchunksempty;
}
// returns true if the source is emitting any sound
bool
sound_source::is_playing( bool const Includesoundends ) const {
- auto isplaying { ( sound( sound_id::begin ).playing > 0 ) || ( sound( sound_id::main ).playing > 0 ) };
- if( ( false == isplaying )
- && ( false == m_soundchunks.empty() ) ) {
+ auto isplaying { sound(sound_id::begin).playing > 0 || sound(sound_id::main).playing > 0 };
+ if( false == isplaying
+ && false == m_soundchunks.empty() ) {
// for emitters with sample tables check also if any of the chunks is active
for( auto const &soundchunk : m_soundchunks ) {
if( soundchunk.first.playing > 0 ) {
@@ -900,21 +887,21 @@ sound_source::is_playing( bool const Includesoundends ) const {
bool
sound_source::is_combined() const {
- return ( ( !m_soundchunks.empty() ) && ( sound( sound_id::main ).buffer == null_handle ) );
+ return !m_soundchunks.empty() && sound(sound_id::main).buffer == null_handle;
}
// returns true if specified buffer is one of the optional bookends
bool
sound_source::is_bookend( audio::buffer_handle const Buffer ) const {
- return ( ( sound( sound_id::begin ).buffer == Buffer ) || ( sound( sound_id::end ).buffer == Buffer ) );
+ return sound(sound_id::begin).buffer == Buffer || sound(sound_id::end).buffer == Buffer;
}
// returns true if the source has optional bookends
bool
sound_source::has_bookends() const {
- return ( ( sound( sound_id::begin ).buffer != null_handle ) && ( sound( sound_id::end ).buffer != null_handle ) );
+ return sound(sound_id::begin).buffer != null_handle && sound(sound_id::end).buffer != null_handle;
}
// returns location of the sound source in simulation region space
@@ -951,8 +938,8 @@ sound_source::update_counter( sound_handle const Sound, int const Value ) {
// sound( Sound ).playing = std::max( 0, sound( Sound ).playing + Value );
sound( Sound ).playing += Value;
- if( ( m_properties.gain > 0.f )
- && ( sound( Sound ).playing == 1 ) ) {
+ if( m_properties.gain > 0.f
+ && sound(Sound).playing == 1 ) {
auto const &buffer { audio::renderer.buffer( sound( Sound ).buffer ) };
if( false == buffer.caption.empty() ) {
ui::Transcripts.Add( buffer.caption );
@@ -998,19 +985,18 @@ sound_source::update_soundproofing() {
// TBD, TODO: clean up parameters for soundproofing() call -- make ambient separate, explicit placement
m_properties.soundproofing = EU07_SOUNDPROOFING_NONE; // default proofing for environment sounds and free listener
if( m_placement != sound_placement::general ) {
- auto const isambient { ( ( m_placement == sound_placement::external ) && ( m_owner == nullptr ) && ( m_range < -1 ) ? 1 : 0 ) };
+ auto const isambient { ( m_placement == sound_placement::external && m_owner == nullptr && m_range < -1 ? 1 : 0 ) };
auto const placement { ( isambient ? sound_placement::external_ambient : m_placement ) };
if( m_owner != nullptr ) {
auto const listenerlocation { (
m_owner != listenervehicle ?
4 : // part of two-stage calculation owner->outside->listener, or single stage owner->outside one
occupiedcab ) };
- m_properties.soundproofing = (
- m_soundproofing ? // custom soundproofing has higher priority than that of the owner
- m_soundproofing.value()[ listenerlocation + 1 ] : // cab indices start from -1 so we have to account for this
- m_owner->soundproofing( static_cast( placement ), listenerlocation ) );
+ m_properties.soundproofing = m_soundproofing ? // custom soundproofing has higher priority than that of the owner
+ m_soundproofing.value()[listenerlocation + 1] : // cab indices start from -1 so we have to account for this
+ m_owner->soundproofing(static_cast(placement), listenerlocation);
}
- if( ( listenervehicle ) && ( listenervehicle != m_owner ) ) {
+ if( listenervehicle && listenervehicle != m_owner ) {
// if the listener is located in another vehicle, calculate additional proofing of the sound coming from outside
m_properties.soundproofing *=
listenervehicle->soundproofing(
@@ -1037,17 +1023,11 @@ sound_source::insert( sound_handle const Sound ) {
sound_source::sound_data &
sound_source::sound( sound_handle const Sound ) {
- return (
- ( Sound & sound_id::chunk ) == sound_id::chunk ?
- m_soundchunks[ Sound ^ sound_id::chunk ].first :
- m_sounds[ Sound ] );
+ return (Sound & sound_id::chunk) == sound_id::chunk ? m_soundchunks[Sound ^ sound_id::chunk].first : m_sounds[Sound];
}
sound_source::sound_data const &
sound_source::sound( sound_handle const Sound ) const {
- return (
- ( Sound & sound_id::chunk ) == sound_id::chunk ?
- m_soundchunks[ Sound ^ sound_id::chunk ].first :
- m_sounds[ Sound ] );
+ return (Sound & sound_id::chunk) == sound_id::chunk ? m_soundchunks[Sound ^ sound_id::chunk].first : m_sounds[Sound];
}
diff --git a/audio/sound.h b/audio/sound.h
index ff85ec03..c0f14513 100644
--- a/audio/sound.h
+++ b/audio/sound.h
@@ -173,7 +173,7 @@ private:
main,
end,
// 31 bits for index into relevant array, msb selects between the sample table and the basic array
- chunk = ( 1u << 31 )
+ chunk = 1u << 31
};
// methods
diff --git a/environment/moon.cpp b/environment/moon.cpp
index 80e34f70..0cd4ce7d 100644
--- a/environment/moon.cpp
+++ b/environment/moon.cpp
@@ -68,14 +68,14 @@ float cMoon::getIntensity() {
// which roughly matches how much sunlight is reflected by the moon
// We alter the intensity further based on current phase of the moon
auto const phasefactor = 1.0f - std::abs( m_phase - 29.53f * 0.5f ) / ( 29.53f * 0.5f );
- return static_cast( ( m_body.etr/ 1399.0 ) * phasefactor * 0.15 ); // arbitrary scaling factor taken from etrn value
+ return static_cast( m_body.etr / 1399.0 * phasefactor * 0.15 ); // arbitrary scaling factor taken from etrn value
}
void cMoon::setLocation( float const Longitude, float const Latitude ) {
// convert fraction from geographical base of 6o minutes
- m_observer.longitude = (int)Longitude + (Longitude - (int)(Longitude)) * 100.0 / 60.0;
- m_observer.latitude = (int)Latitude + (Latitude - (int)(Latitude)) * 100.0 / 60.0 ;
+ m_observer.longitude = (int)Longitude + (Longitude - (int)Longitude) * 100.0 / 60.0;
+ m_observer.latitude = (int)Latitude + (Latitude - (int)Latitude) * 100.0 / 60.0 ;
}
// sets current time, overriding one acquired from the system clock
@@ -120,7 +120,7 @@ void cMoon::move() {
+ 275 * localtime.wMonth / 9
+ localtime.wDay
- 730530
- + ( localut / 24.0 );
+ + localut / 24.0;
// Universal Coordinated (Greenwich standard) time
m_observer.utime = localut - m_observer.timezone;
@@ -254,7 +254,7 @@ void cMoon::refract() {
else
refcor = -20.774 / tanelev;
- prestemp = ( m_observer.press * 283.0 ) / ( 1013.0 * ( 273.0 + m_observer.temp ) );
+ prestemp = m_observer.press * 283.0 / ( 1013.0 * ( 273.0 + m_observer.temp ) );
refcor *= prestemp / 3600.0;
}
@@ -295,7 +295,7 @@ void cMoon::irradiance() {
void
cMoon::phase() {
SYSTEMTIME lt = simulation::Time.data();
- if ((lt.wMonth==5)&&(lt.wDay==4)) //May the forth be with you!
+ if (lt.wMonth == 5 && lt.wDay == 4) //May the forth be with you!
m_phase = 50;
else {
// calculate moon's age in days from new moon
diff --git a/environment/sky.cpp b/environment/sky.cpp
index 6bab884c..f3f09f82 100644
--- a/environment/sky.cpp
+++ b/environment/sky.cpp
@@ -17,8 +17,8 @@ http://mozilla.org/MPL/2.0/.
void TSky::Init() {
- if( ( Global.asSky != "1" )
- && ( Global.asSky != "0" ) ) {
+ if (Global.asSky != "1"
+ && Global.asSky != "0" ) {
mdCloud = TModelsManager::GetModel( Global.asSky );
}
diff --git a/environment/skydome.cpp b/environment/skydome.cpp
index 08bde1da..f5b936f5 100644
--- a/environment/skydome.cpp
+++ b/environment/skydome.cpp
@@ -71,13 +71,13 @@ void CSkyDome::Generate() {
for( int i = 0; i <= latitudes; ++i ) {
- float const latitude = M_PI * ( -0.5f + (float)( i ) / latitudes / 2 ); // half-sphere only
+ float const latitude = M_PI * ( -0.5f + (float)i / latitudes / 2 ); // half-sphere only
float const z = std::sin( latitude );
float const zr = std::cos( latitude );
for( int j = 0; j <= longitudes; ++j ) {
- float const longitude = 2.0 * M_PI * (float)( j ) / longitudes;
+ float const longitude = 2.0 * M_PI * (float)j / longitudes;
float const x = std::cos( longitude );
float const y = std::sin( longitude );
/*
@@ -89,7 +89,7 @@ void CSkyDome::Generate() {
m_vertices.emplace_back( glm::vec3( -x * zr, -z - offset, -y * zr ) * radius );
m_colours.emplace_back( glm::vec3( 0.75f, 0.75f, 0.75f ) ); // placeholder
- if( (i == 0) || (j == 0) ) {
+ if( i == 0 || j == 0 ) {
// initial edge of the dome, don't start indices yet
++index;
}
@@ -188,8 +188,8 @@ void CSkyDome::RebuildColors() {
auto gammacorrection = glm::mix( glm::vec3( 1.0f ), glm::vec3( 0.45f ), twilightfactor );
// get zenith luminance
- float const chi = ( (4.0f / 9.0f) - (m_turbidity / 120.0f) ) * ( M_PI - (2.0f * m_thetasun) );
- float zenithluminance = ( (4.0453f * m_turbidity) - 4.9710f ) * std::tan( chi ) - (0.2155f * m_turbidity) + 2.4192f;
+ float const chi = ( 4.0f / 9.0f - m_turbidity / 120.0f ) * ( M_PI - 2.0f * m_thetasun );
+ float zenithluminance = ( 4.0453f * m_turbidity - 4.9710f ) * std::tan( chi ) - 0.2155f * m_turbidity + 2.4192f;
// get x / y zenith
float zenithx = GetZenith( m_zenithxmatrix, m_thetasun, m_turbidity );
@@ -243,8 +243,8 @@ void CSkyDome::RebuildColors() {
float const yover = std::max( 0.01f, zenithluminance * ( 1.0f + 2.0f * vertex.y ) / 3.0f );
float const Y = std::lerp( yclear, yover, m_overcast );
- float const X = (x / y) * Y;
- float const Z = ((1.0f - x - y) / y) * Y;
+ float const X = x / y * Y;
+ float const Z = (1.0f - x - y) / y * Y;
colorconverter = glm::vec3( X, Y, Z );
color = colors::XYZtoRGB( colorconverter );
@@ -263,13 +263,13 @@ void CSkyDome::RebuildColors() {
colorconverter.y = std::clamp( colorconverter.y * Global.m_skysaturationcorrection, 0.0f, 1.0f );
// desaturate sky colour, based on overcast level
if( colorconverter.y > 0.0f ) {
- colorconverter.y *= ( 1.0f - 0.5f * m_overcast );
+ colorconverter.y *= 1.0f - 0.5f * m_overcast;
}
// override the hue, based on sun height above the horizon. crude way to deal with model shortcomings
// correction begins when the sun is higher than 10 degrees above the horizon, and fully in effect at 10+15 degrees
float const degreesabovehorizon = 90.0f - m_thetasun * ( 180.0f / M_PI );
- auto const sunbasedphase = std::clamp( (1.0f / 15.0f) * ( degreesabovehorizon - 10.0f ), 0.0f, 1.0f );
+ auto const sunbasedphase = std::clamp( 1.0f / 15.0f * ( degreesabovehorizon - 10.0f ), 0.0f, 1.0f );
// correction is applied in linear manner from the bottom, becomes fully in effect for vertices with y = 0.50
auto const heightbasedphase = std::clamp( vertex.y * 2.0f, 0.0f, 1.0f );
// this height-based factor is reduced the farther the sun is up in the sky
@@ -282,8 +282,8 @@ void CSkyDome::RebuildColors() {
// crude correction for the times where the model breaks (late night)
// TODO: use proper night sky calculation for these times instead
- if( ( color.x <= 0.05f )
- && ( color.y <= 0.05f ) ) {
+ if( color.x <= 0.05f
+ && color.y <= 0.05f ) {
// darken the sky as the sun goes deeper below the horizon
// 15:50:75 is picture-based night sky colour. it may not be accurate but looks 'right enough'
color.z = 0.75f * std::max( color.z + m_sundirection.y, 0.075f );
@@ -291,7 +291,7 @@ void CSkyDome::RebuildColors() {
color.y = 0.65f * color.z;
}
// simple gradient, darkening towards the top
- color *= std::clamp( ( 1.0f - vertex.y * 0.75f ), 0.0f, 1.f );
+ color *= std::clamp( 1.0f - vertex.y * 0.75f, 0.0f, 1.f );
float const horizonboost = 1.5f + m_overcast;
float const horizonbandwidth = 0.2f; // boost tapers to 0 by ~11.5 degrees elevation
@@ -302,7 +302,7 @@ void CSkyDome::RebuildColors() {
//color *= ( 0.25f - vertex.y );
m_colours[ i ] = color;
averagecolor += color;
- if( ( m_vertices.size() - i ) <= ( m_tesselation * 10 + 10 ) ) {
+ if( m_vertices.size() - i <= m_tesselation * 10 + 10 ) {
// calculate horizon colour from the bottom band of tris
averagehorizoncolor += color;
}
diff --git a/environment/sun.cpp b/environment/sun.cpp
index a4b6edf3..1ecd94ed 100644
--- a/environment/sun.cpp
+++ b/environment/sun.cpp
@@ -79,8 +79,8 @@ float cSun::getIntensity() {
void cSun::setLocation( float const Longitude, float const Latitude ) {
// convert fraction from geographical base of 6o minutes
- m_observer.longitude = (int)Longitude + (Longitude - (int)(Longitude)) * 100.0 / 60.0;
- m_observer.latitude = (int)Latitude + (Latitude - (int)(Latitude)) * 100.0 / 60.0 ;
+ m_observer.longitude = (int)Longitude + (Longitude - (int)Longitude) * 100.0 / 60.0;
+ m_observer.latitude = (int)Latitude + (Latitude - (int)Latitude) * 100.0 / 60.0 ;
}
// sets current time, overriding one acquired from the system clock
@@ -125,7 +125,7 @@ void cSun::move() {
+ 275 * localtime.wMonth / 9
+ localtime.wDay
- 730530
- + ( localut / 24.0 );
+ + localut / 24.0;
// Universal Coordinated (Greenwich standard) time
m_observer.utime = localut - m_observer.timezone;
@@ -228,7 +228,7 @@ void cSun::refract() {
else
refcor = -20.774 / tanelev;
- prestemp = ( m_observer.press * 283.0 ) / ( 1013.0 * ( 273.0 + m_observer.temp ) );
+ prestemp = m_observer.press * 283.0 / ( 1013.0 * ( 273.0 + m_observer.temp ) );
refcor *= prestemp / 3600.0;
}
diff --git a/input/command.cpp b/input/command.cpp
index dc4ff462..9a373fef 100644
--- a/input/command.cpp
+++ b/input/command.cpp
@@ -888,10 +888,9 @@ command_relay::post(user_command const Command, double const Param1, double cons
Recipient = simulation::Train->id();
}
- if( ( command.target == command_target::vehicle )
- && ( true == FreeFlyModeFlag )
- && ( ( false == DebugModeFlag )
- && ( true == Global.RealisticControlMode ) ) ) {
+ if( command.target == command_target::vehicle
+ && true == FreeFlyModeFlag
+ && false == DebugModeFlag && true == Global.RealisticControlMode ) {
// in realistic control mode don't pass vehicle commands if the user isn't in one, unless we're in debug mode
return;
}
diff --git a/input/command.h b/input/command.h
index b12063db..7ff5b272 100644
--- a/input/command.h
+++ b/input/command.h
@@ -490,7 +490,7 @@ private:
// hash operator for m_active_continuous
struct command_set_hash {
uint64_t operator() (const std::pair &pair) const {
- return ((uint64_t)pair.first << 32) | ((uint64_t) pair.second);
+ return (uint64_t)pair.first << 32 | (uint64_t)pair.second;
}
};
diff --git a/input/drivermouseinput.cpp b/input/drivermouseinput.cpp
index 8f96dc24..434f8be5 100644
--- a/input/drivermouseinput.cpp
+++ b/input/drivermouseinput.cpp
@@ -34,12 +34,12 @@ mouse_slider::bind( user_command const &Command ) {
case user_command::jointcontrollerset:
case user_command::mastercontrollerset:
case user_command::secondcontrollerset: {
- vehicle = ( train ? train->Controlled() : nullptr );
+ vehicle = train ? train->Controlled() : nullptr;
break;
}
case user_command::trainbrakeset:
case user_command::independentbrakeset: {
- vehicle = ( train ? train->Occupied() : nullptr );
+ vehicle = train ? train->Occupied() : nullptr;
break;
}
default: {
@@ -74,14 +74,8 @@ mouse_slider::bind( user_command const &Command ) {
break;
}
case user_command::mastercontrollerset: {
- m_valuerange = (
- vehicle->CoupledCtrl ?
- vehicle->MainCtrlPosNo + vehicle->ScndCtrlPosNo :
- vehicle->MainCtrlPosNo );
- m_value = (
- vehicle->CoupledCtrl ?
- vehicle->MainCtrlPos + vehicle->ScndCtrlPos :
- vehicle->MainCtrlPos );
+ m_valuerange = vehicle->CoupledCtrl ? vehicle->MainCtrlPosNo + vehicle->ScndCtrlPosNo : vehicle->MainCtrlPosNo;
+ m_value = vehicle->CoupledCtrl ? vehicle->MainCtrlPos + vehicle->ScndCtrlPos : vehicle->MainCtrlPos;
m_analogue = false;
m_invertrange = false;
break;
@@ -126,9 +120,7 @@ mouse_slider::bind( user_command const &Command ) {
Application.set_cursor_pos(
Global.window_size.y,
- ( m_analogue ?
- controledge - m_value * controlsize :
- controledge - m_value * stepsize - 0.5 * stepsize ) );
+ m_analogue ? controledge - m_value * controlsize : controledge - m_value * stepsize - 0.5 * stepsize );
}
void
@@ -147,10 +139,7 @@ mouse_slider::on_move( double const Mousex, double const Mousey ) {
auto const stepsize { controlsize / m_valuerange };
auto mousey = std::clamp( Mousey, controledge - controlsize, controledge );
- m_value = (
- m_analogue ?
- ( controledge - mousey ) / controlsize :
- std::floor( ( controledge - mousey ) / stepsize ) );
+ m_value = m_analogue ? (controledge - mousey) / controlsize : std::floor((controledge - mousey) / stepsize);
if( m_invertrange ) {
m_value = ( m_analogue ? 1.0 : m_valuerange ) - m_value; }
}
@@ -309,7 +298,7 @@ drivermouse_input::scroll( double const Xoffset, double const Yoffset ) {
// TODO: allow configurable scroll commands
auto command {
adjust_command(
- ( Yoffset > 0.0 ) ?
+ Yoffset > 0.0 ?
m_wheelbindings.up :
m_wheelbindings.down ) };
@@ -340,24 +329,20 @@ drivermouse_input::button( int const Button, int const Action ) {
if( Action == GLFW_PRESS ) {
GfxRenderer->Pick_Node_Callback(
[this](scene::basic_node *node) {
- if( ( node == nullptr )
- || ( typeid( *node ) != typeid( TAnimModel ) ) )
+ if( node == nullptr
+ || typeid(*node) != typeid(TAnimModel) )
return;
simulation::Region->on_click( static_cast( node ) ); } );
}
}
// right button controls panning
if( Button == GLFW_MOUSE_BUTTON_RIGHT ) {
- m_pickmodepanning = ( Action == GLFW_PRESS );
+ m_pickmodepanning = Action == GLFW_PRESS;
}
}
else {
// cab controls mode
- user_command &mousecommand = (
- Button == GLFW_MOUSE_BUTTON_LEFT ?
- m_mousecommandleft :
- m_mousecommandright
- );
+ user_command &mousecommand = Button == GLFW_MOUSE_BUTTON_LEFT ? m_mousecommandleft : m_mousecommandright;
if( Action == GLFW_RELEASE ) {
if( mousecommand != user_command::none ) {
@@ -401,11 +386,7 @@ drivermouse_input::button( int const Button, int const Action ) {
auto const controlbindings { bindings( simulation::Train->GetLabel( control ) ) };
// if the recognized element under the cursor has a command associated with the pressed button, notify the recipient
- mousecommand = (
- Button == GLFW_MOUSE_BUTTON_LEFT ?
- controlbindings.first :
- controlbindings.second
- );
+ mousecommand = Button == GLFW_MOUSE_BUTTON_LEFT ? controlbindings.first : controlbindings.second;
if( mousecommand == user_command::none ) {
// if we don't have any recognized element under the cursor and the right button was pressed, enter view panning mode
@@ -504,10 +485,7 @@ drivermouse_input::poll() {
user_command
drivermouse_input::command() const {
- return (
- m_slider.command() != user_command::none ? m_slider.command() :
- m_mousecommandleft != user_command::none ? m_mousecommandleft :
- m_mousecommandright );
+ return m_slider.command() != user_command::none ? m_slider.command() : m_mousecommandleft != user_command::none ? m_mousecommandleft : m_mousecommandright;
}
// returns pair of bindings associated with specified cab control
@@ -1151,8 +1129,8 @@ drivermouse_input::default_bindings() {
user_command
drivermouse_input::adjust_command( user_command Command ) {
- if( ( true == Global.shiftState )
- && ( Command != user_command::none ) ) {
+ if( true == Global.shiftState
+ && Command != user_command::none ) {
switch( Command ) {
case user_command::mastercontrollerincrease: { Command = user_command::mastercontrollerincreasefast; break; }
case user_command::mastercontrollerdecrease: { Command = user_command::mastercontrollerdecreasefast; break; }
diff --git a/input/editormouseinput.cpp b/input/editormouseinput.cpp
index ed8d96c1..6daa542c 100644
--- a/input/editormouseinput.cpp
+++ b/input/editormouseinput.cpp
@@ -55,9 +55,9 @@ editormouse_input::button( int const Button, int const Action ) {
// right button controls panning
if( Button == GLFW_MOUSE_BUTTON_RIGHT ) {
- bool const panning = ( Action == GLFW_PRESS );
+ bool const panning = Action == GLFW_PRESS;
// when panning starts, request a one-frame resync so toggling the cursor grab doesn't jerk the view
- if( panning && ( false == m_pickmodepanning ) ) {
+ if( panning && false == m_pickmodepanning ) {
m_pickmodepanning_resync = true;
}
m_pickmodepanning = panning;
diff --git a/input/gamepadinput.cpp b/input/gamepadinput.cpp
index 93453d89..d2118354 100644
--- a/input/gamepadinput.cpp
+++ b/input/gamepadinput.cpp
@@ -95,9 +95,7 @@ gamepad_input::poll() {
// button pressed or released, both are important
on_button(
idx,
- ( buttons[ idx ] == 1 ?
- GLFW_PRESS :
- GLFW_RELEASE ) );
+ buttons[idx] == 1 ? GLFW_PRESS : GLFW_RELEASE);
}
else {
// otherwise we only pass info about button being held down
@@ -476,10 +474,7 @@ gamepad_input::process_axes() {
param = 0.0;
}
else {
- param = (
- param > 0.0 ?
- ( param - m_deadzone ) / ( 1.0 - m_deadzone ) :
- ( param + m_deadzone ) / ( 1.0 - m_deadzone ) );
+ param = param > 0.0 ? (param - m_deadzone) / (1.0 - m_deadzone) : (param + m_deadzone) / (1.0 - m_deadzone);
}
if( param != 0.0 ) {
if( inputtype == input_type::value_invert ) {
@@ -515,8 +510,8 @@ gamepad_input::process_axes() {
auto const param1 { std::get<0>( command.second ) };
auto const param2 { std::get<1>( command.second ) };
auto &lastparams { m_lastcommandparams[ command.first ] };
- if( ( param1 != 0.0 ) || ( std::get<0>( lastparams ) != 0.0 )
- || ( param2 != 0.0 ) || ( std::get<1>( lastparams ) != 0.0 ) ) {
+ if( param1 != 0.0 || std::get<0>(lastparams) != 0.0
+ || param2 != 0.0 || std::get<1>(lastparams) != 0.0 ) {
m_relay.post(
command.first,
param1,
diff --git a/input/keyboardinput.cpp b/input/keyboardinput.cpp
index b8f5e823..c5aedbdf 100644
--- a/input/keyboardinput.cpp
+++ b/input/keyboardinput.cpp
@@ -220,7 +220,7 @@ keyboard_input::recall_bindings() {
else {
// replace any existing binding, preserve modifiers
// (protection from cases where there's more than one key listed in the entry)
- keycode = keylookup->second | ( keycode & 0xffff0000 );
+ keycode = keylookup->second | keycode & 0xffff0000;
}
}
}
@@ -272,29 +272,23 @@ keyboard_input::key( int const Key, int const Action ) {
bool modifier( false );
- if( ( Key == GLFW_KEY_LEFT_SHIFT ) || ( Key == GLFW_KEY_RIGHT_SHIFT ) ) {
+ if( Key == GLFW_KEY_LEFT_SHIFT || Key == GLFW_KEY_RIGHT_SHIFT) {
// update internal state, but don't bother passing these
input::key_shift =
- ( Action == GLFW_RELEASE ?
- false :
- true );
+ Action == GLFW_RELEASE ? false : true;
modifier = true;
// whenever shift key is used it may affect currently pressed movement keys, so check and update these
}
- if( ( Key == GLFW_KEY_LEFT_CONTROL ) || ( Key == GLFW_KEY_RIGHT_CONTROL ) ) {
+ if( Key == GLFW_KEY_LEFT_CONTROL || Key == GLFW_KEY_RIGHT_CONTROL) {
// update internal state, but don't bother passing these
input::key_ctrl =
- ( Action == GLFW_RELEASE ?
- false :
- true );
+ Action == GLFW_RELEASE ? false : true;
modifier = true;
}
- if( ( Key == GLFW_KEY_LEFT_ALT ) || ( Key == GLFW_KEY_RIGHT_ALT ) ) {
+ if( Key == GLFW_KEY_LEFT_ALT || Key == GLFW_KEY_RIGHT_ALT) {
// update internal state, but don't bother passing these
input::key_alt =
- ( Action == GLFW_RELEASE ?
- false :
- true );
+ Action == GLFW_RELEASE ? false : true;
}
if( Key == -1 ) { return false; }
@@ -310,8 +304,8 @@ keyboard_input::key( int const Key, int const Action ) {
// include active modifiers for currently pressed key, except if the key is a modifier itself
auto key =
Key
- | ( modifier ? 0 : ( input::key_shift ? keymodifier::shift : 0 ) )
- | ( modifier ? 0 : ( input::key_ctrl ? keymodifier::control : 0 ) );
+ | ( modifier ? 0 : input::key_shift ? keymodifier::shift : 0 )
+ | ( modifier ? 0 : input::key_ctrl ? keymodifier::control : 0 );
if( Action == GLFW_RELEASE ) {
auto const stored = m_modsforkeys.find( Key );
@@ -333,10 +327,7 @@ keyboard_input::key( int const Key, int const Action ) {
// as we haven't yet implemented either item id system or multiplayer, the 'local' controlled vehicle and entity have temporary ids of 0
// TODO: pass correct entity id once the missing systems are in place
m_relay.post( lookup->second, 0, 0, Action, 0 );
- m_command = (
- Action == GLFW_RELEASE ?
- user_command::none :
- lookup->second );
+ m_command = Action == GLFW_RELEASE ? user_command::none : lookup->second;
return true;
}
@@ -380,12 +371,7 @@ bool
keyboard_input::is_movement_key( int const Key ) const {
bool const ismovementkey =
- ( ( Key == m_bindingscache.forward )
- || ( Key == m_bindingscache.back )
- || ( Key == m_bindingscache.left )
- || ( Key == m_bindingscache.right )
- || ( Key == m_bindingscache.up )
- || ( Key == m_bindingscache.down ) );
+ Key == m_bindingscache.forward || Key == m_bindingscache.back || Key == m_bindingscache.left || Key == m_bindingscache.right || Key == m_bindingscache.up || Key == m_bindingscache.down;
return ismovementkey;
}
@@ -395,22 +381,20 @@ keyboard_input::poll() {
glm::vec2 const movementhorizontal {
// x-axis
- ( Global.shiftState ? 1.f : (2.0f / 3.0f) ) *
+ ( Global.shiftState ? 1.f : 2.0f / 3.0f ) *
( input::keys[ m_bindingscache.left ] != GLFW_RELEASE ? -1.f :
input::keys[ m_bindingscache.right ] != GLFW_RELEASE ? 1.f :
0.f ),
// z-axis
- ( Global.shiftState ? 1.f : (2.0f / 3.0f) ) *
+ ( Global.shiftState ? 1.f : 2.0f / 3.0f ) *
( input::keys[ m_bindingscache.forward ] != GLFW_RELEASE ? 1.f :
input::keys[ m_bindingscache.back ] != GLFW_RELEASE ? -1.f :
0.f ) };
- if( ( movementhorizontal.x != 0.f || movementhorizontal.y != 0.f )
- || ( m_movementhorizontal.x != 0.f || m_movementhorizontal.y != 0.f ) ) {
+ if( movementhorizontal.x != 0.f || movementhorizontal.y != 0.f
+ || m_movementhorizontal.x != 0.f || m_movementhorizontal.y != 0.f ) {
m_relay.post(
- ( true == Global.ctrlState ?
- user_command::movehorizontalfast :
- user_command::movehorizontal ),
+ true == Global.ctrlState ? user_command::movehorizontalfast : user_command::movehorizontal,
movementhorizontal.x,
movementhorizontal.y,
GLFW_PRESS,
@@ -421,17 +405,15 @@ keyboard_input::poll() {
float const movementvertical {
// y-axis
- ( Global.shiftState ? 1.f : (2.0f / 3.0f) ) *
+ ( Global.shiftState ? 1.f : 2.0f / 3.0f ) *
( input::keys[ m_bindingscache.up ] != GLFW_RELEASE ? 1.f :
input::keys[ m_bindingscache.down ] != GLFW_RELEASE ? -1.f :
0.f ) };
- if( ( movementvertical != 0.f )
- || ( m_movementvertical != 0.f ) ) {
+ if( movementvertical != 0.f
+ || m_movementvertical != 0.f ) {
m_relay.post(
- ( true == Global.ctrlState ?
- user_command::moveverticalfast :
- user_command::movevertical ),
+ true == Global.ctrlState ? user_command::moveverticalfast : user_command::movevertical,
movementvertical,
0,
GLFW_PRESS,
diff --git a/input/messaging.cpp b/input/messaging.cpp
index b3c48f40..36ed853c 100644
--- a/input/messaging.cpp
+++ b/input/messaging.cpp
@@ -59,14 +59,14 @@ OnCommandGet(multiplayer::DaneRozkaz *pRozkaz)
case 2: {
// event
CommLog( Now() + " " + std::to_string( pRozkaz->iComm ) + " " +
- std::string( pRozkaz->cString + 1, (unsigned)( pRozkaz->cString[ 0 ] ) ) + " rcvd" );
+ std::string( pRozkaz->cString + 1, (unsigned)pRozkaz->cString[0] ) + " rcvd" );
if( Global.iMultiplayer ) {
- auto *event = simulation::Events.FindEvent( std::string( pRozkaz->cString + 1, (unsigned)( pRozkaz->cString[ 0 ] ) ) );
+ auto *event = simulation::Events.FindEvent( std::string( pRozkaz->cString + 1, (unsigned)pRozkaz->cString[0] ) );
if( event != nullptr ) {
- if( ( typeid( *event ) == typeid( multi_event ) )
- || ( typeid( *event ) == typeid( lights_event ) )
- || ( event->m_sibling != 0 ) ) {
+ if( typeid(*event) == typeid(multi_event)
+ || typeid(*event) == typeid(lights_event)
+ || event->m_sibling != 0 ) {
// tylko jawne albo niejawne Multiple
command_relay relay;
relay.post(user_command::queueevent, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &event->name());
@@ -81,12 +81,12 @@ OnCommandGet(multiplayer::DaneRozkaz *pRozkaz)
int i = int(pRozkaz->cString[8]); // długość pierwszego łańcucha (z przodu dwa floaty)
CommLog(
Now() + " " + std::to_string(pRozkaz->iComm) + " " +
- std::string(pRozkaz->cString + 11 + i, (unsigned)(pRozkaz->cString[10 + i])) +
+ std::string(pRozkaz->cString + 11 + i, (unsigned)pRozkaz->cString[10 + i]) +
" rcvd");
// nazwa pojazdu jest druga
auto *vehicle = simulation::Vehicles.find( { pRozkaz->cString + 11 + i, (unsigned)pRozkaz->cString[ 10 + i ] } );
- if( ( vehicle != nullptr )
- && ( vehicle->Mechanik != nullptr ) ) {
+ if( vehicle != nullptr
+ && vehicle->Mechanik != nullptr ) {
vehicle->Mechanik->PutCommand(
{ pRozkaz->cString + 9, static_cast(i) },
pRozkaz->fPar[0], pRozkaz->fPar[1],
@@ -99,11 +99,11 @@ OnCommandGet(multiplayer::DaneRozkaz *pRozkaz)
case 4: // badanie zajętości toru
{
CommLog(Now() + " " + std::to_string(pRozkaz->iComm) + " " +
- std::string(pRozkaz->cString + 1, (unsigned)(pRozkaz->cString[0])) + " rcvd");
+ std::string(pRozkaz->cString + 1, (unsigned)pRozkaz->cString[0]) + " rcvd");
- auto *track = simulation::Paths.find( std::string( pRozkaz->cString + 1, (unsigned)( pRozkaz->cString[ 0 ] ) ) );
- if( ( track != nullptr )
- && ( track->IsEmpty() ) ) {
+ auto *track = simulation::Paths.find( std::string( pRozkaz->cString + 1, (unsigned)pRozkaz->cString[0] ) );
+ if( track != nullptr
+ && track->IsEmpty() ) {
WyslijWolny( track->name() );
}
}
@@ -134,14 +134,11 @@ OnCommandGet(multiplayer::DaneRozkaz *pRozkaz)
CommLog(
Now() + " "
+ std::to_string( pRozkaz->iComm ) + " "
- + std::string{ pRozkaz->cString + 1, (unsigned)( pRozkaz->cString[ 0 ] ) }
+ + std::string{ pRozkaz->cString + 1, (unsigned)pRozkaz->cString[0] }
+ " rcvd" );
if (pRozkaz->cString[0]) {
// jeśli długość nazwy jest niezerowa szukamy pierwszego pojazdu o takiej nazwie i odsyłamy parametry ramką #7
- auto *vehicle = (
- pRozkaz->cString[ 1 ] == '*' ?
- simulation::Train->Dynamic() :
- simulation::Vehicles.find( std::string{ pRozkaz->cString + 1, (unsigned)pRozkaz->cString[ 0 ] } ) );
+ auto *vehicle = pRozkaz->cString[1] == '*' ? simulation::Train->Dynamic() : simulation::Vehicles.find(std::string{pRozkaz->cString + 1, (unsigned)pRozkaz->cString[0]});
if( vehicle != nullptr ) {
WyslijNamiary( vehicle ); // wysłanie informacji o pojeździe
}
@@ -162,8 +159,8 @@ OnCommandGet(multiplayer::DaneRozkaz *pRozkaz)
break;
case 10: // badanie zajętości jednego odcinka izolowanego
CommLog(Now() + " " + std::to_string(pRozkaz->iComm) + " " +
- std::string(pRozkaz->cString + 1, (unsigned)(pRozkaz->cString[0])) + " rcvd");
- simulation::Paths.IsolatedBusy( std::string( pRozkaz->cString + 1, (unsigned)( pRozkaz->cString[ 0 ] ) ) );
+ std::string(pRozkaz->cString + 1, (unsigned)pRozkaz->cString[0]) + " rcvd");
+ simulation::Paths.IsolatedBusy( std::string( pRozkaz->cString + 1, (unsigned)pRozkaz->cString[0] ) );
break;
case 11: // ustawienie parametrów ruchu pojazdu
// Ground.IsolatedBusy(AnsiString(pRozkaz->cString+1,(unsigned)(pRozkaz->cString[0])));
@@ -175,14 +172,12 @@ OnCommandGet(multiplayer::DaneRozkaz *pRozkaz)
break;
case 13: // ramka uszkodzenia i innych stanow pojazdu, np. wylaczenie CA, wlaczenie recznego itd.
CommLog(Now() + " " + std::to_string(pRozkaz->iComm) + " " +
- std::string(pRozkaz->cString + 1, (unsigned)(pRozkaz->cString[0])) +
+ std::string(pRozkaz->cString + 1, (unsigned)pRozkaz->cString[0]) +
" rcvd");
if( pRozkaz->cString[ 1 ] ) // jeśli długość nazwy jest niezerowa
{ // szukamy pierwszego pojazdu o takiej nazwie i odsyłamy parametry ramką #13
- auto *lookup = (
- pRozkaz->cString[ 2 ] == '*' ?
- simulation::Train->Dynamic() : // nazwa pojazdu użytkownika
- simulation::Vehicles.find( std::string( pRozkaz->cString + 2, (unsigned)pRozkaz->cString[ 1 ] ) ) ); // nazwa pojazdu
+ auto *lookup = pRozkaz->cString[2] == '*' ? simulation::Train->Dynamic() : // nazwa pojazdu użytkownika
+ simulation::Vehicles.find(std::string(pRozkaz->cString + 2, (unsigned)pRozkaz->cString[1])); // nazwa pojazdu
if( lookup == nullptr ) { break; } // nothing found, nothing to do
auto *d { lookup };
while( d != nullptr ) {
diff --git a/input/zmq_input.cpp b/input/zmq_input.cpp
index 1c6e29ac..62fb41ee 100644
--- a/input/zmq_input.cpp
+++ b/input/zmq_input.cpp
@@ -26,7 +26,7 @@ float zmq_input::unpack_float(const zmq::message_t &msg) {
return 0.0f;
uint8_t *buf = (uint8_t*)msg.data();
- uint32_t v = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3];
+ uint32_t v = buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3];
return reinterpret_cast(v);
}
@@ -52,7 +52,7 @@ void zmq_input::poll()
continue;
uint8_t* buf = (uint8_t*)multipart[0].data();
- uint32_t peer_id = (buf[1] << 24) | (buf[2] << 16) | (buf[3] << 8) | buf[4];
+ uint32_t peer_id = buf[1] << 24 | buf[2] << 16 | buf[3] << 8 | buf[4];
auto peer_it = peers.find(peer_id);
if (peer_it == peers.end()) {
@@ -139,8 +139,8 @@ void zmq_input::poll()
else if (type == input_type::none)
continue;
- bool state = (value > 0.5f);
- bool changed = (state != std::get<3>(entry));
+ bool state = value > 0.5f;
+ bool changed = state != std::get<3>(entry);
if (!changed)
continue;
@@ -148,16 +148,12 @@ void zmq_input::poll()
auto const action { (
type != input_type::impulse ?
GLFW_PRESS :
- ( state ?
- GLFW_PRESS :
- GLFW_RELEASE ) ) };
+ state ? GLFW_PRESS : GLFW_RELEASE) };
auto const command { (
type != input_type::toggle ?
std::get<1>( entry ) :
- ( state ?
- std::get<1>( entry ) :
- std::get<2>( entry ) ) ) };
+ state ? std::get<1>(entry) : std::get<2>(entry) ) };
std::get<3>(entry) = state;
@@ -181,7 +177,7 @@ void zmq_input::poll()
continue;
}
- uint8_t peerbuf[5] = { 0, (uint8_t)(peer->first >> 24), (uint8_t)(peer->first >> 16), (uint8_t)(peer->first >> 8), (uint8_t)(peer->first) };
+ uint8_t peerbuf[5] = { 0, (uint8_t)(peer->first >> 24), (uint8_t)(peer->first >> 16), (uint8_t)(peer->first >> 8), (uint8_t)peer->first };
zmq::multipart_t msg;
msg.addmem(peerbuf, sizeof(peerbuf));
diff --git a/launcher/launchermode.cpp b/launcher/launchermode.cpp
index 053f1d88..08c4c101 100644
--- a/launcher/launchermode.cpp
+++ b/launcher/launchermode.cpp
@@ -35,9 +35,9 @@ void launcher_mode::exit()
void launcher_mode::on_key(const int Key, const int Scancode, const int Action, const int Mods)
{
#ifndef __unix__
- Global.shiftState = (Mods & GLFW_MOD_SHIFT) ? true : false;
- Global.ctrlState = (Mods & GLFW_MOD_CONTROL) ? true : false;
- Global.altState = (Mods & GLFW_MOD_ALT) ? true : false;
+ Global.shiftState = Mods & GLFW_MOD_SHIFT ? true : false;
+ Global.ctrlState = Mods & GLFW_MOD_CONTROL ? true : false;
+ Global.altState = Mods & GLFW_MOD_ALT ? true : false;
#endif
m_userinterface->on_key(Key, Action);
}
diff --git a/launcher/scenery_list.cpp b/launcher/scenery_list.cpp
index 7a54b3e2..0b49e80f 100644
--- a/launcher/scenery_list.cpp
+++ b/launcher/scenery_list.cpp
@@ -291,7 +291,7 @@ void ui::scenerylist_panel::draw_trainset(trainset_desc &trainset)
glm::ivec2 size = mini->size();
float width = 30.0f / size.y * size.x;
float beforeX = ImGui::GetCursorPosX();
- ImGui::Image((ImTextureID)(intptr_t)(mini->get()), ImVec2(width, 30), ImVec2(0, 1), ImVec2(1, 0));
+ ImGui::Image((ImTextureID)(intptr_t)mini->get(), ImVec2(width, 30), ImVec2(0, 1), ImVec2(1, 0));
float afterX = ImGui::GetCursorPosX();
ImGui::SameLine(beforeX);
@@ -338,7 +338,7 @@ void ui::scenerylist_panel::draw_droptarget(trainset_desc &trainset, int positio
if (ImGui::BeginDragDropTarget()) {
const ImGuiPayload *payload = ImGui::AcceptDragDropPayload("vehicle_pure");
if (payload) {
- skin_set *ptr = *(reinterpret_cast(payload->Data));
+ skin_set *ptr = *reinterpret_cast(payload->Data);
std::shared_ptr skin;
for (auto &s : ptr->vehicle.lock()->matching_skinsets)
if (s.get() == ptr)
@@ -406,7 +406,7 @@ void ui::dynamic_edit_popup::render_content()
if (ImGui::BeginCombo(STR_C("Skin"), dynamic.skin->skin.c_str(), ImGuiComboFlags_HeightLargest))
{
for (auto const &skin : dynamic.vehicle->matching_skinsets) {
- bool is_selected = (skin == dynamic.skin);
+ bool is_selected = skin == dynamic.skin;
if (ImGui::Selectable(skin->skin.c_str(), is_selected))
dynamic.skin = skin;
if (is_selected)
@@ -419,7 +419,7 @@ void ui::dynamic_edit_popup::render_content()
if (ImGui::BeginCombo(STR_C("Occupancy"), Translations.lookup_c(dynamic.drivertype.c_str())))
{
for (auto const &str : occupancy_names) {
- bool is_selected = (str == dynamic.drivertype);
+ bool is_selected = str == dynamic.drivertype;
if (ImGui::Selectable(Translations.lookup_c(str.c_str()), is_selected))
dynamic.drivertype = str;
if (is_selected)
diff --git a/launcher/scenery_scanner.cpp b/launcher/scenery_scanner.cpp
index c28f7e7e..7bfa8a07 100644
--- a/launcher/scenery_scanner.cpp
+++ b/launcher/scenery_scanner.cpp
@@ -13,7 +13,7 @@ void scenery_scanner::scan()
for (auto &f : std::filesystem::directory_iterator("scenery")) {
std::filesystem::path path(std::filesystem::relative(f.path(), "scenery/"));
- if (*(path.filename().string().begin()) == '$')
+ if (*path.filename().string().begin() == '$')
continue;
if (path.string().ends_with(".scn"))
diff --git a/launcher/textures_scanner.cpp b/launcher/textures_scanner.cpp
index 92e44dea..201ff967 100644
--- a/launcher/textures_scanner.cpp
+++ b/launcher/textures_scanner.cpp
@@ -101,7 +101,7 @@ void ui::vehicles_bank::parse_category_entry(const std::string ¶m)
void ui::vehicles_bank::parse_controllable_entry(const std::string &target, const std::string ¶m)
{
get_vehicle(target)->controllable =
- (param.size() >= 1 && param[0] == '1');
+ param.size() >= 1 && param[0] == '1';
}
void ui::vehicles_bank::parse_texture_info(const std::string &target, const std::string ¶m, std::shared_ptr meta)
diff --git a/launcher/vehicle_picker.cpp b/launcher/vehicle_picker.cpp
index 43d7b198..88c40ef9 100644
--- a/launcher/vehicle_picker.cpp
+++ b/launcher/vehicle_picker.cpp
@@ -47,15 +47,15 @@ void ui::vehiclepicker_panel::render_contents()
bool model_added = false;
bool can_break = false;
- bool map_sel_eq = (selected_group && group == *selected_group);
+ bool map_sel_eq = selected_group && group == *selected_group;
for (auto const &vehicle : kv.second) {
if (vehicle->type != selected_type)
continue;
for (auto const &skinset : vehicle->matching_skinsets) {
- bool map_group_eq = (skinset->group == group);
- bool sel_group_eq = (selected_group && skinset->group == *selected_group);
+ bool map_group_eq = skinset->group == group;
+ bool sel_group_eq = selected_group && skinset->group == *selected_group;
if (!model_added && map_group_eq) {
model_list.push_back(&group);
@@ -253,7 +253,7 @@ bool ui::vehiclepicker_panel::skin_filter(const skin_set *skin, std::vectorgetToken() ).empty() )
- && ( false == is_keyword( token ) ) ) {
+ while( false == (token = parser->getToken()).empty()
+ && false == is_keyword(token) ) {
if( i < iNumLights ) {
// stan światła jest liczbą z ułamkiem
@@ -347,16 +347,16 @@ bool TAnimModel::Load(cParser *parser, bool ter)
if( token == "lightcolors" ) {
auto i{ 0 };
- while( ( false == ( token = parser->getToken() ).empty() )
- && ( false == is_keyword( token ) ) ) {
+ while( false == (token = parser->getToken()).empty()
+ && false == is_keyword(token) ) {
- if( ( i < iNumLights )
- && ( token != "-1" ) ) { // -1 leaves the default color intact
+ if( i < iNumLights
+ && token != "-1" ) { // -1 leaves the default color intact
auto const lightcolor { std::stoi( token, 0, 16 ) };
m_lightcolors[i] = {
- ( ( lightcolor >> 16 ) & 0xff ) / 255.f,
- ( ( lightcolor >> 8 ) & 0xff ) / 255.f,
- ( ( lightcolor ) & 0xff ) / 255.f };
+ ( lightcolor >> 16 & 0xff ) / 255.f,
+ ( lightcolor >> 8 & 0xff ) / 255.f,
+ ( lightcolor & 0xff ) / 255.f };
}
++i;
}
@@ -391,8 +391,8 @@ bool TAnimModel::Load(cParser *parser, bool ter)
m_transition = false;
}
- } while( ( false == token.empty() )
- && ( token != "endmodel" ) );
+ } while( false == token.empty()
+ && token != "endmodel" );
update_instanceable_flag();
return true;
@@ -486,7 +486,7 @@ std::shared_ptr TAnimModel::AddContainer(std::string const &Name
std::shared_ptr TAnimModel::GetContainer(std::string const &Name)
{ // szukanie/dodanie sterowania submodelem dla egzemplarza
if (true == Name.empty())
- return (!m_animlist.empty()) ? m_animlist.front() : nullptr; // pobranie pierwszego (dla obrotnicy)
+ return !m_animlist.empty() ? m_animlist.front() : nullptr; // pobranie pierwszego (dla obrotnicy)
for (auto entry : m_animlist) {
if (entry->NameGet() == Name)
@@ -583,34 +583,28 @@ void TAnimModel::RaPrepare()
case ls_Off:
case ls_Blink: {
if (LightsOn[i]) {
- LightsOn[i]->iVisible = ( m_lightopacities[i] > 0.f );
+ LightsOn[i]->iVisible = m_lightopacities[i] > 0.f;
LightsOn[i]->SetVisibilityLevel( m_lightopacities[i], true, false );
}
if (LightsOff[i]) {
- LightsOff[i]->iVisible = ( m_lightopacities[i] < 1.f );
+ LightsOff[i]->iVisible = m_lightopacities[i] < 1.f;
LightsOff[i]->SetVisibilityLevel( 1.f, true, false );
}
break;
}
case ls_Dark: {
// zapalone, gdy ciemno
- state = (
- Global.fLuminance - std::max( 0.f, Global.Overcast - 1.f ) <= (
- lsLights[ i ] == static_cast( ls_Dark ) ?
- DefaultDarkThresholdLevel :
- ( lsLights[ i ] - static_cast( ls_Dark ) ) ) );
+ state =
+ Global.fLuminance - std::max(0.f, Global.Overcast - 1.f) <= (lsLights[i] == static_cast(ls_Dark) ? DefaultDarkThresholdLevel : lsLights[i] - static_cast(ls_Dark));
break;
}
case ls_Home: {
// like ls_dark but off late at night
auto const simulationhour { simulation::Time.data().wHour };
- state = (
- Global.fLuminance - std::max( 0.f, Global.Overcast - 1.f ) <= (
- lsLights[ i ] == static_cast( ls_Home ) ?
- DefaultDarkThresholdLevel :
- ( lsLights[ i ] - static_cast( ls_Home ) ) ) );
+ state =
+ Global.fLuminance - std::max(0.f, Global.Overcast - 1.f) <= (lsLights[i] == static_cast(ls_Home) ? DefaultDarkThresholdLevel : lsLights[i] - static_cast(ls_Home));
// force the lights off between 1-5am
- state = state && (( simulationhour < 1 ) || ( simulationhour >= 5 ));
+ state = state && (simulationhour < 1 || simulationhour >= 5);
break;
}
default: {
@@ -644,7 +638,7 @@ int TAnimModel::Flags()
{ // informacja dla TGround, czy ma być w Render, RenderAlpha, czy RenderMixed
int i = pModel ? pModel->Flags() : 0; // pobranie flag całego modelu
if( m_materialdata.replacable_skins[ 1 ] > 0 ) // jeśli ma wymienną teksturę 0
- i |= (i & 0x01010001) * ((m_materialdata.textures_alpha & 1) ? 0x20 : 0x10);
+ i |= (i & 0x01010001) * (m_materialdata.textures_alpha & 1 ? 0x20 : 0x10);
return i;
}
@@ -745,7 +739,7 @@ TAnimModel::export_as_text_( std::ostream &Output ) const {
// location and rotation. The 4th token after location is a legacy
// shorthand for the Y rotation. We use it (and skip the angles block)
// whenever the rotation is purely around Y, which is the common case.
- bool const xz_rotation_zero = ( vAngle.x == 0.0f && vAngle.z == 0.0f );
+ bool const xz_rotation_zero = vAngle.x == 0.0f && vAngle.z == 0.0f;
Output << std::fixed << std::setprecision( 3 )
<< location().x << ' '
<< location().y << ' '
diff --git a/model/AnimModel.h b/model/AnimModel.h
index 13f15a90..435c1dba 100644
--- a/model/AnimModel.h
+++ b/model/AnimModel.h
@@ -80,7 +80,7 @@ class TAnimContainer : std::enable_shared_from_this
bool Init(TSubModel *pNewSubModel);
inline
std::string NameGet() {
- return (pSubModel ? pSubModel->pName : ""); };
+ return pSubModel ? pSubModel->pName : ""; };
void SetRotateAnim( glm::vec3 vNewRotateAngles, double fNewRotateSpeed);
void SetTranslateAnim( glm::dvec3 vNewTranslate, double fNewSpeed);
void AnimSetVMD(double fNewSpeed);
diff --git a/model/MdlMngr.cpp b/model/MdlMngr.cpp
index f70ba118..9ead9716 100644
--- a/model/MdlMngr.cpp
+++ b/model/MdlMngr.cpp
@@ -81,8 +81,8 @@ TModelsManager::GetModel(std::string const &Name, bool const Dynamic, bool const
// - wczytanie modelu animowanego - Init() - sprawdzić
std::string const buftp { Global.asCurrentTexturePath }; // zapamiętanie aktualnej ścieżki do tekstur,
std::string filename { Name };
- if( ( false == Dynamic )
- && ( contains( Name, '/' ) ) ) {
+ if( false == Dynamic
+ && contains(Name, '/') ) {
// pobieranie tekstur z katalogu, w którym jest model
// when loading vehicles the path is set by the calling routine, so we can skip it here
Global.asCurrentTexturePath += Name;
@@ -144,10 +144,7 @@ TModelsManager::find_on_disk( std::string const &Name ) {
std::vector extensions { { ".e3d" }, { ".t3d" } };
for( auto const &extension : extensions ) {
- auto lookup = (
- FileExists( Name + extension ) ? Name :
- FileExists( paths::models + Name + extension ) ? paths::models + Name :
- "" );
+ auto lookup = FileExists(Name + extension) ? Name : FileExists(paths::models + Name + extension) ? paths::models + Name : "";
if( false == lookup.empty() ) {
return lookup;
}
diff --git a/model/Model3d.cpp b/model/Model3d.cpp
index d5e5c9dd..5f59558b 100644
--- a/model/Model3d.cpp
+++ b/model/Model3d.cpp
@@ -88,7 +88,7 @@ void TSubModel::SetDiffuseOverride(glm::vec3 const &Color, bool const Includechi
sibling->SetDiffuseOverride(Color, Includechildren, false); // no need for all siblings to duplicate the work
}
}
- if ((true == Includechildren) && (Child != nullptr))
+ if (true == Includechildren && Child != nullptr)
{
Child->SetDiffuseOverride(Color, Includechildren, true); // node's children include child's siblings and children
}
@@ -134,7 +134,7 @@ void TSubModel::SetVisibilityLevel(float const Level, bool const Includechildren
sibling->SetVisibilityLevel(Level, Includechildren, false); // no need for all siblings to duplicate the work
}
}
- if ((true == Includechildren) && (Child != nullptr))
+ if (true == Includechildren && Child != nullptr)
{
Child->SetVisibilityLevel(Level, Includechildren, true); // node's children include child's siblings and children
}
@@ -156,7 +156,7 @@ void TSubModel::SetLightLevel(glm::vec4 const &Level, bool const Includechildren
sibling->SetLightLevel(Level, Includechildren, false); // no need for all siblings to duplicate the work
}
}
- if ((true == Includechildren) && (Child != nullptr))
+ if (true == Includechildren && Child != nullptr)
{
Child->SetLightLevel(Level, Includechildren, true); // node's children include child's siblings and children
}
@@ -175,7 +175,7 @@ void TSubModel::SetSelfIllum(float const Threshold, bool const Includechildren,
sibling->SetSelfIllum(Threshold, Includechildren, false); // no need for all siblings to duplicate the work
}
}
- if ((true == Includechildren) && (Child != nullptr))
+ if (true == Includechildren && Child != nullptr)
{
Child->SetSelfIllum(Threshold, Includechildren, true); // node's children include child's siblings and children
}
@@ -243,7 +243,7 @@ std::pair TSubModel::Load(cParser &parser, bool dynamic)
{
std::string errormessage{"Bad model: expected submodel type definition not found while loading model \"" + parser.Name() + "\"" + "\ncurrent model data stream content: \""};
auto count{10};
- while ((true == parser.getTokens()) && (false == (token = parser.peek()).empty()) && (token != "parent:"))
+ while (true == parser.getTokens() && false == (token = parser.peek()).empty() && token != "parent:")
{
// skip data until next submodel, dump first few tokens in the error message
if (--count > 0)
@@ -275,7 +275,7 @@ std::pair TSubModel::Load(cParser &parser, bool dynamic)
if (dynamic)
{
// dla pojazdu, blokujemy załączone submodele, które mogą być nieobsługiwane
- if ((token.size() >= 3) && (token.find("_on") + 3 == token.length()))
+ if (token.size() >= 3 && token.find("_on") + 3 == token.length())
{
// jeśli nazwa kończy się na "_on" to domyślnie wyłączyć, żeby się nie nakładało z obiektem "_off"
iVisible = 0;
@@ -418,27 +418,27 @@ std::pair TSubModel::Load(cParser &parser, bool dynamic)
else if (material.find("replacableskin") != material.npos)
{ // McZapkie-060702: zmienialne skory modelu
m_material = -1;
- iFlags |= (Opacity < 0.999) ? 1 : 0x10; // zmienna tekstura 1
+ iFlags |= Opacity < 0.999 ? 1 : 0x10; // zmienna tekstura 1
}
else if (material == "-1")
{
m_material = -1;
- iFlags |= (Opacity < 0.999) ? 1 : 0x10; // zmienna tekstura 1
+ iFlags |= Opacity < 0.999 ? 1 : 0x10; // zmienna tekstura 1
}
else if (material == "-2")
{
m_material = -2;
- iFlags |= (Opacity < 0.999) ? 2 : 0x10; // zmienna tekstura 2
+ iFlags |= Opacity < 0.999 ? 2 : 0x10; // zmienna tekstura 2
}
else if (material == "-3")
{
m_material = -3;
- iFlags |= (Opacity < 0.999) ? 4 : 0x10; // zmienna tekstura 3
+ iFlags |= Opacity < 0.999 ? 4 : 0x10; // zmienna tekstura 3
}
else if (material == "-4")
{
m_material = -4;
- iFlags |= (Opacity < 0.999) ? 8 : 0x10; // zmienna tekstura 4
+ iFlags |= Opacity < 0.999 ? 8 : 0x10; // zmienna tekstura 4
}
else
{
@@ -509,10 +509,10 @@ std::pair TSubModel::Load(cParser &parser, bool dynamic)
// check the scaling
auto const matrix = glm::make_mat4(fMatrix->readArray());
glm::vec3 const scale{glm::length(glm::vec3(glm::column(matrix, 0))), glm::length(glm::vec3(glm::column(matrix, 1))), glm::length(glm::vec3(glm::column(matrix, 2)))};
- if ((std::abs(scale.x - 1.0f) > 0.01) || (std::abs(scale.y - 1.0f) > 0.01) || (std::abs(scale.z - 1.0f) > 0.01))
+ if (std::abs(scale.x - 1.0f) > 0.01 || std::abs(scale.y - 1.0f) > 0.01 || std::abs(scale.z - 1.0f) > 0.01)
{
ErrorLog("Bad model: transformation matrix for sub-model \"" + pName + "\" imposes geometry scaling (factors: " + to_string(scale) + ")", logtype::model);
- m_normalizenormals = (((std::abs(scale.x - scale.y) < 0.01f) && (std::abs(scale.y - scale.z) < 0.01f)) ? rescale : normalize);
+ m_normalizenormals = std::abs(scale.x - scale.y) < 0.01f && std::abs(scale.y - scale.z) < 0.01f ? rescale : normalize;
}
transformscalestack *= (scale.x + scale.y + scale.z) / 3.0f;
}
@@ -536,7 +536,7 @@ std::pair TSubModel::Load(cParser &parser, bool dynamic)
}
token = parser.getToken();
}
- if ((token == "numverts:") || (token == "numverts"))
+ if (token == "numverts:" || token == "numverts")
{ // normalna lista wierzchołków
/*
// Ra 15-01: to wczytać jako tekst - jeśli pierwszy znak zawiera "*", to
@@ -550,7 +550,7 @@ std::pair TSubModel::Load(cParser &parser, bool dynamic)
}
*/
m_geometry.vertex_count = parser.getToken(false);
- if ((m_geometry.index_count <= 0) && (m_geometry.vertex_count % 3 != 0))
+ if (m_geometry.index_count <= 0 && m_geometry.vertex_count % 3 != 0)
{
m_geometry.vertex_count = 0;
Error("Bad model: incomplete triangle encountered in submodel \"" + pName + "\"");
@@ -588,12 +588,12 @@ std::pair TSubModel::Load(cParser &parser, bool dynamic)
++vertexidx;
// Ra: z konwersją na układ scenerii - będzie wydajniejsze wyświetlanie
wsp[idx] = -1; // wektory normalne nie są policzone dla tego wierzchołka
- if ((idx % 3) == 0)
+ if (idx % 3 == 0)
{
// jeśli będzie maska -1, to dalej będą wierzchołki z wektorami normalnymi, podanymi jawnie
maska = parser.getToken(false); // maska powierzchni trójkąta
// dla maski -1 będzie 0, czyli nie ma wspólnych wektorów normalnych
- sg[idx / 3] = ((maska == -1) ? 0 : maska);
+ sg[idx / 3] = maska == -1 ? 0 : maska;
}
auto vertex{vertices + idx};
parser.getTokens(3, false);
@@ -630,8 +630,8 @@ std::pair TSubModel::Load(cParser &parser, bool dynamic)
{
// jeśli pierwszy trójkąt będzie zdegenerowany, to zostanie usunięty i nie ma co sprawdzać
// length2 is better than length for comparing because it does not require sqrt function
- if ((glm::length2((vertex)->position - (vertex - 1)->position) > sq(1000.0)) || (glm::length2((vertex - 1)->position - (vertex - 2)->position) > sq(1000.0)) ||
- (glm::length2((vertex - 2)->position - (vertex)->position) > sq(1000.0)))
+ if (glm::length2(vertex->position - (vertex - 1)->position) > sq(1000.0) || glm::length2((vertex - 1)->position - (vertex - 2)->position) > sq(1000.0) ||
+ glm::length2((vertex - 2)->position - vertex->position) > sq(1000.0))
{
// jeżeli są dalej niż 2km od siebie //Ra 15-01:
// obiekt wstawiany nie powinien być większy niż 300m (trójkąty terenu w E3D mogą mieć 1.5km)
@@ -649,7 +649,7 @@ std::pair TSubModel::Load(cParser &parser, bool dynamic)
for (int i = 0; i < facecount; ++i)
{
// pętla po trójkątach - będzie szybciej, jak wstępnie przeliczymy normalne trójkątów
- auto const vertex{vertices + (i * 3)};
+ auto const vertex{vertices + i * 3};
auto facenormal = glm::cross(vertex->position - (vertex + 1)->position, vertex->position - (vertex + 2)->position);
facenormals.emplace_back(glm::length2(facenormal) > 0.0f ? glm::normalize(facenormal) : glm::vec3());
}
@@ -690,7 +690,7 @@ std::pair TSubModel::Load(cParser &parser, bool dynamic)
{
WriteLog("Bad model: zero length normal vector generated for sub-model \"" + pName + "\"", logtype::model);
}
- vertex->normal = (glm::length2(vertexnormal) > 0.0f ? glm::normalize(vertexnormal) : facenormals[vertexidx / 3]); // przepisanie do wierzchołka trójkąta
+ vertex->normal = glm::length2(vertexnormal) > 0.0f ? glm::normalize(vertexnormal) : facenormals[vertexidx / 3]; // przepisanie do wierzchołka trójkąta
}
}
Vertices.resize(m_geometry.vertex_count); // in case we had some degenerate triangles along the way
@@ -740,9 +740,9 @@ std::pair TSubModel::Load(cParser &parser, bool dynamic)
parser.getTokens(5, false);
parser >> vertex->position.x >> vertex->position.y >> vertex->position.z >> color // zakodowany kolor
>> discard;
- vertex->normal = {((color) & 0xff) / 255.0f, // R
- ((color >> 8) & 0xff) / 255.0f, // G
- ((color >> 16) & 0xff) / 255.0f}; // B
+ vertex->normal = {(color & 0xff) / 255.0f, // R
+ (color >> 8 & 0xff) / 255.0f, // G
+ (color >> 16 & 0xff) / 255.0f}; // B
}
}
else if (eType == TP_FREESPOTLIGHT)
@@ -841,15 +841,15 @@ void TSubModel::InitialRotate(bool doit)
else if (Global.iConvertModels & 2)
{
// optymalizacja jest opcjonalna
- if (((iFlags & 0xC000) == 0x8000) // o ile nie ma animacji
- && (false == is_emitter())) // don't optimize smoke emitter attachment points
+ if ((iFlags & 0xC000) == 0x8000 // o ile nie ma animacji
+ && false == is_emitter()) // don't optimize smoke emitter attachment points
{ // jak nie ma potomnych, można wymnożyć przez transform i wyjedynkować go
float4x4 *mat = GetMatrix(); // transform submodelu
if (false == Vertices.empty())
{
for (auto &vertex : Vertices)
{
- vertex.position = (*mat) * vertex.position;
+ vertex.position = *mat * vertex.position;
}
// zerujemy przesunięcie przed obracaniem normalnych
(*mat)(3)[0] = (*mat)(3)[1] = (*mat)(3)[2] = 0.0;
@@ -858,8 +858,8 @@ void TSubModel::InitialRotate(bool doit)
// gwiazdki mają kolory zamiast normalnych, to ich wtedy nie ruszamy
for (auto &vertex : Vertices)
{
- vertex.normal = (*mat) * vertex.normal;
- vertex.tangent.xyz = (*mat) * vertex.tangent.xyz;
+ vertex.normal = *mat * vertex.normal;
+ vertex.tangent.xyz = *mat * vertex.tangent.xyz;
}
}
}
@@ -925,7 +925,7 @@ int TSubModel::count_siblings()
int TSubModel::count_children()
{
- return (Child == nullptr ? 0 : 1 + Child->count_siblings());
+ return Child == nullptr ? 0 : 1 + Child->count_siblings();
}
// locates submodel mapped with replacable -4
@@ -934,7 +934,7 @@ std::tuple TSubModel::find_replacable4()
if (m_material == -4)
{
- return std::make_tuple(this, (fLight != -1.0));
+ return std::make_tuple(this, fLight != -1.0);
}
if (Next != nullptr)
@@ -964,7 +964,7 @@ void TSubModel::find_smoke_sources(nameoffset_sequence &Sourcelist) const
auto const name{ToLower(pName)};
- if ((eType == TP_ROTATOR) && (pName.find("smokesource_") == 0))
+ if (eType == TP_ROTATOR && pName.find("smokesource_") == 0)
{
Sourcelist.emplace_back(pName, offset());
}
@@ -994,7 +994,7 @@ uint32_t TSubModel::FlagsCheck()
if (Child->m_material != m_material) // i jest ona inna niż rodzica
Child->iFlags |= 0x80; // to trzeba sprawdzać, jak z teksturami jest
i = Child->FlagsCheck();
- iFlags |= 0x00FF0000 & ((i << 16) | (i) | (i >> 8)); // potomny, rodzeństwo i dzieci
+ iFlags |= 0x00FF0000 & (i << 16 | i | i >> 8); // potomny, rodzeństwo i dzieci
if (eType == TP_TEXT)
{ // wyłączenie renderowania Next dla znaków
// wyświetlacza tekstowego
@@ -1010,10 +1010,10 @@ uint32_t TSubModel::FlagsCheck()
{ // Next jest renderowany po danym submodelu (kolejność odwrócona
// po wczytaniu T3D)
if (m_material) // o ile dany ma teksturę
- if ((m_material != Next->m_material) || (i & 0x00800000)) // a ma inną albo dzieci zmieniają
+ if (m_material != Next->m_material || i & 0x00800000) // a ma inną albo dzieci zmieniają
iFlags |= 0x80; // to dany submodel musi sobie ją ustawiać
i = Next->FlagsCheck();
- iFlags |= 0xFF000000 & ((i << 24) | (i << 8) | (i)); // następny, kolejne i ich dzieci
+ iFlags |= 0xFF000000 & (i << 24 | i << 8 | i); // następny, kolejne i ich dzieci
// tekstury nie ustawiamy tylko wtedy, gdy jest taka sama jak Next i jego
// dzieci nie zmieniają
}
@@ -1200,7 +1200,7 @@ void TSubModel::RaAnimation(glm::mat4 &m, TAnimType a)
if (sm->pName.size())
{
// musi mieć niepustą nazwę
- if ((sm->pName[0] >= '0') && (sm->pName[0] <= '5'))
+ if (sm->pName[0] >= '0' && sm->pName[0] <= '5')
{
// zegarek ma 6 cyfr maksymalnie
sm->SetRotate(float3(0, 1, 0), -Global.fClockAngleDeg[sm->pName[0] - '0']);
@@ -1278,12 +1278,12 @@ int TSubModel::index_size() const
{
size = std::max(size, Child->index_size());
}
- if ((size < 4) && (m_geometry.handle != null_handle))
+ if (size < 4 && m_geometry.handle != null_handle)
{
auto const indexcount{GfxRenderer->Indices(m_geometry.handle).size()};
- size = std::max(size, (indexcount >= (1 << 16) ? 4 : indexcount >= (1 << 8) ? 2 : 1));
+ size = std::max(size, indexcount >= 1 << 16 ? 4 : indexcount >= 1 << 8 ? 2 : 1);
}
- if ((size < 4) && (Next))
+ if (size < 4 && Next)
{
size = std::max(size, Next->index_size());
}
@@ -1355,7 +1355,7 @@ void TSubModel::create_geometry(std::size_t &Indexoffset, std::size_t &Vertexoff
m_geometry.vertex_offset = static_cast(Vertexoffset);
Vertexoffset += Vertices.size();
// conveniently all relevant custom node types use GL_POINTS, or we'd have to determine the type on individual basis
- auto type = (eType < TP_ROTATOR ? eType : GL_POINTS);
+ auto type = eType < TP_ROTATOR ? eType : GL_POINTS;
m_geometry.handle = GfxRenderer->Insert(Indices, Vertices, Userdata, Bank, type);
}
@@ -1417,7 +1417,7 @@ void TSubModel::ColorsSet(glm::vec3 const &Ambient, glm::vec3 const &Diffuse, gl
bool TSubModel::is_emitter() const
{
- return ((eType == TP_ROTATOR) && (ToLower(pName).find("smokesource_") == 0));
+ return eType == TP_ROTATOR && ToLower(pName).find("smokesource_") == 0;
}
// pobranie transformacji względem wstawienia modelu
@@ -1438,13 +1438,13 @@ void TSubModel::ParentMatrix(float4x4 *m) const
submodelmatrix = float4x4(*submodel->GetMatrix());
}
// ...potentially adjust transformations of the root matrix if the model wasn't yet initialized...
- if ((submodel->Parent == nullptr) && (false == submodel->m_rotation_init_done))
+ if (submodel->Parent == nullptr && false == submodel->m_rotation_init_done)
{
// dla ostatniego może być potrzebny dodatkowy obrót, jeśli wczytano z T3D, a nie obrócono jeszcze
submodelmatrix.InitialRotate();
}
// ...combine the transformations...
- *m = submodelmatrix * (*m);
+ *m = submodelmatrix * *m;
// ...and move up the transformation chain for the iteration...
submodel = submodel->Parent;
// ... until we hit the root
@@ -1528,7 +1528,7 @@ TSubModel *TModel3d::AddToNamed(const char *Name, TSubModel *SubModel)
{
TSubModel *sm = Name ? GetFromName(Name) : nullptr;
- if ((sm == nullptr) && (Name != nullptr) && (std::strcmp(Name, "none") != 0))
+ if (sm == nullptr && Name != nullptr && std::strcmp(Name, "none") != 0)
{
ErrorLog("Bad model: parent for sub-model \"" + SubModel->pName + "\" doesn't exist or is located later in the model data", logtype::model);
}
@@ -1651,7 +1651,7 @@ bool TModel3d::LoadFromFile(std::string const &FileName, bool dynamic)
Init();
}
- bool const result = Root ? (iSubModelsCount > 0) : false; // brak pliku albo problem z wczytaniem
+ bool const result = Root ? iSubModelsCount > 0 : false; // brak pliku albo problem z wczytaniem
if (false == result)
{
ErrorLog("Bad model: failed to load 3d model \"" + name + "\"");
@@ -1701,7 +1701,7 @@ void TSubModel::serialize(std::ostream &s, std::vector &models, std
sn_utils::ls_int32(s, (int)b_Anim);
uint32_t flags = iFlags;
- if (m_material > 0 && (Global.iConvertModels & 16))
+ if (m_material > 0 && Global.iConvertModels & 16)
flags &= ~0x30; // don't save phase information, will be guessed on binary load from material
sn_utils::ls_uint32(s, flags);
sn_utils::ls_int32(s, (int32_t)get_container_pos(transforms, *fMatrix));
@@ -1972,11 +1972,11 @@ void TModel3d::deserialize(std::istream &s, size_t size, bool dynamic)
}
submodeloffsets.emplace_back(submodelgeometry.vertex_offset, submodelindex);
}
- std::sort(std::begin(submodeloffsets), std::end(submodeloffsets), [](std::pair const &Left, std::pair const &Right) { return (Left.first) < (Right.first); });
+ std::sort(std::begin(submodeloffsets), std::end(submodeloffsets), [](std::pair const &Left, std::pair const &Right) { return Left.first < Right.first; });
// once sorted we can grab geometry as it comes, and assign it to the chunks it belongs to
size_t const vertextype{(((type & 0xFF000000) >> 24) - '0')};
- hastangents = ((vertextype & 3) > 0);
- hasuserdata = (vertextype & 4);
+ hastangents = (vertextype & 3) > 0;
+ hasuserdata = vertextype & 4;
size_t vertex_size = 0;
switch (vertextype & 3)
{
@@ -2022,7 +2022,7 @@ void TModel3d::deserialize(std::istream &s, size_t size, bool dynamic)
if (submodel.eType < TP_ROTATOR)
{
// normal vectors debug routine
- if ((false == submodel.m_normalizenormals) && (std::abs(glm::length2(submodel.Vertices[i].normal) - 1.0f) > 0.01f))
+ if (false == submodel.m_normalizenormals && std::abs(glm::length2(submodel.Vertices[i].normal) - 1.0f) > 0.01f)
{
submodel.m_normalizenormals = TSubModel::normalize; // we don't know if uniform scaling would suffice
WriteLog("Bad model: non-unit normal vector(s) encountered during sub-model geometry deserialization", logtype::model);
@@ -2079,7 +2079,7 @@ void TModel3d::deserialize(std::istream &s, size_t size, bool dynamic)
}
submodeloffsets.emplace_back(submodelgeometry.index_offset, submodelindex);
}
- std::sort(std::begin(submodeloffsets), std::end(submodeloffsets), [](std::pair const &Left, std::pair const &Right) { return (Left.first) < (Right.first); });
+ std::sort(std::begin(submodeloffsets), std::end(submodeloffsets), [](std::pair const &Left, std::pair const &Right) { return Left.first < Right.first; });
// once sorted we can grab indices in a continuous read, and assign them to the chunks they belong to
size_t const indexsize{(((type & 0xFF000000) >> 24) - '0')};
for (auto const &submodeloffset : submodeloffsets)
@@ -2204,11 +2204,11 @@ void TSubModel::BinInit(TSubModel *s, float4x4 *m, std::vector *t,
{ // ustawienie wskaźników w submodelu
// m7todo: brzydko
iVisible = 1; // tymczasowo używane
- Child = (iChild > 0) ? s + iChild : nullptr; // zerowy nie może być potomnym
- Next = (iNext > 0) ? s + iNext : nullptr; // zerowy nie może być następnym
- fMatrix = ((iMatrix >= 0) && m) ? m + iMatrix : nullptr;
+ Child = iChild > 0 ? s + iChild : nullptr; // zerowy nie może być potomnym
+ Next = iNext > 0 ? s + iNext : nullptr; // zerowy nie może być następnym
+ fMatrix = iMatrix >= 0 && m ? m + iMatrix : nullptr;
- if (n->size() && (iName >= 0))
+ if (n->size() && iName >= 0)
{
pName = n->at(iName);
if (!pName.empty())
@@ -2303,7 +2303,7 @@ void TSubModel::BinInit(TSubModel *s, float4x4 *m, std::vector *t,
m_material = GfxRenderer->Fetch_Material("stars");
iFlags |= 0x10;
}
- else if ((eType == TP_FREESPOTLIGHT) && (iFlags & 0x10))
+ else if (eType == TP_FREESPOTLIGHT && iFlags & 0x10)
{
// we've added light glare which needs to be rendered during transparent phase,
// but models converted to e3d before addition won't have the render flag set correctly for this
@@ -2328,10 +2328,10 @@ void TSubModel::BinInit(TSubModel *s, float4x4 *m, std::vector *t,
{
auto const matrix = glm::make_mat4(fMatrix->readArray());
glm::vec3 const scale{glm::length(glm::vec3(glm::column(matrix, 0))), glm::length(glm::vec3(glm::column(matrix, 1))), glm::length(glm::vec3(glm::column(matrix, 2)))};
- if ((std::abs(scale.x - 1.0f) > 0.01) || (std::abs(scale.y - 1.0f) > 0.01) || (std::abs(scale.z - 1.0f) > 0.01))
+ if (std::abs(scale.x - 1.0f) > 0.01 || std::abs(scale.y - 1.0f) > 0.01 || std::abs(scale.z - 1.0f) > 0.01)
{
ErrorLog("Bad model: transformation matrix for sub-model \"" + pName + "\" imposes geometry scaling (factors: " + to_string(scale) + ")", logtype::model);
- m_normalizenormals = (((std::abs(scale.x - scale.y) < 0.01f) && (std::abs(scale.y - scale.z) < 0.01f)) ? rescale : normalize);
+ m_normalizenormals = std::abs(scale.x - scale.y) < 0.01f && std::abs(scale.y - scale.z) < 0.01f ? rescale : normalize;
}
}
}
@@ -2492,7 +2492,7 @@ void TModel3d::Init()
Root->m_boundingradius = std::max(Root->m_boundingradius, root->m_boundingradius);
}
- if ((Global.iConvertModels & 1) && (false == asBinary.empty()))
+ if (Global.iConvertModels & 1 && false == asBinary.empty())
{
SaveToBinFile(asBinary);
asBinary = ""; // zablokowanie powtórnego zapisu
diff --git a/model/Model3d.h b/model/Model3d.h
index 87304335..7ebb1317 100644
--- a/model/Model3d.h
+++ b/model/Model3d.h
@@ -228,9 +228,9 @@ public:
// sets activation threshold of self-illumination to specitied value
void SetSelfIllum( float const Threshold, bool const Includechildren = false, bool const Includesiblings = false );
inline float3 Translation1Get() {
- return fMatrix ? *(fMatrix->TranslationGet()) + v_TransVector : v_TransVector; }
+ return fMatrix ? *fMatrix->TranslationGet() + v_TransVector : v_TransVector; }
inline float3 Translation2Get() {
- return *(fMatrix->TranslationGet()) + Child->Translation1Get(); }
+ return *fMatrix->TranslationGet() + Child->Translation1Get(); }
material_handle GetMaterial() const {
return m_material; }
void ParentMatrix(float4x4 *m) const;
@@ -278,11 +278,8 @@ public:
TModel3d() = default;
~TModel3d();
float bounding_radius() const {
- return (
- Root ?
- Root->m_boundingradius :
- 0.f ); }
- inline TSubModel * GetSMRoot() { return (Root); };
+ return Root ? Root->m_boundingradius : 0.f; }
+ inline TSubModel * GetSMRoot() { return Root; };
TSubModel * GetFromName(std::string const &Name) const;
TSubModel * AddToNamed(const char *Name, TSubModel *SubModel);
nameoffset_sequence const & find_smoke_sources();
diff --git a/model/ResourceManager.h b/model/ResourceManager.h
index f75d8b43..c9f3cb0b 100644
--- a/model/ResourceManager.h
+++ b/model/ResourceManager.h
@@ -46,8 +46,8 @@ public:
auto const blanktimestamp { std::chrono::steady_clock::time_point() };
int releasecount{ 0 };
for( auto resourceindex = m_resourcesweepindex; resourceindex < sweeplastindex; ++resourceindex ) {
- if( ( m_container[ resourceindex ].second != blanktimestamp )
- && ( m_resourcetimestamp - m_container[ resourceindex ].second > m_unusedresourcetimetolive ) ) {
+ if( m_container[resourceindex].second != blanktimestamp
+ && m_resourcetimestamp - m_container[resourceindex].second > m_unusedresourcetimetolive ) {
m_container[ resourceindex ].first->release();
m_container[ resourceindex ].second = blanktimestamp;
@@ -59,10 +59,8 @@ public:
WriteLog( "Resource garbage sweep released " + std::to_string( releasecount ) + " " + ( releasecount == 1 ? m_resourcename : m_resourcename + "s" ) );
}
*/
- m_resourcesweepindex = (
- m_resourcesweepindex + m_unusedresourcesweepsize >= m_container.size() ?
- 0 : // if the next sweep chunk is beyond actual data, so start anew
- m_resourcesweepindex + m_unusedresourcesweepsize );
+ m_resourcesweepindex = m_resourcesweepindex + m_unusedresourcesweepsize >= m_container.size() ? 0 : // if the next sweep chunk is beyond actual data, so start anew
+ m_resourcesweepindex + m_unusedresourcesweepsize;
return releasecount; }
diff --git a/model/Texture.cpp b/model/Texture.cpp
index 91e62f8b..abbf577c 100644
--- a/model/Texture.cpp
+++ b/model/Texture.cpp
@@ -206,7 +206,7 @@ void opengl_texture::gles_match_internalformat(GLuint internalformat)
for (int y = 0; y < data_height; y++)
for (int x = 0; x < data_width; x++)
{
- int pixel = (y * data_width + x);
+ int pixel = y * data_width + x;
int in_off = pixel * in_c;
int out_off = pixel * out_c;
for (int i = 0; i < out_c; i++)
@@ -264,19 +264,16 @@ opengl_texture::load() {
if( data_state == resource_state::good ) {
// verify texture size
- if( ( clamp_power_of_two( data_width ) != data_width ) || ( clamp_power_of_two( data_height ) != data_height ) ) {
+ if( clamp_power_of_two(data_width) != data_width || clamp_power_of_two(data_height) != data_height ) {
if( name != "logo" ) {
WriteLog( "Warning: dimensions of texture \"" + name + "\" aren't powers of 2", logtype::texture );
}
}
- if( ( quantize( data_width, 4u ) != data_width ) || ( quantize( data_height, 4u ) != data_height ) ) {
+ if( quantize(data_width, 4u) != data_width || quantize(data_height, 4u) != data_height ) {
WriteLog( "Warning: dimensions of texture \"" + name + "\" aren't multiples of 4", logtype::texture );
}
- has_alpha = (
- data_components == GL_RGBA ?
- true :
- false );
+ has_alpha = data_components == GL_RGBA ? true : false;
size = data.size() / 1024;
@@ -355,7 +352,7 @@ void opengl_texture::load_STBI()
free(image);
data_format = GL_RGBA;
- data_components = (n == 4 ? GL_RGBA : GL_RGB);
+ data_components = n == 4 ? GL_RGBA : GL_RGB;
data_width = x;
data_height = y;
data_mapcount = 1;
@@ -553,12 +550,12 @@ opengl_texture::load_DDS() {
data_height = ddsd.dwHeight;
data_mapcount = ddsd.dwMipMapCount;
- int blockSize = ( data_format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT ? 8 : 16 );
+ int blockSize = data_format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT ? 8 : 16;
int offset = 0;
- while( ( data_width > Global.CurrentMaxTextureSize ) || ( data_height > Global.CurrentMaxTextureSize ) ) {
+ while( data_width > Global.CurrentMaxTextureSize || data_height > Global.CurrentMaxTextureSize ) {
// pomijanie zbyt dużych mipmap, jeśli wymagane jest ograniczenie rozmiaru
- offset += ( ( data_width + 3 ) / 4 ) * ( ( data_height + 3 ) / 4 ) * blockSize;
+ offset += (data_width + 3) / 4 * ( ( data_height + 3 ) / 4 ) * blockSize;
data_width /= 2;
data_height /= 2;
--data_mapcount;
@@ -608,7 +605,7 @@ opengl_texture::load_DDS() {
else if (ddsd.ddpfPixelFormat.dwFourCC == FOURCC_DXT5)
flip_s3tc::flip_dxt45_image(mipmap, width, height);
- mipmap += ( ( width + 3 ) / 4 ) * ( ( height + 3 ) / 4 ) * blockSize;
+ mipmap += (width + 3) / 4 * ( ( height + 3 ) / 4 ) * blockSize;
width = std::max( width / 2, 4 );
height = std::max( height / 2, 4 );
--mapcount;
@@ -616,9 +613,7 @@ opengl_texture::load_DDS() {
}
data_components =
- ( ddsd.ddpfPixelFormat.dwFourCC == FOURCC_DXT1 ?
- GL_RGB :
- GL_RGBA );
+ ddsd.ddpfPixelFormat.dwFourCC == FOURCC_DXT1 ? GL_RGB : GL_RGBA;
data_state = resource_state::good;
@@ -662,7 +657,7 @@ opengl_texture::load_KTX() {
data_width = sub_data.width;
data_height = sub_data.height;
- if( ( data_width > Global.CurrentMaxTextureSize ) || ( data_height > Global.CurrentMaxTextureSize ) ) {
+ if( data_width > Global.CurrentMaxTextureSize || data_height > Global.CurrentMaxTextureSize ) {
data_mapcount--;
continue;
}
@@ -753,9 +748,9 @@ opengl_texture::load_TGA() {
int const bytesperpixel = tgaheader[ 16 ] / 8;
// check whether width, height an BitsPerPixel are valid
- if( ( data_width <= 0 )
- || ( data_height <= 0 )
- || ( ( bytesperpixel != 1 ) && ( bytesperpixel != 3 ) && ( bytesperpixel != 4 ) ) ) {
+ if( data_width <= 0
+ || data_height <= 0
+ || ( bytesperpixel != 1 && bytesperpixel != 3 && bytesperpixel != 4 ) ) {
data_state = resource_state::failed;
return;
@@ -790,7 +785,7 @@ opengl_texture::load_TGA() {
buffer[ 2 ] = buffer[ 0 ];
}
// copy all four values in one operation
- ( *datapointer ) = ( *bufferpointer );
+ *datapointer = *bufferpointer;
++datapointer;
}
}
@@ -822,7 +817,7 @@ opengl_texture::load_TGA() {
buffer[ 2 ] = buffer[ 0 ];
}
// copy all four values in one operation
- ( *datapointer ) = ( *bufferpointer );
+ *datapointer = *bufferpointer;
++datapointer;
++currentpixel;
@@ -842,7 +837,7 @@ opengl_texture::load_TGA() {
// copy the color into the image data as many times as dictated
for( int i = 0; i <= chunkheader; ++i ) {
- ( *datapointer ) = ( *bufferpointer );
+ *datapointer = *bufferpointer;
++datapointer;
++currentpixel;
}
@@ -863,7 +858,7 @@ opengl_texture::load_TGA() {
}
downsize( GL_BGRA );
- if( ( data_width > Global.CurrentMaxTextureSize ) || ( data_height > Global.CurrentMaxTextureSize ) ) {
+ if( data_width > Global.CurrentMaxTextureSize || data_height > Global.CurrentMaxTextureSize ) {
// for non-square textures there's currently possibility the scaling routine will have to abort
// before it gets all work done
data_state = resource_state::failed;
@@ -876,9 +871,7 @@ opengl_texture::load_TGA() {
data_mapcount = 1;
data_format = GL_BGRA;
data_components =
- ( bytesperpixel == 4 ?
- GL_RGBA :
- GL_RGB );
+ bytesperpixel == 4 ? GL_RGBA : GL_RGB;
data_state = resource_state::good;
return;
@@ -887,8 +880,8 @@ opengl_texture::load_TGA() {
bool
opengl_texture::bind(size_t unit) {
- if( ( false == is_ready )
- && ( false == create() ) ) {
+ if( false == is_ready
+ && false == create() ) {
return false;
}
@@ -1044,7 +1037,7 @@ opengl_texture::create( bool const Static ) {
// compressed dds formats
const int datablocksize = blocksize_it->second;
- datasize = ( ( std::max( datawidth, 4 ) + 3 ) / 4 ) * ( ( std::max( dataheight, 4 ) + 3 ) / 4 ) * datablocksize;
+ datasize = (std::max(datawidth, 4) + 3) / 4 * ( ( std::max( dataheight, 4 ) + 3 ) / 4 ) * datablocksize;
::glCompressedTexImage2D(
target, maplevel, internal_format,
@@ -1071,8 +1064,8 @@ opengl_texture::create( bool const Static ) {
glGenerateMipmap(target);
}
- if( ( true == Global.ResourceMove )
- || ( false == Global.ResourceSweep ) ) {
+ if( true == Global.ResourceMove
+ || false == Global.ResourceSweep ) {
// if garbage collection is disabled we don't expect having to upload the texture more than once
data = std::vector();
data_state = resource_state::none;
@@ -1160,16 +1153,10 @@ opengl_texture::alloc_rendertarget( GLint format, GLint components, int width, i
}
layers = l;
if( layers > 1 ) {
- target = (
- samples > 1 ?
- GL_TEXTURE_2D_MULTISAMPLE_ARRAY :
- GL_TEXTURE_2D_ARRAY );
+ target = samples > 1 ? GL_TEXTURE_2D_MULTISAMPLE_ARRAY : GL_TEXTURE_2D_ARRAY;
}
else {
- target = (
- samples > 1 ?
- GL_TEXTURE_2D_MULTISAMPLE :
- GL_TEXTURE_2D );
+ target = samples > 1 ? GL_TEXTURE_2D_MULTISAMPLE : GL_TEXTURE_2D;
}
create();
}
@@ -1196,7 +1183,7 @@ opengl_texture::set_filtering() const
::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
- if( ( Global.AnisotropicFiltering >= 0 )
+ if (Global.AnisotropicFiltering >= 0
&& ( GLAD_GL_EXT_texture_filter_anisotropic || GLAD_GL_ARB_texture_filter_anisotropic) ) {
// anisotropic filtering
::glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, Global.AnisotropicFiltering );
@@ -1228,19 +1215,19 @@ opengl_texture::set_filtering() const
void
opengl_texture::downsize( GLuint const Format ) {
- while( ( data_width > Global.CurrentMaxTextureSize ) || ( data_height > Global.CurrentMaxTextureSize ) ) {
+ while( data_width > Global.CurrentMaxTextureSize || data_height > Global.CurrentMaxTextureSize ) {
// scale down the base texture, if it's larger than allowed maximum
// NOTE: scaling is uniform along both axes, meaning non-square textures can drop below the maximum
// TODO: replace with proper scaling function once we have image middleware in place
- if( ( data_width < 2 ) || ( data_height < 2 ) ) {
+ if( data_width < 2 || data_height < 2 ) {
// can't go any smaller
break;
}
WriteLog( "Texture pixelcount exceeds specified limits, downsampling data" );
// trim potential odd texture sizes
- data_width -= ( data_width % 2 );
- data_height -= ( data_height % 2 );
+ data_width -= data_width % 2;
+ data_height -= data_height % 2;
switch( Format ) {
case GL_RGB: { downsample< glm::tvec3 >( data_width, data_height, data.data() ); break; }
@@ -1400,9 +1387,9 @@ void
texture_manager::delete_textures() {
for( auto const &texture : m_textures ) {
// usunięcie wszyskich tekstur (bez usuwania struktury)
- if( ( texture.first->id > 0 )
- && ( texture.first->id != -1 ) ) {
- ::glDeleteTextures( 1, &(texture.first->id) );
+ if( texture.first->id > 0
+ && texture.first->id != -1 ) {
+ ::glDeleteTextures( 1, &texture.first->id );
}
delete texture.first;
}
@@ -1497,10 +1484,7 @@ texture_manager::find_on_disk( std::string const &Texturename ) {
// if the first attempt fails, try entire extension list
// NOTE: slightly wasteful as it means preferred extension is tested twice, but, eh
- return (
- FileExists(
- filenames,
- { ".dds", ".tga", ".ktx", ".png", ".bmp", ".jpg", ".tex" } ) );
+ return FileExists(filenames, {".dds", ".tga", ".ktx", ".png", ".bmp", ".jpg", ".tex"});
}
//---------------------------------------------------------------------------
diff --git a/model/Texture.h b/model/Texture.h
index cbcce4f6..1f582640 100644
--- a/model/Texture.h
+++ b/model/Texture.h
@@ -155,7 +155,7 @@ public:
mark_as_used( texture_handle const Texture );
// provides direct access to specified texture object
opengl_texture &
- texture( texture_handle const Texture ) const { return *(m_textures[ Texture ].first); }
+ texture( texture_handle const Texture ) const { return *m_textures[Texture].first; }
// performs a resource sweep
void
update();
diff --git a/model/material.cpp b/model/material.cpp
index 272da3ae..f5e32689 100644
--- a/model/material.cpp
+++ b/model/material.cpp
@@ -34,7 +34,7 @@ opengl_material::deserialize( cParser &Input, bool const Loadnow ) {
result = true; // once would suffice but, eh
}
- if( ( path == -1 )
+ if( path == -1
&& ( update_on_weather_change || update_on_season_change ) ) {
// record current texture path in the material, potentially needed when material is reloaded on environment change
// NOTE: we're storing this only for textures that can actually change, to keep the size of path database modest
@@ -95,7 +95,7 @@ void opengl_material::finalize(bool Loadnow)
if( shader && shader->texture_conf.find( key ) != shader->texture_conf.end() ) {
textures[ shader->texture_conf[ key ].id ] = GfxRenderer->Fetch_Texture( value, Loadnow );
}
- else if( ( shader == nullptr )
+ else if( shader == nullptr
&& ( lookup = texture_bindings.find( key ) ) != texture_bindings.end() ) {
textures[ lookup->second ] = GfxRenderer->Fetch_Texture( value, Loadnow );
}
@@ -228,8 +228,8 @@ void opengl_material::finalize(bool Loadnow)
texture_handle handle = textures[entry.id];
// NOTE: texture validation at this stage relies on forced texture load behaviour during its create() call
// TODO: move texture id validation to later stage if/when deferred texture loading is implemented
- if( ( handle )
- && ( GfxRenderer->Texture( handle ).get_id() > 0 ) ) {
+ if( handle
+ && GfxRenderer->Texture(handle).get_id() > 0 ) {
GfxRenderer->Texture(handle).set_components_hint((GLint)entry.components);
}
else {
@@ -277,7 +277,7 @@ std::unordered_set seasons = {
bool is_season( std::string const &String ) {
- return ( seasons.find( String ) != seasons.end() );
+ return seasons.find(String) != seasons.end();
}
std::unordered_set weather = {
@@ -285,7 +285,7 @@ std::unordered_set weather = {
bool is_weather( std::string const &String ) {
- return ( weather.find( String ) != weather.end() );
+ return weather.find(String) != weather.end();
}
// imports member data pair from the config file
@@ -295,7 +295,7 @@ opengl_material::deserialize_mapping( cParser &Input, int const Priority, bool c
// NOTE: comma can be part of legacy file names, so we don't treat it as a separator here
auto key { Input.getToken( true, "\n\r\t ;[]" ) };
// key can be an actual key or block end
- if( ( true == key.empty() ) || ( key == "}" ) ) { return false; }
+ if( true == key.empty() || key == "}" ) { return false; }
if( Priority != -1 ) {
// regular attribute processing mode
@@ -448,10 +448,7 @@ float opengl_material::get_or_guess_opacity() const {
bool
opengl_material::is_translucent() const {
- return (
- textures[ 0 ] != null_handle ?
- GfxRenderer->Texture( textures[ 0 ] ).get_has_alpha() :
- false );
+ return textures[0] != null_handle ? GfxRenderer->Texture(textures[0]).get_has_alpha() : false;
}
// create material object from data stored in specified file.
@@ -501,8 +498,8 @@ material_manager::create( std::string const &Filename, bool const Loadnow ) {
std::make_pair( filename, "make:" ) :
find_on_disk( filename ) };
- if( ( false == isgenerated )
- && ( false == locator.first.empty() ) ) {
+ if( false == isgenerated
+ && false == locator.first.empty() ) {
// try to parse located file resource
cParser materialparser(
locator.first + locator.second,
@@ -615,10 +612,7 @@ std::pair
material_manager::find_on_disk( std::string const &Materialname ) {
auto const materialname { ToLower( Materialname ) };
- return (
- FileExists(
- { Global.asCurrentTexturePath + materialname, materialname, paths::textures + materialname },
- { ".mat" } ) );
+ return FileExists({Global.asCurrentTexturePath + materialname, materialname, paths::textures + materialname}, {".mat"});
}
//---------------------------------------------------------------------------
diff --git a/model/vertex.h b/model/vertex.h
index d3ec3eb9..4c2ff2ad 100644
--- a/model/vertex.h
+++ b/model/vertex.h
@@ -19,7 +19,7 @@ struct world_vertex {
static world_vertex lerp(world_vertex const &a, world_vertex const &b, double factor)
{
- return static_cast((a * (1.0f - factor)) + (b * factor));
+ return static_cast(a * (1.0f - factor) + b * factor);
}
// overloads
diff --git a/scene/scene.cpp b/scene/scene.cpp
index 0675fe3b..14825705 100644
--- a/scene/scene.cpp
+++ b/scene/scene.cpp
@@ -34,9 +34,9 @@ void
basic_cell::on_click( TAnimModel const *Instance ) {
for( auto *launcher : m_eventlaunchers ) {
- if( ( launcher->name() == Instance->name() )
- && ( glm::length2( launcher->location() - Instance->location() ) < launcher->dRadius )
- && ( true == launcher->check_conditions() ) ) {
+ if( launcher->name() == Instance->name()
+ && glm::length2(launcher->location() - Instance->location()) < launcher->dRadius
+ && true == launcher->check_conditions() ) {
launch_event( launcher, true );
}
}
@@ -52,8 +52,8 @@ basic_cell::update_traction( TDynamicObject *Vehicle, int const Pantographindex
auto const position = Vehicle->GetPosition(); // współrzędne środka pojazdu
auto pantograph = Vehicle->pants[ Pantographindex ].fParamPants;
- auto const pantographposition = position + ( vLeft * pantograph->vPos.z ) + ( vUp * pantograph->vPos.y ) + ( vFront * pantograph->vPos.x );
-
+ auto const pantographposition = position + vLeft * pantograph->vPos.z + vUp * pantograph->vPos.y + vFront * pantograph->vPos.x;
+
for( auto *traction : m_directories.traction ) {
// współczynniki równania parametrycznego
@@ -64,8 +64,8 @@ basic_cell::update_traction( TDynamicObject *Vehicle, int const Pantographindex
paramfrontdot :
0.001 ); // div0 trap
- if( ( fRaParam < -0.001 )
- || ( fRaParam > 1.001 ) ) { continue; }
+ if( fRaParam < -0.001
+ || fRaParam > 1.001 ) { continue; }
// jeśli tylko jest w przedziale, wyznaczyć odległość wzdłuż wektorów vUp i vLeft
// punkt styku płaszczyzny z drutem (dla generatora łuku el.)
auto const vStyk = traction->pPoint1 + fRaParam * traction->vParametric;
@@ -76,8 +76,8 @@ basic_cell::update_traction( TDynamicObject *Vehicle, int const Pantographindex
// jeśli ponad pantografem (bo może łapać druty spod wiaduktu)
auto const fHorizontal = std::abs( glm::dot( vGdzie, vLeft ) ) - pantograph->fWidth;
- if( ( Global.bEnableTraction )
- && ( fVertical < pantograph->PantWys - 0.15 ) ) {
+ if (Global.bEnableTraction
+ && fVertical < pantograph->PantWys - 0.15 ) {
// jeśli drut jest niżej niż 15cm pod ślizgiem przełączamy w tryb połamania, o ile jedzie;
// (bEnableTraction) aby dało się jeździć na koślawych sceneriach
// i do tego jeszcze wejdzie pod ślizg
@@ -185,8 +185,8 @@ basic_cell::RaTrackAnimAdd( TTrack *Track ) {
void
basic_cell::RaAnimate( unsigned int const Framestamp ) {
- if( ( tTrackAnim == nullptr )
- || ( Framestamp == m_framestamp ) ) {
+ if( tTrackAnim == nullptr
+ || Framestamp == m_framestamp ) {
// nie ma nic do animowania
return;
}
@@ -244,11 +244,7 @@ basic_cell::deserialize( std::istream &Input ) {
m_lines.emplace_back( lines_node().deserialize( Input ) );
}
// cell activation flag
- m_active = (
- ( true == m_active )
- || ( false == m_shapesopaque.empty() )
- || ( false == m_shapestranslucent.empty() )
- || ( false == m_lines.empty() ) );
+ m_active = true == m_active || false == m_shapesopaque.empty() || false == m_shapestranslucent.empty() || false == m_lines.empty();
}
// sends content of the class in legacy (text) format to provided stream
@@ -274,18 +270,15 @@ basic_cell::insert( shape_node Shape ) {
glm::length( m_area.center - Shape.data().area.center ) + Shape.radius() );
auto const &shapedata { Shape.data() };
- auto &shapes = (
- shapedata.translucent ?
- m_shapestranslucent :
- m_shapesopaque );
+ auto &shapes = shapedata.translucent ? m_shapestranslucent : m_shapesopaque;
for( auto &targetshape : shapes ) {
// try to merge shapes with matching view ranges...
auto const &targetshapedata { targetshape.data() };
- if( ( shapedata.rangesquared_min == targetshapedata.rangesquared_min )
- && ( shapedata.rangesquared_max == targetshapedata.rangesquared_max )
+ if( shapedata.rangesquared_min == targetshapedata.rangesquared_min
+ && shapedata.rangesquared_max == targetshapedata.rangesquared_max
// ...and located close to each other (within arbitrary limit of 25m)
// length2 is better than length for comparing because it does not require sqrt function
- && ( glm::length2( shapedata.area.center - targetshapedata.area.center ) < sq(25.0) ) ) {
+ && glm::length2(shapedata.area.center - targetshapedata.area.center) < sq(25.0) ) {
if( true == targetshape.merge( Shape ) ) {
// if the shape was merged there's nothing left to do
@@ -308,11 +301,11 @@ basic_cell::insert( lines_node Lines ) {
for( auto &targetlines : m_lines ) {
// try to merge shapes with matching view ranges...
auto const &targetlinesdata { targetlines.data() };
- if( ( linesdata.rangesquared_min == targetlinesdata.rangesquared_min )
- && ( linesdata.rangesquared_max == targetlinesdata.rangesquared_max )
+ if( linesdata.rangesquared_min == targetlinesdata.rangesquared_min
+ && linesdata.rangesquared_max == targetlinesdata.rangesquared_max
// ...and located close to each other (within arbitrary limit of 10m)
// length2 is better than length for comparing because it does not require sqrt function
- && ( glm::length2( linesdata.area.center - targetlinesdata.area.center ) < sq(10.0) ) ) {
+ && glm::length2(linesdata.area.center - targetlinesdata.area.center) < sq(10.0) ) {
if( true == targetlines.merge( Lines ) ) {
// if the shape was merged there's nothing left to do
@@ -361,9 +354,7 @@ basic_cell::insert( TAnimModel *Instance ) {
auto const flags = Instance->Flags();
auto alpha =
- ( Instance->Material() != nullptr ?
- Instance->Material()->textures_alpha :
- 0x30300030 );
+ Instance->Material() != nullptr ? Instance->Material()->textures_alpha : 0x30300030;
// assign model to appropriate render phases
if( alpha & flags & 0x2F2F002F ) {
@@ -431,9 +422,7 @@ basic_cell::erase( TAnimModel *Instance ) {
auto const flags = Instance->Flags();
auto alpha =
- ( Instance->Material() != nullptr ?
- Instance->Material()->textures_alpha :
- 0x30300030 );
+ Instance->Material() != nullptr ? Instance->Material()->textures_alpha : 0x30300030;
if( alpha & flags & 0x2F2F002F ) {
// instance has translucent pieces
@@ -524,8 +513,8 @@ basic_cell::find( glm::dvec3 const &Point, float const Radius, bool const Onlyco
for( auto *path : m_paths ) {
for( auto *vehicle : path->Dynamics ) {
- if( ( true == Onlycontrolled )
- && ( vehicle->Mechanik == nullptr ) ) {
+ if( true == Onlycontrolled
+ && vehicle->Mechanik == nullptr ) {
continue;
}
if( false == Findbycoupler ) {
@@ -538,8 +527,8 @@ basic_cell::find( glm::dvec3 const &Point, float const Radius, bool const Onlyco
glm::length2( glm::dvec3{ vehicle->HeadPosition() } - Point ),
glm::length2( glm::dvec3{ vehicle->RearPosition() } - Point ) );
}
- if( ( distance > distancecutoff )
- || ( distance > leastdistance ) ){
+ if( distance > distancecutoff
+ || distance > leastdistance ){
continue;
}
std::tie( vehiclenearest, leastdistance ) = std::tie( vehicle, distance );
@@ -599,19 +588,16 @@ basic_cell::find( glm::dvec3 const &Point, TTraction const *Other, int const Cur
for( auto *traction : m_directories.traction ) {
- if( ( traction == Other )
- || ( traction->psSection != Other->psSection )
- || ( traction == Other->hvNext[ 0 ] )
- || ( traction == Other->hvNext[ 1 ] ) ) {
+ if( traction == Other
+ || traction->psSection != Other->psSection
+ || traction == Other->hvNext[0]
+ || traction == Other->hvNext[1] ) {
// ignore pieces from different sections, and ones connected to the other piece
continue;
}
- endpoint = (
- glm::dot( traction->vParametric, Other->vParametric ) >= 0.0 ?
- Currentdirection ^ 1 :
- Currentdirection );
- if( ( traction->psPower[ endpoint ] == nullptr )
- || ( traction->fResistance[ endpoint ] < 0.0 ) ) {
+ endpoint = glm::dot(traction->vParametric, Other->vParametric) >= 0.0 ? Currentdirection ^ 1 : Currentdirection;
+ if( traction->psPower[endpoint] == nullptr
+ || traction->fResistance[endpoint] < 0.0 ) {
continue;
}
distance = glm::length2( traction->location() - Point );
@@ -728,7 +714,7 @@ basic_section::update_traction( TDynamicObject *Vehicle, int const Pantographind
auto const position = Vehicle->GetPosition(); // współrzędne środka pojazdu
auto pantograph = Vehicle->pants[ Pantographindex ].fParamPants;
- auto const pantographposition = position + ( vLeft * pantograph->vPos.z ) + ( vUp * pantograph->vPos.y ) + ( vFront * pantograph->vPos.x );
+ auto const pantographposition = position + vLeft * pantograph->vPos.z + vUp * pantograph->vPos.y + vFront * pantograph->vPos.x;
auto const radius { EU07_CELLSIZE * 0.5 }; // redius around point of interest
@@ -802,7 +788,7 @@ basic_section::serialize( std::ostream &Output ) const {
// all done; calculate and record section size
auto const sectionendpos { Output.tellp() };
Output.seekp( sectionstartpos );
- sn_utils::ls_uint32( Output, static_cast( ( sizeof( uint32_t ) + ( sectionendpos - sectionstartpos ) ) ) );
+ sn_utils::ls_uint32( Output, static_cast( sizeof(uint32_t) + (sectionendpos - sectionstartpos) ) );
Output.seekp( sectionendpos );
}
@@ -845,9 +831,9 @@ basic_section::insert( shape_node Shape ) {
m_area.radius,
static_cast( glm::length( m_area.center - shapedata.area.center ) + Shape.radius() ) );
- if( ( true == shapedata.translucent )
- || ( shapedata.rangesquared_max <= 90000.0 )
- || ( shapedata.rangesquared_min > 0.0 ) ) {
+ if( true == shapedata.translucent
+ || shapedata.rangesquared_max <= 90000.0
+ || shapedata.rangesquared_min > 0.0 ) {
// small, translucent or not always visible shapes are placed in the sub-cells
cell( shapedata.area.center ).insert( Shape );
}
@@ -891,8 +877,8 @@ basic_section::find( glm::dvec3 const &Point, float const Radius, bool const Onl
continue;
}
std::tie( vehiclefound, distancefound ) = cell.find( Point, Radius, Onlycontrolled, Findbycoupler );
- if( ( vehiclefound != nullptr )
- && ( distancefound < distancenearest ) ) {
+ if( vehiclefound != nullptr
+ && distancefound < distancenearest ) {
std::tie( vehiclenearest, distancenearest ) = std::tie( vehiclefound, distancefound );
}
@@ -937,8 +923,8 @@ basic_section::find( glm::dvec3 const &Point, TTraction const *Other, int const
continue;
}
std::tie( tractionfound, endpointfound, distancefound ) = cell.find( Point, Other, Currentdirection );
- if( ( tractionfound != nullptr )
- && ( distancefound < distancenearest ) ) {
+ if( tractionfound != nullptr
+ && distancefound < distancenearest ) {
std::tie( tractionnearest, endpointnearest, distancenearest ) = std::tie( tractionfound, endpointfound, distancefound );
}
@@ -1032,8 +1018,8 @@ basic_section::cell( glm::dvec3 const &Location, const glm::ivec2 &offset ) {
return
m_cells[
- std::clamp( row, 0, ( EU07_SECTIONSIZE / EU07_CELLSIZE ) - 1 ) * ( EU07_SECTIONSIZE / EU07_CELLSIZE )
- + std::clamp( column, 0, ( EU07_SECTIONSIZE / EU07_CELLSIZE ) - 1 ) ] ;
+ std::clamp( row, 0, EU07_SECTIONSIZE / EU07_CELLSIZE - 1 ) * ( EU07_SECTIONSIZE / EU07_CELLSIZE )
+ + std::clamp( column, 0, EU07_SECTIONSIZE / EU07_CELLSIZE - 1 ) ] ;
}
@@ -1052,7 +1038,7 @@ basic_region::~basic_region() {
void
basic_region::on_click( TAnimModel const *Instance ) {
- if( Instance->name().empty() || ( Instance->name() == "none" ) ) { return; }
+ if( Instance->name().empty() || Instance->name() == "none" ) { return; }
auto const& location { Instance->location() };
@@ -1096,7 +1082,7 @@ basic_region::update_traction( TDynamicObject *Vehicle, int const Pantographinde
auto const position = Vehicle->GetPosition(); // współrzędne środka pojazdu
auto p = Vehicle->pants[ Pantographindex ].fParamPants;
- auto const pant0 = position + ( vLeft * p->vPos.z ) + ( vUp * p->vPos.y ) + ( vFront * p->vPos.x );
+ auto const pant0 = position + vLeft * p->vPos.z + vUp * p->vPos.y + vFront * p->vPos.x;
p->PantTraction = std::numeric_limits::max(); // taka za duża wartość
auto const §ionlist = sections( pant0, EU07_CELLSIZE * 0.5 );
@@ -1127,8 +1113,7 @@ basic_region::is_scene( std::string const &Scenariofile ) const {
uint32_t headermain{ sn_utils::ld_uint32( input ) };
uint32_t headertype{ sn_utils::ld_uint32( input ) };
- if( ( headermain != EU07_FILEHEADER
- || ( headertype != EU07_FILEVERSION_REGION ) ) ) {
+ if( headermain != EU07_FILEHEADER || headertype != EU07_FILEVERSION_REGION ) {
// wrong file type
return false;
}
@@ -1199,8 +1184,7 @@ basic_region::deserialize( std::string const &Scenariofile ) {
uint32_t headermain { sn_utils::ld_uint32( input ) };
uint32_t headertype { sn_utils::ld_uint32( input ) };
- if( ( headermain != EU07_FILEHEADER
- || ( headertype != EU07_FILEVERSION_REGION ) ) ) {
+ if( headermain != EU07_FILEHEADER || headertype != EU07_FILEVERSION_REGION ) {
// wrong file type
WriteLog( "Bad file: \"" + filename + "\" is of either unrecognized type or version" );
return false;
@@ -1326,8 +1310,8 @@ basic_region::insert( shape_node Shape, scratch_data &Scratchpad, bool const Tra
vertex.normal = glm::rotateY( vertex.normal, rotation.y );
}
}
- if( ( false == Scratchpad.location.offset.empty() )
- && ( Scratchpad.location.offset.top() != glm::dvec3( 0, 0, 0 ) ) ) {
+ if( false == Scratchpad.location.offset.empty()
+ && Scratchpad.location.offset.top() != glm::dvec3(0, 0, 0) ) {
// ...and move
auto const& offset = Scratchpad.location.offset.top();
for( auto &vertex : shape.m_data.vertices ) {
@@ -1380,8 +1364,8 @@ basic_region::insert( lines_node Lines, scratch_data &Scratchpad ) {
vertex.position = glm::rotateY( vertex.position, rotation.y );
}
}
- if( ( false == Scratchpad.location.offset.empty() )
- && ( Scratchpad.location.offset.top() != glm::dvec3( 0, 0, 0 ) ) ) {
+ if( false == Scratchpad.location.offset.empty()
+ && Scratchpad.location.offset.top() != glm::dvec3(0, 0, 0) ) {
// ...and move
auto const &offset = Scratchpad.location.offset.top();
for( auto &vertex : Lines.m_data.vertices ) {
@@ -1424,8 +1408,8 @@ basic_region::find_vehicle( glm::dvec3 const &Point, float const Radius, bool co
for( auto *section : sectionlist ) {
std::tie( foundvehicle, founddistance ) = section->find( Point, Radius, Onlycontrolled, Findbycoupler );
- if( ( foundvehicle != nullptr )
- && ( founddistance < nearestdistance ) ) {
+ if( foundvehicle != nullptr
+ && founddistance < nearestdistance ) {
std::tie( nearestvehicle, nearestdistance ) = std::tie( foundvehicle, founddistance );
}
@@ -1477,8 +1461,8 @@ basic_region::find_traction( glm::dvec3 const &Point, TTraction const *Other, in
for( auto *section : sectionlist ) {
std::tie( tractionfound, endpointfound, distancefound ) = section->find( Point, Other, Currentdirection );
- if( ( tractionfound != nullptr )
- && ( distancefound < distancenearest ) ) {
+ if( tractionfound != nullptr
+ && distancefound < distancenearest ) {
std::tie( tractionnearest, endpointnearest, distancenearest ) = std::tie( tractionfound, endpointfound, distancefound );
}
@@ -1509,8 +1493,8 @@ basic_region::sections( glm::dvec3 const &Point, float const Radius ) {
if( column >= EU07_REGIONSIDESECTIONCOUNT ) { break; }
auto *section { m_sections[ row * EU07_REGIONSIDESECTIONCOUNT + column ] };
- if( ( section != nullptr )
- && ( glm::length2( section->area().center - Point ) <= sq( section->area().radius + padding + Radius ) ) ) {
+ if( section != nullptr
+ && glm::length2(section->area().center - Point) <= sq(section->area().radius + padding + Radius) ) {
m_scratchpad.sections.emplace_back( section );
}
@@ -1524,8 +1508,7 @@ bool
basic_region::point_inside( glm::dvec3 const &Location ) {
double const regionboundary = EU07_REGIONSIDESECTIONCOUNT / 2 * EU07_SECTIONSIZE;
- return ( ( Location.x > -regionboundary ) && ( Location.x < regionboundary )
- && ( Location.z > -regionboundary ) && ( Location.z < regionboundary ) );
+ return Location.x > -regionboundary && Location.x < regionboundary && Location.z > -regionboundary && Location.z < regionboundary;
}
// trims provided shape to fit into a section, adds trimmed part at the end of provided list
@@ -1544,12 +1527,12 @@ basic_region::RaTriangleDivider( shape_node &Shape, std::deque &Shap
auto z0 = EU07_SECTIONSIZE * std::floor( 0.001 * Shape.m_data.area.center.z ) - margin;
auto z1 = z0 + EU07_SECTIONSIZE + margin * 2;
- if( ( Shape.m_data.vertices[ 0 ].position.x >= x0 ) && ( Shape.m_data.vertices[ 0 ].position.x <= x1 )
- && ( Shape.m_data.vertices[ 0 ].position.z >= z0 ) && ( Shape.m_data.vertices[ 0 ].position.z <= z1 )
- && ( Shape.m_data.vertices[ 1 ].position.x >= x0 ) && ( Shape.m_data.vertices[ 1 ].position.x <= x1 )
- && ( Shape.m_data.vertices[ 1 ].position.z >= z0 ) && ( Shape.m_data.vertices[ 1 ].position.z <= z1 )
- && ( Shape.m_data.vertices[ 2 ].position.x >= x0 ) && ( Shape.m_data.vertices[ 2 ].position.x <= x1 )
- && ( Shape.m_data.vertices[ 2 ].position.z >= z0 ) && ( Shape.m_data.vertices[ 2 ].position.z <= z1 ) ) {
+ if( Shape.m_data.vertices[0].position.x >= x0 && Shape.m_data.vertices[0].position.x <= x1
+ && Shape.m_data.vertices[0].position.z >= z0 && Shape.m_data.vertices[0].position.z <= z1
+ && Shape.m_data.vertices[1].position.x >= x0 && Shape.m_data.vertices[1].position.x <= x1
+ && Shape.m_data.vertices[1].position.z >= z0 && Shape.m_data.vertices[1].position.z <= z1
+ && Shape.m_data.vertices[2].position.x >= x0 && Shape.m_data.vertices[2].position.x <= x1
+ && Shape.m_data.vertices[2].position.z >= z0 && Shape.m_data.vertices[2].position.z <= z1 ) {
// trójkąt wystający mniej niż 200m z kw. kilometrowego jest do przyjęcia
return false;
}
@@ -1649,17 +1632,13 @@ basic_region::RaTriangleDivider( shape_node &Shape, std::deque &Shap
Shape.m_data.vertices[ 1 ].set_from_z(
Shape.m_data.vertices[ 0 ],
Shape.m_data.vertices[ 1 ],
- ( ( divide & 8 ) ?
- z1 :
- z0 ) );
+ divide & 8 ? z1 : z0 );
}
else {
Shape.m_data.vertices[ 1 ].set_from_x(
Shape.m_data.vertices[ 0 ],
Shape.m_data.vertices[ 1 ],
- ( ( divide & 8 ) ?
- x1 :
- x0 ) );
+ divide & 8 ? x1 : x0 );
}
newshape.m_data.vertices[ 0 ] = Shape.m_data.vertices[ 1 ]; // wierzchołek D jest wspólny
break;
@@ -1672,17 +1651,13 @@ basic_region::RaTriangleDivider( shape_node &Shape, std::deque &Shap
Shape.m_data.vertices[ 2 ].set_from_z(
Shape.m_data.vertices[ 1 ],
Shape.m_data.vertices[ 2 ],
- ( ( divide & 8 ) ?
- z1 :
- z0 ) );
+ divide & 8 ? z1 : z0 );
}
else {
Shape.m_data.vertices[ 2 ].set_from_x(
Shape.m_data.vertices[ 1 ],
Shape.m_data.vertices[ 2 ],
- ( ( divide & 8 ) ?
- x1 :
- x0 ) );
+ divide & 8 ? x1 : x0 );
}
newshape.m_data.vertices[ 1 ] = Shape.m_data.vertices[ 2 ]; // wierzchołek D jest wspólny
break;
@@ -1695,17 +1670,13 @@ basic_region::RaTriangleDivider( shape_node &Shape, std::deque &Shap
Shape.m_data.vertices[ 2 ].set_from_z(
Shape.m_data.vertices[ 2 ],
Shape.m_data.vertices[ 0 ],
- ( ( divide & 8 ) ?
- z1 :
- z0 ) );
+ divide & 8 ? z1 : z0 );
}
else {
Shape.m_data.vertices[ 2 ].set_from_x(
Shape.m_data.vertices[ 2 ],
Shape.m_data.vertices[ 0 ],
- ( ( divide & 8 ) ?
- x1 :
- x0 ) );
+ divide & 8 ? x1 : x0 );
}
newshape.m_data.vertices[ 0 ] = Shape.m_data.vertices[ 2 ]; // wierzchołek D jest wspólny
break;
diff --git a/scene/scene.h b/scene/scene.h
index 7b53783b..9f5201f8 100644
--- a/scene/scene.h
+++ b/scene/scene.h
@@ -341,7 +341,7 @@ public:
//private:
// types
- using cell_array = std::array;
+ using cell_array = std::array;
using shapenode_sequence = std::vector;
// methods
// provides access to section enclosing specified point
diff --git a/scene/sceneeditor.cpp b/scene/sceneeditor.cpp
index be8755a2..4516425d 100644
--- a/scene/sceneeditor.cpp
+++ b/scene/sceneeditor.cpp
@@ -140,8 +140,8 @@ basic_editor::rotate( scene::basic_node *Node, glm::vec3 const &Angle, float con
// quantize resulting angle if requested and type of the node allows it
// TBD, TODO: angle quantization for types other than instanced models
- if( ( Quantization > 0.f )
- && ( typeid( *Node ) == typeid( TAnimModel ) ) ) {
+ if( Quantization > 0.f
+ && typeid(*Node) == typeid(TAnimModel) ) {
auto const initialangle { static_cast( Node )->Angles() };
rotation += initialangle;
diff --git a/scene/sceneeditor.h b/scene/sceneeditor.h
index 8b0344ee..bcff58b6 100644
--- a/scene/sceneeditor.h
+++ b/scene/sceneeditor.h
@@ -25,8 +25,8 @@ struct node_snapshot {
Node->export_as_text( data ); } };
};
-inline bool operator==( node_snapshot const &Left, node_snapshot const &Right ) { return ( ( Left.node == Right.node ) && ( Left.data == Right.data ) ); }
-inline bool operator!=( node_snapshot const &Left, node_snapshot const &Right ) { return ( !( Left == Right ) ); }
+inline bool operator==( node_snapshot const &Left, node_snapshot const &Right ) { return Left.node == Right.node && Left.data == Right.data; }
+inline bool operator!=( node_snapshot const &Left, node_snapshot const &Right ) { return !(Left == Right); }
class basic_editor {
diff --git a/scene/scenenode.cpp b/scene/scenenode.cpp
index eb369751..1ba822e1 100644
--- a/scene/scenenode.cpp
+++ b/scene/scenenode.cpp
@@ -50,9 +50,7 @@ void
bounding_area::deserialize( std::istream &Input, bool const Preserveradius ) {
center = sn_utils::d_dvec3( Input );
- radius = ( Preserveradius ?
- std::max( radius, sn_utils::ld_float32( Input ) ) :
- sn_utils::ld_float32( Input ) );
+ radius = Preserveradius ? std::max(radius, sn_utils::ld_float32(Input)) : sn_utils::ld_float32(Input);
}
@@ -73,9 +71,7 @@ shape_node::shapenode_data::serialize( std::ostream &Output ) const {
// NOTE: material handle is created dynamically on load
sn_utils::s_str(
Output,
- ( material != null_handle ?
- GfxRenderer->Material( material )->GetName() :
- "" ) );
+ material != null_handle ? GfxRenderer->Material(material)->GetName() : "" );
lighting.serialize( Output );
// geometry
sn_utils::s_dvec3( Output, origin );
@@ -152,10 +148,7 @@ shape_node::import( cParser &Input, scene::node_data const &Nodedata ) {
// import common data
m_name = Nodedata.name;
m_data.rangesquared_min = Nodedata.range_min * Nodedata.range_min;
- m_data.rangesquared_max = (
- Nodedata.range_max >= 0.0 ?
- Nodedata.range_max * Nodedata.range_max :
- std::numeric_limits::max() );
+ m_data.rangesquared_max = Nodedata.range_max >= 0.0 ? Nodedata.range_max * Nodedata.range_max : std::numeric_limits::max();
std::string token = Input.getToken();
if( token == "material" ) {
@@ -201,30 +194,14 @@ shape_node::import( cParser &Input, scene::node_data const &Nodedata ) {
// determine way to proceed from the assigned diffuse texture
// TBT, TODO: add methods to material manager to access these simpler
- auto const texturehandle = (
- m_data.material != null_handle ?
- GfxRenderer->Material( m_data.material )->GetTexture(0) :
- null_handle );
- auto const &texture = (
- texturehandle ?
- GfxRenderer->Texture( texturehandle ) :
- *ITexture::null_texture() ); // dirty workaround for lack of better api
- bool const clamps = (
- texturehandle ?
- contains( texture.get_traits(), 's' ) :
- false );
- bool const clampt = (
- texturehandle ?
- contains( texture.get_traits(), 't' ) :
- false );
+ auto const texturehandle = m_data.material != null_handle ? GfxRenderer->Material(m_data.material)->GetTexture(0) : null_handle;
+ auto const &texture = texturehandle ? GfxRenderer->Texture(texturehandle) : *ITexture::null_texture(); // dirty workaround for lack of better api
+ bool const clamps = texturehandle ? contains(texture.get_traits(), 's') : false;
+ bool const clampt = texturehandle ? contains(texture.get_traits(), 't') : false;
// remainder of legacy 'problend' system -- geometry assigned a texture with '@' in its name is treated as translucent, opaque otherwise
if( texturehandle != null_handle ) {
- m_data.translucent = (
- ( ( contains( texture.get_name(), '@' ) )
- && ( true == texture.get_has_alpha() ) ) ?
- true :
- false );
+ m_data.translucent = contains(texture.get_name(), '@') && true == texture.get_has_alpha() ? true : false;
}
else {
m_data.translucent = false;
@@ -237,10 +214,7 @@ shape_node::import( cParser &Input, scene::node_data const &Nodedata ) {
triangle_fan
};
- subtype const nodetype = (
- Nodedata.type == "triangles" ? triangles :
- Nodedata.type == "triangle_strip" ? triangle_strip :
- triangle_fan );
+ subtype const nodetype = Nodedata.type == "triangles" ? triangles : Nodedata.type == "triangle_strip" ? triangle_strip : triangle_fan;
std::size_t vertexcount{ 0 };
world_vertex vertex, vertex1, vertex2;
do {
@@ -349,7 +323,7 @@ shape_node::convert( TSubModel const *Submodel ) {
m_data.lighting.diffuse = Submodel->f4Diffuse;
m_data.lighting.specular = Submodel->f4Specular;
m_data.material = Submodel->m_material;
- m_data.translucent = ( GfxRenderer->Material( m_data.material )->get_or_guess_opacity() == 0.0f );
+ m_data.translucent = GfxRenderer->Material(m_data.material)->get_or_guess_opacity() == 0.0f;
// NOTE: we set unlimited view range typical for terrain, because we don't expect to convert any other 3d models
m_data.rangesquared_max = std::numeric_limits::max();
@@ -453,8 +427,8 @@ shape_node::make_terrain( material_handle const Material, std::vector= 0.0 ?
- Nodedata.range_max * Nodedata.range_max :
- std::numeric_limits::max() );
+ m_data.rangesquared_max = Nodedata.range_max >= 0.0 ? Nodedata.range_max * Nodedata.range_max : std::numeric_limits::max();
// material
Input.getTokens( 3, false );
@@ -614,10 +585,7 @@ lines_node::import( cParser &Input, scene::node_data const &Nodedata ) {
line_loop
};
- subtype const nodetype = (
- Nodedata.type == "lines" ? lines :
- Nodedata.type == "line_strip" ? line_strip :
- line_loop );
+ subtype const nodetype = Nodedata.type == "lines" ? lines : Nodedata.type == "line_strip" ? line_strip : line_loop;
std::size_t vertexcount { 0 };
world_vertex vertex, vertex0, vertex1;
std::string token = Input.getToken();
@@ -661,8 +629,8 @@ lines_node::import( cParser &Input, scene::node_data const &Nodedata ) {
} while( token != "endline" );
// add closing line for the loop
- if( ( nodetype == line_loop )
- && ( vertexcount > 2 ) ) {
+ if( nodetype == line_loop
+ && vertexcount > 2 ) {
m_data.vertices.emplace_back( vertex1 );
m_data.vertices.emplace_back( vertex0 );
}
@@ -678,8 +646,8 @@ lines_node::import( cParser &Input, scene::node_data const &Nodedata ) {
bool
lines_node::merge( lines_node &Lines ) {
- if( ( m_data.line_width != Lines.m_data.line_width )
- || ( m_data.lighting != Lines.m_data.lighting ) ) {
+ if( m_data.line_width != Lines.m_data.line_width
+ || m_data.lighting != Lines.m_data.lighting ) {
// can't merge nodes with different appearance
return false;
}
@@ -754,10 +722,7 @@ basic_node::basic_node( scene::node_data const &Nodedata ) :
uuid = UID::random();
node_type = Nodedata.type;
m_rangesquaredmin = Nodedata.range_min * Nodedata.range_min;
- m_rangesquaredmax = (
- Nodedata.range_max >= 0.0 ?
- Nodedata.range_max * Nodedata.range_max :
- std::numeric_limits::max() );
+ m_rangesquaredmax = Nodedata.range_max >= 0.0 ? Nodedata.range_max * Nodedata.range_max : std::numeric_limits::max();
}
// sends content of the class to provided stream
diff --git a/scene/scenenode.h b/scene/scenenode.h
index a4714705..ca727c2c 100644
--- a/scene/scenenode.h
+++ b/scene/scenenode.h
@@ -34,9 +34,7 @@ struct lighting_data {
inline
bool
operator==( lighting_data const &Left, lighting_data const &Right ) {
- return ( ( Left.diffuse == Right.diffuse )
- && ( Left.ambient == Right.ambient )
- && ( Left.specular == Right.specular ) );
+ return Left.diffuse == Right.diffuse && Left.ambient == Right.ambient && Left.specular == Right.specular;
}
inline
diff --git a/scene/scenenodegroups.cpp b/scene/scenenodegroups.cpp
index a28b1d86..20ac524b 100644
--- a/scene/scenenodegroups.cpp
+++ b/scene/scenenodegroups.cpp
@@ -38,12 +38,12 @@ node_groups::close()
auto const closinggroup { m_activegroup.top() };
m_activegroup.pop();
// if the completed group holds only one item and there's no chance more items will be added, disband it
- if( ( true == m_activegroup.empty() )
- || ( m_activegroup.top() != closinggroup ) ) {
+ if( true == m_activegroup.empty()
+ || m_activegroup.top() != closinggroup ) {
auto lookup { m_groupmap.find( closinggroup ) };
- if( ( lookup != m_groupmap.end() )
- && ( ( lookup->second.nodes.size() + lookup->second.events.size() ) <= 1 ) ) {
+ if( lookup != m_groupmap.end()
+ && lookup->second.nodes.size() + lookup->second.events.size() <= 1 ) {
erase( lookup );
}
@@ -92,7 +92,7 @@ bool node_groups::assign_cross_switch(map::track_switch& sw, std::string &sw_nam
else
pos = 3;
- sw.preview[idx][pos] = ((pos_0 > pos_1) ? '0' : '1');
+ sw.preview[idx][pos] = pos_0 > pos_1 ? '0' : '1';
}
return true;
@@ -231,10 +231,7 @@ node_groups::update_map()
group_handle
node_groups::handle() const {
- return (
- m_activegroup.empty() ?
- null_handle :
- m_activegroup.top() );
+ return m_activegroup.empty() ? null_handle : m_activegroup.top();
}
// places provided node in specified group
@@ -279,8 +276,8 @@ node_groups::export_as_text( std::ostream &Output, bool Dirty ) const {
continue;
// HACK: auto-generated memory cells aren't exported, so we check for this
// TODO: is_exportable as basic_node method
- if( ( typeid( *node ) == typeid( TMemCell ) )
- && ( false == static_cast( node )->is_exportable ) ) {
+ if( typeid(*node) == typeid(TMemCell)
+ && false == static_cast(node)->is_exportable ) {
continue;
}
@@ -322,10 +319,8 @@ node_groups::erase( group_map::const_iterator Group ) {
group_handle
node_groups::create_handle() {
// NOTE: for simplification nested group structure are flattened
- return(
- m_activegroup.empty() ?
- m_groupmap.size() + 1 : // new group isn't created until node registration
- m_activegroup.top() );
+ return m_activegroup.empty() ? m_groupmap.size() + 1 : // new group isn't created until node registration
+ m_activegroup.top();
}
} // scene
diff --git a/scene/sn_utils.cpp b/scene/sn_utils.cpp
index 292c18c3..71e6549c 100644
--- a/scene/sn_utils.cpp
+++ b/scene/sn_utils.cpp
@@ -16,7 +16,7 @@ uint16_t sn_utils::ld_uint16(std::istream &s)
{
uint8_t buf[2];
s.read((char*)buf, 2);
- uint16_t v = (buf[1] << 8) | buf[0];
+ uint16_t v = buf[1] << 8 | buf[0];
return reinterpret_cast(v);
}
@@ -25,7 +25,7 @@ uint32_t sn_utils::ld_uint32(std::istream &s)
{
uint8_t buf[4];
s.read((char*)buf, 4);
- uint32_t v = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
+ uint32_t v = buf[3] << 24 | buf[2] << 16 | buf[1] << 8 | buf[0];
return reinterpret_cast(v);
}
@@ -34,7 +34,7 @@ int32_t sn_utils::ld_int32(std::istream &s)
{
uint8_t buf[4];
s.read((char*)buf, 4);
- uint32_t v = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
+ uint32_t v = buf[3] << 24 | buf[2] << 16 | buf[1] << 8 | buf[0];
return reinterpret_cast(v);
}
@@ -43,10 +43,10 @@ uint64_t sn_utils::ld_uint64(std::istream &s)
{
uint8_t buf[8];
s.read((char*)buf, 8);
- uint64_t v = ((uint64_t)buf[7] << 56) | ((uint64_t)buf[6] << 48) |
- ((uint64_t)buf[5] << 40) | ((uint64_t)buf[4] << 32) |
- ((uint64_t)buf[3] << 24) | ((uint64_t)buf[2] << 16) |
- ((uint64_t)buf[1] << 8) | (uint64_t)buf[0];
+ uint64_t v = (uint64_t)buf[7] << 56 | (uint64_t)buf[6] << 48 |
+ (uint64_t)buf[5] << 40 | (uint64_t)buf[4] << 32 |
+ (uint64_t)buf[3] << 24 | (uint64_t)buf[2] << 16 |
+ (uint64_t)buf[1] << 8 | (uint64_t)buf[0];
return reinterpret_cast(v);
}
@@ -55,10 +55,10 @@ int64_t sn_utils::ld_int64(std::istream &s)
{
uint8_t buf[8];
s.read((char*)buf, 8);
- uint64_t v = ((uint64_t)buf[7] << 56) | ((uint64_t)buf[6] << 48) |
- ((uint64_t)buf[5] << 40) | ((uint64_t)buf[4] << 32) |
- ((uint64_t)buf[3] << 24) | ((uint64_t)buf[2] << 16) |
- ((uint64_t)buf[1] << 8) | (uint64_t)buf[0];
+ uint64_t v = (uint64_t)buf[7] << 56 | (uint64_t)buf[6] << 48 |
+ (uint64_t)buf[5] << 40 | (uint64_t)buf[4] << 32 |
+ (uint64_t)buf[3] << 24 | (uint64_t)buf[2] << 16 |
+ (uint64_t)buf[1] << 8 | (uint64_t)buf[0];
return reinterpret_cast(v);
}
@@ -67,7 +67,7 @@ float sn_utils::ld_float32(std::istream &s)
{
uint8_t buf[4];
s.read((char*)buf, 4);
- uint32_t v = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
+ uint32_t v = buf[3] << 24 | buf[2] << 16 | buf[1] << 8 | buf[0];
return reinterpret_cast(v);
}
@@ -76,10 +76,10 @@ double sn_utils::ld_float64(std::istream &s)
{
uint8_t buf[8];
s.read((char*)buf, 8);
- uint64_t v = ((uint64_t)buf[7] << 56) | ((uint64_t)buf[6] << 48) |
- ((uint64_t)buf[5] << 40) | ((uint64_t)buf[4] << 32) |
- ((uint64_t)buf[3] << 24) | ((uint64_t)buf[2] << 16) |
- ((uint64_t)buf[1] << 8) | (uint64_t)buf[0];
+ uint64_t v = (uint64_t)buf[7] << 56 | (uint64_t)buf[6] << 48 |
+ (uint64_t)buf[5] << 40 | (uint64_t)buf[4] << 32 |
+ (uint64_t)buf[3] << 24 | (uint64_t)buf[2] << 16 |
+ (uint64_t)buf[1] << 8 | (uint64_t)buf[0];
return reinterpret_cast(v);
}
@@ -101,7 +101,7 @@ std::string sn_utils::d_str(std::istream &s)
bool sn_utils::d_bool(std::istream& s)
{
- return ( ld_uint16( s ) == 1 );
+ return ld_uint16(s) == 1;
}
glm::dvec3 sn_utils::d_dvec3(std::istream& s)
@@ -234,9 +234,7 @@ void sn_utils::s_bool(std::ostream &s, bool v)
{
ls_uint16(
s,
- ( true == v ?
- 1 :
- 0 ) );
+ true == v ? 1 : 0 );
}
void sn_utils::s_dvec3(std::ostream &s, glm::dvec3 const &v)
diff --git a/scripting/PyInt.cpp b/scripting/PyInt.cpp
index 0611f51a..1474a584 100644
--- a/scripting/PyInt.cpp
+++ b/scripting/PyInt.cpp
@@ -120,7 +120,7 @@ void render_task::run()
const int screenWidth = static_cast(PyLong_AsLong(outputWidth));
const int screenHeight = static_cast(PyLong_AsLong(outputHeight));
- const bool useRgb = (false && !Global.gfx_usegles);
+ const bool useRgb = false && !Global.gfx_usegles;
const int glFormat = useRgb ? GL_SRGB8 : GL_SRGB8_ALPHA8;
const int glComponents = useRgb ? GL_RGB : GL_RGBA;
@@ -130,7 +130,7 @@ void render_task::run()
Py_ssize_t pythonBufferBytes = 0;
char *pythonBufferPtr = nullptr;
- const bool bufferExtracted = (PyBytes_AsStringAndSize(output, &pythonBufferPtr, &pythonBufferBytes) == 0) && (pythonBufferPtr != nullptr);
+ const bool bufferExtracted = PyBytes_AsStringAndSize(output, &pythonBufferPtr, &pythonBufferBytes) == 0 && pythonBufferPtr != nullptr;
if (!bufferExtracted)
{
@@ -241,7 +241,7 @@ auto python_taskqueue::init() -> bool
crashreport_add_info("python.threadedupload", Global.python_threadedupload ? "yes" : "no");
crashreport_add_info("python.uploadmain", Global.python_uploadmain ? "yes" : "no");
#ifdef _WIN32
- const wchar_t *pythonhome = (sizeof(void *) == 8) ? L"python64" : L"python";
+ const wchar_t *pythonhome = sizeof(void *) == 8 ? L"python64" : L"python";
#elif __linux__
const wchar_t *pythonhome = (sizeof(void *) == 8) ? L"linuxpython64" : L"linuxpython";
#elif __APPLE__
@@ -291,8 +291,8 @@ auto python_taskqueue::init() -> bool
}
stringiomodule = PyImport_ImportModule("io");
- stringioclassname = (stringiomodule != nullptr ? PyObject_GetAttrString(stringiomodule, "StringIO") : nullptr);
- stringioobject = (stringioclassname != nullptr ? PyObject_CallObject(stringioclassname, nullptr) : nullptr);
+ stringioclassname = stringiomodule != nullptr ? PyObject_GetAttrString(stringiomodule, "StringIO") : nullptr;
+ stringioobject = stringioclassname != nullptr ? PyObject_CallObject(stringioclassname, nullptr) : nullptr;
m_stderr = {(stringioobject == nullptr ? nullptr : PySys_SetObject(const_cast("stderr"), stringioobject) != 0 ? nullptr : stringioobject)};
if (false == run_file("abstractscreenrenderer"))
@@ -377,7 +377,7 @@ void python_taskqueue::exit()
auto python_taskqueue::insert(task_request const &Task) -> bool
{
- if (!m_initialized || (false == Global.python_enabled) || (Task.renderer.empty()) || (Task.input == nullptr) || (Task.target == 0))
+ if (!m_initialized || false == Global.python_enabled || Task.renderer.empty() || Task.input == nullptr || Task.target == 0)
{
return false;
}
diff --git a/scripting/ladderlogic.cpp b/scripting/ladderlogic.cpp
index 37a209d0..b86aba6f 100644
--- a/scripting/ladderlogic.cpp
+++ b/scripting/ladderlogic.cpp
@@ -44,10 +44,10 @@ basic_element::output() const -> int {
return std::get(data).value;
}
case basic_element::type_e::timer: {
- return ( std::get(data).time_elapsed >= std::get(data).time_preset ? std::get(data).value : 0 );
+ return std::get(data).time_elapsed >= std::get(data).time_preset ? std::get(data).value : 0;
}
case basic_element::type_e::counter: {
- return ( std::get(data).count_value >= std::get(data).count_limit ? 1 : 0 );
+ return std::get(data).count_value >= std::get(data).count_limit ? 1 : 0;
}
}
@@ -140,10 +140,7 @@ basic_controller::deserialize_operation( cParser &Input ) -> bool {
>> operationparameter;
auto const lookup { m_operationcodemap.find( operationname ) };
- operation.code = (
- lookup != m_operationcodemap.end() ?
- lookup->second :
- opcode_e::op_nop );
+ operation.code = lookup != m_operationcodemap.end() ? lookup->second : opcode_e::op_nop;
if( lookup == m_operationcodemap.end() ) {
log_error( "contains unknown command \"" + operationname + "\"", Input.Line() - 1 );
}
@@ -292,7 +289,7 @@ basic_controller::run() -> int {
case basic_element::type_e::counter: {
std::get(target.data).count_limit = operation.parameter1;
// increase counter value on input activation
- if( ( initialstate == 0 ) && ( target.input() != 0 ) ) {
+ if( initialstate == 0 && target.input() != 0 ) {
/*
// TBD: use overflow-prone version instead of safe one?
target.data.counter.count_value += 1;
@@ -387,10 +384,10 @@ basic_controller::guess_element_type_from_name( std::string const &Name ) const
auto const name { split_string_and_number( Name ) };
- if( ( name.first == "t" ) || ( name.first == "ton" ) || ( name.first.find( "timer." ) == 0 ) ) {
+ if( name.first == "t" || name.first == "ton" || name.first.find("timer.") == 0 ) {
return basic_element::type_e::timer;
}
- if( ( name.first == "c" ) || ( name.first.find( "counter." ) == 0 ) ) {
+ if( name.first == "c" || name.first.find("counter.") == 0 ) {
return basic_element::type_e::counter;
}
diff --git a/scripting/ladderlogic.h b/scripting/ladderlogic.h
index f05afa76..075e4b0d 100644
--- a/scripting/ladderlogic.h
+++ b/scripting/ladderlogic.h
@@ -107,7 +107,7 @@ private:
auto guess_element_type_from_name( std::string const &Name ) const->basic_element::type_e;
inline
auto inverse( int const Value ) const -> int {
- return ( Value == 0 ? 1 : 0 ); }
+ return Value == 0 ? 1 : 0; }
// element access
inline
auto element( element_handle const Element ) const -> basic_element const {
diff --git a/simulation/simulation.cpp b/simulation/simulation.cpp
index 51b7945f..a1493f63 100644
--- a/simulation/simulation.cpp
+++ b/simulation/simulation.cpp
@@ -121,7 +121,7 @@ state_manager::update_clocks() {
// Ra 2014-07: przeliczenie kąta czasu (do animacji zależnych od czasu)
auto const &time = simulation::Time.data();
- Global.fTimeAngleDeg = time.wHour * 15.0 + time.wMinute * 0.25 + ( ( time.wSecond + 0.001 * time.wMilliseconds ) / 240.0 );
+ Global.fTimeAngleDeg = time.wHour * 15.0 + time.wMinute * 0.25 + (time.wSecond + 0.001 * time.wMilliseconds) / 240.0;
Global.fClockAngleDeg[ 0 ] = 36.0 * ( time.wSecond % 10 ); // jednostki sekund
Global.fClockAngleDeg[ 1 ] = 36.0 * ( time.wSecond / 10 ); // dziesiątki sekund
Global.fClockAngleDeg[ 2 ] = 36.0 * ( time.wMinute % 10 ); // jednostki minut
@@ -233,7 +233,7 @@ void state_manager::process_commands() {
// NOTE: because malformed scenario can have vehicle name duplicates we first try to locate vehicle in world, with name search as fallback
TDynamicObject *targetvehicle = std::get( simulation::Region->find_vehicle( commanddata.location, 50, false, false ) );
- if( ( targetvehicle == nullptr ) || ( targetvehicle->name() != commanddata.payload ) ) {
+ if( targetvehicle == nullptr || targetvehicle->name() != commanddata.payload ) {
targetvehicle = simulation::Vehicles.find( commanddata.payload );
}
@@ -251,8 +251,8 @@ void state_manager::process_commands() {
}
auto const sameconsist{
- ( targetvehicle->ctOwner == currentvehicle->Mechanik )
- || ( targetvehicle->ctOwner == currentvehicle->ctOwner ) };
+ targetvehicle->ctOwner == currentvehicle->Mechanik
+ || targetvehicle->ctOwner == currentvehicle->ctOwner };
auto const isincharge{ currentvehicle->Mechanik->primary() };
auto const aidriveractive{ currentvehicle->Mechanik->AIControllFlag };
// TODO: support for primary mode request passed as commanddata.param1
@@ -387,7 +387,7 @@ void state_manager::process_commands() {
// pantographs
for( auto idx = 0; idx < vehicle->iAnimType[ ANIM_PANTS ]; ++idx ) {
- auto &pantograph { *( vehicle->pants[ idx ].fParamPants ) };
+ auto &pantograph { *vehicle->pants[idx].fParamPants };
if( pantograph.PantWys >= 0.0 ) // negative value means pantograph is broken
continue;
pantograph.fAngleL = pantograph.fAngleL0;
diff --git a/simulation/simulationenvironment.cpp b/simulation/simulationenvironment.cpp
index 0f5548be..9837e0e8 100644
--- a/simulation/simulationenvironment.cpp
+++ b/simulation/simulationenvironment.cpp
@@ -61,28 +61,25 @@ world_environment::compute_season( int const Yearday ) {
void
world_environment::compute_weather() {
- Global.Weather = (
- Global.Overcast <= 0.10 ? "clear:" :
- Global.Overcast <= 0.50 ? "scattered:" :
- Global.Overcast <= 0.90 ? "broken:" :
- Global.Overcast <= 1.00 ? "overcast:" :
-
- (Global.AirTemperature > 1 ? "rain:" :
- "snow:" ) );
+ Global.Weather = Global.Overcast <= 0.10 ? "clear:" :
+ Global.Overcast <= 0.50 ? "scattered:" :
+ Global.Overcast <= 0.90 ? "broken:" :
+ Global.Overcast <= 1.00 ? "overcast:" :
- Global.fTurbidity = (
- Global.Overcast <= 0.10 ? 3 :
- Global.Overcast <= 0.20 ? 4 :
- Global.Overcast <= 0.30 ? 5 :
- Global.Overcast <= 0.40 ? 5 :
- Global.Overcast <= 0.50 ? 5 :
- Global.Overcast <= 0.60 ? 5 :
- Global.Overcast <= 0.70 ? 6 :
- Global.Overcast <= 0.80 ? 7 :
- Global.Overcast <= 0.90 ? 8 :
- Global.Overcast > 0.90 ? 9 :
- 9
- );
+ Global.AirTemperature > 1 ? "rain:" :
+ "snow:";
+
+ Global.fTurbidity = Global.Overcast <= 0.10 ? 3 :
+ Global.Overcast <= 0.20 ? 4 :
+ Global.Overcast <= 0.30 ? 5 :
+ Global.Overcast <= 0.40 ? 5 :
+ Global.Overcast <= 0.50 ? 5 :
+ Global.Overcast <= 0.60 ? 5 :
+ Global.Overcast <= 0.70 ? 6 :
+ Global.Overcast <= 0.80 ? 7 :
+ Global.Overcast <= 0.90 ? 8 :
+ Global.Overcast > 0.90 ? 9 :
+ 9;
}
void
@@ -96,9 +93,7 @@ world_environment::init() {
{
auto const rainsoundoverride { simulation::Sound_overrides.find( "weather.rainsound:" ) };
m_rainsound.deserialize(
- ( rainsoundoverride != simulation::Sound_overrides.end() ?
- rainsoundoverride->second :
- "rain-sound-loop" ),
+ rainsoundoverride != simulation::Sound_overrides.end() ? rainsoundoverride->second : "rain-sound-loop",
sound_type::single );
}
m_wind = basic_wind{
@@ -135,7 +130,7 @@ world_environment::update() {
float keylightintensity;
glm::vec3 keylightcolor;
Global.SunAngle = m_sun.getAngle();
- if ((moonlightlevel > sunlightlevel) && (Global.SunAngle <(-20)))
+ if (moonlightlevel > sunlightlevel && Global.SunAngle < -20)
{
// rare situations when the moon is brighter than the sun, typically at night
Global.SunAngle = m_moon.getAngle();
@@ -165,7 +160,7 @@ world_environment::update() {
auto const skydomecolour = m_skydome.GetAverageColor();
auto const skydomehsv = colors::RGBtoHSV( skydomecolour );
// sun strength is reduced by overcast level
- keylightintensity *= ( 1.0f - std::min( 1.f, Global.Overcast ) * 0.65f );
+ keylightintensity *= 1.0f - std::min(1.f, Global.Overcast) * 0.65f;
// intensity combines intensity of the sun and the light reflected by the sky dome
// it'd be more technically correct to have just the intensity of the sun here,
@@ -180,7 +175,7 @@ world_environment::update() {
// tonal impact of skydome color is inversely proportional to how high the sun is above the horizon
// (this is pure conjecture, aimed more to 'look right' than be accurate)
- float const ambienttone = std::clamp( 1.0f - ( Global.SunAngle / 90.0f ), 0.0f, 1.0f );
+ float const ambienttone = std::clamp( 1.0f - Global.SunAngle / 90.0f, 0.0f, 1.0f );
float const ambientintensitynightfactor = 1.f - 0.75f * std::clamp( -m_sun.getAngle(), 0.0f, 18.0f ) / 18.0f;
Global.DayLight.ambient[ 0 ] = std::lerp( skydomehsv.z, skydomecolour.r, ambienttone ) * ambientintensitynightfactor;
Global.DayLight.ambient[ 1 ] = std::lerp( skydomehsv.z, skydomecolour.g, ambienttone ) * ambientintensitynightfactor;
@@ -190,23 +185,17 @@ world_environment::update() {
// update the fog. setting it to match the average colour of the sky dome is cheap
// but quite effective way to make the distant items blend with background better
- Global.FogColor = ((m_skydome.GetAverageHorizonColor()) * keylightcolor) *
+ Global.FogColor = m_skydome.GetAverageHorizonColor() * keylightcolor *
std::clamp((float)Global.fLuminance, 0.f, 1.f);
// weather-related simulation factors
- Global.FrictionWeatherFactor = (
- Global.Weather == "rain:" ? 0.85f :
- Global.Weather == "snow:" ? 0.75f :
- 1.0f );
+ Global.FrictionWeatherFactor = Global.Weather == "rain:" ? 0.85f : Global.Weather == "snow:" ? 0.75f : 1.0f;
- Global.Period = (
- m_sun.getAngle() > -12.0f ?
- "day:" :
- "night:" );
+ Global.Period = m_sun.getAngle() > -12.0f ? "day:" : "night:";
- if( ( true == ( FreeFlyModeFlag || Global.CabWindowOpen ) )
- && ( Global.Weather == "rain:" ) ) {
+ if( true == (FreeFlyModeFlag || Global.CabWindowOpen)
+ && Global.Weather == "rain:" ) {
if( m_rainsound.is_combined() ) {
m_rainsound.pitch( Global.Overcast - 1.0 );
}
diff --git a/simulation/simulationstateserializer.cpp b/simulation/simulationstateserializer.cpp
index aadab538..ef7cd7db 100644
--- a/simulation/simulationstateserializer.cpp
+++ b/simulation/simulationstateserializer.cpp
@@ -53,8 +53,8 @@ state_serializer::deserialize_begin( std::string const &Scenariofile ) {
// TODO: check first for presence of serialized binary files
// if this fails, fall back on the legacy text format
state->scratchpad.name = Scenariofile;
- if( ( true == Global.file_binary_terrain )
- && ( Scenariofile != "$.scn" ) ) {
+ if( true == Global.file_binary_terrain
+ && Scenariofile != "$.scn" ) {
// compilation to binary file isn't supported for rainsted-created overrides
// NOTE: we postpone actual loading of the scene until we process time, season and weather data
state->scratchpad.binary.terrain = Region->is_scene( Scenariofile ) ;
@@ -158,9 +158,9 @@ state_serializer::deserialize_continue(std::shared_ptr state
scene::Groups.update_map();
Region->create_map_geometry();
- if( ( true == Global.file_binary_terrain )
- && ( false == state->scratchpad.binary.terrain )
- && ( state->scenariofile != "$.scn" ) ) {
+ if( true == Global.file_binary_terrain
+ && false == state->scratchpad.binary.terrain
+ && state->scenariofile != "$.scn" ) {
// if we didn't find usable binary version of the scenario files, create them now for future use
// as long as the scenario file wasn't rainsted-created base file override
Region->serialize( state->scenariofile );
@@ -175,8 +175,8 @@ state_serializer::deserialize_isolated( cParser &Input, scene::scratch_data &Scr
auto token { Input.getToken() };
auto *groupowner { TIsolated::Find( token ) };
// ...followed by list of its tracks
- while( ( false == ( token = Input.getToken() ).empty() )
- && ( token != "endisolated" ) ) {
+ while( false == (token = Input.getToken()).empty()
+ && token != "endisolated" ) {
auto *track { simulation::Paths.find( token ) };
if( track != nullptr )
track->AddIsolated( groupowner );
@@ -191,8 +191,8 @@ state_serializer::deserialize_area( cParser &Input, scene::scratch_data &Scratch
auto token { Input.getToken() };
auto *groupowner { TIsolated::Find( token ) };
// ...followed by list of its children
- while( ( false == ( token = Input.getToken() ).empty() )
- && ( token != "endarea" ) ) {
+ while( false == (token = Input.getToken()).empty()
+ && token != "endarea" ) {
// bind the children with their parent
auto *isolated { TIsolated::Find( token ) };
isolated->parent( groupowner );
@@ -203,8 +203,8 @@ void
state_serializer::deserialize_assignment( cParser &Input, scene::scratch_data &Scratchpad ) {
std::string token { Input.getToken() };
- while( ( false == token.empty() )
- && ( token != "endassignment" ) ) {
+ while( false == token.empty()
+ && token != "endassignment" ) {
// assignment is expected to come as string pairs: language id and the actual assignment enclosed in quotes to form a single token
auto assignment{ Input.getToken() };
win1250_to_ascii( assignment );
@@ -254,8 +254,8 @@ state_serializer::deserialize_atmo( cParser &Input, scene::scratch_data &Scratch
// NOTE: ugly, clean it up when we're done with world refactoring
simulation::Environment.compute_weather();
}
- while( ( false == token.empty() )
- && ( token != "endatmo" ) ) {
+ while( false == token.empty()
+ && token != "endatmo" ) {
// anything else left in the section has no defined meaning
token = Input.getToken();
}
@@ -394,11 +394,11 @@ void state_serializer::init_time() {
if( true == Global.ScenarioTimeCurrent ) {
// calculate time shift required to match scenario time with local clock
auto const *localtime = std::gmtime( &Global.starting_timestamp );
- Global.ScenarioTimeOffset = ( ( localtime->tm_hour * 60 + localtime->tm_min ) - ( time.wHour * 60 + time.wMinute ) ) / 60.f;
+ Global.ScenarioTimeOffset = ( localtime->tm_hour * 60 + localtime->tm_min - ( time.wHour * 60 + time.wMinute ) ) / 60.f;
}
else if( false == std::isnan( Global.ScenarioTimeOverride ) ) {
// scenario time override takes precedence over scenario time offset
- Global.ScenarioTimeOffset = ( ( Global.ScenarioTimeOverride * 60 ) - ( time.wHour * 60 + time.wMinute ) ) / 60.f;
+ Global.ScenarioTimeOffset = (Global.ScenarioTimeOverride * 60 - ( time.wHour * 60 + time.wMinute ) ) / 60.f;
}
}
@@ -457,9 +457,9 @@ state_serializer::deserialize_node( cParser &Input, scene::scratch_data &Scratch
ErrorLog( "Bad scenario: duplicate vehicle name \"" + vehicle->name() + "\" defined in file \"" + Input.Name() + "\" (line " + std::to_string( inputline ) + ")" );
}
- if( ( vehicle->MoverParameters->CategoryFlag == 1 ) // trains only
- && ( ( ( vehicle->LightList( end::front ) & ( light::headlight_left | light::headlight_right | light::headlight_upper ) ) != 0 )
- || ( ( vehicle->LightList( end::rear ) & ( light::headlight_left | light::headlight_right | light::headlight_upper ) ) != 0 ) ) ) {
+ if( vehicle->MoverParameters->CategoryFlag == 1 // trains only
+ && ( (vehicle->LightList(end::front) & (light::headlight_left | light::headlight_right | light::headlight_upper)) != 0
+ || (vehicle->LightList(end::rear) & (light::headlight_left | light::headlight_right | light::headlight_upper)) != 0 ) ) {
simulation::Lights.insert( vehicle );
}
}
@@ -564,16 +564,16 @@ state_serializer::deserialize_node( cParser &Input, scene::scratch_data &Scratch
}
}
}
- else if( ( nodedata.type == "triangles" )
- || ( nodedata.type == "triangle_strip" )
- || ( nodedata.type == "triangle_fan" ) ) {
+ else if( nodedata.type == "triangles"
+ || nodedata.type == "triangle_strip"
+ || nodedata.type == "triangle_fan" ) {
auto const skip {
// all shapes will be loaded from the binary version of the file
- ( true == Scratchpad.binary.terrain )
+ true == Scratchpad.binary.terrain
// crude way to detect fixed switch trackbed geometry
- || ( ( true == Global.CreateSwitchTrackbeds )
- && ( Input.Name().size() >= 15 )
+ || ( true == Global.CreateSwitchTrackbeds
+ && Input.Name().size() >= 15
&& Input.Name().starts_with("scenery/zwr")
&& Input.Name().ends_with(".inc") ) };
@@ -589,9 +589,9 @@ state_serializer::deserialize_node( cParser &Input, scene::scratch_data &Scratch
skip_until( Input, "endtri" );
}
}
- else if( ( nodedata.type == "lines" )
- || ( nodedata.type == "line_strip" )
- || ( nodedata.type == "line_loop" ) ) {
+ else if( nodedata.type == "lines"
+ || nodedata.type == "line_strip"
+ || nodedata.type == "line_loop" ) {
if( false == Scratchpad.binary.terrain ) {
@@ -691,10 +691,7 @@ state_serializer::deserialize_scale( cParser &Input, scene::scratch_data &Scratc
factor = glm::vec3( 1.0f );
}
// scales compose component-wise, mirroring how origin offsets compose additively.
- glm::vec3 const parent = (
- Scratchpad.location.scale.empty() ?
- glm::vec3( 1.0f ) :
- Scratchpad.location.scale.top() );
+ glm::vec3 const parent = Scratchpad.location.scale.empty() ? glm::vec3(1.0f) : Scratchpad.location.scale.top();
Scratchpad.location.scale.emplace( factor * parent );
}
@@ -826,7 +823,7 @@ state_serializer::deserialize_editorterrain(cParser &Input, scene::scratch_data
if (!folder.empty() && cells > 0 && cellsize > 0.0f)
{
EditorTerrain.directory(folder);
- EditorTerrain.configure(cells, cellsize, (radius < 0 ? 0 : radius), 0.0f, std::string());
+ EditorTerrain.configure(cells, cellsize, radius < 0 ? 0 : radius, 0.0f, std::string());
EditorTerrain.active(true);
WriteLog("Editor terrain stream enabled: " + folder + " (cells " + std::to_string(cells)
+ ", cellsize " + std::to_string(cellsize) + ", radius " + std::to_string(radius) + ")",
@@ -837,8 +834,8 @@ state_serializer::deserialize_editorterrain(cParser &Input, scene::scratch_data
void
state_serializer::deserialize_endtrainset( cParser &Input, scene::scratch_data &Scratchpad ) {
- if( ( false == Scratchpad.trainset.is_open )
- || ( true == Scratchpad.trainset.vehicles.empty() ) ) {
+ if( false == Scratchpad.trainset.is_open
+ || true == Scratchpad.trainset.vehicles.empty() ) {
// not bloody likely but we better check for it just the same
ErrorLog( "Bad trainset: empty trainset defined in file \"" + Input.Name() + "\" (line " + std::to_string( Input.Line() - 1 ) + ")" );
Scratchpad.trainset.is_open = false;
@@ -848,8 +845,8 @@ state_serializer::deserialize_endtrainset( cParser &Input, scene::scratch_data &
std::size_t vehicleindex { 0 };
for( auto *vehicle : Scratchpad.trainset.vehicles ) {
// go through list of vehicles in the trainset, coupling them together and checking for potential driver
- if( ( vehicle->Mechanik != nullptr )
- && ( vehicle->Mechanik->primary() ) ) {
+ if( vehicle->Mechanik != nullptr
+ && vehicle->Mechanik->primary() ) {
// primary driver will receive the timetable for this trainset
Scratchpad.trainset.driver = vehicle;
// they'll also receive assignment data if there's any
@@ -883,9 +880,7 @@ state_serializer::deserialize_endtrainset( cParser &Input, scene::scratch_data &
// place end signals only on trains without a driver, activate markers otherwise
Scratchpad.trainset.vehicles.back()->RaLightsSet(
-1,
- ( Scratchpad.trainset.driver != nullptr ?
- light::redmarker_left | light::redmarker_right | light::rearendsignals :
- light::rearendsignals ) );
+ Scratchpad.trainset.driver != nullptr ? light::redmarker_left | light::redmarker_right | light::rearendsignals : light::rearendsignals );
}
// all done
Scratchpad.trainset.is_open = false;
@@ -918,10 +913,7 @@ state_serializer::deserialize_traction( cParser &Input, scene::scratch_data &Scr
}
// TODO: refactor track and wrapper classes and their de/serialization. do offset and rotation after deserialization is done
auto *traction = new TTraction( Nodedata );
- auto offset = (
- Scratchpad.location.offset.empty() ?
- glm::dvec3() :
- Scratchpad.location.offset.top() );
+ auto offset = Scratchpad.location.offset.empty() ? glm::dvec3() : Scratchpad.location.offset.top();
traction->Load( &Input, offset );
return traction;
@@ -1020,45 +1012,27 @@ state_serializer::deserialize_dynamic( cParser &Input, scene::scratch_data &Scra
replace_slashes(skinfile);
replace_slashes(mmdfile);
- auto const pathname = (
- Scratchpad.trainset.is_open ?
- Scratchpad.trainset.track :
- Input.getToken() );
+ auto const pathname = Scratchpad.trainset.is_open ? Scratchpad.trainset.track : Input.getToken();
auto const offset { Input.getToken( false ) };
auto const drivertype { Input.getToken() };
- auto const couplingdata = (
- Scratchpad.trainset.is_open ?
- Input.getToken() :
- "3" );
- auto const velocity = (
- Scratchpad.trainset.is_open ?
- Scratchpad.trainset.velocity :
- Input.getToken( false ) );
+ auto const couplingdata = Scratchpad.trainset.is_open ? Input.getToken() : "3";
+ auto const velocity = Scratchpad.trainset.is_open ? Scratchpad.trainset.velocity : Input.getToken(false);
// extract coupling type and optional parameters
auto const couplingdatawithparams = couplingdata.find( '.' );
- auto coupling = (
- couplingdatawithparams != std::string::npos ?
- std::atoi( couplingdata.substr( 0, couplingdatawithparams ).c_str() ) :
- std::atoi( couplingdata.c_str() ) );
+ auto coupling = couplingdatawithparams != std::string::npos ? std::atoi(couplingdata.substr(0, couplingdatawithparams).c_str()) : std::atoi(couplingdata.c_str());
if( coupling < 0 ) {
// sprzęg zablokowany (pojazdy nierozłączalne przy manewrach)
- coupling = ( -coupling ) | coupling::permanent;
+ coupling = -coupling | coupling::permanent;
}
- if( ( offset != -1.0 )
- && ( std::abs( offset ) > 0.5 ) ) { // maksymalna odległość między sprzęgami - do przemyślenia
+ if( offset != -1.0
+ && std::abs(offset) > 0.5 ) { // maksymalna odległość między sprzęgami - do przemyślenia
// likwidacja sprzęgu, jeśli odległość zbyt duża - to powinno być uwzględniane w fizyce sprzęgów...
coupling = coupling::faux;
}
- auto const params = (
- couplingdatawithparams != std::string::npos ?
- couplingdata.substr( couplingdatawithparams + 1 ) :
- "" );
+ auto const params = couplingdatawithparams != std::string::npos ? couplingdata.substr(couplingdatawithparams + 1) : "";
// load amount and type
auto loadcount { Input.getToken( false ) };
- auto loadtype = (
- loadcount ?
- Input.getToken() :
- "" );
+ auto loadtype = loadcount ? Input.getToken() : "";
if( loadtype == "enddynamic" ) {
// idiotoodporność: ładunek bez podanego typu nie liczy się jako ładunek
loadcount = 0;
@@ -1073,11 +1047,11 @@ state_serializer::deserialize_dynamic( cParser &Input, scene::scratch_data &Scra
return nullptr;
}
- if( ( true == Scratchpad.trainset.vehicles.empty() ) // jeśli pierwszy pojazd,
- && ( false == path->m_events0.empty() ) // tor ma Event0
- && ( std::abs( velocity ) <= 1.f ) // a skład stoi
- && ( Scratchpad.trainset.offset >= 0.0 ) // ale może nie sięgać na owy tor
- && ( Scratchpad.trainset.offset < 8.0 ) ) { // i raczej nie sięga
+ if( true == Scratchpad.trainset.vehicles.empty() // jeśli pierwszy pojazd,
+ && false == path->m_events0.empty() // tor ma Event0
+ && std::abs(velocity) <= 1.f // a skład stoi
+ && Scratchpad.trainset.offset >= 0.0 // ale może nie sięgać na owy tor
+ && Scratchpad.trainset.offset < 8.0 ) { // i raczej nie sięga
// przesuwamy około pół EU07 dla wstecznej zgodności
Scratchpad.trainset.offset = 8.0;
}
@@ -1089,22 +1063,20 @@ state_serializer::deserialize_dynamic( cParser &Input, scene::scratch_data &Scra
Nodedata.name,
datafolder, skinfile, mmdfile,
path,
- ( offset == -1.0 ?
- Scratchpad.trainset.offset :
- Scratchpad.trainset.offset - offset ),
+ offset == -1.0 ? Scratchpad.trainset.offset : Scratchpad.trainset.offset - offset,
drivertype,
velocity,
Scratchpad.trainset.name,
loadcount, loadtype,
- ( offset == -1.0 ),
+ offset == -1.0,
params );
if( length != 0.0 ) { // zero oznacza błąd
// przesunięcie dla kolejnego, minus bo idziemy w stronę punktu 1
Scratchpad.trainset.offset -= length;
// automatically establish permanent connections for couplers which specify them in their definitions
- if( ( coupling != 0 )
- && ( vehicle->MoverParameters->Couplers[ ( offset == -1.0 ? end::front : end::rear ) ].AllowedFlag & coupling::permanent ) ) {
+ if( coupling != 0
+ && vehicle->MoverParameters->Couplers[(offset == -1.0 ? end::front : end::rear)].AllowedFlag & coupling::permanent ) {
coupling |= coupling::permanent;
}
if( true == Scratchpad.trainset.is_open ) {
@@ -1160,8 +1132,8 @@ void
state_serializer::skip_until( cParser &Input, std::string const &Token ) {
std::string token { Input.getToken() };
- while( ( false == token.empty() )
- && ( token != Token ) ) {
+ while( false == token.empty()
+ && token != Token ) {
token = Input.getToken();
}
@@ -1296,8 +1268,8 @@ state_serializer::export_as_text(std::string const &Scenariofile) const {
// mem cells
ctrfile << "// memory cells\n";
for( auto const *memorycell : Memory.sequence() ) {
- if( ( true == memorycell->is_exportable )
- && ( memorycell->group() == null_handle ) ) {
+ if( true == memorycell->is_exportable
+ && memorycell->group() == null_handle) {
memorycell->export_as_text( ctrfile );
}
}
diff --git a/simulation/simulationtime.cpp b/simulation/simulationtime.cpp
index e80fb342..52886709 100644
--- a/simulation/simulationtime.cpp
+++ b/simulation/simulationtime.cpp
@@ -28,7 +28,7 @@ scenario_time::init(std::time_t timestamp) {
// potentially adjust scenario clock
auto const requestedtime { clamp_circular( m_time.wHour * 60 + m_time.wMinute + Global.ScenarioTimeOffset * 60, 24 * 60 ) };
- auto const requestedhour { ( requestedtime / 60 ) % 24 };
+ auto const requestedhour { requestedtime / 60 % 24 };
auto const requestedminute { requestedtime % 60 };
// cache requested elements, if any
@@ -50,8 +50,8 @@ scenario_time::init(std::time_t timestamp) {
if( requestedhour != -1 ) { m_time.wHour = static_cast( std::clamp( requestedhour, 0, 23 ) ); }
if( requestedminute != -1 ) { m_time.wMinute = static_cast( std::clamp( requestedminute, 0, 59 ) ); }
// if the time is taken from the local clock leave the seconds intact, otherwise set them to zero
- if( ( requestedhour != -1 )
- || ( requestedminute != 1 ) ) {
+ if( requestedhour != -1
+ || requestedminute != 1 ) {
m_time.wSecond = 0;
}
@@ -82,13 +82,13 @@ scenario_time::init(std::time_t timestamp) {
zonebias += timezoneinfo.StandardBias;
}
- m_timezonebias = ( zonebias / 60.0 );
+ m_timezonebias = zonebias / 60.0;
}
void
scenario_time::update( double const Deltatime ) {
- m_milliseconds += ( 1000.0 * Deltatime );
+ m_milliseconds += 1000.0 * Deltatime;
while( m_milliseconds >= 1000.0 ) {
++m_time.wSecond;
@@ -154,7 +154,7 @@ scenario_time::daymonth( WORD &Day, WORD &Month, WORD const Year, WORD const Yea
int const leap { is_leap( Year ) };
WORD idx = 1;
- while( ( idx < 13 ) && ( Yearday >= daytab[ leap ][ idx ] ) ) {
+ while( idx < 13 && Yearday >= daytab[leap][idx] ) {
++idx;
}
@@ -178,7 +178,7 @@ scenario_time::julian_day() const {
const int gregorianswitchday = 2299160;
if( JD > gregorianswitchday ) {
- int K3 = std::floor( std::floor( ( yy * 0.01 ) + 49 ) * 0.75 ) - 38;
+ int K3 = std::floor( std::floor( yy * 0.01 + 49 ) * 0.75 ) - 38;
JD -= K3;
}
@@ -201,10 +201,10 @@ scenario_time::day_of_week( int const Day, int const Month, int const Year ) con
int const m = Month > 2 ? Month : Month + 12;
int const y = Month > 2 ? Year : Year - 1;
- int const h = ( q + ( 26 * ( m + 1 ) / 10 ) + y + ( y / 4 ) + 6 * ( y / 100 ) + ( y / 400 ) ) % 7;
+ int const h = ( q + 26 * (m + 1) / 10 + y + y / 4 + 6 * ( y / 100 ) + y / 400 ) % 7;
/* return ( (h + 5) % 7 ) + 1; // iso week standard, with monday = 1
-*/ return ( (h + 6) % 7 ) + 1; // sunday = 1 numbering method, used in north america, japan
+*/ return (h + 6) % 7 + 1; // sunday = 1 numbering method, used in north america, japan
}
// calculates day of month for specified weekday of specified month of the year
@@ -251,7 +251,7 @@ scenario_time::convert_transition_time( SYSTEMTIME &Time ) const {
bool
scenario_time::is_leap( int const Year ) const {
- return ( ( Year % 4 == 0 ) && ( ( Year % 100 != 0 ) || ( Year % 400 == 0 ) ) );
+ return Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0);
}
//---------------------------------------------------------------------------
diff --git a/simulation/simulationtime.h b/simulation/simulationtime.h
index 0540ef76..49e1a012 100644
--- a/simulation/simulationtime.h
+++ b/simulation/simulationtime.h
@@ -34,7 +34,7 @@ public:
inline
double
second() const {
- return ( m_time.wMilliseconds * 0.001 + m_time.wSecond ); }
+ return m_time.wMilliseconds * 0.001 + m_time.wSecond; }
inline
int
year_day() const {
diff --git a/utilities/Float3d.h b/utilities/Float3d.h
index 2ff2bcc2..1e5e9892 100644
--- a/utilities/Float3d.h
+++ b/utilities/Float3d.h
@@ -34,7 +34,7 @@ class float3
inline bool operator==(const float3 &v1, const float3 &v2)
{
- return (v1.x == v2.x && v1.y == v2.y && v1.z == v2.z);
+ return v1.x == v2.x && v1.y == v2.y && v1.z == v2.z;
};
inline float3 &operator+=(float3 &v1, const float3 &v2)
{
@@ -60,7 +60,7 @@ inline float float3::Length() const
return std::sqrt(LengthSquared());
};
inline float float3::LengthSquared() const {
- return ( x * x + y * y + z * z );
+ return x * x + y * y + z * z;
}
inline float3 operator*( float3 const &v, float const k ) {
return float3( v.x * k, v.y * k, v.z * k );
@@ -90,7 +90,7 @@ inline float DotProduct( float3 const &v1, float3 const &v2 ) {
inline float3 Interpolate( float3 const &First, float3 const &Second, float const Factor ) {
- return ( First * ( 1.0f - Factor ) ) + ( Second * Factor );
+ return First * (1.0f - Factor) + Second * Factor;
}
class float4
@@ -131,7 +131,7 @@ inline float4 operator-(const float4 &q)
};
inline float4 operator-(const float4 &q1, const float4 &q2)
{ // z odejmowaniem nie ma lekko
- return (-q1) * q2; // inwersja tylko dla znormalizowanych!
+ return -q1 * q2; // inwersja tylko dla znormalizowanych!
};
inline float4 operator+(const float4 &v1, const float4 &v2)
{
@@ -250,7 +250,7 @@ public:
inline bool IdentityIs()
{ // sprawdzenie jednostkowości
for (int i = 0; i < 16; ++i)
- if (e[i] != ((i % 5) ? 0.0 : 1.0)) // jedynki tylko na 0, 5, 10 i 15
+ if (e[i] != (i % 5 ? 0.0 : 1.0)) // jedynki tylko na 0, 5, 10 i 15
return false;
return true;
}
@@ -280,7 +280,7 @@ inline float4x4 &float4x4::Rotation(float const Angle, float3 const &Axis)
auto const c = std::cos(Angle);
auto const s = std::sin(Angle);
// One minus c (short name for legibility of formulai)
- auto const omc = (1.f - c);
+ auto const omc = 1.f - c;
auto const axis = SafeNormalize(Axis);
auto const xs = axis.x * s;
auto const ys = axis.y * s;
diff --git a/utilities/Globals.cpp b/utilities/Globals.cpp
index 0dba2041..332524fb 100644
--- a/utilities/Globals.cpp
+++ b/utilities/Globals.cpp
@@ -251,7 +251,7 @@ bool global_settings::ConfigParseGraphics(cParser& Parser, const std::string& to
{
std::string value;
ParseOne(Parser, value);
- asSky = (value == "yes" ? "1" : "0");
+ asSky = value == "yes" ? "1" : "0";
return true;
}
@@ -263,7 +263,7 @@ bool global_settings::ConfigParseGraphics(cParser& Parser, const std::string& to
if (value == "tga")
szDefaultExt = szTexturesTGA;
else
- szDefaultExt = (value[0] == '.' ? value : "." + value);
+ szDefaultExt = value[0] == '.' ? value : "." + value;
return true;
}
@@ -318,8 +318,8 @@ bool global_settings::ConfigParseGraphics(cParser& Parser, const std::string& to
GfxRenderer = "experimental";
}
- BasicRenderer = (GfxRenderer == "simple");
- LegacyRenderer = !NvRenderer && (GfxRenderer != "default");
+ BasicRenderer = GfxRenderer == "simple";
+ LegacyRenderer = !NvRenderer && GfxRenderer != "default";
return true;
}
@@ -338,7 +338,7 @@ bool global_settings::ConfigParseGraphics(cParser& Parser, const std::string& to
shadowtune.map_size = clamp_power_of_two(shadowtune.map_size, 512, 8192);
shadowtune.range =
- std::max((shadowtune.map_size <= 2048 ? 75.f : 75.f * shadowtune.map_size / 2048),
+ std::max(shadowtune.map_size <= 2048 ? 75.f : 75.f * shadowtune.map_size / 2048,
shadowtune.range);
return true;
}
@@ -696,7 +696,7 @@ bool global_settings::ConfigParseSimulation(cParser& Parser, const std::string&
{
std::string value;
ParseOne(Parser, value);
- iPause |= (value == "yes" ? 1 : 0);
+ iPause |= value == "yes" ? 1 : 0;
return true;
}
@@ -704,7 +704,7 @@ bool global_settings::ConfigParseSimulation(cParser& Parser, const std::string&
{
std::string value;
ParseOne(Parser, value, 1);
- priorityLoadText3D = (value == "yes");
+ priorityLoadText3D = value == "yes";
return true;
}
@@ -993,7 +993,7 @@ bool global_settings::ConfigParseHardware(cParser& Parser, const std::string& to
{
for (auto const& x : uartfeatures_map)
{
- *(x.second) = false;
+ *x.second = false;
}
std::string key;
@@ -1005,7 +1005,7 @@ bool global_settings::ConfigParseHardware(cParser& Parser, const std::string& to
if (uartfeatures_map.count(key))
{
- *(uartfeatures_map[key]) = true;
+ *uartfeatures_map[key] = true;
}
}
}
@@ -1146,7 +1146,7 @@ bool global_settings::ConfigParseDebug(cParser& Parser, const std::string& token
int in = 0;
Parser >> in;
- if ((in < 0) || (in > 5))
+ if (in < 0 || in > 5)
in = 5;
Parser.getTokens(4, false);
@@ -1167,7 +1167,7 @@ bool global_settings::ConfigParseDebug(cParser& Parser, const std::string& token
int in = 0;
Parser >> in;
- if ((in < 0) || (in > 5))
+ if (in < 0 || in > 5)
in = 5;
Parser.getTokens(6, false);
@@ -1187,7 +1187,7 @@ bool global_settings::ConfigParseDebug(cParser& Parser, const std::string& token
int out = 0;
Parser >> out;
- if ((out < 0) || (out > 6))
+ if (out < 0 || out > 6)
out = 6;
Parser.getTokens(4, false);
@@ -1208,7 +1208,7 @@ bool global_settings::ConfigParseDebug(cParser& Parser, const std::string& token
int out = 0;
Parser >> out;
- if ((out < 0) || (out > 6))
+ if (out < 0 || out > 6)
out = 6;
Parser.getTokens(6, false);
@@ -1678,7 +1678,7 @@ global_settings::export_as_text( std::ostream &Output ) const {
std::vector enabled_uartfeatures;
for(auto const &x : uartfeatures_map) {
- if(*(x.second)) {
+ if(*x.second) {
enabled_uartfeatures.push_back(x.first);
}
}
diff --git a/utilities/Logs.cpp b/utilities/Logs.cpp
index 48d74317..554a77b9 100644
--- a/utilities/Logs.cpp
+++ b/utilities/Logs.cpp
@@ -108,7 +108,7 @@ void LogService()
{
if (!output.is_open())
{
- std::string filename = (Global.MultipleLogs ? "logs/log (" + filename_scenery() + ") " + filename_date() + ".txt" : "log.txt");
+ std::string filename = Global.MultipleLogs ? "logs/log (" + filename_scenery() + ") " + filename_date() + ".txt" : "log.txt";
output.open(filename, std::ios::trunc);
}
output << msg << "\n";
@@ -143,7 +143,7 @@ void LogService()
if (!errors.is_open())
{
- std::string filename = (Global.MultipleLogs ? "logs/errors (" + filename_scenery() + ") " + filename_date() + ".txt" : "errors.txt");
+ std::string filename = Global.MultipleLogs ? "logs/errors (" + filename_scenery() + ") " + filename_date() + ".txt" : "errors.txt";
errors.open(filename, std::ios::trunc);
errors << "EU07.EXE " + Global.asVersion << "\n";
}
diff --git a/utilities/Logs.h b/utilities/Logs.h
index 88542be4..93276d65 100644
--- a/utilities/Logs.h
+++ b/utilities/Logs.h
@@ -11,17 +11,17 @@ http://mozilla.org/MPL/2.0/.
enum class logtype : unsigned int {
- generic = ( 1 << 0 ),
- file = ( 1 << 1 ),
- model = ( 1 << 2 ),
- texture = ( 1 << 3 ),
- lua = ( 1 << 4 ),
- material = ( 1 << 5 ),
- shader = ( 1 << 6 ),
- net = ( 1 << 7 ),
- sound = ( 1 << 8 ),
- traction = ( 1 << 9 ),
- powergrid = ( 1 << 10 ),
+ generic = 1 << 0,
+ file = 1 << 1,
+ model = 1 << 2,
+ texture = 1 << 3,
+ lua = 1 << 4,
+ material = 1 << 5,
+ shader = 1 << 6,
+ net = 1 << 7,
+ sound = 1 << 8,
+ traction = 1 << 9,
+ powergrid = 1 << 10,
};
void LogService();
void WriteLog( const char *str, logtype const Type = logtype::generic, bool isError = false );
diff --git a/utilities/Names.h b/utilities/Names.h
index 8d9d4663..0533c696 100644
--- a/utilities/Names.h
+++ b/utilities/Names.h
@@ -26,7 +26,7 @@ public:
bool
insert( Type_ *Item, std::string itemname ) {
m_items.emplace_back( Item );
- if( ( true == itemname.empty() ) || ( itemname == "none" ) ) {
+ if( true == itemname.empty() || itemname == "none" ) {
return true;
}
auto const itemhandle { m_items.size() - 1 };
@@ -64,10 +64,7 @@ public:
}
uint32_t find_id( std::string const &Name) const {
auto lookup = m_itemmap.find( Name );
- return (
- lookup != m_itemmap.end() ?
- lookup->second :
- -1 );
+ return lookup != m_itemmap.end() ? lookup->second : -1;
}
void purge (Type_ *Item)
{
@@ -83,10 +80,7 @@ public:
Type_ *
find( std::string const &Name ) const {
auto lookup = m_itemmap.find( Name );
- return (
- lookup != m_itemmap.end() ?
- m_items[ lookup->second ] :
- nullptr ); }
+ return lookup != m_itemmap.end() ? m_items[lookup->second] : nullptr; }
protected:
// types
diff --git a/utilities/Timer.h b/utilities/Timer.h
index 5ac9cc3c..0e47e14c 100644
--- a/utilities/Timer.h
+++ b/utilities/Timer.h
@@ -34,7 +34,7 @@ public:
m_start = std::chrono::steady_clock::now(); }
std::chrono::duration
stop() {
- m_last = std::chrono::duration_cast( ( std::chrono::steady_clock::now() - m_start ) );
+ m_last = std::chrono::duration_cast( std::chrono::steady_clock::now() - m_start );
m_accumulator = 0.95f * m_accumulator + m_last.count() / 1000.f;
return m_last; }
float
diff --git a/utilities/color.h b/utilities/color.h
index bc3555d4..76aecf16 100644
--- a/utilities/color.h
+++ b/utilities/color.h
@@ -42,7 +42,7 @@ RGBtoHSV( glm::vec3 const &RGB ) {
return hsv;
}
if( max > 0.0 ) { // NOTE: if Max is == 0, this divide would cause a crash
- hsv.y = ( delta / max ); // s
+ hsv.y = delta / max; // s
}
else {
// if max is 0, then r = g = b = 0
@@ -85,8 +85,8 @@ HSVtoRGB( glm::vec3 const &HSV ) {
int const i = (int)hh;
float const ff = hh - i;
float const p = HSV.z * ( 1.f - HSV.y );
- float const q = HSV.z * ( 1.f - ( HSV.y * ff ) );
- float const t = HSV.z * ( 1.f - ( HSV.y * ( 1.f - ff ) ) );
+ float const q = HSV.z * ( 1.f - HSV.y * ff );
+ float const t = HSV.z * ( 1.f - HSV.y * (1.f - ff) );
switch( i ) {
case 0:
diff --git a/utilities/motiontelemetry.cpp b/utilities/motiontelemetry.cpp
index c7f690f8..473970d7 100644
--- a/utilities/motiontelemetry.cpp
+++ b/utilities/motiontelemetry.cpp
@@ -32,7 +32,7 @@ motiontelemetry::motiontelemetry()
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC;
- hints.ai_socktype = (conf.proto == "tcp" ? SOCK_STREAM : SOCK_DGRAM);
+ hints.ai_socktype = conf.proto == "tcp" ? SOCK_STREAM : SOCK_DGRAM;
if (getaddrinfo(conf.address.c_str(), conf.port.c_str(), &hints, &res))
throw std::runtime_error("motiontelemetry: getaddrinfo failed");
diff --git a/utilities/parser.cpp b/utilities/parser.cpp
index 68656c5d..012c6b8a 100644
--- a/utilities/parser.cpp
+++ b/utilities/parser.cpp
@@ -65,7 +65,7 @@ cParser::cParser(std::string const &Stream, buffertype const Type, std::string P
Path.append(Stream);
mStream = std::make_shared(Path, std::ios_base::binary);
// content of *.inc files is potentially grouped together
- if ((Stream.size() >= 4) && (ToLower(Stream.substr(Stream.size() - 4)) == ".inc"))
+ if (Stream.size() >= 4 && ToLower(Stream.substr(Stream.size() - 4)) == ".inc")
{
mIncFile = true;
scene::Groups.create();
@@ -145,7 +145,7 @@ template <> cParser &cParser::operator>>(bool &Right)
return *this;
}
- Right = ((this->tokens.front() == "true") || (this->tokens.front() == "yes") || (this->tokens.front() == "1"));
+ Right = this->tokens.front() == "true" || this->tokens.front() == "yes" || this->tokens.front() == "1";
this->tokens.pop_front();
return *this;
@@ -155,7 +155,7 @@ template <> bool cParser::getToken(bool const ToLower, const char *Break)
{
auto const token = getToken(true, Break);
- return ((token == "true") || (token == "yes") || (token == "1"));
+ return token == "true" || token == "yes" || token == "1";
}
// methods
@@ -284,10 +284,10 @@ void cParser::substituteParameters(std::string& token, bool ToLower) {
if (close == std::string::npos) break; // malformed -> stop like old behavior (it would substr weirdly)
const std::string idxStr = token.substr(pos + 2, close - (pos + 2));
- token.erase(pos, (close - pos) + 1);
+ token.erase(pos, close - pos + 1);
const size_t nr = static_cast(std::atoi(idxStr.c_str()));
- const std::string repl = (nr >= 1 && (nr - 1) < parameters.size())
+ const std::string repl = nr >= 1 && nr - 1 < parameters.size()
? parameters[nr - 1]
: std::string("none");
@@ -317,8 +317,8 @@ void cParser::startIncludeFromParser(cParser& srcParser, bool ToLower, std::stri
replace_slashes(includefile);
const bool allowTraction =
- (true == LoadTraction) ||
- ((false == contains(includefile, "tr/")) && (false == contains(includefile, "tra/")));
+ true == LoadTraction ||
+ (false == contains(includefile, "tr/") && false == contains(includefile, "tra/"));
if (!allowTraction) {
// skip include block until "end" (original behavior in token-mode include)
@@ -368,7 +368,7 @@ bool cParser::handleIncludeIfPresent(std::string& token, bool ToLower, const cha
}
// line-mode HACK: Break == "\n\r" and line begins with "include"
- if ((std::strcmp(Break, "\n\r") == 0) && token.compare(0, 7, "include") == 0) {
+ if (std::strcmp(Break, "\n\r") == 0 && token.compare(0, 7, "include") == 0) {
cParser includeparser(token.substr(7));
std::string includefile;
if (allowRandomIncludes)
@@ -414,7 +414,7 @@ std::vector cParser::readParameters(cParser &Input)
std::vector includeparameters;
std::string parameter;
Input.readToken(parameter, false); // w parametrach nie zmniejszamy
- while ((parameter.empty() == false) && (parameter != "end"))
+ while (parameter.empty() == false && parameter != "end")
{
includeparameters.emplace_back(parameter);
Input.readToken(parameter, false);
@@ -531,7 +531,7 @@ int cParser::getFullProgress() const
int progress = getProgress();
if (mIncludeParser)
- return progress + ((100 - progress) * (mIncludeParser->getProgress()) / 100);
+ return progress + (100 - progress) * mIncludeParser->getProgress() / 100;
else
return progress;
}
diff --git a/utilities/parser.h b/utilities/parser.h
index 6bac77e7..0cf51d8c 100644
--- a/utilities/parser.h
+++ b/utilities/parser.h
@@ -60,7 +60,7 @@ class cParser //: public std::stringstream
inline
bool
ok() {
- return ( !mStream->fail() ); };
+ return !mStream->fail(); };
cParser &
autoclear( bool const Autoclear );
inline
@@ -77,10 +77,7 @@ class cParser //: public std::stringstream
inline
std::string
peek() const {
- return (
- false == tokens.empty() ?
- tokens.front() :
- "" ); }
+ return false == tokens.empty() ? tokens.front() : ""; }
// inject string as internal include
void injectString(const std::string &str);
diff --git a/utilities/translation.cpp b/utilities/translation.cpp
index 129d1be9..0885ab7c 100644
--- a/utilities/translation.cpp
+++ b/utilities/translation.cpp
@@ -38,13 +38,13 @@ const std::string& locale::lookup_s(const std::string &msg, bool constant)
if (constant) {
auto it = pointer_cache.find(&msg);
if (it != pointer_cache.end())
- return *((const std::string*)(it->second));
+ return *(const std::string *)it->second;
}
auto it = lang_mapping.find(msg);
if (it != lang_mapping.end()) {
if (constant)
- pointer_cache.emplace(&msg, &(it->second));
+ pointer_cache.emplace(&msg, &it->second);
return it->second;
}
@@ -58,7 +58,7 @@ const char* locale::lookup_c(const char *msg, bool constant)
if (constant) {
auto it = pointer_cache.find(msg);
if (it != pointer_cache.end())
- return (const char*)(it->second);
+ return (const char*)it->second;
}
auto it = lang_mapping.find(std::string(msg));
@@ -156,7 +156,7 @@ std::string locale::parse_c_literal(const std::string &str)
n2 -= 7;
if (n2 > 16)
n2 -= 32;
- out += ((n1 << 4) | n2);
+ out += n1 << 4 | n2;
}
escape = false;
}
@@ -347,10 +347,7 @@ std::string locale::label_cab_control(std::string const &Label)
};
auto const it = cabcontrols_labels.find( Label );
- return (
- it != cabcontrols_labels.end() ?
- lookup_s(it->second) :
- "" );
+ return it != cabcontrols_labels.end() ? lookup_s(it->second) : "";
}
const std::string& locale::coupling_name(int c)
diff --git a/utilities/uart.cpp b/utilities/uart.cpp
index 525453bf..f835487f 100644
--- a/utilities/uart.cpp
+++ b/utilities/uart.cpp
@@ -27,9 +27,7 @@ const char* uart_baudrates_list[] = {
"2000000"
};
-const size_t uart_baudrates_list_num = (
- sizeof(uart_baudrates_list)/sizeof(uart_baudrates_list[0])
- );
+const size_t uart_baudrates_list_num = sizeof(uart_baudrates_list) / sizeof(uart_baudrates_list[0]);
void uart_status::reset_stats() {
packets_sent = 0;
@@ -423,8 +421,8 @@ void uart_input::poll()
auto const byte { std::get( entry ) / 8 };
auto const bit { std::get( entry ) % 8 };
- bool const state { ( ( buffer[ byte ] & ( 1 << bit ) ) != 0 ) };
- bool const changed { ( ( ( old_packet[ byte ] & ( 1 << bit ) ) != 0 ) != state ) };
+ bool const state { ( ( buffer[ byte ] & 1 << bit ) != 0 ) };
+ bool const changed { ( (old_packet[byte] & 1 << bit) != 0 != state ) };
if( false == changed ) { continue; }
@@ -432,16 +430,12 @@ void uart_input::poll()
auto const action { (
type != input_type_t::impulse ?
GLFW_PRESS :
- ( state ?
- GLFW_PRESS :
- GLFW_RELEASE ) ) };
+ state ? GLFW_PRESS : GLFW_RELEASE) };
auto const command { (
type != input_type_t::toggle ?
std::get<2>( entry ) :
- ( state ?
- std::get<2>( entry ) :
- std::get<3>( entry ) ) ) };
+ state ? std::get<2>(entry) : std::get<3>(entry) ) };
// TODO: pass correct entity id once the missing systems are in place
relay.post( command, 0, 0, action, 0 );
@@ -461,7 +455,7 @@ void uart_input::poll()
}
else {
auto desiredpercent{ buffer[6] * 0.01 };
- auto desiredposition{ desiredpercent > 0.01 ? 1 + ((simulation::Train->Occupied()->MainCtrlPosNo - 1) * desiredpercent) : buffer[6] };
+ auto desiredposition{ desiredpercent > 0.01 ? 1 + (simulation::Train->Occupied()->MainCtrlPosNo - 1) * desiredpercent : buffer[6] };
relay.post(
user_command::mastercontrollerset,
desiredposition,
@@ -484,7 +478,7 @@ void uart_input::poll()
}
if( true == conf.trainenable ) {
// train brake
- double const position { (float)( ( (uint16_t)buffer[ 8 ] | ( (uint16_t)buffer[ 9 ] << 8 ) ) - conf.mainbrakemin ) / ( conf.mainbrakemax - conf.mainbrakemin ) };
+ double const position { (float)( ( (uint16_t)buffer[ 8 ] | (uint16_t)buffer[9] << 8 ) - conf.mainbrakemin ) / ( conf.mainbrakemax - conf.mainbrakemin ) };
relay.post(
user_command::trainbrakeset,
position,
@@ -495,7 +489,7 @@ void uart_input::poll()
}
if( true == conf.localenable ) {
// independent brake
- double const position { (float)( ( (uint16_t)buffer[ 10 ] | ( (uint16_t)buffer[ 11 ] << 8 ) ) - conf.localbrakemin ) / ( conf.localbrakemax - conf.localbrakemin ) };
+ double const position { (float)( ( (uint16_t)buffer[ 10 ] | (uint16_t)buffer[11] << 8 ) - conf.localbrakemin ) / ( conf.localbrakemax - conf.localbrakemin ) };
relay.post(
user_command::independentbrakeset,
position,
@@ -538,7 +532,7 @@ void uart_input::poll()
auto const trainstate = t->get_state();
SYSTEMTIME time = simulation::Time.data();
- uint16_t tacho = Global.iPause ? 0 : (trainstate.velocity * conf.tachoscale);
+ uint16_t tacho = Global.iPause ? 0 : trainstate.velocity * conf.tachoscale;
uint16_t tank_press = (uint16_t)std::min(conf.tankuart, trainstate.reservoir_pressure * 0.1f / conf.tankmax * conf.tankuart);
uint16_t pipe_press = (uint16_t)std::min(conf.pipeuart, trainstate.pipe_pressure * 0.1f / conf.pipemax * conf.pipeuart);
uint16_t brake_press = (uint16_t)std::min(conf.brakeuart, trainstate.brake_pressure * 0.1f / conf.brakemax * conf.brakeuart);
@@ -655,5 +649,5 @@ void uart_input::poll()
}
bool uart_input::is_connected() {
- return (port != nullptr);
+ return port != nullptr;
}
diff --git a/utilities/utilities.cpp b/utilities/utilities.cpp
index 6ee5ffe6..dfde6854 100644
--- a/utilities/utilities.cpp
+++ b/utilities/utilities.cpp
@@ -61,14 +61,14 @@ std::string Now()
double CompareTime(double t1h, double t1m, double t2h, double t2m)
{
- if ((t2h < 0))
+ if (t2h < 0)
return 0;
else
{
auto t = (t2h - t1h) * 60 + t2m - t1m; // jeśli t2=00:05, a t1=23:50, to różnica wyjdzie ujemna
- if ((t < -720)) // jeśli różnica przekracza 12h na minus
+ if (t < -720) // jeśli różnica przekracza 12h na minus
t = t + 1440; // to dodanie doby minut;else
- if ((t > 720)) // jeśli przekracza 12h na plus
+ if (t > 720) // jeśli przekracza 12h na plus
t = t - 1440; // to odjęcie doby minut
return t;
}
@@ -130,8 +130,8 @@ std::string generate_uuid_v4()
b = static_cast(dist(gen));
// UUID v4 (RFC 4122)
- bytes[6] = (bytes[6] & 0x0F) | 0x40;
- bytes[8] = (bytes[8] & 0x3F) | 0x80;
+ bytes[6] = bytes[6] & 0x0F | 0x40;
+ bytes[8] = bytes[8] & 0x3F | 0x80;
char buf[37]; // 36 znaków + \0
std::snprintf(buf, sizeof(buf),
@@ -153,16 +153,16 @@ double LocalRandom(double a, double b)
bool FuzzyLogic(double Test, double Threshold, double Probability)
{
- if ((Test > Threshold) && (!DebugModeFlag))
- return (Random() < Probability * Threshold * 1.0 / Test) /*im wiekszy Test tym wieksza szansa*/;
+ if (Test > Threshold && !DebugModeFlag)
+ return Random() < Probability * Threshold * 1.0 / Test /*im wiekszy Test tym wieksza szansa*/;
else
return false;
}
bool FuzzyLogicAI(double Test, double Threshold, double Probability)
{
- if ((Test > Threshold))
- return (Random() < Probability * Threshold * 1.0 / Test) /*im wiekszy Test tym wieksza szansa*/;
+ if (Test > Threshold)
+ return Random() < Probability * Threshold * 1.0 / Test /*im wiekszy Test tym wieksza szansa*/;
else
return false;
}
@@ -223,8 +223,8 @@ std::string to_minutes_str(float const Minutes, bool const Leadingzero, int cons
float minutesintegral;
auto const minutesfractional{std::modf(Minutes, &minutesintegral)};
auto const width{Width - 1};
- auto minutes = (std::string(width - 1, ' ') + (Leadingzero ? std::to_string(100 + minutesintegral).substr(1, 2) : to_string(minutesintegral, 0)));
- return (minutes.substr(minutes.size() - width, width) + fractionlabels[static_cast(std::floor(minutesfractional * 10 + 0.1))]);
+ auto minutes = std::string(width - 1, ' ') + (Leadingzero ? std::to_string(100 + minutesintegral).substr(1, 2) : to_string(minutesintegral, 0));
+ return minutes.substr(minutes.size() - width, width) + fractionlabels[static_cast(std::floor(minutesfractional * 10 + 0.1))];
}
int stol_def(const std::string &str, const int &DefaultValue)
@@ -307,7 +307,7 @@ std::string Bezogonkow(std::string Input, bool const Underscorestospaces)
{
input = space;
}
- else if (Underscorestospaces && (input == underscore))
+ else if (Underscorestospaces && input == underscore)
{
input = space;
}
@@ -323,7 +323,7 @@ template <> bool extract_value(bool &Variable, std::string const &Key, std::stri
if (false == value.empty())
{
// set the specified variable to retrieved value
- Variable = (ToLower(value) == "yes");
+ Variable = ToLower(value) == "yes";
return true; // located the variable
}
else
@@ -331,7 +331,7 @@ template <> bool extract_value(bool &Variable, std::string const &Key, std::stri
// set the variable to provided default value
if (false == Default.empty())
{
- Variable = (ToLower(Default) == "yes");
+ Variable = ToLower(Default) == "yes";
}
return false; // couldn't locate the variable in provided input
}
@@ -422,13 +422,13 @@ std::ptrdiff_t len_common_prefix(std::string_view a, std::string_view b)
bool contains(std::string_view const String, std::string_view Substring)
{
// To be replaced with string::contains in C++ 23
- return (String.find(Substring) != std::string::npos);
+ return String.find(Substring) != std::string::npos;
}
bool contains(std::string_view const String, char Character)
{
// To be replaced with string::contains in C++ 23
- return (String.find(Character) != std::string::npos);
+ return String.find(Character) != std::string::npos;
}
// helper, restores content of a 3d vector from provided input stream
@@ -457,7 +457,7 @@ std::string deserialize_random_set(cParser &Input, char const *Break)
// if instead of a single token we've encountered '[' this marks a beginning of a random set
// we retrieve all entries, then return a random one
std::vector tokens;
- while (((token = deserialize_random_set(Input, Break)) != "") && (token != "]"))
+ while ((token = deserialize_random_set(Input, Break)) != "" && token != "]")
{
tokens.emplace_back(token);
}
diff --git a/utilities/utilities.h b/utilities/utilities.h
index 5097173f..89cb41bc 100644
--- a/utilities/utilities.h
+++ b/utilities/utilities.h
@@ -17,7 +17,7 @@ http://mozilla.org/MPL/2.0/.
template T sign(T x)
{
- return x < static_cast(0) ? static_cast(-1) : (x > static_cast(0) ? static_cast(1) : static_cast(0));
+ return x < static_cast(0) ? static_cast(-1) : x > static_cast(0) ? static_cast(1) : static_cast