From d85096f64da7b9bd55b373eb157bae00db335b57 Mon Sep 17 00:00:00 2001 From: jerrrrycho Date: Tue, 30 Jun 2026 21:19:46 +0200 Subject: [PATCH] reformat: remove redundant parentheses --- Console/PoKeys55.cpp | 32 +- McZapkie/MOVER.h | 34 +- McZapkie/Mover.cpp | 1594 ++++++++++----------- McZapkie/Oerlikon_ESt.cpp | 57 +- McZapkie/friction.cpp | 4 +- McZapkie/hamulce.cpp | 462 +++--- McZapkie/hamulce.h | 6 +- application/application.cpp | 14 +- application/driverhints.cpp | 253 ++-- application/drivermode.cpp | 68 +- application/driveruilayer.cpp | 20 +- application/driveruipanels.cpp | 221 +-- application/editormode.cpp | 48 +- application/editoruipanels.cpp | 28 +- application/scenarioloadermode.cpp | 2 +- application/uilayer.cpp | 4 +- audio/audio.cpp | 2 +- audio/audio.h | 2 +- audio/audiorenderer.cpp | 67 +- audio/audiorenderer.h | 2 +- audio/audiorenderer_extra.h | 2 +- audio/sound.cpp | 122 +- audio/sound.h | 2 +- environment/moon.cpp | 12 +- environment/sky.cpp | 4 +- environment/skydome.cpp | 26 +- environment/sun.cpp | 8 +- input/command.cpp | 7 +- input/command.h | 2 +- input/drivermouseinput.cpp | 52 +- input/editormouseinput.cpp | 4 +- input/gamepadinput.cpp | 13 +- input/keyboardinput.cpp | 58 +- input/messaging.cpp | 43 +- input/zmq_input.cpp | 18 +- launcher/launchermode.cpp | 6 +- launcher/scenery_list.cpp | 8 +- launcher/scenery_scanner.cpp | 2 +- launcher/textures_scanner.cpp | 2 +- launcher/vehicle_picker.cpp | 8 +- model/AnimModel.cpp | 72 +- model/AnimModel.h | 2 +- model/MdlMngr.cpp | 9 +- model/Model3d.cpp | 118 +- model/Model3d.h | 11 +- model/ResourceManager.h | 10 +- model/Texture.cpp | 86 +- model/Texture.h | 2 +- model/material.cpp | 28 +- model/vertex.h | 2 +- scene/scene.cpp | 169 +-- scene/scene.h | 2 +- scene/sceneeditor.cpp | 4 +- scene/sceneeditor.h | 4 +- scene/scenenode.cpp | 73 +- scene/scenenode.h | 4 +- scene/scenenodegroups.cpp | 25 +- scene/sn_utils.cpp | 38 +- scripting/PyInt.cpp | 12 +- scripting/ladderlogic.cpp | 15 +- scripting/ladderlogic.h | 2 +- simulation/simulation.cpp | 10 +- simulation/simulationenvironment.cpp | 65 +- simulation/simulationstateserializer.cpp | 142 +- simulation/simulationtime.cpp | 20 +- simulation/simulationtime.h | 2 +- utilities/Float3d.h | 12 +- utilities/Globals.cpp | 28 +- utilities/Logs.cpp | 4 +- utilities/Logs.h | 22 +- utilities/Names.h | 12 +- utilities/Timer.h | 2 +- utilities/color.h | 6 +- utilities/motiontelemetry.cpp | 2 +- utilities/parser.cpp | 20 +- utilities/parser.h | 7 +- utilities/translation.cpp | 13 +- utilities/uart.cpp | 26 +- utilities/utilities.cpp | 34 +- utilities/utilities.h | 14 +- utilities/uuid.hpp | 8 +- vehicle/AirCoupler.h | 2 +- vehicle/Button.cpp | 15 +- vehicle/Button.h | 3 +- vehicle/Camera.cpp | 48 +- vehicle/Driver.cpp | 1646 ++++++++++------------ vehicle/Driver.h | 11 +- vehicle/DynObj.cpp | 849 ++++++----- vehicle/DynObj.h | 8 +- vehicle/Gauge.cpp | 72 +- vehicle/Gauge.h | 6 +- vehicle/Train.cpp | 797 +++++------ vehicle/Train.h | 7 +- world/EvLaunch.cpp | 31 +- world/Event.cpp | 165 ++- world/Event.h | 5 +- world/MemCell.cpp | 14 +- world/Segment.cpp | 39 +- world/Segment.h | 2 +- world/Spring.cpp | 4 +- world/Track.cpp | 301 ++-- world/Track.h | 16 +- world/Traction.cpp | 117 +- world/TractionPower.cpp | 10 +- world/TractionPower.h | 2 +- world/TrkFoll.cpp | 28 +- world/mtable.cpp | 104 +- world/station.cpp | 2 +- 108 files changed, 4098 insertions(+), 4662 deletions(-) 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(0); } template constexpr T sq(T v) @@ -99,11 +99,11 @@ double CompareTime(double t1h, double t1m, double t2h, double t2m); /*funkcje logiczne*/ inline bool TestFlag(int const Flag, int const Value) { - return ((Flag & Value) == Value); + return (Flag & Value) == Value; } inline bool TestFlagAny(int const Flag, int const Value) { - return ((Flag & Value) != 0); + return (Flag & Value) != 0; } bool SetFlag(int &Flag, int const Value); bool ClearFlag(int &Flag, int const Value); @@ -126,7 +126,7 @@ std::string to_minutes_str(float const Minutes, bool const Leadingzero, int cons template T> // Without this line this function can be used with other types implicit casted to boolean which may create hard to debug bugs. inline std::string to_string(T Value) { - return (Value == true ? "true" : "false"); + return Value == true ? "true" : "false"; } template std::string to_string(glm::tvec3 const &Value) @@ -241,7 +241,7 @@ template bool is_equal(T const &Left, T const &Right, T const Epsil if (Epsilon != T(0)) return glm::epsilonEqual(Left, Right, Epsilon); - return (Left == Right); + return Left == Right; } // keeps the provided value in specified range 0-Range, as if the range was circular buffer @@ -278,7 +278,7 @@ template T clamp_power_of_two(T Value, T const Min = T(1), T const template Type_ quantize(Type_ const Value, Type_ const Step) { - return (Step * std::round(Value / Step)); + return Step * std::round(Value / Step); } template T min_speed(T const Left, T const Right) @@ -305,7 +305,7 @@ template bool degenerate(VecType_ const &Vertex1, VecType_ c { // degenerate( A, B, C, minarea ) = ( ( B - A ).cross( C - A ) ).lengthSquared() < ( 4.0f * minarea * minarea ); - return (glm::length2(glm::cross(Vertex2 - Vertex1, Vertex3 - Vertex1)) == 0.0); + return glm::length2(glm::cross(Vertex2 - Vertex1, Vertex3 - Vertex1)) == 0.0; } // calculates bounding box for provided set of points diff --git a/utilities/uuid.hpp b/utilities/uuid.hpp index a69b3191..d94fd0cc 100644 --- a/utilities/uuid.hpp +++ b/utilities/uuid.hpp @@ -17,11 +17,11 @@ public: UID u; uint64_t a = gen(); uint64_t b = gen(); - for (int i = 0; i < 8; ++i) u.bytes[i] = uint8_t((a >> (i*8)) & 0xFF); - for (int i = 0; i < 8; ++i) u.bytes[8 + i] = uint8_t((b >> (i*8)) & 0xFF); + for (int i = 0; i < 8; ++i) u.bytes[i] = uint8_t(a >> (i * 8) & 0xFF); + for (int i = 0; i < 8; ++i) u.bytes[8 + i] = uint8_t(b >> (i * 8) & 0xFF); - u.bytes[6] = (u.bytes[6] & 0x0F) | 0x40; - u.bytes[8] = (u.bytes[8] & 0x3F) | 0x80; + u.bytes[6] = u.bytes[6] & 0x0F | 0x40; + u.bytes[8] = u.bytes[8] & 0x3F | 0x80; return u; } diff --git a/vehicle/AirCoupler.h b/vehicle/AirCoupler.h index 77f91f4c..3f860e63 100644 --- a/vehicle/AirCoupler.h +++ b/vehicle/AirCoupler.h @@ -74,7 +74,7 @@ public: }; inline bool Active() const { - return ( ( ModelOn != nullptr ) || ( ModelxOn != nullptr ) ); + return ModelOn != nullptr || ModelxOn != nullptr; }; }; diff --git a/vehicle/Button.cpp b/vehicle/Button.cpp index 6649a4de..d4d31877 100644 --- a/vehicle/Button.cpp +++ b/vehicle/Button.cpp @@ -34,7 +34,7 @@ bool TButton::Init( std::string const &asName, TModel3d const *pModel, bool bNew m_state = bNewOn; Update(); - return( ( pModelOn != nullptr ) || ( pModelOff != nullptr ) ); + return pModelOn != nullptr || pModelOff != nullptr; }; void TButton::Load( cParser &Parser, TDynamicObject const *Owner ) { @@ -66,8 +66,8 @@ void TButton::Load( cParser &Parser, TDynamicObject const *Owner ) { break; } } - if( ( pModelOn == nullptr ) - && ( pModelOff == nullptr ) ) { + if( pModelOn == nullptr + && pModelOff == nullptr ) { // if we failed to locate even one state submodel, cry ErrorLog( "Bad model: failed to locate sub-model \"" + submodelname + "\" in 3d model(s) of \"" + Owner->name() + "\"", logtype::model ); } @@ -88,7 +88,7 @@ TButton::Load_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 == "soundinc:" ) { m_soundfxincrease.deserialize( Input, sound_type::single ); } else if( key == "sounddec:" ) { m_soundfxdecrease.deserialize( Input, sound_type::single ); } @@ -106,10 +106,7 @@ TButton::model_offset() const { pModelOff ? pModelOff : nullptr ) }; - return ( - submodel != nullptr ? - submodel->offset( std::numeric_limits::max() ) : - glm::vec3() ); + return submodel != nullptr ? submodel->offset(std::numeric_limits::max()) : glm::vec3(); } void @@ -135,7 +132,7 @@ void TButton::Update( bool const Power ) { } if( pModelOn != nullptr ) { pModelOn->iVisible = m_state; } - if( pModelOff != nullptr ) { pModelOff->iVisible = (!m_state); } + if( pModelOff != nullptr ) { pModelOff->iVisible = !m_state; } #ifdef _WIN32 if (iFeedbackBit) { diff --git a/vehicle/Button.h b/vehicle/Button.h index 5e43056f..e2eb38cb 100644 --- a/vehicle/Button.h +++ b/vehicle/Button.h @@ -28,8 +28,7 @@ public: return m_state; } inline bool Active() { - return ( ( pModelOn != nullptr ) - || ( pModelOff != nullptr ) ); } + return pModelOn != nullptr || pModelOff != nullptr; } void Update( bool const Power = true ); bool Init( std::string const &asName, TModel3d const *pModel, bool bNewOn = false ); void Load( cParser &Parser, TDynamicObject const *Owner ); diff --git a/vehicle/Camera.cpp b/vehicle/Camera.cpp index 875b90a1..3186030e 100644 --- a/vehicle/Camera.cpp +++ b/vehicle/Camera.cpp @@ -48,7 +48,7 @@ static double ComputeAxisSpeed(double param, double walkspeed, double maxspeed, double absval = std::abs(param); // 2/3rd of the stick range lerps walk speed, past that we lerp between max walk and run speed double walk = walkspeed * std::min(absval / threshold, 1.0); - double run = (std::max(0.0, absval - threshold) / (1.0 - threshold)) * std::max(0.0, maxspeed - walkspeed); + double run = std::max(0.0, absval - threshold) / (1.0 - threshold) * std::max(0.0, maxspeed - walkspeed); return (param >= 0.0 ? 1.0 : -1.0) * (walk + run); } @@ -76,17 +76,13 @@ TCamera::OnCommand( command_data const &Command ) { case user_command::movehorizontal: case user_command::movehorizontalfast: { - auto const movespeed = ( - m_owner == nullptr ? runspeed : // free roam + auto const movespeed = m_owner == nullptr ? runspeed : // free roam false == FreeFlyModeFlag ? walkspeed : // vehicle cab - 0.0 ); // vehicle external + 0.0; // vehicle external // if( movespeed == 0.0 ) { break; } // enable to fix external cameras in place - auto const speedmultiplier = ( - ( ( true == FreeFlyModeFlag ) && ( Command.command == user_command::movehorizontalfast ) ) ? - ( m_owner == nullptr ) ? 30.0 : 5.0 : - 1.0 ); + auto const speedmultiplier = true == FreeFlyModeFlag && Command.command == user_command::movehorizontalfast ? m_owner == nullptr ? 30.0 : 5.0 : 1.0; // left-right m_moverate.x = ComputeAxisSpeed(Command.param1, walkspeed, movespeed, stickthreshold) * speedmultiplier; @@ -99,17 +95,13 @@ TCamera::OnCommand( command_data const &Command ) { case user_command::movevertical: case user_command::moveverticalfast: { - auto const movespeed = ( - m_owner == nullptr ? runspeed * 0.5 : // free roam + auto const movespeed = m_owner == nullptr ? runspeed * 0.5 : // free roam false == FreeFlyModeFlag ? walkspeed : // vehicle cab - 0.0 ); // vehicle external + 0.0; // vehicle external // if( movespeed == 0.0 ) { break; } // enable to fix external cameras in place - auto const speedmultiplier = ( - ( ( true == FreeFlyModeFlag ) && ( Command.command == user_command::moveverticalfast ) ) ? - ( m_owner == nullptr ) ? 10.0 : 3.0 : - 1.0 ); + auto const speedmultiplier = true == FreeFlyModeFlag && Command.command == user_command::moveverticalfast ? m_owner == nullptr ? 10.0 : 3.0 : 1.0; // up-down m_moverate.y = ComputeAxisSpeed(Command.param1, walkspeed, movespeed, stickthreshold) * speedmultiplier; @@ -151,26 +143,26 @@ void TCamera::Update() auto const rotationfactor { std::min( 1.0, 20 * deltatime ) }; Angle.y -= m_rotationoffsets.y * rotationfactor; - m_rotationoffsets.y *= ( 1.0 - rotationfactor ); + m_rotationoffsets.y *= 1.0 - rotationfactor; Angle.y = std::remainder(Angle.y, 2.0 * M_PI); // Limit the camera pitch to +/- 90°. - Angle.x = std::clamp(Angle.x - (m_rotationoffsets.x * rotationfactor), -M_PI_2, M_PI_2); - m_rotationoffsets.x *= ( 1.0 - rotationfactor ); + Angle.x = std::clamp(Angle.x - m_rotationoffsets.x * rotationfactor, -M_PI_2, M_PI_2); + m_rotationoffsets.x *= 1.0 - rotationfactor; // update position - if( ( m_owner == nullptr ) - || ( true == FreeFlyModeFlag ) - || ( false == Global.ctrlState ) - || ( true == DebugCameraFlag ) ) { + if( m_owner == nullptr + || true == FreeFlyModeFlag + || false == Global.ctrlState + || true == DebugCameraFlag ) { // ctrl is used for mirror view, so we ignore the controls when in vehicle if ctrl is pressed // McZapkie-170402: poruszanie i rozgladanie we free takie samo jak w follow UpdateVelocityAxis(Velocity.x, m_moverate.x, deltatime); UpdateVelocityAxis(Velocity.y, m_moverate.y, deltatime); UpdateVelocityAxis(Velocity.z, m_moverate.z, deltatime); } - if( ( m_owner == nullptr ) - || ( true == DebugCameraFlag ) ) { + if( m_owner == nullptr + || true == DebugCameraFlag ) { // free movement position update auto movement { Velocity }; movement = RotateY(movement, (double)Angle.y); @@ -184,8 +176,8 @@ void TCamera::Update() m_owner->Mechanik ? m_owner->Mechanik : m_owner->ctOwner ) }; - if( ( owner && owner->Occupied() ) - && ( owner->Occupied()->CabOccupied < 0 ) ) { + if( owner && owner->Occupied() + && owner->Occupied()->CabOccupied < 0 ) { movement *= -1.f; movement.y = -movement.y; } @@ -208,7 +200,7 @@ bool TCamera::SetMatrix( glm::dmat4 &Matrix ) { Matrix = glm::rotate(Matrix, -(double)Angle.y, glm::dvec3(0, 1, 0)); // w zewnętrznym widoku: kierunek patrzenia Matrix = glm::rotate(Matrix, -(double)Angle.z, glm::dvec3(0, 0, 1)); // po wyłączeniu tego kręci się pojazd, a sceneria nie - if( ( m_owner != nullptr ) && ( false == DebugCameraFlag ) ) { + if( m_owner != nullptr && false == DebugCameraFlag ) { Matrix *= glm::lookAt(Pos, LookAt, glm::dvec3{ vUp } ); } @@ -222,7 +214,7 @@ bool TCamera::SetMatrix( glm::dmat4 &Matrix ) { void TCamera::RaLook() { // zmiana kierunku patrzenia - przelicza Yaw auto where = LookAt - Pos /*+ Math3D::vector3(0, 3, 0)*/; // trochę w górę od szyn - if( ( where.x != 0.0 ) || ( where.z != 0.0 ) ) { + if( where.x != 0.0 || where.z != 0.0 ) { Angle.y = atan2( -where.x, -where.z ); // kąt horyzontalny m_rotationoffsets.y = 0.0; } diff --git a/vehicle/Driver.cpp b/vehicle/Driver.cpp index 88c1b669..1d648a6f 100644 --- a/vehicle/Driver.cpp +++ b/vehicle/Driver.cpp @@ -42,10 +42,8 @@ ProjectEventOnTrack( basic_event const *Event, TTrack const *Track, double const auto const segment = Track->CurrentSegment(); auto const nearestpoint = segment->find_nearest_point( Event->input_location() ); - return ( - Direction > 0 ? - nearestpoint * segment->GetLength() : // measure from point1 - ( 1.0 - nearestpoint ) * segment->GetLength() ); // measure from point2 + return Direction > 0 ? nearestpoint * segment->GetLength() : // measure from point1 + (1.0 - nearestpoint) * segment->GetLength(); // measure from point2 }; double GetDistanceToEvent(TTrack const *track, basic_event const *event, double scan_dir, double start_dist, int iter = 0, bool back = false) @@ -66,17 +64,17 @@ double GetDistanceToEvent(TTrack const *track, basic_event const *event, double seg_len += scan_dir > 0 ? dzielnik : -dzielnik; len2 = glm::length2(pos_event - segment->FastGetPoint(seg_len)); ++krok; - } while ((len1 > len2) && (seg_len >= dzielnik && (seg_len <= (1.0 - dzielnik)))); + } while (len1 > len2 && seg_len >= dzielnik && seg_len <= 1.0 - dzielnik); //trzeba sprawdzić czy seg_len nie osiągnął skrajnych wartości, bo wtedy // trzeba sprawdzić tor obok if (1 == krok) sd = -sd; // jeśli tylko jeden krok tzn, że event przy poprzednim sprawdzaym torze - if (((1 == krok) || (seg_len <= dzielnik) || (seg_len > (1.0 - dzielnik))) && (iter < 3)) + if ((1 == krok || seg_len <= dzielnik || seg_len > 1.0 - dzielnik) && iter < 3) { // przejście na inny tor track = track->Connected(int(sd), sd); - start_dist += (1 == krok) ? 0 : back ? -segment->GetLength() : segment->GetLength(); - if( ( track != nullptr ) - && ( track->eType == tt_Cross ) ) { + start_dist += 1 == krok ? 0 : back ? -segment->GetLength() : segment->GetLength(); + if( track != nullptr + && track->eType == tt_Cross ) { // NOTE: tracing through crossroads currently poses risk of tracing through wrong segment // as it's possible to be performerd before setting a route through the crossroads // as a stop-gap measure we don't trace through crossroads which should be reasonable in most cases @@ -93,7 +91,7 @@ double GetDistanceToEvent(TTrack const *track, basic_event const *event, double seg_len = scan_dir < 0 ? 1 - seg_len : seg_len; seg_len = back ? 1 - seg_len : seg_len; // odwracamy jeśli idzie do tyłu start_dist -= back ? segment->GetLength() : 0; - return start_dist + (segment->GetLength() * seg_len); + return start_dist + segment->GetLength() * seg_len; } }; @@ -305,7 +303,7 @@ bool TSpeedPos::Update() // railways if( iFlags & spSwitch ) { // jeśli odcinek zmienny - if( ( ( trTrack->GetSwitchState() & 1 ) != 0 ) != + if( (trTrack->GetSwitchState() & 1) != 0 != ( ( iFlags & spSwitchStatus ) != 0 ) ) { // czy stan się zmienił? // Ra: zakładam, że są tylko 2 możliwe stany @@ -335,8 +333,8 @@ bool TSpeedPos::Update() } else if (iFlags & spEvent) { // jeśli event - if( ( ( iFlags & spElapsed ) == 0 ) - || ( fVelNext == 0.0 ) ) { + if( (iFlags & spElapsed) == 0 + || fVelNext == 0.0 ) { // ignore already passed signals, but keep an eye on overrun stops // odczyt komórki pamięci najlepiej by było zrobić jako notyfikację, // czyli zmiana komórki wywoła jakąś podaną funkcję @@ -394,8 +392,8 @@ bool TSpeedPos::Set(basic_event *event, double dist, double length, TOrders orde evEvent = event; vPos = event->input_location(); // współrzędne eventu albo komórki pamięci (zrzutować na tor?) // ignore events located behind the consist, but with exception of stop points which may be needed to update freshly received timetable - if( ( dist + length < 0 ) - && ( event->input_command() != TCommandType::cm_PassengerStopPoint ) ) { + if( dist + length < 0 + && event->input_command() != TCommandType::cm_PassengerStopPoint ) { return false; } iFlags |= spEnabled; @@ -424,7 +422,7 @@ void TSpeedPos::Set(TTrack *track, double dist, int flag) trTrack = track; // TODO: (t) może być NULL i nie odczytamy końca poprzedniego :/ if (trTrack) { - iFlags = flag | (trTrack->eType == tt_Normal ? spTrack : (spTrack | spSwitch) ); // zapamiętanie kierunku wraz z typem + iFlags = flag | (trTrack->eType == tt_Normal ? spTrack : spTrack | spSwitch ); // zapamiętanie kierunku wraz z typem if (iFlags & spSwitch) if (trTrack->GetSwitchState() & 1) iFlags |= spSwitchStatus; @@ -432,11 +430,11 @@ void TSpeedPos::Set(TTrack *track, double dist, int flag) if (trTrack->iDamageFlag & 128) fVelNext = 0.0; // jeśli uszkodzony, to też stój if (iFlags & spEnd) - fVelNext = (trTrack->iCategoryFlag & 1) ? + fVelNext = trTrack->iCategoryFlag & 1 ? 0.0 : 20.0; // jeśli koniec, to pociąg stój, a samochód zwolnij vPos = - ( iFlags & spReverse ) ? + iFlags & spReverse ? trTrack->CurrentSegment()->FastGetPoint_1() : trTrack->CurrentSegment()->FastGetPoint_0(); } @@ -461,8 +459,8 @@ std::vector TController::CheckTrackEvent( TTrack *Track, double c std::vector events; auto const &eventsequence { ( fDirection > 0 ? Track->m_events2 : Track->m_events1 ) }; for( auto const &event : eventsequence ) { - if( ( event.second != nullptr ) - && ( event.second->m_passive ) ) { + if( event.second != nullptr + && event.second->m_passive ) { events.emplace_back( event.second ); } } @@ -483,19 +481,16 @@ bool TController::TableNotFound(basic_event const *Event, double const Distance sSpeedTable.begin(), sSpeedTable.end(), [Event]( TSpeedPos const &speedpoint ){ - return ( ( true == TestFlag( speedpoint.iFlags, spEnabled | spEvent ) ) - && ( speedpoint.evEvent == Event ) ); } ); + return true == TestFlag(speedpoint.iFlags, spEnabled | spEvent) && speedpoint.evEvent == Event; } ); - if( ( Global.iWriteLogEnabled & 8 ) - && ( lookup != sSpeedTable.end() ) ) { + if (Global.iWriteLogEnabled & 8 + && lookup != sSpeedTable.end() ) { WriteLog( "Speed table for " + OwnerName() + " already contains event " + lookup->evEvent->m_name ); } // ignore duplicates which seem to be reasonably apart from each other, on account of looping tracks // NOTE: since supplied distance is only rough approximation of distance to the event, we're using large safety margin - return ( - ( lookup == sSpeedTable.end() ) - || ( Distance - lookup->fDist > 100.0 ) ); + return lookup == sSpeedTable.end() || Distance - lookup->fDist > 100.0; }; void TController::TableTraceRoute(double fDistance, TDynamicObject *pVehicle) @@ -547,26 +542,26 @@ void TController::TableTraceRoute(double fDistance, TDynamicObject *pVehicle) if( iTableDirection == 0 ) { return; } // NOTE: provisory fix for BUG: sempahor indices no longer matching table size // TODO: find and really fix the reason it happens - if( ( SemNextIndex != -1 ) - && ( SemNextIndex >= sSpeedTable.size() ) ) { + if( SemNextIndex != -1 + && SemNextIndex >= sSpeedTable.size() ) { SemNextIndex = -1; } - if( ( SemNextStopIndex != -1 ) - && ( SemNextStopIndex >= sSpeedTable.size() ) ) { + if( SemNextStopIndex != -1 + && SemNextStopIndex >= sSpeedTable.size() ) { SemNextStopIndex = -1; } // kontynuacja skanowania od ostatnio sprawdzonego toru (w ostatniej pozycji zawsze jest tor) - if( ( SemNextStopIndex != -1 ) - && ( sSpeedTable[SemNextStopIndex].fVelNext == 0.0 ) ) { + if( SemNextStopIndex != -1 + && sSpeedTable[SemNextStopIndex].fVelNext == 0.0 ) { // znaleziono semafor lub tarczę lub tor z prędkością zero, trzeba sprawdzić czy to nadał semafor // jeśli jest następny semafor to sprawdzamy czy to on nadał zero - if( ( OrderCurrentGet() & Obey_train ) - && ( sSpeedTable[SemNextStopIndex].iFlags & spSemaphor ) ) { + if( OrderCurrentGet() & Obey_train + && sSpeedTable[SemNextStopIndex].iFlags & spSemaphor ) { return; } else { - if( ( OrderCurrentGet() < Obey_train ) - && ( sSpeedTable[SemNextStopIndex].iFlags & ( spSemaphor | spShuntSemaphor | spOutsideStation ) ) ) { + if( OrderCurrentGet() < Obey_train + && sSpeedTable[SemNextStopIndex].iFlags & (spSemaphor | spShuntSemaphor | spOutsideStation) ) { return; } } @@ -576,7 +571,7 @@ void TController::TableTraceRoute(double fDistance, TDynamicObject *pVehicle) pTrack = lastspeedpoint.trTrack; assert( pTrack != nullptr ); // flaga ustawiona, gdy Point2 toru jest blizej - fLastDir = ( ( ( lastspeedpoint.iFlags & spReverse ) != 0 ) ? -1.0 : 1.0 ); + fLastDir = (lastspeedpoint.iFlags & spReverse) != 0 ? -1.0 : 1.0; fCurrentDistance = lastspeedpoint.fDist; // aktualna odleglosc do jego Point1 fTrackLength = pTrack->Length(); } @@ -630,8 +625,8 @@ void TController::TableTraceRoute(double fDistance, TDynamicObject *pVehicle) } } else { - if( ( true == newspeedpoint.IsProperSemaphor( OrderCurrentGet() ) ) - && ( SemNextIndex == -1 ) ) { + if( true == newspeedpoint.IsProperSemaphor(OrderCurrentGet()) + && SemNextIndex == -1 ) { SemNextIndex = iLast; // sprawdzamy czy pierwszy na drodze } if (Global.iWriteLogEnabled & 8) { @@ -644,16 +639,14 @@ void TController::TableTraceRoute(double fDistance, TDynamicObject *pVehicle) } } // event dodajemy najpierw, żeby móc sprawdzić, czy tor został dodany po odczytaniu prędkości następnego - if( ( pTrack->VelocityGet() == 0.0 ) // zatrzymanie - || ( pTrack->iAction ) // jeśli tor ma własności istotne dla skanowania - || ( pTrack->VelocityGet() != fLastVel ) ) // następuje zmiana prędkości + if( pTrack->VelocityGet() == 0.0 // zatrzymanie + || pTrack->iAction // jeśli tor ma własności istotne dla skanowania + || pTrack->VelocityGet() != fLastVel ) // następuje zmiana prędkości { // odcinek dodajemy do tabelki, gdy jest istotny dla ruchu TableAddNew(); sSpeedTable[ iLast ].Set( pTrack, fCurrentDistance, - ( fLastDir < 0 ? - spEnabled | spReverse : - spEnabled ) ); // dodanie odcinka do tabelki z flagą kierunku wejścia + fLastDir < 0 ? spEnabled | spReverse : spEnabled ); // dodanie odcinka do tabelki z flagą kierunku wejścia if (pTrack->eType == tt_Cross) { // na skrzyżowaniach trzeba wybrać segment, po którym pojedzie pojazd // dopiero tutaj jest ustalany kierunek segmentu na skrzyżowaniu @@ -672,15 +665,13 @@ void TController::TableTraceRoute(double fDistance, TDynamicObject *pVehicle) */ auto const routewanted { 1 + std::floor( Random( static_cast( pTrack->RouteCount() ) - 0.001 ) ) }; sSpeedTable[iLast].iFlags |= - ( ( pTrack->CrossSegment( - (fLastDir < 0 ? - tLast->iPrevDirection : - tLast->iNextDirection), -/* - iRouteWanted ) -*/ - routewanted ) - & 0xf ) << 28 ); // ostatnie 4 bity pola flag + (pTrack->CrossSegment(fLastDir < 0 ? tLast->iPrevDirection : tLast->iNextDirection, + /* + iRouteWanted ) + */ + routewanted) & + 0xf) + << 28; // ostatnie 4 bity pola flag sSpeedTable[iLast].iFlags &= ~spReverse; // usunięcie flagi kierunku, bo może być błędna if (sSpeedTable[iLast].iFlags < 0) { sSpeedTable[iLast].iFlags |= spReverse; // ustawienie flagi kierunku na podstawie wybranego segmentu @@ -696,17 +687,15 @@ void TController::TableTraceRoute(double fDistance, TDynamicObject *pVehicle) */ } } - else if ( ( pTrack->fRadius != 0.0 ) // odległość na łuku lepiej aproksymować cięciwami - || ( ( tLast != nullptr ) - && ( tLast->fRadius != 0.0 ) )) // koniec łuku też jest istotny + else if ( pTrack->fRadius != 0.0 // odległość na łuku lepiej aproksymować cięciwami + || ( tLast != nullptr + && tLast->fRadius != 0.0 )) // koniec łuku też jest istotny { // albo dla liczenia odległości przy pomocy cięciw - te usuwać po przejechaniu if (TableAddNew()) { // dodanie odcinka do tabelki sSpeedTable[iLast].Set( pTrack, fCurrentDistance, - ( fLastDir < 0 ? - spEnabled | spCurve | spReverse : - spEnabled | spCurve ) ); + fLastDir < 0 ? spEnabled | spCurve | spReverse : spEnabled | spCurve ); } } } @@ -715,21 +704,19 @@ void TController::TableTraceRoute(double fDistance, TDynamicObject *pVehicle) tLast = pTrack; // odhaczenie, że sprawdzony fLastVel = pTrack->VelocityGet(); // prędkość na poprzednio sprawdzonym odcinku pTrack = pTrack->Connected( - ( pTrack->eType == tt_Cross ? - (sSpeedTable[iLast].iFlags >> 28) : - static_cast(fLastDir) ), + pTrack->eType == tt_Cross ? sSpeedTable[iLast].iFlags >> 28 : static_cast(fLastDir), fLastDir); // może być NULL if (pTrack != nullptr ) { // jeśli kolejny istnieje if( tLast != nullptr ) { - if( ( tLast->VelocityGet() > 0 ) - && ( ( tLast->VelocityGet() < pTrack->VelocityGet() ) - || ( pTrack->VelocityGet() < 0 ) ) ) { + if( tLast->VelocityGet() > 0 + && ( tLast->VelocityGet() < pTrack->VelocityGet() + || pTrack->VelocityGet() < 0 ) ) { - if( ( iLast != -1 ) - && ( sSpeedTable[ iLast ].trTrack == tLast ) ) { + if( iLast != -1 + && sSpeedTable[iLast].trTrack == tLast ) { // if the track is already in the table we only need to mark it as relevant sSpeedTable[ iLast ].iFlags |= spEnabled; } @@ -752,17 +739,15 @@ void TController::TableTraceRoute(double fDistance, TDynamicObject *pVehicle) } else { // definitywny koniec skanowania, chyba że dalej puszczamy samochód po gruncie... - if( ( iLast == -1 ) - || ( ( false == TestFlag( sSpeedTable[iLast].iFlags, spEnabled | spEnd ) ) - && ( sSpeedTable[iLast].trTrack != tLast ) ) ) { + if( iLast == -1 + || ( false == TestFlag(sSpeedTable[iLast].iFlags, spEnabled | spEnd) + && sSpeedTable[iLast].trTrack != tLast ) ) { // only if we haven't already marked end of the track and if the new track doesn't duplicate last one if( TableAddNew() ) { // zapisanie ostatniego sprawdzonego toru sSpeedTable[iLast].Set( tLast, fCurrentDistance - fTrackLength, // by now the current distance points to beginning of next track, - ( fLastDir < 0 ? - spEnabled | spEnd | spReverse : - spEnabled | spEnd )); + fLastDir < 0 ? spEnabled | spEnd | spReverse : spEnabled | spEnd); } } else if( sSpeedTable[ iLast ].trTrack == tLast ) { @@ -770,7 +755,7 @@ void TController::TableTraceRoute(double fDistance, TDynamicObject *pVehicle) // TODO: investigate exactly how we can wind up not marking the last existing track as actual end if( false == TestFlag( sSpeedTable[ iLast ].trTrack->iCategoryFlag, 0x100 ) ) { // don't mark portals, as these aren't exactly track ends, but teleport devices - sSpeedTable[ iLast ].iFlags |= ( spEnabled | spEnd ); + sSpeedTable[ iLast ].iFlags |= spEnabled | spEnd; } } // to ostatnia pozycja, bo NULL nic nie da, a może się podpiąć obrotnica, czy jakieś transportery @@ -781,9 +766,7 @@ void TController::TableTraceRoute(double fDistance, TDynamicObject *pVehicle) // zapisanie ostatniego sprawdzonego toru sSpeedTable[ iLast ].Set( pTrack, fCurrentDistance, - ( fLastDir < 0 ? - spNone | spReverse : - spNone ) ); + fLastDir < 0 ? spNone | spReverse : spNone ); } }; @@ -840,10 +823,10 @@ void TController::TableCheck(double fDistance) else if (sSpeedTable[i].iFlags & spEvent) // jeśli event { if (sSpeedTable[i].fDist < ( - typeid( *(sSpeedTable[i].evEvent) ) == typeid( putvalues_event ) ? + typeid( *sSpeedTable[i].evEvent ) == typeid( putvalues_event ) ? -fLength : 0)) // jeśli jest z tyłu - if ((mvOccupied->CategoryFlag == 2) && (sSpeedTable[i].fDist < -0.75)) + if (mvOccupied->CategoryFlag == 2 && sSpeedTable[i].fDist < -0.75) { // pociąg staje zawsze, a samochód tylko jeśli nie przejedzie całą długością (może być zaskoczony zmianą) // WriteLog("TableCheck: Event is behind. Delete from table: " + sSpeedTable[i].evEvent->asName); sSpeedTable[i].iFlags &= ~spEnabled; // degradacja pozycji dla samochodu; @@ -904,32 +887,30 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN if( TableUpdateEvent( v, go, point, d_to_next_sem, idx ) ) { continue; } } - auto const railwaytrackend { ( true == TestFlag( point.iFlags, spEnd ) ) && ( is_train() ) }; - if( ( v >= 0.0 ) // pozycje z prędkością -1 można spokojnie pomijać - || ( railwaytrackend ) ) { + auto const railwaytrackend { true == TestFlag(point.iFlags, spEnd) && is_train() }; + if( v >= 0.0 // pozycje z prędkością -1 można spokojnie pomijać + || railwaytrackend ) { d = point.fDist; if( v >= 0.0 ) { // points located in front of us can potentially affect our acceleration and target speed - if( ( d > 0.0 ) - && ( false == TestFlag( point.iFlags, spElapsed ) ) ) { + if( d > 0.0 + && false == TestFlag(point.iFlags, spElapsed) ) { // sygnał lub ograniczenie z przodu (+32=przejechane) // 2014-02: jeśli stoi, a ma do przejechania kawałek, to niech jedzie - if( ( mvOccupied->Vel < 0.01 ) - && ( true == TestFlag( point.iFlags, ( spEnabled | spEvent | spPassengerStopPoint ) ) ) - && ( false == IsAtPassengerStop ) ) { + if( mvOccupied->Vel < 0.01 + && true == TestFlag(point.iFlags, spEnabled | spEvent | spPassengerStopPoint) + && false == IsAtPassengerStop ) { // ma podjechać bliżej - czy na pewno w tym miejscu taki warunek? - a = ( ( d > passengerstopmaxdistance ) || ( ( iDrivigFlags & moveStopCloser ) != 0 ) ? - fAcc : - 0.0 ); + a = d > passengerstopmaxdistance || (iDrivigFlags & moveStopCloser) != 0 ? fAcc : 0.0; } else { // przyspieszenie: ujemne, gdy trzeba hamować if( v >= 0.0 ) { a = ( v * v - mvOccupied->Vel * mvOccupied->Vel ) / ( 25.92 * d ); - if( ( mvOccupied->Vel < v ) - || ( v == 0.0 ) ) { + if( mvOccupied->Vel < v + || v == 0.0 ) { // if we're going slower than the target velocity and there's enough room for safe stop, speed up auto const brakingdistance { 1.2 * fBrakeDist * braking_distance_multiplier( v ) }; if( brakingdistance > 0.0 ) { @@ -938,8 +919,8 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN a = std::lerp( a, AccPreferred, std::clamp( ( d - brakingdistance ) / brakingdistance, 0.0, 1.0 ) ); } } - if( ( d < fMinProximityDist ) - && ( v < fVelDes ) ) { + if( d < fMinProximityDist + && v < fVelDes ) { // jak jest już blisko, ograniczenie aktualnej prędkości fVelDes = v; } @@ -975,11 +956,11 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN } else { // event trzyma tylko jeśli VelNext=0, nawet po przejechaniu (nie powinno dotyczyć samochodów?) - a = (v > 0.0 ? + a = v > 0.0 ? fAcc : mvOccupied->Vel < 0.01 ? 0.0 : // already standing still so no need to bother with brakes - -2.0 ); // ruszanie albo hamowanie + -2.0; // ruszanie albo hamowanie } } // track can potentially end, which creates another virtual point of interest with speed limit of 0 at the end of it @@ -987,7 +968,7 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN if( railwaytrackend ) { // if the railway track ends here set the velnext accordingly as well // TODO: test this with turntables and such - auto const stopatendacceleration = ( -1.0 * mvOccupied->Vel * mvOccupied->Vel ) / ( 25.92 * ( d + point.trTrack->Length() ) ); + auto const stopatendacceleration = -1.0 * mvOccupied->Vel * mvOccupied->Vel / ( 25.92 * ( d + point.trTrack->Length() ) ); if( stopatendacceleration < a ) { a = stopatendacceleration; v = 0.0; @@ -999,8 +980,8 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN } } - if( ( a <= fAcc ) - && ( ( v < fNext ) || ( fNext < 0 ) ) ) { // filter out consecutive, farther out blocks with the same speed limit; they'd make us accelerate slower due to their lower a value + if( a <= fAcc + && ( v < fNext || fNext < 0 ) ) { // filter out consecutive, farther out blocks with the same speed limit; they'd make us accelerate slower due to their lower a value // mniejsze przyspieszenie to mniejsza możliwość rozpędzenia się albo konieczność hamowania // jeśli droga wolna, to może być a>1.0 i się tu nie załapuje fAcc = a; // zalecane przyspieszenie (nie musi być uwzględniane przez AI) @@ -1016,15 +997,15 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN */ // we'll pick first scanned target speed as our goal // farther scan table points can override it through previous clause, if they require lower acceleration or speed reduction - else if( ( a > 0 ) && ( a <= fAcc ) && ( v >= 0 ) && ( fNext < 0 ) ) { + else if( a > 0 && a <= fAcc && v >= 0 && fNext < 0 ) { fAcc = a; fNext = v; fDist = d; } // potentially update our current speed limit - if( ( v < VelLimitLastDist.first ) - && ( ( d < 0 ) // the point counts as part of last speed limit either if it's behind us - || ( VelLimitLastDist.second > 0 ) ) ) { // or if we already have the last limit ongoing + if( v < VelLimitLastDist.first + && ( d < 0 // the point counts as part of last speed limit either if it's behind us + || VelLimitLastDist.second > 0 ) ) { // or if we already have the last limit ongoing VelLimitLastDist.second = d + fLength; if( ( point.iFlags & spTrack ) != 0 ) { VelLimitLastDist.second += point.trTrack->Length(); @@ -1060,24 +1041,24 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN } // jeśli mieliśmy ograniczenie z semafora i nie ma przed nami - if( ( VelSignalLast >= 0.0 ) - && ( ( iDrivigFlags & ( moveSignalFound | moveSwitchFound | moveStopPointFound ) ) == 0 ) - && ( true == TestFlag( OrderCurrentGet(), Obey_train ) ) ) { + if( VelSignalLast >= 0.0 + && (iDrivigFlags & (moveSignalFound | moveSwitchFound | moveStopPointFound)) == 0 + && true == TestFlag(OrderCurrentGet(), Obey_train) ) { VelSignalLast = -1.0; } // if there's unbroken speed limit through our scan table take a note of it - if( ( VelLimitLastDist.second > 0 ) - && ( speedlimitiscontinuous ) ) { + if( VelLimitLastDist.second > 0 + && speedlimitiscontinuous ) { VelLimitLastDist.second = EU07_AI_SPEEDLIMITEXTENDSBEYONDSCANRANGE; } // take into account the effect switches have on duration of signal-imposed speed limit, in calculation of speed limit end point - if( ( VelSignalLast >= 0.0 ) && ( SwitchClearDist >= 0.0 ) ) { + if( VelSignalLast >= 0.0 && SwitchClearDist >= 0.0 ) { VelLimitLastDist.second = std::max( VelLimitLastDist.second, SwitchClearDist ); } //analiza spisanych z tabelki ograniczeń i nadpisanie aktualnego // if stopped at a valid passenger stop, hold there - if( ( true == IsAtPassengerStop ) && ( mvOccupied->Vel < 0.01 ) ) { + if( true == IsAtPassengerStop && mvOccupied->Vel < 0.01 ) { fVelDes = 0.0; } else { @@ -1100,9 +1081,9 @@ TController::TableUpdateStopPoint( TCommandType &Command, TSpeedPos &Point, doub // first 19 chars of the command is expected to be "PassengerStopPoint:" so we skip them if( ToLower( Point.evEvent->input_text() ).compare( 19, sizeof( asNextStop ), ToLower( asNextStop ) ) != 0 ) { // jeśli nazwa nie jest zgodna - if( ( false == IsScheduledPassengerStopVisible ) // check if our next scheduled stop didn't show up earlier in the scan - && ( Point.fDist < ( 1.15 * fBrakeDist + 300 ) ) - && ( Point.fDist > 0 ) ) // tylko jeśli W4 jest blisko, przy dwóch może zaczać szaleć + if( false == IsScheduledPassengerStopVisible // check if our next scheduled stop didn't show up earlier in the scan + && Point.fDist < 1.15 * fBrakeDist + 300 + && Point.fDist > 0 ) // tylko jeśli W4 jest blisko, przy dwóch może zaczać szaleć { // porównuje do następnej stacji, więc trzeba przewinąć do poprzedniej // nastepnie ustawić następną na aktualną tak żeby prawidłowo ją obsłużył w następnym kroku @@ -1171,7 +1152,7 @@ TController::TableUpdateStopPoint( TCommandType &Command, TSpeedPos &Point, doub auto L = 0.0; auto Par1 = Point.evEvent->input_value(1); auto Par2 = Point.evEvent->input_value(2); - if ((Par2 >= 0) || (fLength < -Par2)) { //użyj tego W4 + if (Par2 >= 0 || fLength < -Par2) { //użyj tego W4 if (Par1 < 0) { L = -Par1; } @@ -1189,29 +1170,26 @@ TController::TableUpdateStopPoint( TCommandType &Command, TSpeedPos &Point, doub } } // for human-driven vehicles discard the stop point if they leave it far enough behind - if( ( false == AIControllFlag ) - && ( Point.fDist < -1 * std::max( fLength + 100, 250.0 ) - Point.fMoved ) ) { + if( false == AIControllFlag + && Point.fDist < -1 * std::max(fLength + 100, 250.0) - Point.fMoved ) { Point.iFlags = 0; // nie liczy się już zupełnie (nie wyśle SetVelocity) Point.fVelNext = -1; // można jechać za W4 - if( ( Point.fDist <= 0.0 ) && ( eSignNext == Point.evEvent ) ) { + if( Point.fDist <= 0.0 && eSignNext == Point.evEvent ) { // sanity check, if we're held by this stop point, let us go VelSignalLast = -1; } return true; } - IsAtPassengerStop = ( - ( Point.fDist <= passengerstopmaxdistance ) - // Ra 2F1I: odległość plus długość pociągu musi być mniejsza od długości - // peronu, chyba że pociąg jest dłuższy, to wtedy minimalna. - // jeśli długość peronu ((sSpeedTable[i].evEvent->ValueGet(2)) nie podana, - // przyjąć odległość fMinProximityDist - && ( ( iDrivigFlags & moveStopCloser ) != 0 ? - Point.fDist + fLength + (Point.fMoved - fMinProximityDist * 0.5f) <= - std::max( - std::abs( Point.evEvent->input_value( 2 ) ), - 2.0 * fMaxProximityDist + fLength ) : // fmaxproximitydist typically equals ~50 m - Point.fDist < Signaldistance ) ); + IsAtPassengerStop = Point.fDist <= passengerstopmaxdistance + // Ra 2F1I: odległość plus długość pociągu musi być mniejsza od długości + // peronu, chyba że pociąg jest dłuższy, to wtedy minimalna. + // jeśli długość peronu ((sSpeedTable[i].evEvent->ValueGet(2)) nie podana, + // przyjąć odległość fMinProximityDist + && ((iDrivigFlags & moveStopCloser) != 0 ? + Point.fDist + fLength + (Point.fMoved - fMinProximityDist * 0.5f) <= std::max(std::abs(Point.evEvent->input_value(2)), + 2.0 * fMaxProximityDist + fLength) : // fmaxproximitydist typically equals ~50 m + Point.fDist < Signaldistance); if( !eSignNext ) { //jeśli nie widzi następnego sygnału ustawia dotychczasową @@ -1221,9 +1199,9 @@ TController::TableUpdateStopPoint( TCommandType &Command, TSpeedPos &Point, doub // jeśli jedzie (nie trzeba czekać, aż się drgania wytłumią - drzwi zamykane od 1.0) to będzie zatrzymanie Point.fVelNext = 0; // potentially announce pending stop - if( ( m_lastannouncement != announcement_t::approaching ) - && ( Point.fDist < 750 ) - && ( Point.fDist > 250 ) ) { + if( m_lastannouncement != announcement_t::approaching + && Point.fDist < 750 + && Point.fDist > 250 ) { announce( announcement_t::approaching ); } } else if( true == IsAtPassengerStop ) { @@ -1294,9 +1272,9 @@ TController::TableUpdateStopPoint( TCommandType &Command, TSpeedPos &Point, doub if (TrainParams.StationIndex < TrainParams.StationCount) { // jeśli są dalsze stacje, czekamy do godziny odjazdu - if ( ( true == IsCargoTrain ) - || ( true == TrainParams.IsMaintenance() ) - || ( TrainParams.IsTimeToGo( simulation::Time.data().wHour, simulation::Time.data().wMinute + simulation::Time.data().wSecond*0.0167 ) ) ) { + if ( true == IsCargoTrain + || true == TrainParams.IsMaintenance() + || TrainParams.IsTimeToGo(simulation::Time.data().wHour, simulation::Time.data().wMinute + simulation::Time.data().wSecond * 0.0167) ) { // z dalszą akcją czekamy do godziny odjazdu // cargo trains and passenger trains at maintenance stop don't need to wait IsAtPassengerStop = false; @@ -1325,7 +1303,7 @@ TController::TableUpdateStopPoint( TCommandType &Command, TSpeedPos &Point, doub iDrivigFlags |= moveStopCloser; // do następnego W4 podjechać blisko (z dociąganiem) Point.iFlags = 0; // nie liczy się już zupełnie (nie wyśle SetVelocity) Point.fVelNext = -1; // można jechać za W4 - if( ( Point.fDist <= 0.0 ) && ( eSignNext == Point.evEvent ) ) { + if( Point.fDist <= 0.0 && eSignNext == Point.evEvent ) { // sanity check, if we're held by this stop point, let us go VelSignalLast = -1; } @@ -1357,15 +1335,15 @@ TController::TableUpdateStopPoint( TCommandType &Command, TSpeedPos &Point, doub asNextStop = TrainParams.NextStop(); // informacja o końcu trasy TrainParams.NewName("none"); // czyszczenie nieaktualnego rozkładu // ma nie podjeżdżać pod W4 i ma je pomijać - iDrivigFlags &= ~( moveStopCloser ); + iDrivigFlags &= ~moveStopCloser; if( false == TestFlag( iDrivigFlags, movePushPull ) ) { // if the consist can change direction through a simple cab change it doesn't need fiddling with recognition of passenger stops - iDrivigFlags &= ~( moveStopPoint ); + iDrivigFlags &= ~moveStopPoint; } fLastStopExpDist = -1.0f; // nie ma rozkładu, nie ma usuwania stacji Point.iFlags = 0; // W4 nie liczy się już (nie wyśle SetVelocity) Point.fVelNext = -1; // można jechać za W4 - if( ( Point.fDist <= 0.0 ) && ( eSignNext == Point.evEvent ) ) { + if( Point.fDist <= 0.0 && eSignNext == Point.evEvent ) { // sanity check, if we're held by this stop point, let us go VelSignalLast = -1; } @@ -1422,12 +1400,12 @@ TController::TableUpdateEvent( double &Velocity, TCommandType &Command, TSpeedPo auto const magnetlocation { pVehicles[ end::front ]->MoverParameters->SecuritySystem.MagnetLocation }; auto const magnetrange { 1.0 }; auto const ismagnetpassed { Point.fDist < -( magnetlocation + magnetrange ) }; - if( Point.fDist < -( magnetlocation ) ) { + if( Point.fDist < -magnetlocation ) { // NOTE: normally we'd activate the magnet once the leading vehicle passes it // but on a fresh scan after direction change it would be detected as long as it's under consist, and meet the (simple) activation condition // thus we're doing a more precise check in such situation (we presume direction change takes place only if the vehicle is standing still) - if( ( mvOccupied->Vel > EU07_AI_NOMOVEMENT ) - || ( false == ismagnetpassed ) ) { + if( mvOccupied->Vel > EU07_AI_NOMOVEMENT + || false == ismagnetpassed ) { mvOccupied->SecuritySystem.set_cabsignal_lock(!AIControllFlag); // don't make life difficult for the ai, but a human driver is a fair game PutCommand( Point.evEvent->input_text(), @@ -1466,10 +1444,10 @@ TController::TableUpdateEvent( double &Velocity, TCommandType &Command, TSpeedPo if( Point.IsProperSemaphor( OrderCurrentGet() ) ) { // special rule for cars: ignore stop signals at distance too short to come to a stop // as trying to stop in such situation is likely to place the car on train tracks - if( ( is_car() ) - && ( Point.fVelNext != -1.0 ) - && ( Point.fVelNext < 1.0 ) - && ( Point.fDist < -0.5 + std::min( fBrakeDist * 0.2, mvOccupied->Vel * 0.2 ) ) ) { + if( is_car() + && Point.fVelNext != -1.0 + && Point.fVelNext < 1.0 + && Point.fDist < -0.5 + std::min(fBrakeDist * 0.2, mvOccupied->Vel * 0.2) ) { Point.Clear(); return true; } @@ -1481,9 +1459,9 @@ TController::TableUpdateEvent( double &Velocity, TCommandType &Command, TSpeedPo WriteLog( "Speed table update for " + OwnerName() + ", next semaphor is " + sSpeedTable[ SemNextIndex ].GetName() ); } } - if( ( SemNextStopIndex == -1 ) - || ( ( sSpeedTable[ SemNextStopIndex ].fVelNext != 0 ) - && ( Point.fVelNext == 0 ) ) ) { + if( SemNextStopIndex == -1 + || ( sSpeedTable[SemNextStopIndex].fVelNext != 0 + && Point.fVelNext == 0 ) ) { SemNextStopIndex = Pointindex; } } @@ -1525,8 +1503,8 @@ TController::TableUpdateEvent( double &Velocity, TCommandType &Command, TSpeedPo // stanąć nie musi, ale zwolnić przynajmniej // jest w maksymalnym zasięgu to można go pominąć (wziąć drugą prędkosć) // as long as there isn't any obstacle in arbitrary view range - if( ( Point.fDist < fMaxProximityDist ) - && ( Obstacle.distance > 1000 ) ) { + if( Point.fDist < fMaxProximityDist + && Obstacle.distance > 1000 ) { eSignSkip = Point.evEvent; // jazda na widoczność - skanować możliwość kolizji i nie podjeżdżać zbyt blisko // usunąć flagę po podjechaniu blisko semafora zezwalającego na jazdę @@ -1546,8 +1524,8 @@ TController::TableUpdateEvent( double &Velocity, TCommandType &Command, TSpeedPo { // to semaphor if( Point.fDist < 0 ) { // for human-driven vehicles ignore the signal if it was passed by sufficient distance - if( ( false == AIControllFlag ) - && ( Point.fDist < -1 * std::max( fLength + 100, 250.0 ) ) ) { + if( false == AIControllFlag + && Point.fDist < -1 * std::max(fLength + 100, 250.0) ) { VelSignal = -1.0; Point.Clear(); return true; @@ -1563,7 +1541,7 @@ TController::TableUpdateEvent( double &Velocity, TCommandType &Command, TSpeedPo Signaldistance = std::min( Point.fDist, Signaldistance ); // if there's another vehicle closer to the signal, then it's likely its intended recipient // HACK: if so, make it a stop point, to prevent non-signals farther down affect us - auto const isforsomeoneelse { ( is_train() ) && ( Obstacle.distance < Point.fDist ) }; + auto const isforsomeoneelse { is_train() && Obstacle.distance < Point.fDist }; if( Point.fDist <= Signaldistance ) { if( isforsomeoneelse ) { VelSignalNext = 0.0; @@ -1596,8 +1574,8 @@ TController::TableUpdateEvent( double &Velocity, TCommandType &Command, TSpeedPo } else if ( Point.fSectionVelocityDist < 0.0) { // ograniczenie obowiązujące do następnego - if ( (Point.fVelNext == min_speed( Point.fVelNext, VelLimitLast)) - && (Point.fVelNext != VelLimitLast)) { + if ( Point.fVelNext == min_speed(Point.fVelNext, VelLimitLast) + && Point.fVelNext != VelLimitLast) { // jeśli ograniczenie jest mniejsze niż obecne to obowiązuje od zaraz VelLimitLast = Point.fVelNext; } @@ -1612,13 +1590,13 @@ TController::TableUpdateEvent( double &Velocity, TCommandType &Command, TSpeedPo } else { // jeśli większe to ograniczenie ma swoją długość - if ( (Point.fVelNext == min_speed( Point.fVelNext, VelLimitLast)) - && (Point.fVelNext != VelLimitLast)) { + if ( Point.fVelNext == min_speed(Point.fVelNext, VelLimitLast) + && Point.fVelNext != VelLimitLast) { // jeśli ograniczenie jest mniejsze niż obecne to obowiązuje od zaraz VelLimitLast = Point.fVelNext; } - else if ( (Point.fDist < -fLength) - && (Point.fVelNext != VelLimitLast)) { + else if ( Point.fDist < -fLength + && Point.fVelNext != VelLimitLast) { // jeśli większe to musi wyjechać za poprzednie VelLimitLast = Point.fVelNext; } @@ -1637,8 +1615,8 @@ TController::TableUpdateEvent( double &Velocity, TCommandType &Command, TSpeedPo { // zawalidrogi nie ma (albo pojazd jest samochodem), sprawdzić sygnał if ( Point.iFlags & spShuntSemaphor) // jeśli Tm - w zasadzie to sprawdzić komendę! { // jeśli podana prędkość manewrowa - if( ( Velocity == 0.0 ) - && ( true == TestFlag( OrderCurrentGet(), Obey_train ) ) ) { + if( Velocity == 0.0 + && true == TestFlag(OrderCurrentGet(), Obey_train) ) { // jeśli tryb pociągowy a tarcze ma ShuntVelocity 0 0 Velocity = -1; // ignorować, chyba że prędkość stanie się niezerowa if( true == TestFlag( Point.iFlags, spElapsed ) ) { @@ -1671,8 +1649,8 @@ TController::TableUpdateEvent( double &Velocity, TCommandType &Command, TSpeedPo //jeśli jakiś event pasywny ale nie ograniczenie if( Command == TCommandType::cm_Unknown ) { // jeśli nie było komendy wcześniej - pierwsza się liczy - ustawianie VelSignal - if( ( Velocity < 0.0 ) - || ( Velocity >= 1.0 ) ) { + if( Velocity < 0.0 + || Velocity >= 1.0 ) { // bo wartość 0.1 służy do hamowania tylko Command = TCommandType::cm_SetVelocity; // może odjechać // Ra 2014-06: (VelSignal) nie może być tu ustawiane, bo semafor może być daleko @@ -1683,12 +1661,12 @@ TController::TableUpdateEvent( double &Velocity, TCommandType &Command, TSpeedPo } if( Point.fDist < 0.0 ) { // jeśli przejechany - VelSignal = ( Velocity == 0.0 ? 0.0 : -1.0 ); + VelSignal = Velocity == 0.0 ? 0.0 : -1.0; // ustawienie, gdy przejechany jest lepsze niż wcale, ale to jeszcze nie to if( Point.iFlags & spEvent ) { // jeśli event - if( ( Point.evEvent != eSignSkip ) - || ( Point.fVelNext != VelRestricted ) ) { + if( Point.evEvent != eSignSkip + || Point.fVelNext != VelRestricted ) { // ale inny niż ten, na którym minięto S1, chyba że się już zmieniło // sygnał zezwalający na jazdę wyłącza jazdę na widoczność (po S1 na SBL) iDrivigFlags &= ~moveVisibility; @@ -1735,37 +1713,23 @@ TController::braking_distance_multiplier( float const Targetvelocity ) const { if( Targetvelocity > 65.f ) { return 1.f * frictionmultiplier; } if( Targetvelocity < 5.f ) { // HACK: engaged automatic transmission means extra/earlier braking effort is needed for the last leg before full stop - if( ( is_dmu() ) - && ( mvOccupied->Vel < 40.0 ) - && ( Targetvelocity == 0.f ) ) { + if( is_dmu() + && mvOccupied->Vel < 40.0 + && Targetvelocity == 0.f ) { auto const multiplier { std::clamp( 1.f + iVehicles * 0.5f, 2.f, 4.f ) }; - return ( - std::lerp( - multiplier, 1.f, - static_cast( mvOccupied->Vel / 40.0 ) ) - * frictionmultiplier ); + return std::lerp(multiplier, 1.f, static_cast(mvOccupied->Vel / 40.0)) * frictionmultiplier; } // HACK: cargo trains or trains going downhill with high braking threshold need more distance to come to a full stop - if( ( fBrake_a0[ 1 ] > 0.2 ) - && ( ( true == IsCargoTrain ) - || ( fAccGravity > 0.025 ) ) ) { - return ( - std::lerp( - 1.f, 2.f, - std::clamp( - ( fBrake_a0[ 1 ] - 0.2 ) / 0.2, - 0.0, 1.0 ) ) - * frictionmultiplier ); + if( fBrake_a0[1] > 0.2 + && ( true == IsCargoTrain + || fAccGravity > 0.025 ) ) { + return std::lerp(1.f, 2.f, std::clamp((fBrake_a0[1] - 0.2) / 0.2, 0.0, 1.0)) * frictionmultiplier; } return 1.f * frictionmultiplier; } // stretch the braking distance up to 3 times; the lower the speed, the greater the stretch - return ( - std::lerp( - 3.f, 1.f, - ( Targetvelocity - 5.f ) / 60.f ) - * frictionmultiplier ); + return std::lerp(3.f, 1.f, (Targetvelocity - 5.f) / 60.f) * frictionmultiplier; } void TController::TablePurger() @@ -1779,9 +1743,9 @@ void TController::TablePurger() std::size_t trimcount{ 0 }; for( std::size_t idx = 0; idx < sSpeedTable.size() - 1; ++idx ) { auto const &speedpoint = sSpeedTable[ idx ]; - if( ( 0 == ( speedpoint.iFlags & spEnabled ) ) - || ( ( ( speedpoint.iFlags & ( spElapsed | spTrack | spCurve | spSwitch ) ) == ( spElapsed | spTrack | spCurve ) ) - && ( speedpoint.fVelNext < 0.0 ) ) ) { + if( 0 == (speedpoint.iFlags & spEnabled) + || ( (speedpoint.iFlags & (spElapsed | spTrack | spCurve | spSwitch)) == (spElapsed | spTrack | spCurve) + && speedpoint.fVelNext < 0.0 ) ) { // NOTE: we could break out early here, but running through entire thing gives us exact size needed for new table ++trimcount; } @@ -1801,9 +1765,9 @@ void TController::TablePurger() SemNextStopIndex = trimmedtable.size(); } auto const &speedpoint = sSpeedTable[ idx ]; - if( ( 0 == ( speedpoint.iFlags & spEnabled ) ) - || ( ( ( speedpoint.iFlags & ( spElapsed | spTrack | spCurve | spSwitch ) ) == ( spElapsed | spTrack | spCurve ) ) - && ( speedpoint.fVelNext < 0.0 ) ) ) { + if( 0 == (speedpoint.iFlags & spEnabled) + || ( (speedpoint.iFlags & (spElapsed | spTrack | spCurve | spSwitch)) == (spElapsed | spTrack | spCurve) + && speedpoint.fVelNext < 0.0 ) ) { // if the trimmed point happens to be currently active semaphor we need to invalidate their placements if( idx == SemNextIndex ) { SemNextIndex = -1; @@ -1834,7 +1798,7 @@ void TController::TableSort() { return; } TSpeedPos sp_temp = TSpeedPos(); // uzywany do przenoszenia - for( int i = 0; i < ( iLast - 1 ); ++i ) { + for( int i = 0; i < iLast - 1; ++i ) { // pętla tylko do dwóch pozycji od końca bo ostatniej nie modyfikujemy if (sSpeedTable[i].fDist > sSpeedTable[i + 1].fDist) { // jesli pozycja wcześniejsza jest dalej to źle @@ -1888,10 +1852,7 @@ TController::TController(bool AI, TDynamicObject *NewControll, bool InitPsyche, // fAccThreshold może podlegać uczeniu się - hamowanie powinno być rejestrowane, a potem analizowane // próg opóźnienia dla zadziałania hamulca - fAccThreshold = ( - is_emu() ? -0.55 : - is_dmu() ? -0.45 : - -0.2 ); + fAccThreshold = is_emu() ? -0.55 : is_dmu() ? -0.45 : -0.2; /* // HACK: emu with induction motors need to start their braking a bit sooner than the ones with series motors if( ( mvOccupied->TrainType == dt_EZT ) @@ -1961,8 +1922,8 @@ TController::~TController() // zamiana kodu rozkazu na opis std::string TController::Order2Str(TOrders Order) const { - if( ( ( Order & Change_direction ) != 0 ) - && ( Order != Change_direction ) ) { + if( (Order & Change_direction) != 0 + && Order != Change_direction ) { // może być nałożona na inną i wtedy ma priorytet return Order2Str( Change_direction ) @@ -2104,9 +2065,9 @@ void TController::Activation() if (pVehicle != initialvehicle) { // jeśli zmieniony został pojazd prowadzony ControllingSet(); // utworzenie połączenia do sterowanego pojazdu (może się zmienić) - silnikowy dla EZT - if( ( mvOccupied->BrakeCtrlPosNo > 0 ) - && ( ( BrakeSystem == TBrakeSystem::Pneumatic ) - || ( BrakeSystem == TBrakeSystem::ElectroPneumatic ) ) ) { + if( mvOccupied->BrakeCtrlPosNo > 0 + && ( BrakeSystem == TBrakeSystem::Pneumatic + || BrakeSystem == TBrakeSystem::ElectroPneumatic ) ) { mvOccupied->LimPipePress = mvOccupied->PipePress; mvOccupied->ActFlowSpeed = 0; } @@ -2116,8 +2077,8 @@ void TController::Activation() // dla 2Ls150 - przed ustawieniem kierunku - można zmienić tryb pracy if( mvControlling->ShuntModeAllow ) { mvControlling->CurrentSwitch( - ( ( OrderCurrentGet() & ( Shunt | Loose_shunt ) ) != 0 ) - || ( fMass > 224000.0 ) ); // do tego na wzniesieniu może nie dać rady na liniowym + (OrderCurrentGet() & (Shunt | Loose_shunt)) != 0 + || fMass > 224000.0 ); // do tego na wzniesieniu może nie dać rady na liniowym } } // Ra: to przełączanie poniżej jest tu bez sensu @@ -2168,18 +2129,18 @@ void TController::AutoRewident() ustaw = 16 + bdelay_R; // lokomotywa luzem (może być wieloczłonowa) else { // jeśli są wagony - ustaw = (g < std::min(4, r + p) ? 16 : 0); + ustaw = g < std::min(4, r + p) ? 16 : 0; if (ustaw) // jeśli towarowe < Min(4, pospieszne+osobowe) { // to skład pasażerski - nastawianie pasażerskiego - ustaw += (g && (r < g + p)) ? bdelay_P : bdelay_R; + ustaw += g && r < g + p ? bdelay_P : bdelay_R; // jeżeli towarowe>0 oraz pospiesze<=towarowe+osobowe to P (0) // inaczej R (2) } else { // inaczej towarowy - nastawianie towarowego - if ((fLength < 300.0) && (fMass < 600000.0)) //[kg] + if (fLength < 300.0 && fMass < 600000.0) //[kg] ustaw |= bdelay_P; // jeżeli długość<300 oraz masa<600 to P (0) - else if ((fLength < 500.0) && (fMass < 1300000.0)) + else if (fLength < 500.0 && fMass < 1300000.0) ustaw |= bdelay_R; // jeżeli długość<500 oraz masa<1300 to GP (2) else ustaw |= bdelay_G; // inaczej G (1) @@ -2191,8 +2152,8 @@ void TController::AutoRewident() p = 0; // będziemy tu liczyć wagony od lokomotywy dla nastawy GP while (d) { // 3. Nastawianie - if( ( true == AIControllFlag ) - || ( d != pVehicle ) ) { + if( true == AIControllFlag + || d != pVehicle ) { // don't touch human-controlled vehicle, but others are free game switch( ustaw ) { @@ -2265,13 +2226,10 @@ void TController::AutoRewident() if( OrderCurrentGet() & ( Shunt | Loose_shunt ) ) { // for uniform behaviour and compatibility with older scenarios set default acceleration table values for shunting - fAccThreshold = ( - is_emu() ? -0.55 : - is_dmu() ? -0.45 : - -0.2 ); + fAccThreshold = is_emu() ? -0.55 : is_dmu() ? -0.45 : -0.2; // HACK: emu with induction motors need to start their braking a bit sooner than the ones with series motors - if( ( is_emu() ) - && ( mvControlling->EngineType == TEngineType::ElectricInductionMotor ) ) { + if( is_emu() + && mvControlling->EngineType == TEngineType::ElectricInductionMotor ) { fAccThreshold += 0.10; } fNominalAccThreshold = fAccThreshold; @@ -2282,7 +2240,7 @@ void TController::AutoRewident() if( OrderCurrentGet() & ( Obey_train | Bank ) ) { // 4. Przeliczanie siły hamowania - double const velstep = ( mvOccupied->Vmax*0.5 ) / BrakeAccTableSize; + double const velstep = mvOccupied->Vmax * 0.5 / BrakeAccTableSize; d = pVehicles[0]; // pojazd na czele składu while (d) { for( int i = 0; i < BrakeAccTableSize; ++i ) { @@ -2296,22 +2254,16 @@ void TController::AutoRewident() fBrake_a1[i+1] -= fBrake_a0[i+1]; fBrake_a0[i+1] /= fMass; fBrake_a0[i + 1] += 0.001*velstep*(1 + 2 * i); - fBrake_a1[i+1] /= (12*fMass); + fBrake_a1[i+1] /= 12 * fMass; } - IsPassengerTrain = ( is_train() ) && ( false == is_emu() ) && ( false == is_dmu() ) && ( ( mvOccupied->BrakeDelayFlag & bdelay_G ) == 0 ); - IsCargoTrain = ( is_train() ) && ( ( mvOccupied->BrakeDelayFlag & bdelay_G ) != 0 ); - IsHeavyCargoTrain = ( true == IsCargoTrain ) && ( fBrake_a0[ 1 ] > 0.4 ) && ( iVehicles - ControlledEnginesCount > 0 ) && ( fMass / iVehicles > 50000 ); + IsPassengerTrain = is_train() && false == is_emu() && false == is_dmu() && (mvOccupied->BrakeDelayFlag & bdelay_G) == 0; + IsCargoTrain = is_train() && (mvOccupied->BrakeDelayFlag & bdelay_G) != 0; + IsHeavyCargoTrain = true == IsCargoTrain && fBrake_a0[1] > 0.4 && iVehicles - ControlledEnginesCount > 0 && fMass / iVehicles > 50000; - BrakingInitialLevel = ( - IsHeavyCargoTrain ? 1.25 : - IsCargoTrain ? 1.25 : - 1.00 ); + BrakingInitialLevel = IsHeavyCargoTrain ? 1.25 : IsCargoTrain ? 1.25 : 1.00; - BrakingLevelIncrease = ( - IsHeavyCargoTrain ? 0.25 : - IsCargoTrain ? 0.25 : - 0.25 ); + BrakingLevelIncrease = IsHeavyCargoTrain ? 0.25 : IsCargoTrain ? 0.25 : 0.25; if( is_emu() ) { auto ep_factor { ( BrakeSystem == TBrakeSystem::ElectroPneumatic ? 8 : 4 ) }; @@ -2352,7 +2304,7 @@ double TController::ESMVelocity(bool Main) MCPN += 1; else SCPN += 1; - if ((mvControlling->RList[MCPN].ScndAct < 255)&&(mvControlling->ScndCtrlActualPos==0)) + if (mvControlling->RList[MCPN].ScndAct < 255 && mvControlling->ScndCtrlActualPos == 0) SCPN = mvControlling->RList[MCPN].ScndAct; double FrictionMax = mvControlling->Mass*9.81*mvControlling->Adhesive(mvControlling->RunningTrack.friction)*fFrictionCoeff; double IF = mvControlling->Imax; @@ -2411,14 +2363,14 @@ bool TController::CheckVehicles(TOrders user) // Ra 2014-09: ustawić moveMultiControl, jeśli wszystkie są w ukrotnieniu (i skrajne mają kabinę?) while (p) { // sprawdzanie, czy jest głównym sterującym, żeby nie było konfliktu - if( ( p->Mechanik ) // jeśli ma obsadę - && ( p->Mechanik != this ) ) { // ale chodzi o inny pojazd, niż aktualnie sprawdzający + if( p->Mechanik // jeśli ma obsadę + && p->Mechanik != this ) { // ale chodzi o inny pojazd, niż aktualnie sprawdzający if( p->Mechanik->iDrivigFlags & movePrimary ) { // a tamten ma priorytet // TODO: take into account drivers' operating modes, one or more of them might be on banking duty - if( ( iDrivigFlags & movePrimary ) - && ( mvOccupied->DirAbsolute ) - && ( mvOccupied->BrakeCtrlPos >= -1 ) ) { + if( iDrivigFlags & movePrimary + && mvOccupied->DirAbsolute + && mvOccupied->BrakeCtrlPos >= -1 ) { // jeśli rządzi i ma kierunek p->Mechanik->primary( false ); // dezaktywuje tamtego p->Mechanik->ZeroLocalBrake(); @@ -2436,9 +2388,9 @@ bool TController::CheckVehicles(TOrders user) fMass += p->MoverParameters->TotalMass; // dodanie masy łącznie z ładunkiem fVelMax = min_speed( fVelMax, p->MoverParameters->Vmax ); // ustalenie maksymalnej prędkości dla składu // reset oerlikon brakes consist flag as different type was detected - if( ( p->MoverParameters->BrakeSubsystem != TBrakeSubSystem::ss_ESt ) - && ( p->MoverParameters->BrakeSubsystem != TBrakeSubSystem::ss_LSt ) ) { - iDrivigFlags &= ~( moveOerlikons ); + if( p->MoverParameters->BrakeSubsystem != TBrakeSubSystem::ss_ESt + && p->MoverParameters->BrakeSubsystem != TBrakeSubSystem::ss_LSt ) { + iDrivigFlags &= ~moveOerlikons; } p = p->Neighbour(dir); // pojazd podłączony od wskazanej strony } @@ -2467,7 +2419,7 @@ bool TController::CheckVehicles(TOrders user) } // with the order established the virtual train manager can do their work p = pVehicles[ end::front ]; - ControlledEnginesCount = ( p->MoverParameters->Power > 1.0 ? 1 : 0 ); + ControlledEnginesCount = p->MoverParameters->Power > 1.0 ? 1 : 0; auto hasheaters { false }; while (p) { @@ -2499,10 +2451,10 @@ bool TController::CheckVehicles(TOrders user) p = p->Next(); // pojazd podłączony od tyłu (licząc od czoła) } - if( ( user == Connect ) && ( true == main ) ) { + if( user == Connect && true == main ) { // HACK: with additional vehicles in the consist ensure all linked vehicles are set to move in the same direction - if( ( pVehicle->Prev( coupling::control ) != nullptr ) - || ( pVehicle->Next( coupling::control ) != nullptr ) ) { + if( pVehicle->Prev(coupling::control) != nullptr + || pVehicle->Next(coupling::control) != nullptr ) { sync_consist_reversers(); } // potentially sync compartment lighting state for the newly connected vehicles @@ -2573,7 +2525,7 @@ bool TController::CheckVehicles(TOrders user) cue_action( driver_hint::consistdoorlockson ); // potentially enable train heating { - auto const ispassengertrain { ( IsPassengerTrain ) && ( iVehicles - ControlledEnginesCount > 0 ) }; + auto const ispassengertrain { IsPassengerTrain && iVehicles - ControlledEnginesCount > 0 }; // TODO: replace connection test with connection check between last engine and first car, specifically auto const isheatingcouplingactive { ( ControlledEnginesCount == 1 ? @@ -2594,8 +2546,8 @@ bool TController::CheckVehicles(TOrders user) } } - if( ( user == Connect ) - || ( user == Disconnect ) ) { + if( user == Connect + || user == Disconnect ) { // HACK: force route table update on consist change, new consist length means distances to points of interest are now wrong iTableDirection = 0; } @@ -2615,7 +2567,7 @@ void TController::DirectionInitial() if (mvOccupied->Vel > EU07_AI_NOMOVEMENT) { // jeśli na starcie jedzie iDirection = iDirectionOrder = - (mvOccupied->V > 0 ? 1 : -1); // początkowa prędkość wymusza kierunek jazdy + mvOccupied->V > 0 ? 1 : -1; // początkowa prędkość wymusza kierunek jazdy DirectionForward(mvOccupied->V * mvOccupied->CabActive >= 0.0); // a dalej ustawienie nawrotnika } CheckVehicles(); // sprawdzenie świateł oraz skrajnych pojazdów do skanowania @@ -2638,21 +2590,18 @@ TBrakeSystem TController::consist_brake_system() const { if( pVehicles[ end::front ] != pVehicles[ end::rear ] ) { // more detailed version, will use manual braking also for coupled sets of controlled vehicles auto *vehicle = pVehicles[ end::front ]; // start from first - while( ( true == isepcapable ) - && ( vehicle != nullptr ) ) { + while( true == isepcapable + && vehicle != nullptr ) { // NOTE: we could simplify this by doing only check of the rear coupler, but this can be quite tricky in itself // TODO: add easier ways to access front/rear coupler taking into account vehicle's direction - isepcapable = ( - ( ( vehicle->MoverParameters->Couplers[ end::front ].Connected == nullptr ) - || ( ( vehicle->MoverParameters->Couplers[ end::front ].CouplingFlag & coupling::control ) - && ( vehicle->MoverParameters->Couplers[ end::front ].Connected->Power > -1 ) ) ) - && ( ( vehicle->MoverParameters->Couplers[ end::rear ].Connected == nullptr ) - || ( ( vehicle->MoverParameters->Couplers[ end::rear ].CouplingFlag & coupling::control ) - && ( vehicle->MoverParameters->Couplers[ end::rear ].Connected->Power > -1 ) ) ) ); + isepcapable = (vehicle->MoverParameters->Couplers[end::front].Connected == nullptr || + (vehicle->MoverParameters->Couplers[end::front].CouplingFlag & coupling::control && vehicle->MoverParameters->Couplers[end::front].Connected->Power > -1)) && + (vehicle->MoverParameters->Couplers[end::rear].Connected == nullptr || + (vehicle->MoverParameters->Couplers[end::rear].CouplingFlag & coupling::control && vehicle->MoverParameters->Couplers[end::rear].Connected->Power > -1)); vehicle = vehicle->Next(); // kolejny pojazd, podłączony od tyłu (licząc od czoła) } } - return ( isepcapable ? TBrakeSystem::ElectroPneumatic : TBrakeSystem::Pneumatic ); + return isepcapable ? TBrakeSystem::ElectroPneumatic : TBrakeSystem::Pneumatic; } int TController::OrderDirectionChange(int newdir, TMoverParameters *Vehicle) @@ -2674,7 +2623,7 @@ int TController::OrderDirectionChange(int newdir, TMoverParameters *Vehicle) } else // jeśli jedzie VelforDriver = 0; // ma się zatrzymać w celu zmiany kierunku - if ((Vehicle->DirActive == 0) && (VelforDriver < Vehicle->Vel)) // Ra: to jest chyba bez sensu + if (Vehicle->DirActive == 0 && VelforDriver < Vehicle->Vel) // Ra: to jest chyba bez sensu IncBrake(); // niech hamuje if (Vehicle->DirActive == testd * Vehicle->CabActive) VelforDriver = -1; // można jechać, bo kierunek jest zgodny z żądanym @@ -2700,12 +2649,12 @@ void TController::SetVelocity(double NewVel, double NewVelNext, TStopReason r) else { eStopReason = stopNone; // podana prędkość, to nie ma powodów do stania // to całe poniżej to warunki zatrąbienia przed ruszeniem - if( ( is_train() ) // tylko pociągi trąbią (unimogi tylko na torach, więc trzeba raczej sprawdzać tor) - && ( ( OrderCurrentGet() & ( Shunt | Loose_shunt | Obey_train | Bank | Connect | Prepare_engine ) ) != 0 ) // jeśli jedzie w dowolnym trybie - && ( ( iDrivigFlags & moveStartHorn ) != 0 ) // jezeli trąbienie włączone - && ( ( iDrivigFlags & ( moveStartHornDone | moveConnect ) ) == 0 ) // jeśli nie zatrąbione i nie jest to moment podłączania składu - && ( mvOccupied->Vel < 1.0 ) // jesli stoi (na razie, bo chyba powinien też, gdy hamuje przed semaforem) - && ( ( NewVel >= 1.0 ) || ( NewVel < 0.0 ) ) ) { // o ile prędkość jest znacząca zatrąb po odhamowaniu + if( is_train() // tylko pociągi trąbią (unimogi tylko na torach, więc trzeba raczej sprawdzać tor) + && (OrderCurrentGet() & (Shunt | Loose_shunt | Obey_train | Bank | Connect | Prepare_engine)) != 0 // jeśli jedzie w dowolnym trybie + && (iDrivigFlags & moveStartHorn) != 0 // jezeli trąbienie włączone + && (iDrivigFlags & (moveStartHornDone | moveConnect)) == 0 // jeśli nie zatrąbione i nie jest to moment podłączania składu + && mvOccupied->Vel < 1.0 // jesli stoi (na razie, bo chyba powinien też, gdy hamuje przed semaforem) + && ( NewVel >= 1.0 || NewVel < 0.0 ) ) { // o ile prędkość jest znacząca zatrąb po odhamowaniu iDrivigFlags |= moveStartHornNow; } } @@ -2717,11 +2666,11 @@ double TController::BrakeAccFactor() const { double Factor = 1.0; - if( ( fAccThreshold != 0.0 ) - && ( AccDesired < 0.0 ) - && ( ( ActualProximityDist > fMinProximityDist ) - || ( mvOccupied->Vel > VelDesired + fVelPlus ) ) ) { - Factor += ( fBrakeReaction * ( /*mvOccupied->BrakeCtrlPosR*/BrakeCtrlPosition < 0.5 ? 1.5 : 1 ) ) * mvOccupied->Vel / ( std::max( 0.0, ActualProximityDist ) + 1 ) * ( ( AccDesired - AbsAccS ) / fAccThreshold ); + if( fAccThreshold != 0.0 + && AccDesired < 0.0 + && ( ActualProximityDist > fMinProximityDist + || mvOccupied->Vel > VelDesired + fVelPlus ) ) { + Factor += fBrakeReaction * (/*mvOccupied->BrakeCtrlPosR*/ BrakeCtrlPosition < 0.5 ? 1.5 : 1) * mvOccupied->Vel / ( std::max( 0.0, ActualProximityDist ) + 1 ) * ( ( AccDesired - AbsAccS ) / fAccThreshold ); } /* if (mvOccupied->TrainType == dt_DMU && mvOccupied->Vel > 40 && VelNext<40) @@ -2732,7 +2681,7 @@ double TController::BrakeAccFactor() const void TController::SetDriverPsyche() { - if ((Psyche == Aggressive) && (OrderCurrentGet() == Obey_train)) { + if (Psyche == Aggressive && OrderCurrentGet() == Obey_train) { ReactionTime = HardReactionTime; // w zaleznosci od charakteru maszynisty if (is_car()) { WaitingExpireTime = 1; // tyle ma czekać samochód, zanim się ruszy @@ -2759,10 +2708,10 @@ void TController::SetDriverPsyche() { bool TController::PrepareEngine() { // odpalanie silnika // HACK: don't immediately activate inert vehicle in case the simulation is about to replace us with human driver - if( ( mvOccupied->Vel < 1.0 ) && ( fActionTime < 0.0 ) ) { return false; } + if( mvOccupied->Vel < 1.0 && fActionTime < 0.0 ) { return false; } LastReactionTime = 0.0; - ReactionTime = ( mvOccupied->Vel < 5 ? PrepareTime : EasyReactionTime ); // react faster with rolling start + ReactionTime = mvOccupied->Vel < 5 ? PrepareTime : EasyReactionTime; // react faster with rolling start cue_action( driver_hint::batteryon ); cue_action( driver_hint::cabactivation); @@ -2779,8 +2728,8 @@ bool TController::PrepareEngine() } } - if( ( mvPantographUnit->EnginePowerSource.SourceType == TPowerSource::CurrentCollector ) - && ( mvPantographUnit->EnginePowerSource.CollectorParameters.CollectorsNo > 0 ) ) { + if( mvPantographUnit->EnginePowerSource.SourceType == TPowerSource::CurrentCollector + && mvPantographUnit->EnginePowerSource.CollectorParameters.CollectorsNo > 0 ) { // if our pantograph unit isn't a pantograph-devoid fallback auto const sufficientpantographpressure { ( is_emu() ? @@ -2801,27 +2750,27 @@ bool TController::PrepareEngine() } else { // jeżeli jest wystarczające ciśnienie w pantografach - if( ( false == mvPantographUnit->bPantKurek3 ) - || ( mvPantographUnit->PantPress <= mvPantographUnit->ScndPipePress ) ) { // kurek przełączony albo główna już pompuje + if( false == mvPantographUnit->bPantKurek3 + || mvPantographUnit->PantPress <= mvPantographUnit->ScndPipePress ) { // kurek przełączony albo główna już pompuje cue_action( driver_hint::pantographcompressoroff ); // sprężarkę pantografów można już wyłączyć } } // TODO: make pantograph setup a part of control_pantographs() and call it here instead - if( ( fOverhead2 == -1.0 ) && ( iOverheadDown == 0 ) ) { + if( fOverhead2 == -1.0 && iOverheadDown == 0 ) { cue_action( driver_hint::pantographsvalveon ); - cue_action( driver_hint::frontpantographvalveon, ( iDirection >= 0 ? 5 : 0 ) ); - cue_action( driver_hint::rearpantographvalveon, ( iDirection >= 0 ? 0 : 5 ) ); + cue_action( driver_hint::frontpantographvalveon, iDirection >= 0 ? 5 : 0 ); + cue_action( driver_hint::rearpantographvalveon, iDirection >= 0 ? 0 : 5 ); } } auto const ispoweravailable = - ( mvControlling->EnginePowerSource.SourceType != TPowerSource::CurrentCollector ) - || ( std::max( mvControlling->GetTrainsetHighVoltage(), mvControlling->PantographVoltage ) > mvControlling->EnginePowerSource.CollectorParameters.MinV ); + mvControlling->EnginePowerSource.SourceType != TPowerSource::CurrentCollector + || std::max(mvControlling->GetTrainsetHighVoltage(), mvControlling->PantographVoltage) > mvControlling->EnginePowerSource.CollectorParameters.MinV; bool isready = false; - if( ( IsHeatingTemperatureOK ) - && ( ispoweravailable ) ) { + if( IsHeatingTemperatureOK + && ispoweravailable ) { // najpierw ustalamy kierunek, jeśli nie został ustalony PrepareDirection(); @@ -2854,7 +2803,7 @@ bool TController::PrepareEngine() if( IsAnyCompressorPresent && IsAnyConverterEnabled ) { cue_action( driver_hint::compressoron ); } - if( ( mvControlling->ScndPipePress < 4.5 ) && ( mvControlling->VeselVolume > 0.0 ) ) { + if( mvControlling->ScndPipePress < 4.5 && mvControlling->VeselVolume > 0.0 ) { cue_action( driver_hint::waitpressuretoolow ); } // enable motor blowers @@ -2878,8 +2827,8 @@ bool TController::PrepareEngine() } // set up train brake if( mvOccupied->fBrakeCtrlPos != mvOccupied->Handle->GetPos( bh_RP ) ) { - if ( ( !mvOccupied->Handle->Time) - || ( mvOccupied->Handle->GetCP() < mvOccupied->HighPipePress - 0.05 ) ); + if ( !mvOccupied->Handle->Time + || mvOccupied->Handle->GetCP() < mvOccupied->HighPipePress - 0.05 ); cue_action( driver_hint::trainbrakerelease ); } // sync spring brake state across consist @@ -2888,15 +2837,15 @@ bool TController::PrepareEngine() driver_hint::springbrakeon : driver_hint::springbrakeoff ); } - isready = ( false == IsAnyConverterOverloadRelayOpen ) - && ( mvOccupied->DirActive != 0 ) - && ( false == IsAnyLineBreakerOpen ) - && ( ( false == IsAnyConverterPresent ) || ( true == IsAnyConverterEnabled ) ) - && ( ( false == IsAnyCompressorPresent ) || ( true == IsAnyCompressorEnabled ) ) - && ( ( mvControlling->ScndPipePress > 4.5 ) || ( mvControlling->VeselVolume == 0.0 ) ) - && ( ( static_cast( mvOccupied->fBrakeCtrlPos ) == static_cast( mvOccupied->Handle->GetPos( bh_RP ) ) ) - || ( static_cast( mvOccupied->fBrakeCtrlPos ) != static_cast( mvOccupied->Handle->GetPos( bh_NP ) ) ) - || ( mvOccupied->BrakeHandle == TBrakeHandle::NoHandle ) ); + isready = false == IsAnyConverterOverloadRelayOpen + && mvOccupied->DirActive != 0 + && false == IsAnyLineBreakerOpen + && ( false == IsAnyConverterPresent || true == IsAnyConverterEnabled ) + && ( false == IsAnyCompressorPresent || true == IsAnyCompressorEnabled ) + && ( mvControlling->ScndPipePress > 4.5 || mvControlling->VeselVolume == 0.0 ) + && ( static_cast(mvOccupied->fBrakeCtrlPos) == static_cast(mvOccupied->Handle->GetPos(bh_RP)) + || static_cast(mvOccupied->fBrakeCtrlPos) != static_cast(mvOccupied->Handle->GetPos(bh_NP)) + || mvOccupied->BrakeHandle == TBrakeHandle::NoHandle ); } if( true == isready ) { @@ -2981,8 +2930,8 @@ bool TController::ReleaseEngine() { // activate parking brake // TBD: do it earlier? cue_action( driver_hint::springbrakeon ); - if( ( mvOccupied->LocalBrake == TLocalBrake::ManualBrake ) - || ( mvOccupied->MBrake == true ) ) { + if( mvOccupied->LocalBrake == TLocalBrake::ManualBrake + || mvOccupied->MBrake == true ) { cue_action( driver_hint::manualbrakon ); } // switch off remaining power @@ -2991,11 +2940,11 @@ bool TController::ReleaseEngine() { } auto const OK { - ( mvOccupied->DirActive == 0 ) + mvOccupied->DirActive == 0 // && ( false == IsAnyCompressorEnabled ) // && ( false == IsAnyConverterEnabled ) - && ( false == mvControlling->Mains ) - && ( false == mvOccupied->Power24vIsAvailable ) }; + && false == mvControlling->Mains + && false == mvOccupied->Power24vIsAvailable }; if (OK) { // jeśli się zatrzymał @@ -3015,7 +2964,7 @@ bool TController::IncBrake() { // zwiększenie hamowania auto OK { false }; auto const bs { - ( ( BrakeSystem == TBrakeSystem::ElectroPneumatic ) && ( ForcePNBrake ) ) ? + BrakeSystem == TBrakeSystem::ElectroPneumatic && ForcePNBrake ? TBrakeSystem::Pneumatic : BrakeSystem }; switch( bs ) { @@ -3038,16 +2987,16 @@ bool TController::IncBrake() } // NOTE: can't perform just test whether connected vehicle == nullptr, due to virtual couplers formed with nearby vehicles auto standalone { true }; - if( ( mvOccupied->TrainType == dt_ET41 ) - || ( mvOccupied->TrainType == dt_ET42 ) ) { + if( mvOccupied->TrainType == dt_ET41 + || mvOccupied->TrainType == dt_ET42 ) { // NOTE: we're doing simplified checks full of presuptions here. // they'll break if someone does strange thing like turning around the second unit - if( ( mvOccupied->Couplers[ end::rear ].CouplingFlag & coupling::permanent ) - && ( mvOccupied->Couplers[ end::rear ].Connected->Couplers[ end::rear ].Connected != nullptr ) ) { + if( mvOccupied->Couplers[end::rear].CouplingFlag & coupling::permanent + && mvOccupied->Couplers[end::rear].Connected->Couplers[end::rear].Connected != nullptr ) { standalone = false; } - if( ( mvOccupied->Couplers[ end::front ].CouplingFlag & coupling::permanent ) - && ( mvOccupied->Couplers[ end::front ].Connected->Couplers[ end::front ].Connected != nullptr ) ) { + if( mvOccupied->Couplers[end::front].CouplingFlag & coupling::permanent + && mvOccupied->Couplers[end::front].Connected->Couplers[end::front].Connected != nullptr ) { standalone = false; } } @@ -3055,8 +3004,8 @@ bool TController::IncBrake() // enforce use of train brake for DMUs standalone = false; } - else if( ( ( OrderCurrentGet() & ( Loose_shunt ) ) != 0 ) - && ( mvOccupied->Vel - VelDesired < fVelPlus + fVelMinus ) ) { + else if( (OrderCurrentGet() & Loose_shunt) != 0 + && mvOccupied->Vel - VelDesired < fVelPlus + fVelMinus ) { // try to reduce train brake use in loose shunting mode standalone = true; } @@ -3069,17 +3018,15 @@ bool TController::IncBrake() if( pVehicles[ end::front ] != pVehicles[ end::rear ] ) { // more detailed version, will use manual braking also for coupled sets of controlled vehicles auto *vehicle = pVehicles[ end::front ]; // start from first - while( ( true == standalone ) - && ( vehicle != nullptr ) ) { + while( true == standalone + && vehicle != nullptr ) { // NOTE: we could simplify this by doing only check of the rear coupler, but this can be quite tricky in itself // TODO: add easier ways to access front/rear coupler taking into account vehicle's direction standalone = - ( ( ( vehicle->MoverParameters->Couplers[ end::front ].Connected == nullptr ) - || ( ( vehicle->MoverParameters->Couplers[ end::front ].CouplingFlag & coupling::control ) - && ( vehicle->MoverParameters->Couplers[ end::front ].Connected->Power > 1 ) ) ) - && ( ( vehicle->MoverParameters->Couplers[ end::rear ].Connected == nullptr ) - || ( ( vehicle->MoverParameters->Couplers[ end::rear ].CouplingFlag & coupling::control ) - && ( vehicle->MoverParameters->Couplers[ end::rear ].Connected->Power > 1 ) ) ) ); + (vehicle->MoverParameters->Couplers[end::front].Connected == nullptr || + (vehicle->MoverParameters->Couplers[end::front].CouplingFlag & coupling::control && vehicle->MoverParameters->Couplers[end::front].Connected->Power > 1)) && + (vehicle->MoverParameters->Couplers[end::rear].Connected == nullptr || + (vehicle->MoverParameters->Couplers[end::rear].CouplingFlag & coupling::control && vehicle->MoverParameters->Couplers[end::rear].Connected->Power > 1)); vehicle = vehicle->Next(); // kolejny pojazd, podłączony od tyłu (licząc od czoła) } } @@ -3087,7 +3034,7 @@ bool TController::IncBrake() //standalone = standalone && ( mvControlling->EIMCtrlType == 0 ); - if( ( true == standalone ) && ( false == ForcePNBrake ) ) { + if( true == standalone && false == ForcePNBrake ) { if( mvControlling->EIMCtrlType > 0 ) { OK = IncBrakeEIM(); } @@ -3130,9 +3077,9 @@ bool TController::IncBrake() if( /*GBH mvOccupied->BrakeCtrlPosR*/BrakeCtrlPosition < 0.1 ) { OK = /*mvOccupied->*/BrakeLevelAdd( BrakingInitialLevel ); //GBH // HACK: stronger braking to overcome SA134 engine behaviour - if( ( is_dmu() ) - && ( VelNext == 0.0 ) - && ( fBrakeDist < 200.0 ) ) { + if( is_dmu() + && VelNext == 0.0 + && fBrakeDist < 200.0 ) { BrakeLevelAdd( fBrakeDist / ActualProximityDist < 0.8 ? 0.5 : @@ -3146,8 +3093,8 @@ bool TController::IncBrake() && ( mvOccupied->BrakeCtrlPosR + BrakingLevelIncrease <= 5.0 ) ) { mvOccupied->BrakeLevelAdd( BrakingLevelIncrease ); } GBH */ - if( ( deltaAcc > 2 * fBrake_a1[ 0 ] ) - && ( BrakeCtrlPosition + BrakingLevelIncrease <= 5.0 ) ) { + if( deltaAcc > 2 * fBrake_a1[0] + && BrakeCtrlPosition + BrakingLevelIncrease <= 5.0 ) { /*mvOccupied->*/BrakeLevelAdd( BrakingLevelIncrease ); } } @@ -3164,7 +3111,7 @@ bool TController::IncBrake() break; } case TBrakeSystem::ElectroPneumatic: { - while( ( mvOccupied->BrakeOpModeFlag << 1 ) <= mvOccupied->BrakeOpModes ) { + while( mvOccupied->BrakeOpModeFlag << 1 <= mvOccupied->BrakeOpModes ) { mvOccupied->BrakeOpModeFlag <<= 1; } if( mvOccupied->EngineType == TEngineType::ElectricInductionMotor ) { @@ -3184,7 +3131,7 @@ bool TController::IncBrake() mvOccupied->Handle->GetPos( bh_EPR ), mvOccupied->Handle->GetPos( bh_EPB ), std::clamp( -AccDesired / AccMax * mvOccupied->AIHintLocalBrakeAccFactor, 0.0, 1.0 ) ) ); - OK = ( mvOccupied->fBrakeCtrlPos != initialbrakeposition ); + OK = mvOccupied->fBrakeCtrlPos != initialbrakeposition; } else if( mvOccupied->fBrakeCtrlPos != mvOccupied->Handle->GetPos( bh_EPB ) ) { mvOccupied->BrakeLevelSet( mvOccupied->Handle->GetPos( bh_EPB ) ); @@ -3212,7 +3159,7 @@ bool TController::IncBrakeEIM() auto const brakelimit{ -2.2 * AccDesired / fMedAmax - 1.0}; //additional limit when hinted is too low auto const brakehinted{ -1.0 * mvOccupied->AIHintLocalBrakeAccFactor * AccDesired / fMedAmax }; //preffered by AI auto const brakeposition{ maxpos * std::clamp(std::max(brakelimit, brakehinted), 0.0, 1.0)}; - OK = ( brakeposition != mvOccupied->LocalBrakePosA ); + OK = brakeposition != mvOccupied->LocalBrakePosA; mvOccupied->LocalBrakePosA = brakeposition; } else { @@ -3255,22 +3202,19 @@ bool TController::DecBrake() { auto OK { false }; auto const bs { - ( ( BrakeSystem == TBrakeSystem::ElectroPneumatic ) && ( ForcePNBrake ) ) ? + BrakeSystem == TBrakeSystem::ElectroPneumatic && ForcePNBrake ? TBrakeSystem::Pneumatic : BrakeSystem }; switch( bs ) { case TBrakeSystem::Individual: { auto const positionchange { 1 + std::floor( 0.5 + std::abs( AccDesired ) ) }; - OK = ( - mvOccupied->LocalBrake == TLocalBrake::ManualBrake ? - mvOccupied->DecManualBrakeLevel( positionchange ) : - mvOccupied->DecLocalBrakeLevel( positionchange ) ); + OK = mvOccupied->LocalBrake == TLocalBrake::ManualBrake ? mvOccupied->DecManualBrakeLevel(positionchange) : mvOccupied->DecLocalBrakeLevel(positionchange); break; } case TBrakeSystem::Pneumatic: { auto deltaAcc { -1.0 }; - if( ( fBrake_a0[ 0 ] != 0.0 ) - || ( fBrake_a1[ 0 ] != 0.0 ) ) { + if( fBrake_a0[0] != 0.0 + || fBrake_a1[0] != 0.0 ) { auto const pos_diff { ( is_dmu() ? 0.25 : 1.0 ) }; deltaAcc = -AccDesired * BrakeAccFactor() - ( fBrake_a0[ 0 ] + 4 * (/*GBH mvOccupied->BrakeCtrlPosR*/BrakeCtrlPosition - pos_diff )*fBrake_a1[ 0 ] ); } @@ -3316,7 +3260,7 @@ bool TController::DecBrake() { mvOccupied->Handle->GetPos( bh_EPR ), mvOccupied->Handle->GetPos( bh_EPB ), std::clamp( -AccDesired / AccMax * mvOccupied->AIHintLocalBrakeAccFactor, 0.0, 1.0 ) ) ); - OK = ( mvOccupied->fBrakeCtrlPos != initialbrakeposition ); + OK = mvOccupied->fBrakeCtrlPos != initialbrakeposition; } else { OK = false; @@ -3373,7 +3317,7 @@ bool TController::DecBrakeEIM() if( mvOccupied->MED_amax != 9.81 ) { auto const desiredacceleration { ( mvOccupied->Vel > EU07_AI_NOMOVEMENT ? AccDesired : std::max( 0.0, AccDesired ) ) }; auto const brakeposition { std::clamp( -1.0 * mvOccupied->AIHintLocalBrakeAccFactor * desiredacceleration / mvOccupied->MED_amax, 0.0, 1.0 ) }; - OK = ( brakeposition != mvOccupied->LocalBrakePosA ); + OK = brakeposition != mvOccupied->LocalBrakePosA; mvOccupied->LocalBrakePosA = brakeposition; } else { @@ -3424,24 +3368,22 @@ bool TController::IncSpeed() if( mvControlling->EnginePowerSource.SourceType == TPowerSource::Accumulator ) { fVoltage = mvControlling->BatteryVoltage; } - if ((!IsAnyMotorOverloadRelayOpen) - &&(!mvControlling->ControlPressureSwitch)) { - if ((mvControlling->IsMainCtrlNoPowerPos()) - || (mvControlling->StLinFlag)) { // youBy polecił dodać 2012-09-08 v367 + if (!IsAnyMotorOverloadRelayOpen + && !mvControlling->ControlPressureSwitch) { + if (mvControlling->IsMainCtrlNoPowerPos() + || mvControlling->StLinFlag) { // youBy polecił dodać 2012-09-08 v367 // na pozycji 0 przejdzie, a na pozostałych będzie czekać, aż się załączą liniowe (zgaśnie DelayCtrlFlag) - if (Ready || (iDrivigFlags & movePress)) { + if (Ready || iDrivigFlags & movePress) { auto const usehighoverloadrelaythreshold { - ( mvControlling->TrainType != dt_ET42 ) // ET42 uses these variables for different purpose. TODO: fix this - && ( mvControlling->ImaxHi > mvControlling->ImaxLo ) - && ( mvOccupied->Vel < ( mvControlling->IsMotorOverloadRelayHighThresholdOn() ? 30.0 : 20.0 ) ) - && ( iVehicles - ControlledEnginesCount > 0 ) + mvControlling->TrainType != dt_ET42 // ET42 uses these variables for different purpose. TODO: fix this + && mvControlling->ImaxHi > mvControlling->ImaxLo + && mvOccupied->Vel < (mvControlling->IsMotorOverloadRelayHighThresholdOn() ? 30.0 : 20.0) + && iVehicles - ControlledEnginesCount > 0 // && ( std::fabs( mvControlling->Im ) > 0.85 * mvControlling->Imax ) - && ( ( mvControlling->Imax * mvControlling->EngineVoltage * ControlledEnginesCount ) - / ( fMass * ( - fAccGravity == 0.025 ? - -0.01 : // prevent div/0 - fAccGravity - 0.025 ) ) - < -2.8 ) }; + && mvControlling->Imax * mvControlling->EngineVoltage * ControlledEnginesCount / + (fMass * (fAccGravity == 0.025 ? -0.01 : // prevent div/0 + fAccGravity - 0.025)) < + -2.8 }; // use series mode: // if high threshold is set for motor overload relay, // if the power station is heavily burdened, @@ -3449,34 +3391,25 @@ bool TController::IncSpeed() // to build up speed to 30/40 km/h for passenger/cargo train (10 km/h less if going uphill) auto const sufficienttractionforce { std::abs( mvControlling->Ft ) * ControlledEnginesCount > ( IsHeavyCargoTrain ? 75 : 50 ) * 1000.0 }; auto const sufficientacceleration { AbsAccS >= ( IsHeavyCargoTrain ? 0.03 : IsCargoTrain ? 0.06 : 0.09 ) }; - auto const seriesmodefieldshunting { ( mvControlling->ScndCtrlPos > 0 ) && ( mvControlling->RList[ mvControlling->MainCtrlPos ].Bn == 1 ) }; - auto const parallelmodefieldshunting { ( mvControlling->ScndCtrlPos > 0 ) && ( mvControlling->RList[ mvControlling->MainCtrlPos ].Bn > 1 ) }; + auto const seriesmodefieldshunting { mvControlling->ScndCtrlPos > 0 && mvControlling->RList[mvControlling->MainCtrlPos].Bn == 1 }; + auto const parallelmodefieldshunting { mvControlling->ScndCtrlPos > 0 && mvControlling->RList[mvControlling->MainCtrlPos].Bn > 1 }; auto const minvoltage { ( mvPantographUnit->EnginePowerSource.SourceType == TPowerSource::CurrentCollector ? mvPantographUnit->EnginePowerSource.CollectorParameters.MinV : 0.0 ) }; auto const maxvoltage { ( mvPantographUnit->EnginePowerSource.SourceType == TPowerSource::CurrentCollector ? mvPantographUnit->EnginePowerSource.CollectorParameters.MaxV : 0.0 ) }; auto const seriesmodevoltage { std::lerp( minvoltage, maxvoltage, - ( IsHeavyCargoTrain ? 0.35 : 0.40 ) ) }; - auto const useseriesmode = ( - ( mvControlling->Imax > mvControlling->ImaxLo ) - || ( true == usehighoverloadrelaythreshold ) - || ( fVoltage < seriesmodevoltage ) - || ( ( true == sufficientacceleration ) - && ( true == sufficienttractionforce ) - && ( mvOccupied->Vel <= ( IsCargoTrain ? 40 : 30 ) + ( seriesmodefieldshunting ? 5 : 0 ) - ( ( fAccGravity < -0.025 ) ? 10 : 0 ) ) ) ); + IsHeavyCargoTrain ? 0.35 : 0.40 ) }; + auto const useseriesmode = mvControlling->Imax > mvControlling->ImaxLo || true == usehighoverloadrelaythreshold || fVoltage < seriesmodevoltage || + (true == sufficientacceleration && true == sufficienttractionforce && + mvOccupied->Vel <= (IsCargoTrain ? 40 : 30) + (seriesmodefieldshunting ? 5 : 0) - (fAccGravity < -0.025 ? 10 : 0)); // when not in series mode use the first available parallel mode configuration until 50/60 km/h for passenger/cargo train // (if there's only one parallel mode configuration it'll be used regardless of current speed) - auto const usefieldshunting = ( - ( mvControlling->StLinFlag ) - && ( mvControlling->RList[ mvControlling->MainCtrlPos ].R < 0.01 ) - && ( useseriesmode ? - mvControlling->RList[ mvControlling->MainCtrlPos ].Bn == 1 : - ( ( true == sufficientacceleration ) - && ( true == sufficienttractionforce ) - && ( mvOccupied->Vel <= ( IsCargoTrain ? 60 : 50 ) + ( parallelmodefieldshunting ? 5 : 0 ) ) ? - mvControlling->RList[ mvControlling->MainCtrlPos ].Bn > 1 : - mvControlling->MainCtrlPos == mvControlling->MainCtrlPosNo ) ) ); + auto const usefieldshunting = mvControlling->StLinFlag && mvControlling->RList[mvControlling->MainCtrlPos].R < 0.01 && + (useseriesmode ? mvControlling->RList[mvControlling->MainCtrlPos].Bn == 1 : + true == sufficientacceleration && true == sufficienttractionforce && mvOccupied->Vel <= (IsCargoTrain ? 60 : 50) + (parallelmodefieldshunting ? 5 : 0) ? + mvControlling->RList[mvControlling->MainCtrlPos].Bn > 1 : + mvControlling->MainCtrlPos == mvControlling->MainCtrlPosNo); // if needed enable high threshold for overload relay... if( mvControlling->TrainType != dt_ET42 ) { // ET42 uses these variables for different purpose. TODO: fix this @@ -3487,8 +3420,8 @@ bool TController::IncSpeed() if( false == mvControlling->IsScndCtrlNoPowerPos() ) { mvControlling->DecScndCtrl( 2 ); } - while( ( false == mvControlling->IsMainCtrlNoPowerPos() ) - && ( mvControlling->RList[ mvControlling->MainCtrlPos ].Bn > 1 ) ) { + while( false == mvControlling->IsMainCtrlNoPowerPos() + && mvControlling->RList[mvControlling->MainCtrlPos].Bn > 1 ) { mvControlling->DecMainCtrl( 1 ); // kręcimy nastawnik jazdy o 1 wstecz } } @@ -3497,8 +3430,8 @@ bool TController::IncSpeed() } // ...or disable high threshold for overload relay if no longer needed else { - if( ( mvControlling->IsMotorOverloadRelayHighThresholdOn() ) - && ( std::fabs( mvControlling->Im ) < mvControlling->ImaxLo ) ) { + if( mvControlling->IsMotorOverloadRelayHighThresholdOn() + && std::fabs(mvControlling->Im) < mvControlling->ImaxLo ) { mvControlling->CurrentSwitch( false ); // rozruch wysoki wyłącz } } @@ -3506,23 +3439,20 @@ bool TController::IncSpeed() double Vs = 99999; if( usefieldshunting ? - ( mvControlling->ScndCtrlPos < mvControlling->ScndCtrlPosNo ) : - ( mvControlling->MainCtrlPos < mvControlling->MainCtrlPosNo ) ) { + mvControlling->ScndCtrlPos < mvControlling->ScndCtrlPosNo : + mvControlling->MainCtrlPos < mvControlling->MainCtrlPosNo ) { Vs = ESMVelocity( !usefieldshunting ); } - if( ( std::abs( mvControlling->Im ) < ( fReady < 0.4 ? mvControlling->Imin : mvControlling->IminLo ) ) - || ( mvControlling->Vel > Vs ) ) { + if( std::abs(mvControlling->Im) < (fReady < 0.4 ? mvControlling->Imin : mvControlling->IminLo) + || mvControlling->Vel > Vs ) { // Ra: wywalał nadmiarowy, bo Im może być ujemne; jak nie odhamowany, to nie przesadzać z prądem if( usefieldshunting ) { // to dać bocznik // engage the shuntfield only if there's sufficient power margin to draw from auto const sufficientpowermargin { fVoltage - seriesmodevoltage > ( IsHeavyCargoTrain ? 100.0 : 75.0 ) * ControlledEnginesCount }; - OK = ( - sufficientpowermargin ? - mvControlling->IncScndCtrl( 1 ) : - true ); + OK = sufficientpowermargin ? mvControlling->IncScndCtrl(1) : true; } else { // jeśli ustawiony bocznik to bocznik na zero po chamsku @@ -3539,10 +3469,7 @@ bool TController::IncSpeed() seriesmodevoltage ) > ( IsHeavyCargoTrain ? 100.0 : 75.0 ) * ControlledEnginesCount }; - OK = ( - ( sufficientpowermargin && ( false == mvControlling->DelayCtrlFlag ) ) ? - mvControlling->IncMainCtrl( 1 ) : - true ); + OK = sufficientpowermargin && false == mvControlling->DelayCtrlFlag ? mvControlling->IncMainCtrl(1) : true; // czekaj na 1 pozycji, zanim się nie włączą liniowe if( true == mvControlling->StLinFlag ) { iDrivigFlags |= moveIncSpeed; @@ -3551,8 +3478,8 @@ bool TController::IncSpeed() iDrivigFlags &= ~moveIncSpeed; } - if( ( mvControlling->Im == 0 ) - && ( mvControlling->MainCtrlPowerPos() > 1 ) ) { + if( mvControlling->Im == 0 + && mvControlling->MainCtrlPowerPos() > 1 ) { // brak prądu na dalszych pozycjach // nie załączona lokomotywa albo wywalił nadmiarowy Need_TryAgain = true; @@ -3569,7 +3496,7 @@ bool TController::IncSpeed() break; case TEngineType::Dumb: if (!IsAnyMotorOverloadRelayOpen) - if (Ready || (iDrivigFlags & movePress)) //{(BrakePress<=0.01*MaxBrakePress)} + if (Ready || iDrivigFlags & movePress) //{(BrakePress<=0.01*MaxBrakePress)} { OK = IncSpeedEIM(); if( !OK ) @@ -3579,12 +3506,12 @@ bool TController::IncSpeed() } break; case TEngineType::DieselElectric: - if ((!IsAnyMotorOverloadRelayOpen) - &&(!mvControlling->ControlPressureSwitch)) { - if ((mvControlling->IsMainCtrlNoPowerPos()) || - (mvControlling->StLinFlag)) { // youBy polecił dodać 2012-09-08 v367 + if (!IsAnyMotorOverloadRelayOpen + && !mvControlling->ControlPressureSwitch) { + if (mvControlling->IsMainCtrlNoPowerPos() || + mvControlling->StLinFlag) { // youBy polecił dodać 2012-09-08 v367 // na pozycji 0 przejdzie, a na pozostałych będzie czekać, aż się załączą liniowe (zgaśnie DelayCtrlFlag) - if (Ready || (iDrivigFlags & movePress)) //{(BrakePress<=0.01*MaxBrakePress)} + if (Ready || iDrivigFlags & movePress) //{(BrakePress<=0.01*MaxBrakePress)} { OK = IncSpeedEIM(); if( !OK ) @@ -3597,18 +3524,18 @@ bool TController::IncSpeed() break; case TEngineType::ElectricInductionMotor: if( !IsAnyMotorOverloadRelayOpen ) { - if( Ready || ( iDrivigFlags & movePress ) || ( mvOccupied->ShuntMode ) ) //{(BrakePress<=0.01*MaxBrakePress)} + if( Ready || iDrivigFlags & movePress || mvOccupied->ShuntMode ) //{(BrakePress<=0.01*MaxBrakePress)} { OK = IncSpeedEIM(); - if( ( mvControlling->SpeedCtrl ) && ( mvControlling->Mains ) ) { + if( mvControlling->SpeedCtrl && mvControlling->Mains ) { // cruise control - auto const couplinginprogress{ ( true == TestFlag( iDrivigFlags, moveConnect ) ) && ( true == TestFlag( OrderCurrentGet(), Connect ) ) }; + auto const couplinginprogress{ true == TestFlag(iDrivigFlags, moveConnect) && true == TestFlag(OrderCurrentGet(), Connect) }; auto const SpeedCntrlVel{ ( - ( ActualProximityDist > std::max( 50.0, fMaxProximityDist ) ) || ( couplinginprogress ) ? + ActualProximityDist > std::max(50.0, fMaxProximityDist) || couplinginprogress ? VelDesired : min_speed( VelDesired, VelNext ) ) }; - if( ( SpeedCntrlVel >= mvControlling->SpeedCtrlUnit.MinVelocity ) - && ( SpeedCntrlVel - mvControlling->SpeedCtrlUnit.MinVelocity == quantize( SpeedCntrlVel - mvControlling->SpeedCtrlUnit.MinVelocity, mvControlling->SpeedCtrlUnit.VelocityStep ) ) ) { + if( SpeedCntrlVel >= mvControlling->SpeedCtrlUnit.MinVelocity + && SpeedCntrlVel - mvControlling->SpeedCtrlUnit.MinVelocity == quantize(SpeedCntrlVel - mvControlling->SpeedCtrlUnit.MinVelocity, mvControlling->SpeedCtrlUnit.VelocityStep) ) { SpeedCntrl( SpeedCntrlVel ); } else if( SpeedCntrlVel > 0.1 ) { @@ -3632,14 +3559,14 @@ bool TController::IncSpeed() { // dla 2Ls150 można zmienić tryb pracy, jeśli jest w liniowym i nie daje rady (wymaga zerowania kierunku) // mvControlling->ShuntMode=(OrderList[OrderPos]&Shunt)||(fMass>224000.0); } - if ((mvControlling->SpeedCtrl)&&(mvControlling->Mains)) {// cruise control - auto const couplinginprogress { ( true == TestFlag( iDrivigFlags, moveConnect ) ) && ( true == TestFlag( OrderCurrentGet(), Connect ) ) }; + if (mvControlling->SpeedCtrl && mvControlling->Mains) {// cruise control + auto const couplinginprogress { true == TestFlag(iDrivigFlags, moveConnect) && true == TestFlag(OrderCurrentGet(), Connect) }; auto const SpeedCntrlVel { ( - ( ActualProximityDist > std::max( 50.0, fMaxProximityDist ) ) || ( couplinginprogress ) ? + ActualProximityDist > std::max(50.0, fMaxProximityDist) || couplinginprogress ? VelDesired : min_speed( VelDesired, VelNext ) ) }; - if( ( SpeedCntrlVel >= mvControlling->SpeedCtrlUnit.MinVelocity ) - && ( SpeedCntrlVel - mvControlling->SpeedCtrlUnit.MinVelocity == quantize( SpeedCntrlVel - mvControlling->SpeedCtrlUnit.MinVelocity, mvControlling->SpeedCtrlUnit.VelocityStep ) ) ) { + if( SpeedCntrlVel >= mvControlling->SpeedCtrlUnit.MinVelocity + && SpeedCntrlVel - mvControlling->SpeedCtrlUnit.MinVelocity == quantize(SpeedCntrlVel - mvControlling->SpeedCtrlUnit.MinVelocity, mvControlling->SpeedCtrlUnit.VelocityStep) ) { SpeedCntrl(SpeedCntrlVel); } else if (SpeedCntrlVel > 0.1) { @@ -3650,16 +3577,16 @@ bool TController::IncSpeed() if (mvControlling->EIMCtrlType > 0) { if (true == Ready) { - bool max = (mvControlling->Vel > mvControlling->dizel_minVelfullengage) + bool max = mvControlling->Vel > mvControlling->dizel_minVelfullengage || (mvControlling->SpeedCtrl && mvControlling->ScndCtrlPos > 0); - DizelPercentage = (max ? 100 : 1); + DizelPercentage = max ? 100 : 1; } break; } else { if( true == Ready ) { - if( ( mvControlling->Vel > mvControlling->dizel_minVelfullengage ) - && ( mvControlling->RList[ mvControlling->MainCtrlPos ].Mn > 0 ) ) { + if( mvControlling->Vel > mvControlling->dizel_minVelfullengage + && mvControlling->RList[mvControlling->MainCtrlPos].Mn > 0 ) { OK = mvControlling->IncMainCtrl( 1 ); } if( mvControlling->RList[ mvControlling->MainCtrlPos ].Mn == 0 ) { @@ -3709,7 +3636,7 @@ bool TController::DecSpeed(bool force) case TEngineType::DieselElectric: OK = mvControlling->DecScndCtrl(2); if (!OK) - OK = mvControlling->DecMainCtrl( std::min( mvControlling->MainCtrlPowerPos(), ( 2 + (mvControlling->MainCtrlPowerPos() / 2) ) ) ); + OK = mvControlling->DecMainCtrl( std::min( mvControlling->MainCtrlPowerPos(), 2 + mvControlling->MainCtrlPowerPos() / 2 ) ); break; case TEngineType::ElectricInductionMotor: OK = DecSpeedEIM(); @@ -3730,26 +3657,26 @@ bool TController::DecSpeed(bool force) SpeedCntrl(0.0); //wylacz od razu tempomat mvControlling->DecScndCtrl(2); } - if ((VelDesired > 0.1) && (mvControlling->SpeedCtrlUnit.MinVelocity > VelDesired)) { + if (VelDesired > 0.1 && mvControlling->SpeedCtrlUnit.MinVelocity > VelDesired) { SpeedCntrl(0.0); //wylacz od razu tempomat mvControlling->DecScndCtrl(2); } break; } - if ((mvControlling->Vel > mvControlling->dizel_minVelfullengage)) + if (mvControlling->Vel > mvControlling->dizel_minVelfullengage) { if (mvControlling->RList[mvControlling->MainCtrlPos].Mn > 0) OK = mvControlling->DecMainCtrl(1); } else { - while( ( mvControlling->RList[ mvControlling->MainCtrlPos ].Mn > 0 ) - && ( mvControlling->MainCtrlPowerPos() > 1 ) ) { + while( mvControlling->RList[mvControlling->MainCtrlPos].Mn > 0 + && mvControlling->MainCtrlPowerPos() > 1 ) { OK = mvControlling->DecMainCtrl( 1 ); } } if (force) { // przy aktywacji kabiny jest potrzeba natychmiastowego wyzerowania - OK = mvControlling->DecMainCtrl((mvControlling->MainCtrlPowerPos() > 2 ? 2 : 1)); + OK = mvControlling->DecMainCtrl(mvControlling->MainCtrlPowerPos() > 2 ? 2 : 1); SpeedCntrl(0.0); //wylacz od razu tempomat mvControlling->DecScndCtrl( 2 ); } @@ -3804,10 +3731,10 @@ bool TController::DecSpeedEIM( int const Amount ) break; } case 2: { - if( ( AccDesired > 0 ) - && ( mvControlling->SpeedCtrlUnit.IsActive ) - && ( mvControlling->SpeedCtrlUnit.PowerStep > 0 ) - && ( mvControlling->SpeedCtrlUnit.DesiredPower > mvControlling->SpeedCtrlUnit.MinPower ) ) { + if( AccDesired > 0 + && mvControlling->SpeedCtrlUnit.IsActive + && mvControlling->SpeedCtrlUnit.PowerStep > 0 + && mvControlling->SpeedCtrlUnit.DesiredPower > mvControlling->SpeedCtrlUnit.MinPower ) { mvControlling->SpeedCtrlPowerDec(); } else { @@ -3837,8 +3764,8 @@ bool TController::BrakeLevelAdd(double b) { // dodanie wartości (b) do pozycji hamulca (w tym ujemnej) // zwraca false, gdy po dodaniu było by poza zakresem BrakeLevelSet(BrakeCtrlPosition + b); - return b > 0.0 ? (BrakeCtrlPosition < gbh_MAX) : - (BrakeCtrlPosition > -1.0); // true, jeśli można kontynuować + return b > 0.0 ? BrakeCtrlPosition < gbh_MAX : + BrakeCtrlPosition > -1.0; // true, jeśli można kontynuować } // Ra: regulacja prędkości, wykonywana w każdym przebłysku świadomości AI @@ -3855,8 +3782,8 @@ void TController::SpeedSet() { // TODO: sprawdzanie innego czlonu //if (!FuseFlagCheck()) if( ( iDrivigFlags & moveIncSpeed ) == 0 ) { // przetok rozłączać od razu (no dependency on fActionTime) - while( ( mvControlling->MainCtrlPos ) - && ( mvControlling->DecMainCtrl( 1 ) ) ) { + while( mvControlling->MainCtrlPos + && mvControlling->DecMainCtrl(1) ) { ; // na zero } if( fActionTime >= 0.0 ) { @@ -3873,8 +3800,8 @@ void TController::SpeedSet() { mvOccupied->DirectionForward(); //żeby EN57 jechały na drugiej nastawie } - if( ( mvControlling->MainCtrlPos > 0 ) - && ( false == mvControlling->StLinFlag ) ) { + if( mvControlling->MainCtrlPos > 0 + && false == mvControlling->StLinFlag ) { // jak niby jedzie, ale ma rozłączone liniowe to na zero i czekać na przewalenie kułakowego mvControlling->DecMainCtrl( 2 ); } @@ -3981,8 +3908,8 @@ void TController::SpeedSet() { // ...presuming there is a higher gear if( mvControlling->ScndCtrlPos < mvControlling->ScndCtrlPosNo ) { mvControlling->DecMainCtrl( 2 ); - while( ( mvControlling->IncScndCtrl( 1 ) ) - && ( mvControlling->MotorParam[ mvControlling->ScndCtrlPos ].mIsat == 0.0 ) ) { // jeśli bieg jałowy to kolejny + while( mvControlling->IncScndCtrl(1) + && mvControlling->MotorParam[mvControlling->ScndCtrlPos].mIsat == 0.0 ) { // jeśli bieg jałowy to kolejny ; } } @@ -3992,9 +3919,9 @@ void TController::SpeedSet() { // ... but ensure we don't switch all way down to 0 if( mvControlling->ScndCtrlPos > 1 ) { mvControlling->DecMainCtrl( 2 ); - while( ( mvControlling->ScndCtrlPos > 1 ) // repeat the entry check as we're working in a loop - && ( mvControlling->DecScndCtrl( 1 ) ) - && ( mvControlling->MotorParam[ mvControlling->ScndCtrlPos ].mIsat == 0.0 ) ) { // jeśli bieg jałowy to kolejny + while( mvControlling->ScndCtrlPos > 1 // repeat the entry check as we're working in a loop + && mvControlling->DecScndCtrl(1) + && mvControlling->MotorParam[mvControlling->ScndCtrlPos].mIsat == 0.0 ) { // jeśli bieg jałowy to kolejny ; } } @@ -4029,14 +3956,14 @@ void TController::SpeedCntrl(double DesiredSpeed) mvControlling->IncScndCtrl(1); mvControlling->RunCommand("SpeedCntrl", DesiredSpeed, mvControlling->CabActive); } - else if ((mvControlling->ScndCtrlPosNo > 1) && (!mvOccupied->SpeedCtrlTypeTime)) + else if (mvControlling->ScndCtrlPosNo > 1 && !mvOccupied->SpeedCtrlTypeTime) { int DesiredPos = 1 + mvControlling->ScndCtrlPosNo * ((DesiredSpeed - 1.0) / mvControlling->Vmax); - while( ( mvControlling->ScndCtrlPos > DesiredPos ) && ( true == mvControlling->DecScndCtrl( 1 ) ) ) { ; } // all work is done in the condition loop - while( ( mvControlling->ScndCtrlPos < DesiredPos ) && ( true == mvControlling->IncScndCtrl( 1 ) ) ) { ; } // all work is done in the condition loop + while( mvControlling->ScndCtrlPos > DesiredPos && true == mvControlling->DecScndCtrl(1) ) { ; } // all work is done in the condition loop + while( mvControlling->ScndCtrlPos < DesiredPos && true == mvControlling->IncScndCtrl(1) ) { ; } // all work is done in the condition loop } - if( ( mvControlling->SpeedCtrlUnit.PowerStep > 0 ) && ( mvControlling->ScndCtrlPos > 0 ) ) { + if( mvControlling->SpeedCtrlUnit.PowerStep > 0 && mvControlling->ScndCtrlPos > 0 ) { while (mvControlling->SpeedCtrlUnit.DesiredPower < mvControlling->SpeedCtrlUnit.MaxPower) { mvControlling->SpeedCtrlPowerInc(); @@ -4055,9 +3982,9 @@ void TController::SetTimeControllers() if (mvOccupied->Handle->Time) { auto const pressuredifference { mvOccupied->Handle->GetCP() - ( mvOccupied->HighPipePress - BrakeCtrlPosition * 0.25*mvOccupied->DeltaPipePress ) }; - if ((BrakeCtrlPosition > 0) && (pressuredifference > 0.05)) + if (BrakeCtrlPosition > 0 && pressuredifference > 0.05) mvOccupied->BrakeLevelSet(mvOccupied->Handle->GetPos(bh_FB)); - else if ((BrakeCtrlPosition > 0) && (pressuredifference < -0.05)) + else if (BrakeCtrlPosition > 0 && pressuredifference < -0.05) mvOccupied->BrakeLevelSet(mvOccupied->Handle->GetPos(bh_RP)); else if (BrakeCtrlPosition == 0) mvOccupied->BrakeLevelSet(mvOccupied->Handle->GetPos(bh_RP)); @@ -4069,8 +3996,8 @@ void TController::SetTimeControllers() if( mvOccupied->BrakeHandle == TBrakeHandle::FV4a ) { mvOccupied->BrakeLevelSet( BrakeCtrlPosition ); } - if( ( mvOccupied->BrakeHandle == TBrakeHandle::MHZ_K8P ) - || ( mvOccupied->BrakeHandle == TBrakeHandle::MHZ_EN57 ) ) { + if( mvOccupied->BrakeHandle == TBrakeHandle::MHZ_K8P + || mvOccupied->BrakeHandle == TBrakeHandle::MHZ_EN57 ) { if( BrakeCtrlPosition == 0 ) { mvOccupied->BrakeLevelSet( mvOccupied->Handle->GetPos( bh_RP ) ); } @@ -4107,8 +4034,8 @@ void TController::SetTimeControllers() } } */ - if( ( mvOccupied->UniCtrlIntegratedLocalBrakeCtrl ) - && ( mvOccupied->LocalBrakePosA > 0.95 ) ) { + if( mvOccupied->UniCtrlIntegratedLocalBrakeCtrl + && mvOccupied->LocalBrakePosA > 0.95 ) { while( IncBrakeEIM() ) { ; } } @@ -4116,7 +4043,7 @@ void TController::SetTimeControllers() if (mvOccupied->EngineType == TEngineType::ElectricInductionMotor && mvOccupied->ScndCtrlPosNo > 1 && mvOccupied->SpeedCtrlTypeTime) { double SpeedCntrlVel = - (ActualProximityDist > std::max(50.0, fMaxProximityDist)) ? + ActualProximityDist > std::max(50.0, fMaxProximityDist) ? VelDesired : min_speed(VelDesired, VelNext); SpeedCntrlVel = 10 * std::floor(SpeedCntrlVel*0.1); @@ -4130,26 +4057,24 @@ void TController::SetTimeControllers() } //5. Check Main Controller in Dizels //5.1. Digital controller in DMUs with hydro - if ((mvControlling->EngineType == TEngineType::DieselEngine) && (mvControlling->EIMCtrlType == 3)) + if (mvControlling->EngineType == TEngineType::DieselEngine && mvControlling->EIMCtrlType == 3) { DizelPercentage_Speed = DizelPercentage; //wstepnie procenty auto MinVel{ std::min(mvControlling->hydro_TC_LockupSpeed, mvControlling->Vmax / 6) }; //minimal velocity //when speed controll unit is active - start with the procedure - if ((mvControlling->SpeedCtrl) && (mvControlling->ScndCtrlPos > 0)) { - if ((mvControlling->ScndCtrlPos > 0) && (mvControlling->Vel < 1 + mvControlling->SpeedCtrlUnit.StartVelocity) && (DizelPercentage > 0)) + if (mvControlling->SpeedCtrl && mvControlling->ScndCtrlPos > 0) { + if (mvControlling->ScndCtrlPos > 0 && mvControlling->Vel < 1 + mvControlling->SpeedCtrlUnit.StartVelocity && DizelPercentage > 0) DizelPercentage_Speed = 101; //keep last position to start } else if (VelDesired > MinVel) //more power for faster ride { - auto const Factor{ 10 * (mvControlling->Vmax) / (mvControlling->Vmax + 3 * mvControlling->Vel) }; + auto const Factor{ 10 * mvControlling->Vmax / (mvControlling->Vmax + 3 * mvControlling->Vel) }; auto DesiredPercentage{ std::clamp( - (VelDesired > mvControlling->Vel ? - (VelDesired - mvControlling->Vel) / Factor : - 0), + VelDesired > mvControlling->Vel ? (VelDesired - mvControlling->Vel) / Factor : 0, 0.0, 1.0) }; //correction for reaching desired velocity - if ((VelDesired < 0.5 * mvControlling->Vmax) //low velocity and reaching desired - && (VelDesired - mvControlling->Vel < 10)) { + if (VelDesired < 0.5 * mvControlling->Vmax //low velocity and reaching desired + && VelDesired - mvControlling->Vel < 10) { DesiredPercentage = std::min(DesiredPercentage, 0.75); } DizelPercentage_Speed = std::round(DesiredPercentage * DizelPercentage); @@ -4164,8 +4089,8 @@ void TController::SetTimeControllers() auto const PosInc { mvControlling->MainCtrlPosNo }; auto PosDec { 0 }; for( int i = PosInc; i >= 0; --i ) { - if( ( mvControlling->UniCtrlList[ i ].SetCtrlVal <= 0 ) - && ( mvControlling->UniCtrlList[ i ].SpeedDown > 0.01 ) ) { + if( mvControlling->UniCtrlList[i].SetCtrlVal <= 0 + && mvControlling->UniCtrlList[i].SpeedDown > 0.01 ) { PosDec = i; break; } @@ -4173,10 +4098,10 @@ void TController::SetTimeControllers() if( std::abs( DizelPercentage_Speed - DizelActualPercentage ) > ( DizelPercentage > 1 ? 0 : 0 ) ) { - if( ( PosDec > 0 ) - && ( ( DizelActualPercentage - DizelPercentage_Speed > 50 ) - || ( ( DizelPercentage_Speed == 0 ) - && ( DizelActualPercentage > 10 ) ) ) ) { + if( PosDec > 0 + && ( DizelActualPercentage - DizelPercentage_Speed > 50 + || ( DizelPercentage_Speed == 0 + && DizelActualPercentage > 10 ) ) ) { //one position earlier should be fast decreasing PosDec -= 1; } @@ -4192,14 +4117,14 @@ void TController::SetTimeControllers() } else //5.2. Analog direct controller - if ((mvControlling->EngineType == TEngineType::DieselEngine)&&(mvControlling->Vmax>30)) + if (mvControlling->EngineType == TEngineType::DieselEngine && mvControlling->Vmax > 30) { int MaxPos = mvControlling->MainCtrlPosNo; int MinPos = MaxPos; - for (int i = MaxPos; (i > 1) && (mvControlling->RList[i].Mn > 0); i--) MinPos = i; - if ((MaxPos > MinPos)&&(mvControlling->MainCtrlPos>0)&&(AccDesired>0)) + for (int i = MaxPos; i > 1 && mvControlling->RList[i].Mn > 0; i--) MinPos = i; + if (MaxPos > MinPos && mvControlling->MainCtrlPos > 0 && AccDesired > 0) { - double Factor = 5 * (mvControlling->Vmax) / (mvControlling->Vmax + mvControlling->Vel); + double Factor = 5 * mvControlling->Vmax / (mvControlling->Vmax + mvControlling->Vel); int DesiredPos = MinPos + (MaxPos - MinPos)*(VelDesired > mvControlling->Vel ? (VelDesired - mvControlling->Vel) / Factor : 0); if (DesiredPos > MaxPos) DesiredPos = MaxPos; if (DesiredPos < MinPos) DesiredPos = MinPos; @@ -4212,12 +4137,12 @@ void TController::SetTimeControllers() } } // 5.5 universal control for diesel electric vehicles - if ((mvControlling->EngineType == TEngineType::DieselElectric) && (mvControlling->EIMCtrlType == 3)) + if (mvControlling->EngineType == TEngineType::DieselElectric && mvControlling->EIMCtrlType == 3) { // NOTE: partial implementation for speedinc/dec // TBD, TODO: implement fully? - if( ( AccDesired >= 0.0 ) - && ( mvControlling->StLinFlag ) ) { + if( AccDesired >= 0.0 + && mvControlling->StLinFlag ) { auto const PosInc { mvControlling->MainCtrlPosNo }; auto PosKeep { 0 }; @@ -4239,21 +4164,21 @@ void TController::SetTimeControllers() AccDesired < AbsAccS - 0.05 ? PosDec : PosKeep ) }; - while( ( mvControlling->MainCtrlPos > DesiredPos ) && mvControlling->DecMainCtrl( 1 ) ) { ; } - while( ( mvControlling->MainCtrlPos < DesiredPos ) && mvControlling->IncMainCtrl( 1 ) ) { ; } + while( mvControlling->MainCtrlPos > DesiredPos && mvControlling->DecMainCtrl( 1 ) ) { ; } + while( mvControlling->MainCtrlPos < DesiredPos && mvControlling->IncMainCtrl( 1 ) ) { ; } } } //6. UniversalBrakeButtons //6.1. Checking flags for Over pressure if (std::abs(BrakeCtrlPosition - gbh_FS)<0.5) { - UniversalBrakeButtons |= (TUniversalBrake::ub_HighPressure | TUniversalBrake::ub_Overload); + UniversalBrakeButtons |= TUniversalBrake::ub_HighPressure | TUniversalBrake::ub_Overload; } else { UniversalBrakeButtons &= ~(TUniversalBrake::ub_HighPressure | TUniversalBrake::ub_Overload); } //6.2. Setting buttons for (int i = 0; i < 3; i++) { - mvOccupied->UniversalBrakeButton(i, (UniversalBrakeButtons & mvOccupied->UniversalBrakeButtonFlag[i])); + mvOccupied->UniversalBrakeButton(i, UniversalBrakeButtons & mvOccupied->UniversalBrakeButtonFlag[i]); } }; @@ -4301,21 +4226,21 @@ void TController::CheckTimeControllers() //5. Check Main Controller in Dizels //5.1. Digital controller in DMUs with hydro - if ((mvControlling->EngineType == TEngineType::DieselEngine) && (mvControlling->EIMCtrlType == 3)) + if (mvControlling->EngineType == TEngineType::DieselEngine && mvControlling->EIMCtrlType == 3) { int DizelActualPercentage = 100.4 * mvControlling->eimic_real; int NeutralPos = mvControlling->MainCtrlPosNo - 1; //przedostatnia powinna wstrzymywać - hipoteza robocza for (int i = mvControlling->MainCtrlPosNo; i >= 0; i--) - if ((mvControlling->UniCtrlList[i].SetCtrlVal <= 0) && (mvControlling->UniCtrlList[i].SpeedDown < 0.01)) //niby zero, ale nie zmniejsza procentów + if (mvControlling->UniCtrlList[i].SetCtrlVal <= 0 && mvControlling->UniCtrlList[i].SpeedDown < 0.01) //niby zero, ale nie zmniejsza procentów { NeutralPos = i; break; } if (BrakeCtrlPosition < 0.1) //jesli nie hamuje { - if ((DizelActualPercentage >= DizelPercentage_Speed) && (mvControlling->MainCtrlPos > NeutralPos)) + if (DizelActualPercentage >= DizelPercentage_Speed && mvControlling->MainCtrlPos > NeutralPos) while (mvControlling->MainCtrlPos > NeutralPos) mvControlling->DecMainCtrl(1); - if ((DizelActualPercentage <= DizelPercentage_Speed) && (mvControlling->MainCtrlPos < NeutralPos)) + if (DizelActualPercentage <= DizelPercentage_Speed && mvControlling->MainCtrlPos < NeutralPos) while (mvControlling->MainCtrlPos < NeutralPos) mvControlling->IncMainCtrl(1); mvOccupied->BrakeLevelSet(mvControlling->UniCtrlList[mvControlling->MainCtrlPos].mode); //zeby nie bruzdzilo machanie zespolonym } @@ -4327,7 +4252,7 @@ void TController::Doors( bool const Open, int const Side ) { // otwieranie drzwi if( true == Open ) { - auto const lewe = ( pVehicle->DirectionGet() > 0 ) ? 1 : 2; + auto const lewe = pVehicle->DirectionGet() > 0 ? 1 : 2; auto const prawe = 3 - lewe; // grant door control permission if it's not automatic // TBD: stricter requirements? @@ -4340,8 +4265,8 @@ void TController::Doors( bool const Open, int const Side ) { } } // consist-wide remote signals to open doors doors - if( ( pVehicle->MoverParameters->Doors.open_control == control_t::conductor ) - || ( pVehicle->MoverParameters->Doors.open_control == control_t::driver ) + if( pVehicle->MoverParameters->Doors.open_control == control_t::conductor + || pVehicle->MoverParameters->Doors.open_control == control_t::driver // NOTE: disabled for mixed controls, leave it up to passengers to open doors by themselves /* || ( pVehicle->MoverParameters->Doors.open_control == control_t::mixed ) */ ) { if( Side & prawe ) { @@ -4355,8 +4280,8 @@ void TController::Doors( bool const Open, int const Side ) { // zamykanie drzwi else { // if the doors are already closed and locked then there's nothing to do - if( ( false == doors_permit_active() ) - && ( false == doors_open() ) ) { + if( false == doors_permit_active() + && false == doors_open() ) { iDrivigFlags &= ~moveDoorOpened; iDrivigFlags &= ~moveDepartureWarned; return; @@ -4380,9 +4305,9 @@ void TController::Doors( bool const Open, int const Side ) { if( true == doors_open() ) { // consist-wide remote signals to close doors - if( ( pVehicle->MoverParameters->Doors.close_control == control_t::conductor ) - || ( pVehicle->MoverParameters->Doors.close_control == control_t::driver ) - || ( pVehicle->MoverParameters->Doors.close_control == control_t::mixed ) ) { + if( pVehicle->MoverParameters->Doors.close_control == control_t::conductor + || pVehicle->MoverParameters->Doors.close_control == control_t::driver + || pVehicle->MoverParameters->Doors.close_control == control_t::mixed ) { cue_action( driver_hint::doorrightclose ); cue_action( driver_hint::doorleftclose ); } @@ -4397,13 +4322,13 @@ void TController::Doors( bool const Open, int const Side ) { while( vehicle != nullptr ) { // zamykanie drzwi w pojazdach - flaga zezwolenia była by lepsza auto const ismanualdoor { - ( vehicle->MoverParameters->Doors.auto_velocity == -1.f ) - && ( ( vehicle->MoverParameters->Doors.close_control == control_t::passenger ) - || ( vehicle->MoverParameters->Doors.close_control == control_t::mixed ) ) }; + vehicle->MoverParameters->Doors.auto_velocity == -1.f + && ( vehicle->MoverParameters->Doors.close_control == control_t::passenger + || vehicle->MoverParameters->Doors.close_control == control_t::mixed ) }; - if( ( true == ismanualdoor ) - && ( ( vehicle->LoadExchangeTime() == 0.f ) - || ( vehicle->MoverParameters->Vel > EU07_AI_MOVEMENT ) ) ) { + if( true == ismanualdoor + && ( vehicle->LoadExchangeTime() == 0.f + || vehicle->MoverParameters->Vel > EU07_AI_MOVEMENT ) ) { vehicle->MoverParameters->OperateDoors( side::right, false, range_t::local ); vehicle->MoverParameters->OperateDoors( side::left, false, range_t::local ); } @@ -4420,17 +4345,13 @@ void TController::Doors( bool const Open, int const Side ) { bool TController::doors_open() const { - return ( - IsAnyDoorOpen[ side::right ] - || IsAnyDoorOpen[ side::left ] ); + return IsAnyDoorOpen[side::right] || IsAnyDoorOpen[side::left]; } bool TController::doors_permit_active() const { - return ( - IsAnyDoorPermitActive[ side::right ] - || IsAnyDoorPermitActive[ side::left ] ); + return IsAnyDoorPermitActive[side::right] || IsAnyDoorPermitActive[side::left]; } void @@ -4518,8 +4439,8 @@ bool TController::PutCommand( std::string NewCommand, double NewValue1, double N if( true == AIControllFlag ) { // simplified door closing procedure, to sync actual door state with the door state flag // NOTE: this may result in visually ugly quick switch between closing and opening the doors, but eh - if( ( pVehicle->MoverParameters->Doors.close_control == control_t::driver ) - || ( pVehicle->MoverParameters->Doors.close_control == control_t::mixed ) ) { + if( pVehicle->MoverParameters->Doors.close_control == control_t::driver + || pVehicle->MoverParameters->Doors.close_control == control_t::mixed ) { pVehicle->MoverParameters->OperateDoors( side::right, false ); pVehicle->MoverParameters->OperateDoors( side::left, false ); } @@ -4528,7 +4449,7 @@ bool TController::PutCommand( std::string NewCommand, double NewValue1, double N pVehicle->MoverParameters->PermitDoors( side::left, false ); } } - iDrivigFlags &= ~( moveDoorOpened ); + iDrivigFlags &= ~moveDoorOpened; TrainParams.UpdateMTable( simulation::Time, TrainParams.NextStationName ); TrainParams.StationIndexInc(); // przejście do następnej @@ -4573,7 +4494,7 @@ bool TController::PutCommand( std::string NewCommand, double NewValue1, double N { auto v = *NewLocation - pVehicle->GetPosition(); // wektor do punktu sterującego auto d = pVehicle->VectorFront(); // wektor wskazujący przód - iDirectionOrder = ((v.x * d.x + v.z * d.z) * NewValue1 > 0) ? + iDirectionOrder = (v.x * d.x + v.z * d.z) * NewValue1 > 0 ? 1 : -1; // do przodu, gdy iloczyn skalarny i prędkość dodatnie /* @@ -4620,7 +4541,7 @@ bool TController::PutCommand( std::string NewCommand, double NewValue1, double N { if (NewLocation) vCommandLocation = *NewLocation; - if ((NewValue1 != 0.0) && (OrderCurrentGet() != Obey_train)) + if (NewValue1 != 0.0 && OrderCurrentGet() != Obey_train) { // o ile jazda if( false == iEngineActive ) { // trzeba odpalić silnik najpierw, światła ustawi @@ -4708,7 +4629,7 @@ bool TController::PutCommand( std::string NewCommand, double NewValue1, double N { auto v = *NewLocation - pVehicle->GetPosition(); // wektor do punktu sterującego auto d = pVehicle->VectorFront(); // wektor wskazujący przód - iDirectionOrder = ((v.x * d.x + v.z * d.z) * NewValue1 > 0) ? + iDirectionOrder = (v.x * d.x + v.z * d.z) * NewValue1 > 0 ? 1 : -1; // do przodu, gdy iloczyn skalarny i prędkość dodatnie // iDirectionOrder=1; else if (NewValue1<0.0) iDirectionOrder=-1; @@ -4749,7 +4670,7 @@ bool TController::PutCommand( std::string NewCommand, double NewValue1, double N return true; } - if( ( NewCommand == "Shunt" ) || ( NewCommand == "Loose_shunt" ) ) + if( NewCommand == "Shunt" || NewCommand == "Loose_shunt" ) { // NewValue1 - ilość wagonów (-1=wszystkie); NewValue2: 0=odczep, 1..63=dołącz, -1=bez zmian //-3,-y - podłączyć do całego stojącego składu (sprzęgiem y>=1), zmienić kierunek i czekać w trybie pociągowym //-2,-y - podłączyć do całego stojącego składu (sprzęgiem y>=1), zmienić kierunek i czekać @@ -4773,8 +4694,8 @@ bool TController::PutCommand( std::string NewCommand, double NewValue1, double N iDirectionOrder = -iDirection; // zmiana na ciągnięcie OrderPush(Change_direction); // najpierw zmień kierunek, bo odczepiamy z tyłu OrderPush(Disconnect); // a odczep już po zmianie kierunku - if( ( NewValue2 > 0.0 ) - && ( NewCommand == "Loose_shunt" ) ) { + if( NewValue2 > 0.0 + && NewCommand == "Loose_shunt" ) { // after decoupling continue pushing in the original direction // NOTE: for backward compatibility this option isn't supported for basic shunting mode iDirectionOrder = iDirection; // back to pushing @@ -4792,8 +4713,8 @@ bool TController::PutCommand( std::string NewCommand, double NewValue1, double N if( NewValue1 >= 0.0 ) { // jeśli ilość wagonów inna niż wszystkie będzie odczepianie, // ale jeśli wagony są z przodu, to trzeba najpierw zmienić kierunek - if( ( mvOccupied->Couplers[ mvOccupied->DirAbsolute > 0 ? end::rear : end::front ].Connected == nullptr ) // z tyłu nic - && ( mvOccupied->Couplers[ mvOccupied->DirAbsolute > 0 ? end::front : end::rear ].Connected != nullptr ) ) { // a z przodu skład + if( mvOccupied->Couplers[mvOccupied->DirAbsolute > 0 ? end::rear : end::front].Connected == nullptr // z tyłu nic + && mvOccupied->Couplers[mvOccupied->DirAbsolute > 0 ? end::front : end::rear].Connected != nullptr ) { // a z przodu skład iDirectionOrder = -iDirection; // zmiana na ciągnięcie OrderNext( Change_direction ); // najpierw zmień kierunek (zastąpi Disconnect) OrderPush( Disconnect ); // a odczep już po zmianie kierunku @@ -4819,10 +4740,10 @@ bool TController::PutCommand( std::string NewCommand, double NewValue1, double N } // (nie dotyczy Connect) if( NewValue1 < -2.5 ) { // jeśli -3 to potem jazda pociągowa - OrderNext( ( NewCommand == "Shunt" ? Obey_train : Bank ) ); + OrderNext( NewCommand == "Shunt" ? Obey_train : Bank ); } else { // otherwise continue shunting - OrderNext( ( NewCommand == "Shunt" ? Shunt : Loose_shunt ) ); + OrderNext( NewCommand == "Shunt" ? Shunt : Loose_shunt ); } CheckVehicles(); // sprawdzić światła iVehicleCount = std::floor( NewValue1 ); @@ -4840,7 +4761,7 @@ bool TController::PutCommand( std::string NewCommand, double NewValue1, double N if( NewValue1 == -1.0 ) { JumpToNextOrder(); } - else if ((NewValue1 >= 0) && (NewValue1 < maxorders)) + else if (NewValue1 >= 0 && NewValue1 < maxorders) { OrderPos = floor(NewValue1); if( !OrderPos ) { @@ -4856,7 +4777,7 @@ bool TController::PutCommand( std::string NewCommand, double NewValue1, double N if (NewCommand == "Warning_signal") { - if( ( NewValue1 > 0 ) && ( NewValue2 > 0 ) ) { + if( NewValue1 > 0 && NewValue2 > 0 ) { fWarningDuration = NewValue1; // czas trąbienia cue_action( driver_hint::hornon, NewValue2 ); // horn combination flag } @@ -5042,12 +4963,12 @@ TController::PrepareHeating() { // if the heater has configured maximum temperature, it'll disable itself automatically, so we can leave it always running // otherwise enable the heater only to maintain minimum required temperature auto const lowtemperature { ( - ( ( heat.water.config.temp_min > 0 ) && ( heat.temperatura1 < heat.water.config.temp_min + ( mvControlling->WaterHeater.is_active ? 5 : 0 ) ) ) - || ( ( heat.water_aux.config.temp_min > 0 ) && ( heat.temperatura2 < heat.water_aux.config.temp_min + ( mvControlling->WaterHeater.is_active ? 5 : 0 ) ) ) - || ( ( heat.oil.config.temp_min > 0 ) && ( heat.To < heat.oil.config.temp_min + ( mvControlling->WaterHeater.is_active ? 5 : 0 ) ) ) ) }; + ( heat.water.config.temp_min > 0 && heat.temperatura1 < heat.water.config.temp_min + (mvControlling->WaterHeater.is_active ? 5 : 0) ) + || ( heat.water_aux.config.temp_min > 0 && heat.temperatura2 < heat.water_aux.config.temp_min + (mvControlling->WaterHeater.is_active ? 5 : 0) ) + || ( heat.oil.config.temp_min > 0 && heat.To < heat.oil.config.temp_min + (mvControlling->WaterHeater.is_active ? 5 : 0) ) ) }; auto const heateron { ( - ( mvControlling->WaterHeater.config.temp_max > 0 ) - || ( true == lowtemperature ) ) }; + mvControlling->WaterHeater.config.temp_max > 0 + || true == lowtemperature ) }; if( true == heateron ) { // make sure the water pump is running before enabling the heater if( false == mvControlling->WaterPump.is_active ) { @@ -5081,7 +5002,7 @@ TController::PrepareHeating() { } } // TBD, TODO: potentially pay attention to too high temperature as well? - IsHeatingTemperatureOK = ( false == IsHeatingTemperatureTooLow ); + IsHeatingTemperatureOK = false == IsHeatingTemperatureTooLow; return IsHeatingTemperatureOK; } @@ -5109,10 +5030,8 @@ TController::PrepareDirection() { } else { // ustalenie kierunku, gdy jedzie - iDirection = ( - mvOccupied->V >= 0 ? - 1 : // jazda w kierunku sprzęgu 0 - -1 ); // jazda w kierunku sprzęgu 1 + iDirection = mvOccupied->V >= 0 ? 1 : // jazda w kierunku sprzęgu 0 + -1; // jazda w kierunku sprzęgu 1 } } cue_action( driver_hint::mastercontrollersetreverserunlock ); @@ -5126,8 +5045,8 @@ void TController::JumpToNextOrder( bool const Ignoremergedchangedirection ) { // wykonanie kolejnej komendy z tablicy rozkazów if (OrderList[OrderPos] != Wait_for_orders) { - if( ( ( OrderList[ OrderPos ] & Change_direction ) != 0 ) // jeśli zmiana kierunku - && ( OrderList[ OrderPos ] != Change_direction ) ) { // ale nałożona na coś + if( (OrderList[OrderPos] & Change_direction) != 0 // jeśli zmiana kierunku + && OrderList[OrderPos] != Change_direction ) { // ale nałożona na coś if( false == Ignoremergedchangedirection ) { // usunięcie zmiany kierunku z innej komendy @@ -5193,13 +5112,13 @@ void TController::OrderNext(TOrders NewOrder) OrderTop = OrderPos; // ale może jest czymś zajęty na razie if (NewOrder >= Shunt) // jeśli ma jechać { // ale może być zajęty chwilowymi operacjami - while ((OrderList[OrderTop] != Wait_for_orders) && (OrderList[OrderTop] < Shunt)) // jeśli coś robi + while (OrderList[OrderTop] != Wait_for_orders && OrderList[OrderTop] < Shunt) // jeśli coś robi ++OrderTop; // pomijamy wszystkie tymczasowe prace } else { // jeśli ma ustawioną jazdę, to wyłączamy na rzecz operacji while (OrderList[OrderTop] ? - (OrderList[OrderTop] < Shunt) && (OrderList[OrderTop] != NewOrder) : + OrderList[OrderTop] < Shunt && OrderList[OrderTop] != NewOrder : false) // jeśli coś robi ++OrderTop; // pomijamy wszystkie tymczasowe prace } @@ -5249,11 +5168,11 @@ void TController::OrdersInit(double fVel) } else { // jeśli z rozkładem, to jedzie na szlak - if ((fVel > 0.0) && (fVel < 0.02)) + if (fVel > 0.0 && fVel < 0.02) OrderPush(Shunt); // dla prędkości 0.01 włączamy jazdę manewrową else if (TrainParams.DirectionChange() ? // jeśli obrót na pierwszym przystanku - ((iDrivigFlags & movePushPull) ? // SZT również! SN61 zależnie od wagonów... - (TrainParams.TimeTable[1].StationName == TrainParams.Relation1) : + (iDrivigFlags & movePushPull ? // SZT również! SN61 zależnie od wagonów... + TrainParams.TimeTable[1].StationName == TrainParams.Relation1 : false) : false) OrderPush(Shunt); // a teraz start będzie w manewrowym, a tryb pociągowy włączy W4 @@ -5302,11 +5221,11 @@ void TController::OrdersInit(double fVel) } else { // jeśli podana niezerowa prędkość - if( ( fVel >= 1.0 ) - || ( fVel < 0.02 ) ) { + if( fVel >= 1.0 + || fVel < 0.02 ) { // jeśli ma jechać - dla 0.01 ma podjechać manewrowo po podaniu sygnału // to do następnego W4 ma podjechać blisko - iDrivigFlags = ( iDrivigFlags & ~( moveStopHere ) ) | moveStopCloser; + iDrivigFlags = iDrivigFlags & ~moveStopHere | moveStopCloser; } else { // czekać na sygnał @@ -5330,7 +5249,7 @@ std::string TController::StopReasonText() const if (eStopReason != 7) // zawalidroga będzie inaczej return StopReasonTable[eStopReason]; else - return "Blocked by " + (pVehicles[0]->PrevAny()->name()); + return "Blocked by " + pVehicles[0]->PrevAny()->name(); }; //---------------------------------------------------------------------------------------------------------------------- @@ -5372,14 +5291,14 @@ basic_event * TController::CheckTrackEventBackward(double fDirection, TTrack *Tr auto const pos{ End == end::front ? Vehicle->RearPosition() : Vehicle->HeadPosition() }; auto const &eventsequence { ( fDirection * Eventdirection > 0 ? Track->m_events2 : Track->m_events1 ) }; for( auto const &event : eventsequence ) { - if( ( event.second != nullptr ) - && ( event.second->m_passive ) - && ( typeid(*(event.second)) == typeid( getvalues_event ) ) ) { + if( event.second != nullptr + && event.second->m_passive + && typeid(*event.second) == typeid(getvalues_event) ) { // since we're checking for events behind us discard the sources in front of the scanning vehicle auto const sl{ event.second->input_location() }; // położenie komórki pamięci auto const sem{ sl - pos }; // wektor do komórki pamięci od końca składu auto const isahead { dir.x * sem.x + dir.z * sem.z > 0 }; - if( ( End == end::front ? isahead : !isahead ) ) { + if( End == end::front ? isahead : !isahead ) { // iloczyn skalarny jest ujemny, gdy sygnał stoi z tyłu return event.second; } @@ -5487,7 +5406,7 @@ TCommandType TController::BackwardScan( double const Range ) // dzięki temu będzie można stawać za wskazanym sygnalizatorem, a zwłaszcza jeśli będzie jazda na kozioł // ograniczenia prędkości nie są wtedy istotne, również koniec toru jest do niczego nie przydatny // zwraca true, jeśli należy odwrócić kierunek jazdy pojazdu - if( ( OrderCurrentGet() & ~( Shunt | Loose_shunt | Connect ) ) ) { + if( OrderCurrentGet() & ~(Shunt | Loose_shunt | Connect) ) { // skanowanie sygnałów tylko gdy jedzie w trybie manewrowym albo czeka na rozkazy return TCommandType::cm_Unknown; } @@ -5556,16 +5475,15 @@ TCommandType TController::BackwardScan( double const Range ) auto move{false}; // czy AI w trybie manewerowym ma dociągnąć pod S1 if (e->input_command() == TCommandType::cm_SetVelocity) { - if ((scanvel == 0.0) ? (OrderCurrentGet() & (Shunt | Loose_shunt | Connect)) : - (OrderCurrentGet() & Connect)) + if (scanvel == 0.0 ? OrderCurrentGet() & (Shunt | Loose_shunt | Connect) : + OrderCurrentGet() & Connect) { // przy podczepianiu ignorować wyjazd? move = true; // AI w trybie manewerowym ma dociągnąć pod S1 } else { - if ((scandist > fMinProximityDist) && - ((mvOccupied->Vel > EU07_AI_NOMOVEMENT) && - ((OrderCurrentGet() & (Shunt | Loose_shunt)) == 0))) + if (scandist > fMinProximityDist && + mvOccupied->Vel > EU07_AI_NOMOVEMENT && (OrderCurrentGet() & (Shunt | Loose_shunt)) == 0) { // jeśli semafor jest daleko, a pojazd jedzie, to informujemy o zmianie prędkości // jeśli jedzie manewrowo, musi dostać SetVelocity, żeby sie na pociągowy przełączył @@ -5575,7 +5493,7 @@ TCommandType TController::BackwardScan( double const Range ) WriteLog(edir); #endif // SetProximityVelocity(scandist,scanvel,&sl); - return (scanvel > 0 ? TCommandType::cm_SetVelocity : TCommandType::cm_Unknown); + return scanvel > 0 ? TCommandType::cm_SetVelocity : TCommandType::cm_Unknown; } else { @@ -5588,7 +5506,7 @@ TCommandType TController::BackwardScan( double const Range ) WriteLog(edir + " - [SetVelocity] [" + to_string(scanvel, 2) + "] [" + to_string(e->input_value(2), 2) + "]"); #endif - return (scanvel > 0 ? TCommandType::cm_SetVelocity : TCommandType::cm_Unknown); + return scanvel > 0 ? TCommandType::cm_SetVelocity : TCommandType::cm_Unknown; } } } @@ -5647,16 +5565,15 @@ TCommandType TController::BackwardScan( double const Range ) return (scanvel > 0 ? TCommandType::cm_ShuntVelocity : TCommandType::cm_Unknown); } */ - return ((VelNext > 0) ? + return VelNext > 0 ? TCommandType::cm_Unknown : // no need to bother if we can continue in current direction - (scanvel == 0) ? + scanvel == 0 ? TCommandType::cm_Unknown : // no need to bother with a stop signal - TCommandType::cm_ShuntVelocity); // otherwise report a relevant shunt signal behind + TCommandType::cm_ShuntVelocity; // otherwise report a relevant shunt signal behind } // if (move?... } // if (OrderCurrentGet()==Shunt) - return (((e->m_passive) && (e->is_command())) ? TCommandType::cm_Command : - TCommandType::cm_Unknown); + return e->m_passive && e->is_command() ? TCommandType::cm_Command : TCommandType::cm_Unknown; }; std::string TController::NextStop() const @@ -5696,7 +5613,7 @@ void TController::UpdateDelayFlag() { void TController::TakeControl( bool const Aidriver, bool const Forcevehiclecheck ) { // przejęcie kontroli przez AI albo oddanie - if ((AIControllFlag == Aidriver) && (!Forcevehiclecheck)) + if (AIControllFlag == Aidriver && !Forcevehiclecheck) return; // już jest jak ma być if (Aidriver) //żeby nie wykonywać dwa razy { // teraz AI prowadzi @@ -5761,24 +5678,24 @@ void TController::DirectionForward(bool forward) if( forward ) { // do przodu w obecnej kabinie - while( ( mvOccupied->DirActive <= 0 ) - && ( mvOccupied->DirectionForward() ) ) { + while( mvOccupied->DirActive <= 0 + && mvOccupied->DirectionForward() ) { // force scan table update iTableDirection = 0; } } else { // do tyłu w obecnej kabinie - while( ( mvOccupied->DirActive >= 0 ) - && ( mvOccupied->DirectionBackward() ) ) { + while( mvOccupied->DirActive >= 0 + && mvOccupied->DirectionBackward() ) { // force scan table update iTableDirection = 0; } } if( mvOccupied->TrainType == dt_SN61 ) { // specjalnie dla SN61 żeby nie zgasł - while( ( mvControlling->RList[ mvControlling->MainCtrlPos ].Mn == 0 ) - && ( mvControlling->IncMainCtrl( 1 ) ) ) { + while( mvControlling->RList[mvControlling->MainCtrlPos].Mn == 0 + && mvControlling->IncMainCtrl(1) ) { ; // all work is done in the header } } @@ -5786,17 +5703,15 @@ void TController::DirectionForward(bool forward) void TController::ZeroDirection() { - while( ( mvOccupied->DirActive > 0 ) && ( mvOccupied->DirectionBackward() ) ) { ; } - while( ( mvOccupied->DirActive < 0 ) && ( mvOccupied->DirectionForward() ) ) { ; } + while( mvOccupied->DirActive > 0 && mvOccupied->DirectionBackward() ) { ; } + while( mvOccupied->DirActive < 0 && mvOccupied->DirectionForward() ) { ; } } void TController::sync_consist_reversers() { auto const currentdirection { mvOccupied->DirActive }; - auto const fastforward { ( - ( is_emu() ) - && ( mvOccupied->EngineType != TEngineType::ElectricInductionMotor ) ) - && ( mvOccupied->Imin == mvOccupied->IminHi ) }; + auto const fastforward { is_emu() && mvOccupied->EngineType != TEngineType::ElectricInductionMotor + && mvOccupied->Imin == mvOccupied->IminHi }; // move reverser all way in the opposite direction... for( auto idx = 0; idx < 3; ++idx ) { @@ -5819,7 +5734,7 @@ void TController::sync_consist_reversers() { } } // potentially restore 'fast forward' setting - if( ( currentdirection > 0 ) && ( true == fastforward ) ) { + if( currentdirection > 0 && true == fastforward ) { mvOccupied->DirectionForward(); } } @@ -5863,8 +5778,8 @@ TController::TrackObstacle() const { void TController::MoveTo(TDynamicObject *to) { // przesunięcie AI do innego pojazdu (przy zmianie kabiny) - if( ( to->Mechanik != nullptr ) - && ( to->Mechanik != this ) ) { + if( to->Mechanik != nullptr + && to->Mechanik != this ) { // ai controller thunderdome, there can be only one if( to->Mechanik->AIControllFlag ) { if( to->Mechanik->primary() ) { @@ -5898,10 +5813,7 @@ void TController::ControllingSet() mvControlling = pVehicle->FindPowered()->MoverParameters; // poszukiwanie członu sterowanego { auto *lookup { pVehicle->FindPantographCarrier() }; - mvPantographUnit = ( - lookup != nullptr ? - lookup->MoverParameters : - mvControlling ); + mvPantographUnit = lookup != nullptr ? lookup->MoverParameters : mvControlling; } BrakeSystem = consist_brake_system(); }; @@ -5925,10 +5837,10 @@ int TController::CrossRoute(TTrack *tr) { // trzeba przejrzeć tabelę skanowania w poszukiwaniu (tr) // i jak się znajdzie, to zwrócić zapamiętany numer segmentu i kierunek przejazdu // (-6..-1,1..6) - if( ( true == TestFlag( sSpeedTable[ i ].iFlags, spEnabled | spTrack ) ) - && ( sSpeedTable[ i ].trTrack == tr ) ) { + if( true == TestFlag(sSpeedTable[i].iFlags, spEnabled | spTrack) + && sSpeedTable[i].trTrack == tr ) { // jeśli pozycja odpowiadająca skrzyżowaniu (tr) - return ( sSpeedTable[ i ].iFlags >> 28 ); // najstarsze 4 bity jako liczba -8..7 + return sSpeedTable[i].iFlags >> 28; // najstarsze 4 bity jako liczba -8..7 } } return 0; // nic nie znaleziono? @@ -5967,7 +5879,7 @@ void TController::RouteSwitch(int d) */ std::string TController::OwnerName() const { - return ( pVehicle ? pVehicle->MoverParameters->Name : "none" ); + return pVehicle ? pVehicle->MoverParameters->Name : "none"; }; void @@ -5983,8 +5895,8 @@ TController::update_timers( double dt ) { fStopTime += dt; // zliczanie czasu postoju, nie ruszy dopóki ujemne fActionTime += dt; // czas używany przy regulacji prędkości i zamykaniu drzwi LastReactionTime += dt; - if( ( mvOccupied->Vel < 0.05 ) - && ( ( OrderCurrentGet() & ( Shunt | Loose_shunt | Obey_train | Bank ) ) != 0 ) ) { + if( mvOccupied->Vel < 0.05 + && (OrderCurrentGet() & (Shunt | Loose_shunt | Obey_train | Bank)) != 0 ) { IdleTime += dt; } else { @@ -5997,8 +5909,8 @@ void TController::update_logs( double const dt ) { // log vehicle data LastUpdatedTime += dt; - if( ( WriteLogFlag ) - && ( LastUpdatedTime > deltalog ) ) { + if( WriteLogFlag + && LastUpdatedTime > deltalog ) { // zapis do pliku DAT PhysicsLog(); LastUpdatedTime -= deltalog; @@ -6015,7 +5927,7 @@ TController::determine_consist_state() { cue_action( driver_hint::cabactivation ); } else if (!mvOccupied->AutomaticCabActivation - && ( (mvOccupied->CabActive == -mvOccupied->CabOccupied) || (!mvOccupied->CabMaster) || (!mvOccupied->Power24vIsAvailable) ) ) + && ( mvOccupied->CabActive == -mvOccupied->CabOccupied || !mvOccupied->CabMaster || !mvOccupied->Power24vIsAvailable ) ) { cue_action( driver_hint::cabdeactivation ); } @@ -6025,17 +5937,15 @@ TController::determine_consist_state() { fBrake_a0[0] = fBrake_a0[index]; fBrake_a1[0] = fBrake_a1[index]; - if ((is_emu()) || (is_dmu())) { + if (is_emu() || is_dmu()) { auto Coeff = std::clamp( mvOccupied->Vel*0.015 , 0.5 , 1.0); fAccThreshold = fNominalAccThreshold * Coeff - fBrake_a0[BrakeAccTableSize] * (1.0 - Coeff); } Ready = true; // wstępnie gotowy fReady = 0.0; // założenie, że odhamowany - IsConsistBraked = ( - ( ( mvOccupied->BrakeSystem == TBrakeSystem::ElectroPneumatic ) && ( false == ForcePNBrake ) ) ? - mvOccupied->BrakePress > 2.0 : - mvOccupied->PipePress < std::max( 3.9, mvOccupied->BrakePressureActual.PipePressureVal ) + 0.1 ); + IsConsistBraked = mvOccupied->BrakeSystem == TBrakeSystem::ElectroPneumatic && false == ForcePNBrake ? mvOccupied->BrakePress > 2.0 : + mvOccupied->PipePress < std::max(3.9, mvOccupied->BrakePressureActual.PipePressureVal) + 0.1; fAccGravity = 0.0; // przyspieszenie wynikające z pochylenia IsAnyCouplerStretched = false; IsAnyDoorOnlyOpen[ side::right ] = IsAnyDoorOnlyOpen[ side::left ] = false; @@ -6050,19 +5960,18 @@ TController::determine_consist_state() { auto const bp { std::max( 0.0, vehicle->BrakePress - ( vehicle->SpeedCtrlUnit.Parking ? vehicle->MaxBrakePress[ 0 ] * vehicle->StopBrakeDecc : 0.0 ) ) }; if (Ready) { // bo jak coś nie odhamowane, to dalej nie ma co sprawdzać - if( ( TestFlagAny( vehicle->Hamulec->GetBrakeStatus(), ( b_hld | b_on ) ) ) - || ( ( vehicle->Vel < 1.0 ? - ( bp > 0.4 ) : // ensure the brakes are sufficiently released when starting to move - ( vehicle->Fb * 0.001 > 10.0 ) ) ) ) { // once in motion we can make a more lenient check + if( TestFlagAny(vehicle->Hamulec->GetBrakeStatus(), b_hld | b_on) + || ( vehicle->Vel < 1.0 ? bp > 0.4 : // ensure the brakes are sufficiently released when starting to move + vehicle->Fb * 0.001 > 10.0 ) ) { // once in motion we can make a more lenient check Ready = false; } // Ra: odluźnianie przeładowanych lokomotyw, ciągniętych na zimno - prowizorka... if( bp >= 0.4 ) { // wg UIC określone sztywno na 0.04 if( AIControllFlag || (Global.AITrainman && mvOccupied->Vel < EU07_AI_NOMOVEMENT && !is_emu() && !is_dmu())) { - if( ( BrakeCtrlPosition == gbh_RP ) // jest pozycja jazdy - && ( false == TestFlag( vehicle->Hamulec->GetBrakeStatus(), b_dmg ) ) // brake isn't broken - && ( vehicle->PipePress - mvOccupied->Handle->GetRP() > -0.1 ) // jeśli ciśnienie jak dla jazdy - && ( vehicle->Hamulec->GetCRP() > vehicle->PipePress + 0.12 ) ) { // za dużo w zbiorniku + if( BrakeCtrlPosition == gbh_RP // jest pozycja jazdy + && false == TestFlag(vehicle->Hamulec->GetBrakeStatus(), b_dmg) // brake isn't broken + && vehicle->PipePress - mvOccupied->Handle->GetRP() > -0.1 // jeśli ciśnienie jak dla jazdy + && vehicle->Hamulec->GetCRP() > vehicle->PipePress + 0.12 ) { // za dużo w zbiorniku // indywidualne luzowanko vehicle->BrakeReleaser( 1 ); } @@ -6070,8 +5979,8 @@ TController::determine_consist_state() { } if (bp < 0.1) { if ( AIControllFlag || Global.AITrainman ) { - if (( false == TestFlag( vehicle->Hamulec->GetBrakeStatus(), b_dmg ) ) // brake isn't broken - && ( vehicle->Hamulec->GetCRP() < vehicle->PipePress - 0.1 ) ) { // już nie jest za dużo w zbiorniku + if (false == TestFlag(vehicle->Hamulec->GetBrakeStatus(), b_dmg) // brake isn't broken + && vehicle->Hamulec->GetCRP() < vehicle->PipePress - 0.1 ) { // już nie jest za dużo w zbiorniku // koniec indywidualnego luzowanka vehicle->BrakeReleaser( 0 ); } @@ -6087,20 +5996,20 @@ TController::determine_consist_state() { // check coupler state IsAnyCouplerStretched = IsAnyCouplerStretched - || ( vehicle->Couplers[ end::front ].stretch_duration > 0.0 ) - || ( vehicle->Couplers[ end::rear ].stretch_duration > 0.0 ); + || vehicle->Couplers[end::front].stretch_duration > 0.0 + || vehicle->Couplers[end::rear].stretch_duration > 0.0; // check door state { auto const switchsides{ p->DirectionGet() != (iDirection == 0 ? mvOccupied->CabOccupied : iDirection) }; auto const &rightdoor { vehicle->Doors.instances[ ( switchsides ? side::left : side::right ) ] }; auto const &leftdoor { vehicle->Doors.instances[ ( switchsides ? side::right : side::left ) ] }; if( vehicle->Doors.close_control != control_t::autonomous ) { - IsAnyDoorOpen[ side::right ] |= ( false == rightdoor.is_closed ); - IsAnyDoorOpen[ side::left ] |= ( false == leftdoor.is_closed ); + IsAnyDoorOpen[ side::right ] |= false == rightdoor.is_closed; + IsAnyDoorOpen[ side::left ] |= false == leftdoor.is_closed; } if (vehicle->Doors.close_control != control_t::autonomous) { - IsAnyDoorOnlyOpen[ side::right ] |= ( false == rightdoor.is_door_closed ); - IsAnyDoorOnlyOpen[ side::left ] |= ( false == leftdoor.is_door_closed ); + IsAnyDoorOnlyOpen[ side::right ] |= false == rightdoor.is_door_closed; + IsAnyDoorOnlyOpen[ side::left ] |= false == leftdoor.is_door_closed; } if( vehicle->Doors.permit_needed ) { IsAnyDoorPermitActive[ side::right ] |= rightdoor.open_permit; @@ -6109,7 +6018,7 @@ TController::determine_consist_state() { } // measure lighting level // TBD: apply weight (multiplier) to partially lit vehicles? - ConsistShade += ( p->fShade > 0.0 ? p->fShade : 1.0 ); + ConsistShade += p->fShade > 0.0 ? p->fShade : 1.0; p = p->Next(); // pojazd podłączony z tyłu (patrząc od czoła) } // calculate average amount of received sunlight @@ -6133,18 +6042,18 @@ TController::determine_consist_state() { auto const *vehicle { Vehicle->MoverParameters }; IsAnyConverterOverloadRelayOpen |= vehicle->ConvOvldFlag; IsAnyMotorOverloadRelayOpen |= vehicle->FuseFlag; - IsAnyGroundRelayOpen |= !( vehicle->GroundRelay ); - IsAnyCompressorPresent |= ( vehicle->CompressorSpeed > 0.0 ); - IsAnyCompressorEnabled |= ( vehicle->CompressorSpeed > 0.0 ? ( vehicle->CompressorAllow || vehicle->CompressorStart == start_t::automatic ) && ( vehicle->CompressorAllowLocal ) : false ); - IsAnyCompressorExplicitlyEnabled |= ( vehicle->CompressorSpeed > 0.0 ? ( vehicle->CompressorAllow && vehicle->CompressorAllowLocal ) : false ); - IsAnyConverterPresent |= ( vehicle->ConverterStart != start_t::disabled ); - IsAnyConverterEnabled |= ( vehicle->ConverterAllow || vehicle->ConverterStart == start_t::automatic ) && ( vehicle->ConverterAllowLocal ); - IsAnyConverterExplicitlyEnabled |= ( vehicle->ConverterAllow && vehicle->ConverterAllowLocal ); + IsAnyGroundRelayOpen |= !vehicle->GroundRelay; + IsAnyCompressorPresent |= vehicle->CompressorSpeed > 0.0; + IsAnyCompressorEnabled |= vehicle->CompressorSpeed > 0.0 ? (vehicle->CompressorAllow || vehicle->CompressorStart == start_t::automatic) && vehicle->CompressorAllowLocal : false; + IsAnyCompressorExplicitlyEnabled |= vehicle->CompressorSpeed > 0.0 ? vehicle->CompressorAllow && vehicle->CompressorAllowLocal : false; + IsAnyConverterPresent |= vehicle->ConverterStart != start_t::disabled; + IsAnyConverterEnabled |= ( vehicle->ConverterAllow || vehicle->ConverterStart == start_t::automatic ) && vehicle->ConverterAllowLocal; + IsAnyConverterExplicitlyEnabled |= vehicle->ConverterAllow && vehicle->ConverterAllowLocal; if( vehicle->Power > 0.01 ) { - IsAnyLineBreakerOpen |= !( vehicle->Mains ); } } ); + IsAnyLineBreakerOpen |= !vehicle->Mains; } } ); // siłę generują pojazdy na pochyleniu ale działa ona całość składu, więc a=F/m - fAccGravity *= ( iDirection >= 0 ? 1 : -1 ); + fAccGravity *= iDirection >= 0 ? 1 : -1; fAccGravity /= fMass; { auto absaccs { fAccGravity }; // Ra 2014-03: jesli skład stoi, to działa na niego składowa styczna grawitacji @@ -6155,7 +6064,7 @@ TController::determine_consist_state() { absaccs += d->MoverParameters->TotalMass * d->MoverParameters->AccS * ( d->DirectionGet() == iDirection ? 1 : -1 ); d = d->Next(); // kolejny pojazd, podłączony od tyłu (licząc od czoła) } - absaccs *= ( iDirection >= 0 ? 1 : -1 ); + absaccs *= iDirection >= 0 ? 1 : -1; absaccs /= fMass; } AbsAccS = absaccs; @@ -6164,37 +6073,33 @@ TController::determine_consist_state() { WriteLog( "Vel=" + to_string( DirectionalVel() ) + ", AbsAccS=" + to_string( AbsAccS ) + ", AccGrav=" + to_string( fAccGravity ) ); #endif - if( ( !Ready ) // v367: jeśli wg powyższych warunków skład nie jest odhamowany - && ( fAccGravity < -0.05 ) // jeśli ma pod górę na tyle, by się stoczyć - && ( fReady < 0.8 ) ) { // delikatniejszy warunek, obejmuje wszystkie wagony + if( !Ready // v367: jeśli wg powyższych warunków skład nie jest odhamowany + && fAccGravity < -0.05 // jeśli ma pod górę na tyle, by się stoczyć + && fReady < 0.8 ) { // delikatniejszy warunek, obejmuje wszystkie wagony Ready = true; //żeby uznać za odhamowany } // second pass, for diesel engines verify the (live) engines are fully started // TODO: cache presence of diesel engines in the consist, to skip this test if there isn't any p = pVehicles[ end::front ]; // pojazd na czole składu - while( ( true == Ready ) - && ( p != nullptr ) ) { + while( true == Ready + && p != nullptr ) { auto const *vehicle { p->MoverParameters }; if( has_diesel_engine() ) { - Ready = ( - ( vehicle->Vel > EU07_AI_MOVEMENT ) // already moving - || ( false == vehicle->Mains ) // deadweight vehicle - || ( vehicle->enrot > 0.8 * ( - vehicle->EngineType == TEngineType::DieselEngine ? - vehicle->dizel_nmin : - vehicle->DElist[ 0 ].RPM / 60.0 ) ) ); + Ready = vehicle->Vel > EU07_AI_MOVEMENT // already moving + || false == vehicle->Mains // deadweight vehicle + || vehicle->enrot > 0.8 * (vehicle->EngineType == TEngineType::DieselEngine ? vehicle->dizel_nmin : vehicle->DElist[0].RPM / 60.0); } p = p->Next(); // pojazd podłączony z tyłu (patrząc od czoła) } // test consist state for external events and/or weird things human user could've done iEngineActive &= - ( false == IsAnyConverterOverloadRelayOpen ) - && ( false == IsAnyLineBreakerOpen ) - && ( ( false == IsAnyConverterPresent ) || ( true == IsAnyConverterEnabled ) ) - && ( ( false == IsAnyCompressorPresent ) || ( true == IsAnyCompressorEnabled ) ); + false == IsAnyConverterOverloadRelayOpen + && false == IsAnyLineBreakerOpen + && ( false == IsAnyConverterPresent || true == IsAnyConverterEnabled ) + && ( false == IsAnyCompressorPresent || true == IsAnyCompressorEnabled ); } void @@ -6223,8 +6128,8 @@ TController::control_pantographs() { if( mvPantographUnit->EnginePowerSource.SourceType != TPowerSource::CurrentCollector ) { return; } - if( ( false == mvPantographUnit->PantAutoValve ) - && ( mvOccupied->ScndPipePress > 4.3 ) ) { + if( false == mvPantographUnit->PantAutoValve + && mvOccupied->ScndPipePress > 4.3 ) { // gdy główna sprężarka bezpiecznie nabije ciśnienie to można przestawić kurek na zasilanie pantografów z głównej pneumatyki cue_action( driver_hint::pantographairsourcesetmain ); } @@ -6241,18 +6146,18 @@ TController::control_pantographs() { // raise/lower pantographs as needed auto const useregularpantographlayout { - ( pVehicle->Next( coupling::control ) == nullptr ) // standalone - || ( is_emu() ) // special case - || ( mvControlling->TrainType == dt_ET41 ) }; // special case + pVehicle->Next(coupling::control) == nullptr // standalone + || is_emu() // special case + || mvControlling->TrainType == dt_ET41 }; // special case if( mvOccupied->Vel > EU07_AI_NOMOVEMENT ) { - if( ( fOverhead2 >= 0.0 ) || iOverheadZero ) { + if( fOverhead2 >= 0.0 || iOverheadZero ) { // jeśli jazda bezprądowa albo z opuszczonym pantografem cue_action( driver_hint::mastercontrollersetzerospeed ); } - if( ( fOverhead2 > 0.0 ) || iOverheadDown ) { + if( fOverhead2 > 0.0 || iOverheadDown ) { // jazda z opuszczonymi pantografami if( mvPantographUnit->Pantographs[ end::front ].is_active ) { cue_action( driver_hint::frontpantographvalveoff ); @@ -6267,21 +6172,21 @@ TController::control_pantographs() { if( fActionTime > 0.0 ) { if( mvOccupied->AIHintPantstate == 0 ) { // jazda na tylnym - if( ( iDirection >= 0 ) && ( useregularpantographlayout ) ) { + if( iDirection >= 0 && useregularpantographlayout ) { // jak jedzie w kierunku sprzęgu 0 - if( ( mvPantographUnit->PantRearVolt == 0.0 ) + if( mvPantographUnit->PantRearVolt == 0.0 // filter out cases with single _other_ working pantograph so we don't try to raise something we can't - && ( ( mvPantographUnit->PantographVoltage == 0.0 ) - || ( mvPantographUnit->EnginePowerSource.CollectorParameters.CollectorsNo > 1 ) ) ) { + && ( mvPantographUnit->PantographVoltage == 0.0 + || mvPantographUnit->EnginePowerSource.CollectorParameters.CollectorsNo > 1 ) ) { cue_action( driver_hint::rearpantographvalveon ); } } else { // jak jedzie w kierunku sprzęgu 0 - if( ( mvPantographUnit->PantFrontVolt == 0.0 ) + if( mvPantographUnit->PantFrontVolt == 0.0 // filter out cases with single _other_ working pantograph so we don't try to raise something we can't - && ( ( mvPantographUnit->PantographVoltage == 0.0 ) - || ( mvPantographUnit->EnginePowerSource.CollectorParameters.CollectorsNo > 1 ) ) ) { + && ( mvPantographUnit->PantographVoltage == 0.0 + || mvPantographUnit->EnginePowerSource.CollectorParameters.CollectorsNo > 1 ) ) { cue_action( driver_hint::frontpantographvalveon ); } } @@ -6289,16 +6194,16 @@ TController::control_pantographs() { if( mvOccupied->Vel > 5 ) { // opuszczenie przedniego po rozpędzeniu się o ile jest więcej niż jeden if( mvPantographUnit->EnginePowerSource.CollectorParameters.CollectorsNo > 1 ) { - if( ( iDirection >= 0 ) && ( useregularpantographlayout ) ) // jak jedzie w kierunku sprzęgu 0 + if( iDirection >= 0 && useregularpantographlayout ) // jak jedzie w kierunku sprzęgu 0 { // poczekać na podniesienie tylnego - if( ( mvPantographUnit->PantFrontVolt != 0.0 ) - && ( mvPantographUnit->PantRearVolt != 0.0 ) ) { // czy jest napięcie zasilające na tylnym? + if( mvPantographUnit->PantFrontVolt != 0.0 + && mvPantographUnit->PantRearVolt != 0.0 ) { // czy jest napięcie zasilające na tylnym? cue_action( driver_hint::frontpantographvalveoff ); // opuszcza od sprzęgu 0 } } else { // poczekać na podniesienie przedniego - if( ( mvPantographUnit->PantRearVolt != 0.0 ) - && ( mvPantographUnit->PantFrontVolt != 0.0 ) ) { // czy jest napięcie zasilające na przednim? + if( mvPantographUnit->PantRearVolt != 0.0 + && mvPantographUnit->PantFrontVolt != 0.0 ) { // czy jest napięcie zasilające na przednim? cue_action( driver_hint::rearpantographvalveoff ); // opuszcza od sprzęgu 1 } } @@ -6311,26 +6216,22 @@ TController::control_pantographs() { if( mvOccupied->Vel > 5 ) { auto const pantographsetup{ mvOccupied->AIHintPantstate }; cue_action( - ( pantographsetup & ( 1 << 0 ) ? - driver_hint::frontpantographvalveon : - driver_hint::frontpantographvalveoff ) ); + pantographsetup & 1 << 0 ? driver_hint::frontpantographvalveon : driver_hint::frontpantographvalveoff ); cue_action( - ( pantographsetup & ( 1 << 1 ) ? - driver_hint::rearpantographvalveon : - driver_hint::rearpantographvalveoff ) ); + pantographsetup & 1 << 1 ? driver_hint::rearpantographvalveon : driver_hint::rearpantographvalveoff ); } } } } } else { - if( ( mvOccupied->AIHintPantUpIfIdle ) - && ( IdleTime > 45.0 ) + if( mvOccupied->AIHintPantUpIfIdle + && IdleTime > 45.0 // NOTE: abs(stoptime) covers either at least 15 sec remaining for a scheduled stop, or 15+ secs spent at a basic stop - && ( std::abs( fStopTime ) > 15.0 ) ) { + && std::abs(fStopTime) > 15.0 ) { // spending a longer at a stop, raise also front pantograph if( mvPantographUnit->EnginePowerSource.CollectorParameters.CollectorsNo > 1 ) { - if( ( iDirection >= 0 ) && ( useregularpantographlayout ) ) { + if( iDirection >= 0 && useregularpantographlayout ) { // jak jedzie w kierunku sprzęgu 0 if( mvPantographUnit->PantFrontVolt == 0.0 ) { cue_action( driver_hint::frontpantographvalveon, 5 ); // discard the hint if speed exceeds 5 km/h @@ -6366,10 +6267,10 @@ TController::control_horns( double const Timedelta ) { iDrivigFlags |= moveStartHorn; // i trąbić przed następnym ruszeniem } - if( ( true == TestFlag( iDrivigFlags, moveStartHornNow ) ) - && ( true == Ready ) - && ( true == iEngineActive ) - && ( mvControlling->MainCtrlPowerPos() > 0 ) ) { + if( true == TestFlag(iDrivigFlags, moveStartHornNow) + && true == Ready + && true == iEngineActive + && mvControlling->MainCtrlPowerPos() > 0 ) { // uruchomienie trąbienia przed ruszeniem fWarningDuration = 0.3; // czas trąbienia cue_action( driver_hint::hornon, pVehicle->iHornWarning ); // wysokość tonu (2=wysoki) @@ -6382,8 +6283,8 @@ void TController::control_security_system( double const Timedelta ) { if( mvOccupied->SecuritySystem.is_cabsignal_blinking() && mvOccupied->SecuritySystem.has_separate_acknowledge()) { // jak zadziałało SHP - if( ( false == is_emu() ) - && ( mvOccupied->DirActive == 0 ) ) { + if( false == is_emu() + && mvOccupied->DirActive == 0 ) { cue_action( driver_hint::directionforward ); } cue_action( driver_hint::shpsystemreset ); // to skasuj @@ -6396,8 +6297,8 @@ TController::control_security_system( double const Timedelta ) { if( mvOccupied->SecuritySystem.is_blinking() ) { // jak zadziałało CA/SHP - if( ( false == is_emu() ) - && ( mvOccupied->DirActive == 0 ) ) { + if( false == is_emu() + && mvOccupied->DirActive == 0 ) { cue_action( driver_hint::directionforward ); } cue_action( driver_hint::securitysystemreset ); // to skasuj @@ -6408,9 +6309,9 @@ TController::control_security_system( double const Timedelta ) { } } // basic emergency stop handling, while at it - if( ( true == mvOccupied->RadioStopFlag ) // radio-stop - && ( mvOccupied->Vel < 0.01 ) // and actual stop - && ( true == mvOccupied->Radio ) ) { // and we didn't touch the radio yet + if( true == mvOccupied->RadioStopFlag // radio-stop + && mvOccupied->Vel < 0.01 // and actual stop + && true == mvOccupied->Radio ) { // and we didn't touch the radio yet // turning off the radio should reset the flag, during security system check if( m_radiocontroltime > 5.0 ) { // arbitrary delay between stop and disabling the radio cue_action( driver_hint::radiooff ); @@ -6419,9 +6320,9 @@ TController::control_security_system( double const Timedelta ) { m_radiocontroltime += Timedelta; } } - if( ( iEngineActive ) - && ( false == mvOccupied->Radio ) - && ( false == mvOccupied->RadioStopFlag ) ) { + if( iEngineActive + && false == mvOccupied->Radio + && false == mvOccupied->RadioStopFlag ) { // otherwise if it's safe to do so, turn the radio back on // arbitrary 5 sec delay before switching radio back on m_radiocontroltime = std::min( m_radiocontroltime, 5.0 ); @@ -6440,9 +6341,9 @@ TController::control_handles() { switch( mvControlling->EngineType ) { case TEngineType::ElectricSeriesMotor: { // styczniki liniowe rozłączone yBARC - if( ( false == mvControlling->StLinFlag ) - && ( false == mvControlling->DelayCtrlFlag ) - && ( mvControlling->MainCtrlPowerPos() > 1 ) ) { + if( false == mvControlling->StLinFlag + && false == mvControlling->DelayCtrlFlag + && mvControlling->MainCtrlPowerPos() > 1 ) { cue_action( driver_hint::mastercontrollersetzerospeed ); } // if the power station is heavily burdened drop down to series mode to reduce the load @@ -6450,28 +6351,28 @@ TController::control_handles() { std::lerp( mvControlling->EnginePowerSource.CollectorParameters.MinV, mvControlling->EnginePowerSource.CollectorParameters.MaxV, - ( IsHeavyCargoTrain ? 0.35 : 0.40 ) ) }; + IsHeavyCargoTrain ? 0.35 : 0.40 ) }; if( fVoltage <= useseriesmodevoltage ) { cue_action( driver_hint::mastercontrollersetseriesmode ); } // sanity check - if( ( false == Ready ) - && ( mvControlling->MainCtrlPowerPos() > 1 ) ) { + if( false == Ready + && mvControlling->MainCtrlPowerPos() > 1 ) { cue_action( driver_hint::mastercontrollersetzerospeed ); } break; } case TEngineType::DieselElectric: { // styczniki liniowe rozłączone yBARC - if( ( false == mvControlling->StLinFlag ) - && ( false == mvControlling->DelayCtrlFlag ) - && ( mvControlling->MainCtrlPowerPos() > 1 ) ) { + if( false == mvControlling->StLinFlag + && false == mvControlling->DelayCtrlFlag + && mvControlling->MainCtrlPowerPos() > 1 ) { cue_action( driver_hint::mastercontrollersetzerospeed ); } // sanity check - if( ( false == Ready ) - && ( mvControlling->MainCtrlPowerPos() > 1 ) ) { + if( false == Ready + && mvControlling->MainCtrlPowerPos() > 1 ) { cue_action( driver_hint::mastercontrollersetzerospeed ); } break; @@ -6535,10 +6436,7 @@ TController::control_compartment_lights() { lightlevel < 0.40 : // turn off if lighting level goes above 0.4 lightlevel < 0.35 ) }; // turn on if lighting level goes below 0.35 if( desiredlightstate != currentlightstate ) { - cue_action( ( - desiredlightstate ? - driver_hint::consistlightson : - driver_hint::consistlightsoff ) ); + cue_action( desiredlightstate ? driver_hint::consistlightson : driver_hint::consistlightsoff ); } } @@ -6558,9 +6456,7 @@ TController::control_doors() { if( false == AIControllFlag ) { // for diesel engines react when engine is put past idle revolutions // for others straightforward master controller check - if( ( mvControlling->EngineType == TEngineType::DieselEngine ? - mvControlling->RList[ mvControlling->MainCtrlPos ].Mn > 0 : - mvControlling->MainCtrlPowerPos() > 0 ) ) { + if( mvControlling->EngineType == TEngineType::DieselEngine ? mvControlling->RList[mvControlling->MainCtrlPos].Mn > 0 : mvControlling->MainCtrlPowerPos() > 0 ) { Doors( false ); return; } @@ -6581,8 +6477,8 @@ TController::UpdateCommand() { void TController::UpdateNextStop() { - if( ( fLastStopExpDist > 0.0 ) - && ( mvOccupied->DistCounter > fLastStopExpDist ) ) { + if( fLastStopExpDist > 0.0 + && mvOccupied->DistCounter > fLastStopExpDist ) { // zaktualizować wyświetlanie rozkładu TrainParams.StationStart = TrainParams.StationIndex; fLastStopExpDist = -1.0; // usunąć licznik @@ -6603,17 +6499,17 @@ TController::determine_braking_distance() { // korekta dla ciężkich, bo przeżynają - da to coś? fBrakeDist *= 2.0; } - if( ( -fAccThreshold > 0.05 ) - && ( mvOccupied->CategoryFlag == 1 ) ) { + if( -fAccThreshold > 0.05 + && mvOccupied->CategoryFlag == 1 ) { fBrakeDist = velceil * velceil / 25.92 / -fAccThreshold; } if( mvOccupied->BrakeDelayFlag == bdelay_G ) { // dla nastawienia G koniecznie należy wydłużyć drogę na czas reakcji fBrakeDist += 2 * velceil; } - if( ( mvOccupied->Vel > 15.0 ) - && ( mvControlling->EngineType == TEngineType::ElectricInductionMotor ) - && ( is_emu() ) ) { + if( mvOccupied->Vel > 15.0 + && mvControlling->EngineType == TEngineType::ElectricInductionMotor + && is_emu() ) { // HACK: make the induction motor powered EMUs start braking slightly earlier fBrakeDist += 10.0; } @@ -6643,11 +6539,9 @@ TController::scan_obstacles( double const Range ) { int routescandirection; // for moving vehicle determine heading from velocity; for standing fall back on the set direction - if( ( std::abs( frontvehicle->MoverParameters->V ) > 0.5 ? // ignore potential micro-stutters in oposite direction during "almost stop" - frontvehicle->MoverParameters->V > 0.0 : - ( pVehicle->DirectionGet() == frontvehicle->DirectionGet() ? - iDirection >= 0 : - iDirection <= 0 ) ) ) { + if( std::abs(frontvehicle->MoverParameters->V) > 0.5 ? // ignore potential micro-stutters in oposite direction during "almost stop" + frontvehicle->MoverParameters->V > 0.0 : + pVehicle->DirectionGet() == frontvehicle->DirectionGet() ? iDirection >= 0 : iDirection <= 0 ) { // towards coupler 0 routescandirection = end::front; } @@ -6662,7 +6556,7 @@ TController::scan_obstacles( double const Range ) { } */ Obstacle = neighbour_data(); - auto const obstaclescanrange { std::max( ( is_car() ? 250.0 : 1000.0 ), Range ) }; + auto const obstaclescanrange { std::max( is_car() ? 250.0 : 1000.0, Range ) }; auto const lookup { frontvehicle->find_vehicle( routescandirection, obstaclescanrange ) }; if( std::get( lookup ) == true ) { @@ -6720,8 +6614,8 @@ TController::determine_proximity_ranges() { fMaxProximityDist += 5.0; } // take into account weather conditions - if( ( Global.FrictionWeatherFactor < 1.f ) - && ( iVehicles > 1 ) ) { + if (Global.FrictionWeatherFactor < 1.f + && iVehicles > 1 ) { fMinProximityDist += 5.0; fMaxProximityDist += 5.0; } @@ -6757,8 +6651,8 @@ TController::determine_proximity_ranges() { */ } - if( ( Global.FrictionWeatherFactor < 1.f ) - && ( iVehicles > 1 ) ) { + if (Global.FrictionWeatherFactor < 1.f + && iVehicles > 1 ) { // take into account weather conditions fMinProximityDist += 5.0; fMaxProximityDist += 5.0; @@ -6819,12 +6713,12 @@ TController::check_departure() { if(( OrderCurrentGet() & ( Shunt | Loose_shunt | Obey_train | Bank | Connect ) ) == 0 ) { return; } // odjechać sam może tylko jeśli jest w trybie jazdy // automatyczne ruszanie po odstaniu albo spod SBL - if( ( VelSignal == 0.0 ) - && ( WaitingTime > 0.0 ) - && ( mvOccupied->RunningTrack.Velmax != 0.0 ) ) { + if( VelSignal == 0.0 + && WaitingTime > 0.0 + && mvOccupied->RunningTrack.Velmax != 0.0 ) { // jeśli stoi, a upłynął czas oczekiwania i tor ma niezerową prędkość - if( ( OrderCurrentGet() & ( Shunt | Loose_shunt | Obey_train | Bank ) ) - && ( iDrivigFlags & moveStopHere ) ) { + if( OrderCurrentGet() & (Shunt | Loose_shunt | Obey_train | Bank) + && iDrivigFlags & moveStopHere ) { // zakaz ruszania z miejsca bez otrzymania wolnej drogi WaitingTime = -WaitingExpireTime; } @@ -6836,8 +6730,8 @@ TController::check_departure() { fWarningDuration = 1.5; // a zatrąbić trochę } else { // samochód ma stać, aż dostanie odjazd, chyba że stoi przez kolizję - if( ( eStopReason == stopBlock ) - && ( Obstacle.distance > fDriverDist ) ) { + if( eStopReason == stopBlock + && Obstacle.distance > fDriverDist ) { PrepareDirection(); // zmieni ustawiony kierunek SetVelocity( -1, -1 ); // jak się nastał, to niech jedzie WaitingTime = 0.0; @@ -6845,8 +6739,8 @@ TController::check_departure() { } } } - else if( ( VelSignal == 0.0 ) && ( VelNext > 0.0 ) && ( mvOccupied->Vel < 1.0 ) ) { - if( ( iCoupler > 0 ) || ( ( iDrivigFlags & moveStopHere ) == 0 ) ) { + else if( VelSignal == 0.0 && VelNext > 0.0 && mvOccupied->Vel < 1.0 ) { + if( iCoupler > 0 || (iDrivigFlags & moveStopHere) == 0 ) { // Ra: tu jest coś nie tak, bo bez tego warunku ruszało w manewrowym !!!! SetVelocity( VelNext, VelNext, stopSem ); // omijanie SBL } @@ -6866,7 +6760,7 @@ TController::check_load_exchange() { auto *vehicle { pVehicles[ end::front ] }; while( vehicle != nullptr ) { auto const vehicleexchangetime { vehicle->LoadExchangeTime() }; - DoesAnyDoorNeedOpening |= ( ( vehicleexchangetime > 0 ) && ( vehicle->LoadExchangeSpeed() == 0 ) ); + DoesAnyDoorNeedOpening |= vehicleexchangetime > 0 && vehicle->LoadExchangeSpeed() == 0; ExchangeTime = std::max( ExchangeTime, vehicleexchangetime ); vehicle = vehicle->Next(); } @@ -6874,16 +6768,16 @@ TController::check_load_exchange() { if( pVehicle->DirectionGet() != m_lastexchangedirection ) { // generally means the ai driver moved to the opposite end of the consist // TODO: investigate whether user playing with the reverser can mess this up - auto const left { ( m_lastexchangedirection > 0 ) ? 1 : 2 }; + auto const left { m_lastexchangedirection > 0 ? 1 : 2 }; auto const right { 3 - left }; m_lastexchangeplatforms = ( ( m_lastexchangeplatforms & left ) != 0 ? right : 0 ) + ( ( m_lastexchangeplatforms & right ) != 0 ? left : 0 ); m_lastexchangedirection = pVehicle->DirectionGet(); } - if( ( false == TrainParams.IsMaintenance() ) - && ( ( false == TestFlag( iDrivigFlags, moveDoorOpened ) ) - || ( true == DoesAnyDoorNeedOpening ) ) ) { + if( false == TrainParams.IsMaintenance() + && ( false == TestFlag(iDrivigFlags, moveDoorOpened) + || true == DoesAnyDoorNeedOpening ) ) { iDrivigFlags |= moveDoorOpened; // nie wykonywać drugi raz remove_hint( driver_hint::doorleftopen ); remove_hint( driver_hint::doorrightopen ); @@ -6904,8 +6798,8 @@ TController::UpdateChangeDirection() { } // Change_direction (tylko dla AI) } // shared part of the routine, implement if direction matches what was requested - if( ( mvOccupied->Vel < EU07_AI_NOMOVEMENT ) - && ( iDirection == iDirectionOrder ) ) { + if( mvOccupied->Vel < EU07_AI_NOMOVEMENT + && iDirection == iDirectionOrder ) { // NOTE: we can't be sure there's a visible signal within scan range after direction change // which would normally overwrite the old limit, so we reset signal value manually here VelSignal = -1; @@ -6930,10 +6824,10 @@ TController::UpdateLooseShunt() { // TODO: run also for potential settings-based virtual assistant auto const autobrakerelease { ( true == AIControllFlag ) }; - if( ( autobrakerelease ) - && ( Obstacle.distance < 1.0 ) - && ( AccDesired > 0.1 ) - && ( mvOccupied->Vel < 1.0 ) ) { + if( autobrakerelease + && Obstacle.distance < 1.0 + && AccDesired > 0.1 + && mvOccupied->Vel < 1.0 ) { auto *vehicle { Obstacle.vehicle }; auto const direction { ( vehicle->Prev() != nullptr ? end::front : end::rear ) }; @@ -6944,7 +6838,7 @@ TController::UpdateLooseShunt() { } // NOTE: we trust the consist to be arranged in a valid chain // TBD, TODO: traversal direction validation? - vehicle = ( direction == end::front ? vehicle->Prev() : vehicle->Next() ); + vehicle = direction == end::front ? vehicle->Prev() : vehicle->Next(); } } } @@ -6954,8 +6848,8 @@ TController::UpdateObeyTrain() { UpdateNextStop(); - if( ( ( iDrivigFlags & moveGuardSignal ) != 0 ) - && ( VelDesired > 0.0 ) ) { + if( (iDrivigFlags & moveGuardSignal) != 0 + && VelDesired > 0.0 ) { // komunikat od kierownika tu, bo musi być wolna droga i odczekany czas stania iDrivigFlags &= ~moveGuardSignal; // tylko raz nadać iDrivigFlags &= ~moveGuardOpenDoor; // nie trzeba już otwierać drzwi @@ -7014,7 +6908,7 @@ TController::UpdateConnect() { } // próba podczepienia if( AIControllFlag || Global.AITrainman ) { - if( ( coupleriscompatible ) && ( neighbour.distance < 2 ) ) { + if( coupleriscompatible && neighbour.distance < 2 ) { vehicleparameters->Attach( couplingend, neighbour.vehicle_end, neighbour.vehicle->MoverParameters, @@ -7060,7 +6954,7 @@ TController::GuardOpenDoor() { vehicle = vehicle->Next(); } if (vehicle != nullptr && vehicle->MoverParameters->Doors.range > 0) { - auto const lewe = (vehicle->DirectionGet() > 0) ? 1 : 2; + auto const lewe = vehicle->DirectionGet() > 0 ? 1 : 2; auto const prawe = 3 - lewe; if (m_lastexchangeplatforms & lewe) { vehicle->MoverParameters->OperateDoors(side::left, true, range_t::local); @@ -7116,7 +7010,7 @@ TController::UpdateDisconnect() { cue_action( driver_hint::mastercontrollersetreverserunlock ); cue_action( driver_hint::directionother ); } - if( ( ( iDrivigFlags & movePress ) != 0 ) && ( iDirection == iDirectionOrder ) ) { + if( (iDrivigFlags & movePress) != 0 && iDirection == iDirectionOrder ) { if( iVehicleCount >= 0 ) { // zmieni się po odczepieniu WriteLog( "Uncoupling [" + mvOccupied->Name + "]: actuating and compressing buffers..." ); @@ -7222,10 +7116,10 @@ TController::UpdateDisconnect() { void TController::handle_engine() { // HACK: activate route scanning if an idling vehicle is activated by a human user - if( ( OrderCurrentGet() == Wait_for_orders ) - && ( false == iEngineActive ) + if( OrderCurrentGet() == Wait_for_orders + && false == iEngineActive // && ( false == AIControllFlag ) - && ( true == mvOccupied->Power24vIsAvailable ) ) { + && true == mvOccupied->Power24vIsAvailable ) { OrderNext( Prepare_engine ); } // basic engine preparation @@ -7235,8 +7129,8 @@ TController::handle_engine() { } } // engine state can potentially deteriorate in one of usual driving modes - if( ( OrderCurrentGet() & ( Change_direction | Connect | Disconnect | Shunt | Loose_shunt | Obey_train | Bank ) ) - && ( false == iEngineActive ) ) { + if( OrderCurrentGet() & (Change_direction | Connect | Disconnect | Shunt | Loose_shunt | Obey_train | Bank) + && false == iEngineActive ) { // jeśli coś ma robić to niech odpala do skutku PrepareEngine(); } @@ -7304,8 +7198,8 @@ TController::pick_optimal_speed( double const Range ) { AccDesired = AccPreferred; // AccPreferred wynika z osobowości mechanika // nie przekraczać rozkladowej - if( ( ( OrderCurrentGet() & Obey_train ) != 0 ) - && ( TrainParams.TTVmax > 0.0 ) ) { + if( (OrderCurrentGet() & Obey_train) != 0 + && TrainParams.TTVmax > 0.0 ) { VelDesired = min_speed( VelDesired, @@ -7330,7 +7224,7 @@ TController::pick_optimal_speed( double const Range ) { if( ( OrderCurrentGet() & Disconnect ) != 0 ) { if( iVehicleCount >= 0 ) { // 3rd stage: compress buffers and uncouple - if( ( ( iDrivigFlags & movePress ) != 0 ) && ( iDirection == iDirectionOrder ) ) { + if( (iDrivigFlags & movePress) != 0 && iDirection == iDirectionOrder ) { SetVelocity( 2, 0 ); // jazda w ustawionym kierunku z prędkością 2 } // 1st stage: bring it to stop @@ -7394,8 +7288,8 @@ TController::pick_optimal_speed( double const Range ) { AccDesired = std::min( AccDesired, AccPreferred ); AccDesired = std::clamp( AccDesired, - ( is_car() ? -2.0 : -0.9 ), - ( is_car() ? 2.0 : 0.9 ) ); + is_car() ? -2.0 : -0.9, + is_car() ? 2.0 : 0.9 ); // if the route ahead is blocked we might need to head the other way check_route_behind( 1000 ); // NOTE: legacy scan range value @@ -7423,7 +7317,7 @@ TController::adjust_desired_speed_for_obstacles() { Obstacle.distance ); if( Obstacle.distance <= ( - ( mvOccupied->CategoryFlag & 2 ) ? + mvOccupied->CategoryFlag & 2 ? 100.0 : // cars 250.0 ) ) { // others // regardless of driving mode at close distance take precaution measures: @@ -7433,20 +7327,19 @@ TController::adjust_desired_speed_for_obstacles() { VelDesired, std::max( k, - ( mvOccupied->CategoryFlag & 2 ) ? + mvOccupied->CategoryFlag & 2 ? 40.0 : // cars 20.0 ) ); // others if( vel > VelDesired + fVelPlus ) { // if going too fast force some prompt braking AccPreferred = std::min( - ( ( mvOccupied->CategoryFlag & 2 ) ? - -0.65 : // cars - -0.30 ), // others + mvOccupied->CategoryFlag & 2 ? -0.65 : // cars + -0.30, // others AccPreferred ); } } - double const distance = Obstacle.distance - fMaxProximityDist - ( fBrakeDist * 1.15 ); // odległość bezpieczna zależy od prędkości + double const distance = Obstacle.distance - fMaxProximityDist - fBrakeDist * 1.15; // odległość bezpieczna zależy od prędkości if( distance < 0.0 ) { // jeśli odległość jest zbyt mała if( k < 10.0 ) // k - prędkość tego z przodu @@ -7455,9 +7348,7 @@ TController::adjust_desired_speed_for_obstacles() { VelDesired = std::floor( min_speed( VelDesired, - ( Obstacle.distance > 100 ? - k + 20.0: - std::min( 8.0, k + 4.0 ) ) ) ); + Obstacle.distance > 100 ? k + 20.0 : std::min(8.0, k + 4.0) ) ); if( ( OrderCurrentGet() & ( Connect | Loose_shunt ) ) != 0 ) { // jeśli spinanie, to jechać dalej @@ -7471,8 +7362,8 @@ TController::adjust_desired_speed_for_obstacles() { VelDesired = 0.0; } - if( ( mvOccupied->CategoryFlag & 1 ) - && ( OrderCurrentGet() & Obey_train ) ) { + if( mvOccupied->CategoryFlag & 1 + && OrderCurrentGet() & Obey_train ) { // trains which move normally should try to stop at safe margin ActualProximityDist -= fDriverDist; } @@ -7481,14 +7372,14 @@ TController::adjust_desired_speed_for_obstacles() { else { // jeśli oba jadą, to przyhamuj lekko i ogranicz prędkość if( Obstacle.distance < ( - ( mvOccupied->CategoryFlag & 2 ) ? + mvOccupied->CategoryFlag & 2 ? fMaxProximityDist + 0.5 * vel : // cars 2.0 * fMaxProximityDist + 2.0 * vel ) ) { //others // jak tamten jedzie wolniej a jest w drodze hamowania AccPreferred = std::min( -0.9, AccPreferred ); VelNext = min_speed( std::round( k ) - 5.0, VelDesired ); if( Obstacle.distance <= ( - ( mvOccupied->CategoryFlag & 2 ) ? + mvOccupied->CategoryFlag & 2 ? fMaxProximityDist : // cars 2.0 * fMaxProximityDist ) ) { //others // try to force speed change if obstacle is really close @@ -7496,10 +7387,8 @@ TController::adjust_desired_speed_for_obstacles() { } } } - ReactionTime = ( - mvOccupied->Vel > EU07_AI_NOMOVEMENT ? - 0.1 : // orientuj się, bo jest goraco - 2.0 ); // we're already standing still, so take it easy + ReactionTime = mvOccupied->Vel > EU07_AI_NOMOVEMENT ? 0.1 : // orientuj się, bo jest goraco + 2.0; // we're already standing still, so take it easy } else { if( OrderCurrentGet() & Connect ) { @@ -7507,9 +7396,7 @@ TController::adjust_desired_speed_for_obstacles() { VelDesired = min_speed( VelDesired, - ( Obstacle.distance > 100 ? - 20.0 : - 4.0 ) ); + Obstacle.distance > 100 ? 20.0 : 4.0 ); } } } @@ -7545,8 +7432,8 @@ TController::adjust_desired_speed_for_limits() { // recalculate potential load exchange duration check_load_exchange(); - if( ( ExchangeTime > 0 ) - || ( mvOccupied->Vel > 2.0 ) ) { // HACK: force timer reset if the load exchange is cancelled due to departure + if( ExchangeTime > 0 + || mvOccupied->Vel > 2.0 ) { // HACK: force timer reset if the load exchange is cancelled due to departure WaitingSet( ExchangeTime ); } if( fStopTime < 0 ) { @@ -7557,9 +7444,9 @@ TController::adjust_desired_speed_for_limits() { if( ( OrderCurrentGet() & ( Shunt | Loose_shunt | Obey_train | Bank ) ) != 0 ) { // w Connect nie, bo moveStopHere odnosi się do stanu po połączeniu - if( ( ( iDrivigFlags & moveStopHere ) != 0 ) - && ( mvOccupied->Vel < 0.01 ) - && ( VelSignalNext == 0.0 ) ) { + if( (iDrivigFlags & moveStopHere) != 0 + && mvOccupied->Vel < 0.01 + && VelSignalNext == 0.0 ) { // jeśli ma czekać na wolną drogę, stoi a wyjazdu nie ma, to ma stać VelDesired = 0.0; return; // speed limit can't get any lower @@ -7585,21 +7472,18 @@ TController::adjust_desired_speed_for_target_speed( double const Range ) { // gdy jedzie wolniej niż potrzeba, albo nie ma przeszkód na drodze // normalna jazda - AccDesired = ( - VelDesired != 0.0 ? - AccPreferred : - -0.01 ); + AccDesired = VelDesired != 0.0 ? AccPreferred : -0.01; auto const vel { DirectionalVel() }; - if( ( VelNext >= 0.0 ) - && ( ActualProximityDist <= Range ) - && ( vel >= VelNext ) ) { + if( VelNext >= 0.0 + && ActualProximityDist <= Range + && vel >= VelNext ) { // gdy zbliża się i jest za szybki do nowej prędkości, albo stoi na zatrzymaniu if (vel > EU07_AI_NOMOVEMENT) { // jeśli jedzie - if( ( vel < VelNext ) - && ( ActualProximityDist > fMaxProximityDist * ( 1.0 + 0.1 * vel ) ) ) { + if( vel < VelNext + && ActualProximityDist > fMaxProximityDist * (1.0 + 0.1 * vel) ) { // jeśli jedzie wolniej niż można i jest wystarczająco daleko, to można przyspieszyć if( AccPreferred > 0.0 ) { // jeśli nie ma zawalidrogi dojedz do semafora/przeszkody @@ -7617,8 +7501,8 @@ TController::adjust_desired_speed_for_target_speed( double const Range ) { if( VelNext == 0.0 ) { if( mvOccupied->CategoryFlag & 1 ) { // trains - if( ( OrderCurrentGet() & ( Shunt | Connect ) ) - && ( Obstacle.distance < 50 ) ) { + if( OrderCurrentGet() & (Shunt | Connect) + && Obstacle.distance < 50 ) { // crude detection of edge case, if approaching another vehicle coast slowly until min distance // this should allow to bunch up trainsets more on sidings VelDesired = min_speed( 5.0, VelDesired ); @@ -7639,16 +7523,16 @@ TController::adjust_desired_speed_for_target_speed( double const Range ) { else { // outside of max safe range AccDesired = AccPreferred; - if( vel > min_speed( (ActualProximityDist > 10.0 ? 10.0 : 5.0 ), VelDesired ) ) { + if( vel > min_speed( ActualProximityDist > 10.0 ? 10.0 : 5.0, VelDesired ) ) { // allow to coast at reasonably low speed auto const brakingdistance { fBrakeDist * braking_distance_multiplier( VelNext ) }; auto const slowdowndistance { ( mvOccupied->CategoryFlag == 2 ? // cars can stop on a dime, for bigger vehicles we enforce some minimal braking distance brakingdistance : std::max( - ( ( OrderCurrentGet() & Connect ) == 0 ? 100.0 : 25.0 ), + (OrderCurrentGet() & Connect) == 0 ? 100.0 : 25.0, brakingdistance ) ) }; - if( ( brakingdistance + std::max( slowdowndistance, fMaxProximityDist ) ) >= ( ActualProximityDist - fMaxProximityDist ) ) { + if( brakingdistance + std::max(slowdowndistance, fMaxProximityDist) >= ActualProximityDist - fMaxProximityDist ) { // don't slow down prematurely; as long as we have room to come to a full stop at a safe distance, we're good // ensure some minimal coasting speed, otherwise a vehicle entering this zone at very low speed will be crawling forever auto const brakingpointoffset = VelNext * braking_distance_multiplier( VelNext ); @@ -7694,7 +7578,7 @@ TController::adjust_desired_speed_for_target_speed( double const Range ) { else { // jeśli daleko jechać nie można if( ActualProximityDist > ( - ( mvOccupied->CategoryFlag & 2 ) ? + mvOccupied->CategoryFlag & 2 ? fMinProximityDist : // cars fMaxProximityDist ) ) { // trains and others // ale ma kawałek do sygnalizatora @@ -7731,7 +7615,7 @@ TController::adjust_desired_speed_for_current_speed() { } else { // slow down, not full stop - if( vel > ( VelDesired + fVelPlus ) ) { + if( vel > VelDesired + fVelPlus ) { // hamuj tak średnio AccDesired = std::min( AccDesired, -0.05 + fAccThreshold ); } @@ -7758,8 +7642,8 @@ TController::adjust_desired_speed_for_current_speed() { // if it looks like we'll exceed maximum speed start thinking about slight slowing down AccDesired = std::min( AccDesired, -0.05 + fAccThreshold ); // HACK: for cargo trains with high braking threshold ensure we cross that threshold - if( ( true == IsCargoTrain ) - && ( fBrake_a0[ 0 ] > 0.2 ) ) { + if( true == IsCargoTrain + && fBrake_a0[0] > 0.2 ) { AccDesired -= std::clamp( fBrake_a0[ 0 ] - 0.2, 0.0, 0.15 ); } } @@ -7808,7 +7692,7 @@ TController::adjust_desired_speed_for_current_speed() { } else { // slow down, not full stop - if( vel > ( VelDesired + fVelPlus ) ) { + if( vel > VelDesired + fVelPlus ) { // hamuj tak średnio AccDesired = std::min( AccDesired, -fBrake_a0[ 0 ] * 0.5 ); } @@ -7827,8 +7711,7 @@ TController::adjust_desired_speed_for_current_speed() { if( vel < VelDesired ) { // don't adjust acceleration when going above current target speed if( -AccDesired * BrakeAccFactor() < ( - ( ( false == Ready ) - || ( VelNext > vel - 40.0 ) ) ? + false == Ready || VelNext > vel - 40.0 ? fBrake_a0[ 0 ] * 0.8 : -fAccThreshold ) / ( 1.2 * braking_distance_multiplier( VelNext ) ) ) { @@ -7853,12 +7736,12 @@ TController::adjust_desired_speed_for_braking_test() { switch( DynamicBrakeTest ) { case 0: { - if( ( primary() ) - && ( vel < VelDesired ) - && ( fAccGravity >= 0.0 ) // not if going uphill - && ( AccDesired >= EU07_AI_ACCELERATION ) - && ( TrainParams.TTVmax >= 10.0 ) - && ( vel > std::min( TrainParams.TTVmax, 60.0 ) - 2.0 ) ) { + if( primary() + && vel < VelDesired + && fAccGravity >= 0.0 // not if going uphill + && AccDesired >= EU07_AI_ACCELERATION + && TrainParams.TTVmax >= 10.0 + && vel > std::min(TrainParams.TTVmax, 60.0) - 2.0 ) { DynamicBrakeTest = 1; DBT_BrakingTime = ElapsedTime; DBT_VelocityBrake = vel; @@ -7937,8 +7820,8 @@ TController::control_tractive_and_braking_force() { control_motor_connectors(); // if the radio-stop was issued don't waste effort trying to fight it - if( ( true == mvOccupied->RadioStopFlag ) // radio-stop - && ( mvOccupied->Vel > EU07_AI_NOMOVEMENT ) ) { // and still moving + if( true == mvOccupied->RadioStopFlag // radio-stop + && mvOccupied->Vel > EU07_AI_NOMOVEMENT ) { // and still moving cue_action( driver_hint::mastercontrollersetzerospeed ); // just throttle down... return; // ...and don't touch any other controls } @@ -7982,9 +7865,9 @@ void TController::control_relays() { void TController::control_motor_connectors() { // ensure motor connectors are active - if( ( mvControlling->EngineType == TEngineType::ElectricSeriesMotor ) - || ( mvControlling->EngineType == TEngineType::DieselElectric ) - || ( is_emu() ) ) { + if( mvControlling->EngineType == TEngineType::ElectricSeriesMotor + || mvControlling->EngineType == TEngineType::DieselElectric + || is_emu() ) { if( Need_TryAgain ) { // true, jeśli druga pozycja w elektryku nie załapała cue_action( driver_hint::mastercontrollersetzerospeed ); @@ -7997,21 +7880,19 @@ void TController::control_tractive_force() { auto const velocity { DirectionalVel() }; // jeśli przyspieszenie pojazdu jest mniejsze niż żądane oraz... - if( ( AccDesired > EU07_AI_NOACCELERATION ) // don't add power if not asked for actual speed-up - && (( AbsAccS < AccDesired /*- std::min( 0.05, 0.01 * iDriverFailCount )*/ ) || (mvOccupied->SpeedCtrlUnit.IsActive && velocity < mvOccupied->SpeedCtrlUnit.FullPowerVelocity)) - && ( false == TestFlag( iDrivigFlags, movePress ) ) ) { + if( AccDesired > EU07_AI_NOACCELERATION // don't add power if not asked for actual speed-up + && (AbsAccS < AccDesired /*- std::min( 0.05, 0.01 * iDriverFailCount )*/ || (mvOccupied->SpeedCtrlUnit.IsActive && velocity < mvOccupied->SpeedCtrlUnit.FullPowerVelocity)) + && false == TestFlag(iDrivigFlags, movePress) ) { // ...jeśli prędkość w kierunku czoła jest mniejsza od dozwolonej o margines... if( velocity < ( VelDesired == 1.0 ? // work around for trains getting stuck on tracks with speed limit = 1 VelDesired : VelDesired - fVelMinus ) ) { // within proximity margin don't exceed next scheduled speed, outside of the margin accelerate as you like - if( ( ActualProximityDist > ( - is_car() ? - fMinProximityDist : // cars are allowed to move within min proximity distance - fMaxProximityDist ) ? // other vehicle types keep wider margin - true : - ( velocity + 1.0 ) < VelNext ) ) { + if( ActualProximityDist > (is_car() ? fMinProximityDist : // cars are allowed to move within min proximity distance + fMaxProximityDist) ? // other vehicle types keep wider margin + true : + velocity + 1.0 < VelNext ) { // ...to można przyspieszyć increase_tractive_force(); } @@ -8020,16 +7901,16 @@ void TController::control_tractive_force() { // zmniejszanie predkosci // margines dla prędkości jest doliczany tylko jeśli oczekiwana prędkość jest większa od 5km/h if( false == TestFlag( iDrivigFlags, movePress ) ) { - double SpeedCtrlMargin = (mvControlling->SpeedCtrlUnit.IsActive && VelDesired > 5) ? 3 : 0; + double SpeedCtrlMargin = mvControlling->SpeedCtrlUnit.IsActive && VelDesired > 5 ? 3 : 0; // jeśli nie dociskanie if( AccDesired <= EU07_AI_NOACCELERATION ) { cue_action( driver_hint::mastercontrollersetzerospeed ); } - else if( ( velocity > VelDesired + SpeedCtrlMargin) + else if( velocity > VelDesired + SpeedCtrlMargin || ( fAccGravity < -0.01 ? AccDesired < 0.0 : - ( AbsAccS > AccDesired + 10.05 ) ) - || ( IsAnyCouplerStretched ) ) { + AbsAccS > AccDesired + 10.05 ) + || IsAnyCouplerStretched ) { // jak za bardzo przyspiesza albo prędkość przekroczona // dodany wyjatek na "pelna w przod" cue_action( driver_hint::tractiveforcedecrease ); @@ -8048,7 +7929,7 @@ void TController::increase_tractive_force() { if( mvOccupied->SpringBrake.Activate ) { cue_action( driver_hint::springbrakeoff ); } - if( ( VelDesired > 0.0 ) // to prevent door shuffle on stop + if( VelDesired > 0.0 // to prevent door shuffle on stop && ( doors_open() || doors_permit_active() ) ) { // zamykanie drzwi - tutaj wykonuje tylko AI (zmienia fActionTime) Doors( false ); @@ -8071,13 +7952,13 @@ void TController::control_braking_force() { // jeśli przyspieszamy, to nie hamujemy if( AccDesired > 0.0 ) { - if( ( OrderCurrentGet() != Disconnect ) // przy odłączaniu nie zwalniamy tu hamulca - && ( false == TestFlag( iDrivigFlags, movePress ) ) ) { + if( OrderCurrentGet() != Disconnect // przy odłączaniu nie zwalniamy tu hamulca + && false == TestFlag(iDrivigFlags, movePress) ) { cue_action( driver_hint::brakingforcesetzero ); } } - if( is_emu() && ( !ForcePNBrake ) ) { + if( is_emu() && !ForcePNBrake ) { // właściwie, to warunek powinien być na działający EP // Ra: to dobrze hamuje EP w EZT auto const accthreshold { ( @@ -8085,11 +7966,11 @@ void TController::control_braking_force() { fAccThreshold : std::max( -0.2, fAccThreshold ) ) }; auto const AccMax{ std::min(fBrake_a0[0] + 12 * fBrake_a1[0], mvOccupied->MED_amax) }; - auto const accmargin = ((AccMax > 1.1 * AccDesired) && (fAccGravity < 0.025)) ? + auto const accmargin = AccMax > 1.1 * AccDesired && fAccGravity < 0.025 ? 0.05 : 0.0; - if( ( AccDesired < accthreshold ) // jeśli hamować - u góry ustawia się hamowanie na fAccThreshold - && ( ( AbsAccS > AccDesired + accmargin) - || ( BrakeCtrlPosition < 0 ) ) ) { + if( AccDesired < accthreshold // jeśli hamować - u góry ustawia się hamowanie na fAccThreshold + && ( AbsAccS > AccDesired + accmargin + || BrakeCtrlPosition < 0 ) ) { // hamować bardziej, gdy aktualne opóźnienie hamowania mniejsze niż (AccDesired) cue_action( driver_hint::brakingforceincrease ); } @@ -8110,12 +7991,12 @@ void TController::control_braking_force() { } // type & dt_ezt else { // a stara wersja w miarę dobrze działa na składy wagonowe - if( ( ( AccDesired < fAccGravity - 0.1 ) && ( AbsAccS > AccDesired + fBrake_a1[ 0 ] ) ) // regular braking - || ( ( fAccGravity < -0.05 ) && ( velocity < -0.1 ) ) ) { // also brake if uphill and slipping back + if( ( AccDesired < fAccGravity - 0.1 && AbsAccS > AccDesired + fBrake_a1[0] ) // regular braking + || ( fAccGravity < -0.05 && velocity < -0.1 ) ) { // also brake if uphill and slipping back // u góry ustawia się hamowanie na fAccThreshold - if( ( fBrakeTime < 0.0 ) - || ( AccDesired < fAccGravity - 0.5 ) - || ( BrakeCtrlPosition <= 0 ) ) { + if( fBrakeTime < 0.0 + || AccDesired < fAccGravity - 0.5 + || BrakeCtrlPosition <= 0 ) { // jeśli upłynął czas reakcji hamulca, chyba że nagłe albo luzował // TODO: check whether brake delay variable still has any purpose cue_action( @@ -8130,8 +8011,8 @@ void TController::control_braking_force() { * 0.5 ); // Ra: tymczasowo, bo przeżyna S1 } } - if ( ( AccDesired < fAccGravity - 0.05 ) - && ( ( AccDesired - fBrake_a1[ 0 ] * 0.51 ) ) - AbsAccS > 0.05 ) { + if ( AccDesired < fAccGravity - 0.05 + && AccDesired - fBrake_a1[0] * 0.51 - AbsAccS > 0.05 ) { // jak hamuje, to nie tykaj kranu za często // yB: luzuje hamulec dopiero przy różnicy opóźnień rzędu 0.2 if( OrderCurrentGet() != Disconnect ) { // przy odłączaniu nie zwalniamy tu hamulca @@ -8139,10 +8020,7 @@ void TController::control_braking_force() { // TODO: check whether brake delay variable still has any purpose cue_action( driver_hint::brakingforcedecrease, - ( ( mvOccupied->BrakeDelayFlag > bdelay_G ? - mvOccupied->BrakeDelay[ 0 ] : - mvOccupied->BrakeDelay[ 2 ] ) - / 3.0 ) + (mvOccupied->BrakeDelayFlag > bdelay_G ? mvOccupied->BrakeDelay[0] : mvOccupied->BrakeDelay[2]) / 3.0 * 0.5 ); // Ra: tymczasowo, bo przeżyna S1 } } @@ -8150,26 +8028,26 @@ void TController::control_braking_force() { // stop-gap measure to ensure cars actually brake to stop even when above calculactions go awry // instead of releasing the brakes and creeping into obstacle at 1-2 km/h if( is_car() ) { - if( ( VelDesired == 0.0 ) - && ( velocity > VelDesired ) - && ( ActualProximityDist <= fMinProximityDist ) - && ( mvOccupied->LocalBrakePosA < 0.01 ) ) { + if( VelDesired == 0.0 + && velocity > VelDesired + && ActualProximityDist <= fMinProximityDist + && mvOccupied->LocalBrakePosA < 0.01 ) { cue_action( driver_hint::brakingforceincrease ); } } } // odhamowywanie składu po zatrzymaniu i zabezpieczanie lokomotywy - if( ( mvOccupied->Vel < EU07_AI_NOMOVEMENT ) - && ( ( VelDesired == 0.0 ) - || ( AccDesired <= EU07_AI_NOACCELERATION ) ) ) { + if( mvOccupied->Vel < EU07_AI_NOMOVEMENT + && ( VelDesired == 0.0 + || AccDesired <= EU07_AI_NOACCELERATION ) ) { - if( ( ( OrderCurrentGet() & ( Disconnect | Connect | Change_direction ) ) == 0 ) // przy (p)odłączaniu nie zwalniamy tu hamulca - && ( std::abs( fAccGravity ) < 0.01 ) ) { // only do this on flats, on slopes keep applied the train brake + if( (OrderCurrentGet() & (Disconnect | Connect | Change_direction)) == 0 // przy (p)odłączaniu nie zwalniamy tu hamulca + && std::abs(fAccGravity) < 0.01 ) { // only do this on flats, on slopes keep applied the train brake apply_independent_brake_only(); } // if told to change direction don't confuse human driver with request to leave applied brake in the cab they're about to leave - if( ( OrderCurrentGet() & ( Change_direction ) ) != 0 ) { + if( ( OrderCurrentGet() & Change_direction ) != 0 ) { cue_action( driver_hint::independentbrakerelease ); } } @@ -8178,8 +8056,8 @@ void TController::control_braking_force() { void TController::apply_independent_brake_only() { if( mvOccupied->LocalBrake != TLocalBrake::ManualBrake ) { - if( ( false == mvOccupied->ShuntMode ) // no need for independent brake if autobrake is active - && ( is_equal( mvOccupied->fBrakeCtrlPos, mvOccupied->Handle->GetPos( bh_RP ), 0.2 ) ) ) { + if( false == mvOccupied->ShuntMode // no need for independent brake if autobrake is active + && is_equal(mvOccupied->fBrakeCtrlPos, mvOccupied->Handle->GetPos(bh_RP), 0.2) ) { cue_action( driver_hint::independentbrakeapply ); } else { @@ -8190,18 +8068,18 @@ void TController::apply_independent_brake_only() { void TController::control_releaser() { // HACK: don't immediately touch releaser in inert vehicle, in case the simulation is about to replace us with human driver - if( ( mvOccupied->Vel < 1.0 ) && ( fActionTime < 0.0 ) ) { return; } + if( mvOccupied->Vel < 1.0 && fActionTime < 0.0 ) { return; } // TODO: combine all releaser handling in single decision tree instead of having bits all over the place // TODO: replace handle and system conditions with flag indicating releaser presence if( BrakeSystem != TBrakeSystem::Pneumatic ) { return; } auto const hasreleaser { - ( false == ( is_dmu() || is_emu() ) ) // TODO: a more refined test than rejecting these types wholesale - && ( ( mvOccupied->BrakeHandle == TBrakeHandle::FV4a ) - || ( mvOccupied->BrakeHandle == TBrakeHandle::MHZ_6P ) - || ( mvOccupied->BrakeHandle == TBrakeHandle::MHZ_K5P ) - || ( mvOccupied->BrakeHandle == TBrakeHandle::MHZ_K8P ) - || ( mvOccupied->BrakeHandle == TBrakeHandle::M394 ) ) }; + false == (is_dmu() || is_emu()) // TODO: a more refined test than rejecting these types wholesale + && ( mvOccupied->BrakeHandle == TBrakeHandle::FV4a + || mvOccupied->BrakeHandle == TBrakeHandle::MHZ_6P + || mvOccupied->BrakeHandle == TBrakeHandle::MHZ_K5P + || mvOccupied->BrakeHandle == TBrakeHandle::MHZ_K8P + || mvOccupied->BrakeHandle == TBrakeHandle::M394 ) }; if( false == hasreleaser ) { return; } @@ -8215,17 +8093,17 @@ void TController::control_releaser() { // some vehicles require brake handle to be moved to specific position if( mvOccupied->HandleUnlock != -3 ) { cue_action( driver_hint::trainbrakesetpipeunlock ); - isbrakehandleinrightposition &= ( BrakeCtrlPosition == mvOccupied->HandleUnlock ); + isbrakehandleinrightposition &= BrakeCtrlPosition == mvOccupied->HandleUnlock; } } // wyluzuj lokomotywę, to szybciej ruszymy - if( ( mvOccupied->BrakePress > 0.4 ) - && ( mvOccupied->Hamulec->GetCRP() > 4.9 ) ) { + if( mvOccupied->BrakePress > 0.4 + && mvOccupied->Hamulec->GetCRP() > 4.9 ) { actuate = true; } // keep engine brakes released during coupling/uncoupling - if( ( true == TestFlag( iDrivigFlags, movePress ) ) - && ( mvOccupied->BrakePress > 0.1 ) ) { + if( true == TestFlag(iDrivigFlags, movePress) + && mvOccupied->BrakePress > 0.1 ) { actuate = true; } } @@ -8237,8 +8115,8 @@ void TController::control_releaser() { if( actuate ) { // some vehicles may require master controller in neutral position cue_action( driver_hint::mastercontrollersetzerospeed ); - if( ( false == mvOccupied->Hamulec->Releaser() ) - && ( isbrakehandleinrightposition ) ) { + if( false == mvOccupied->Hamulec->Releaser() + && isbrakehandleinrightposition ) { cue_action( driver_hint::releaseron ); } } @@ -8252,8 +8130,8 @@ void TController::control_releaser() { void TController::control_main_pipe() { // unlocking main pipe - if( ( AccDesired > -0.03 ) - && ( true == mvOccupied->LockPipe ) ) { + if( AccDesired > -0.03 + && true == mvOccupied->LockPipe ) { UniversalBrakeButtons |= TUniversalBrake::ub_UnlockPipe; } else if (false == mvOccupied->LockPipe ) { @@ -8263,26 +8141,26 @@ void TController::control_main_pipe() { // napełnianie uderzeniowe if( BrakeSystem != TBrakeSystem::Pneumatic ) { return; } - if( ( mvOccupied->BrakeHandle == TBrakeHandle::FV4a ) - || ( mvOccupied->BrakeHandle == TBrakeHandle::MHZ_6P ) - || ( mvOccupied->BrakeHandle == TBrakeHandle::MHZ_K5P ) - || ( mvOccupied->BrakeHandle == TBrakeHandle::MHZ_K8P ) - || ( mvOccupied->BrakeHandle == TBrakeHandle::M394 ) ) { + if( mvOccupied->BrakeHandle == TBrakeHandle::FV4a + || mvOccupied->BrakeHandle == TBrakeHandle::MHZ_6P + || mvOccupied->BrakeHandle == TBrakeHandle::MHZ_K5P + || mvOccupied->BrakeHandle == TBrakeHandle::MHZ_K8P + || mvOccupied->BrakeHandle == TBrakeHandle::M394 ) { - if( ( iDrivigFlags & moveOerlikons ) - || ( true == IsCargoTrain ) ) { + if( iDrivigFlags & moveOerlikons + || true == IsCargoTrain ) { - if( ( BrakeCtrlPosition == gbh_RP ) - && ( AbsAccS < 0.03 ) - && ( AccDesired > -0.03 ) - && ( VelDesired - mvOccupied->Vel > 2.0 ) ) { + if( BrakeCtrlPosition == gbh_RP + && AbsAccS < 0.03 + && AccDesired > -0.03 + && VelDesired - mvOccupied->Vel > 2.0 ) { - if( ( fReady > 0.35 ) - && ( mvOccupied->EqvtPipePress < 4.5 ) // don't charge with a risk of overcharging the main pipe - && ( mvOccupied->Compressor >= 7.5 ) // don't charge without sufficient pressure in the tank - && ( BrakeChargingCooldown >= 0.0 ) // don't charge while cooldown is active - && ( ( ActualProximityDist > 100.0 ) // don't charge if we're about to be braking soon - || ( min_speed( mvOccupied->Vel, VelNext ) >= mvOccupied->Vel ) ) ) { + if( fReady > 0.35 + && mvOccupied->EqvtPipePress < 4.5 // don't charge with a risk of overcharging the main pipe + && mvOccupied->Compressor >= 7.5 // don't charge without sufficient pressure in the tank + && BrakeChargingCooldown >= 0.0 // don't charge while cooldown is active + && ( ActualProximityDist > 100.0 // don't charge if we're about to be braking soon + || min_speed(mvOccupied->Vel, VelNext) >= mvOccupied->Vel ) ) { BrakeLevelSet( gbh_FS ); // don't charge the brakes too often, or we risk overcharging @@ -8291,9 +8169,9 @@ void TController::control_main_pipe() { } } - if( ( mvOccupied->Compressor < 5.0 ) - || ( ( BrakeCtrlPosition < gbh_RP ) - && ( mvOccupied->EqvtPipePress > ( fReady < 0.25 ? 5.1 : 5.2 ) ) ) ) { + if( mvOccupied->Compressor < 5.0 + || ( BrakeCtrlPosition < gbh_RP + && mvOccupied->EqvtPipePress > (fReady < 0.25 ? 5.1 : 5.2) ) ) { cue_action( driver_hint::trainbrakerelease ); } } @@ -8365,9 +8243,9 @@ TController::check_route_behind( double const Range ) { // jedzie w Shunt albo Connect, albo Wait_for_orders // w trybie Connect skanować do tyłu tylko jeśli przed kolejnym sygnałem nie ma taboru do podłączenia auto const couplinginprogress { - ( TestFlag( OrderCurrentGet(), Connect ) ) - && ( ( Obstacle.distance < std::min( 2000.0, FirstSemaphorDist ) ) - || ( TestFlag( iDrivigFlags, moveConnect ) ) ) }; + TestFlag(OrderCurrentGet(), Connect) + && ( Obstacle.distance < std::min(2000.0, FirstSemaphorDist) + || TestFlag(iDrivigFlags, moveConnect) ) }; if( couplinginprogress ) { return; } auto const commandbehind { BackwardScan( Range ) }; @@ -8390,25 +8268,25 @@ TController::check_route_behind( double const Range ) { void TController::UpdateBrakingHelper() { - if (( HelperState > 0 ) && (-AccDesired < fBrake_a0[0] + 2 * fBrake_a1[0]) && (mvOccupied->Vel > EU07_AI_NOMOVEMENT)) { + if (HelperState > 0 && -AccDesired < fBrake_a0[0] + 2 * fBrake_a1[0] && mvOccupied->Vel > EU07_AI_NOMOVEMENT) { HelperState = 0; } switch( HelperState ) { case 0: { - if( ( -AccDesired > fBrake_a0[0] + 8 * fBrake_a1[0] ) ) { + if( -AccDesired > fBrake_a0[0] + 8 * fBrake_a1[0] ) { HelperState = 1; } break; } case 1: { - if( ( -AccDesired > fBrake_a0[0] + 12 * fBrake_a1[0] ) ) { + if( -AccDesired > fBrake_a0[0] + 12 * fBrake_a1[0] ) { HelperState = 2; } break; } case 2: { - if( ( -AccDesired > 0 ) && ( -ActualProximityDist > 5 ) ) { + if( -AccDesired > 0 && -ActualProximityDist > 5 ) { HelperState = 3; } break; diff --git a/vehicle/Driver.h b/vehicle/Driver.h index 84dbbe55..e7c4fac0 100644 --- a/vehicle/Driver.h +++ b/vehicle/Driver.h @@ -224,11 +224,11 @@ public: void TakeControl( bool const Aidriver, bool const Forcevehiclecheck = false ); inline bool primary( bool const Primary ) { - SetFlag( iDrivigFlags, ( Primary ? movePrimary : -movePrimary ) ); + SetFlag( iDrivigFlags, Primary ? movePrimary : -movePrimary ); return primary(); } inline bool primary() const { - return ( ( iDrivigFlags & movePrimary ) != 0 ); }; + return (iDrivigFlags & movePrimary) != 0; }; inline TMoverParameters const *Controlling() const { return mvControlling; } @@ -257,14 +257,13 @@ public: return TestFlag( mvOccupied->CategoryFlag, 2 ); } inline bool is_emu() const { - return ( mvControlling->TrainType == dt_EZT ); } + return mvControlling->TrainType == dt_EZT; } inline bool is_dmu() const { - return ( mvControlling->TrainType == dt_DMU ); } + return mvControlling->TrainType == dt_DMU; } inline bool has_diesel_engine() const { - return ( ( mvControlling->EngineType == TEngineType::DieselElectric ) - || ( mvControlling->EngineType == TEngineType::DieselEngine ) ); + return mvControlling->EngineType == TEngineType::DieselElectric || mvControlling->EngineType == TEngineType::DieselEngine; } TBrakeSystem consist_brake_system() const; private: diff --git a/vehicle/DynObj.cpp b/vehicle/DynObj.cpp index a6487c9b..7adfa8b8 100644 --- a/vehicle/DynObj.cpp +++ b/vehicle/DynObj.cpp @@ -52,10 +52,7 @@ bool TDynamicObject::bDynamicRemove { false }; TSubModel * GetSubmodelFromName( TModel3d * const Model, std::string const Name ) { - return ( - Model ? - Model->GetFromName( Name ) : - nullptr ); + return Model ? Model->GetFromName(Name) : nullptr; } // Ra 2015-01: sprawdzenie dostępności tekstury o podanej nazwie @@ -67,7 +64,7 @@ TextureTest( std::string const &Name ) { { Global.asCurrentTexturePath + Name, Name, paths::textures + Name }, { ".mat", ".dds", ".tga", ".ktx", ".png", ".bmp", ".jpg", ".tex" } ) }; - return ( lookup.first + lookup.second ); + return lookup.first + lookup.second; } //--------------------------------------------------------------------------- @@ -183,16 +180,16 @@ int TAnim::TypeSet(int i, TMoverParameters currentMover, int fl) iFlags = 0x055; fParamPants = new TAnimPant(); switch (currentMover.EnginePowerSource.CollectorParameters.PantographType) { - case (TPantType::AKP_4E): + case TPantType::AKP_4E: fParamPants->AKP_4E(); break; - case(TPantType::DSAx): + case TPantType::DSAx: fParamPants->DSAx(); break; - case(TPantType::EC160_200): + case TPantType::EC160_200: fParamPants->EC160_200(); break; - case(TPantType::WBL85): + case TPantType::WBL85: fParamPants->WBL85(); break; } @@ -248,7 +245,7 @@ material_data::assign( std::string const &Replacableskin ) { nameparser.getTokens( 4, false, "|" ); int skinindex = 0; std::string texturename; nameparser >> texturename; - while( ( texturename != "" ) && ( skinindex < 4 ) ) { + while( texturename != "" && skinindex < 4 ) { replacable_skins[ skinindex + 1 ] = GfxRenderer->Fetch_Material( texturename ); ++skinindex; texturename = ""; nameparser >> texturename; @@ -280,10 +277,8 @@ material_data::assign( std::string const &Replacableskin ) { // BUGS! it's not entierly designed whether opacity is property of material or submodel, // and code does confusing things with this in various places - textures_alpha = ( - GfxRenderer->Material( replacable_skins[ 1 ] )->is_translucent() ? - 0x31310031 : // tekstura -1 z kanałem alfa - nie renderować w cyklu nieprzezroczystych - 0x30300030 ); // wszystkie tekstury nieprzezroczyste - nie renderować w cyklu przezroczystych + textures_alpha = GfxRenderer->Material(replacable_skins[1])->is_translucent() ? 0x31310031 : // tekstura -1 z kanałem alfa - nie renderować w cyklu nieprzezroczystych + 0x30300030; // wszystkie tekstury nieprzezroczyste - nie renderować w cyklu przezroczystych if( GfxRenderer->Material( replacable_skins[ 2 ] )->is_translucent() ) { // tekstura -2 z kanałem alfa - nie renderować w cyklu nieprzezroczystych textures_alpha |= 0x02020002; @@ -310,7 +305,7 @@ bool TDynamicObject::destination_data::deserialize_mapping( cParser &Input ) { // token can be a key or block end auto const key { Input.getToken( true, "\n\r\t ,;[]" ) }; - if( ( true == key.empty() ) || ( key == "}" ) ) { return false; } + if( true == key.empty() || key == "}" ) { return false; } if( key == "{" ) { script = Input.getToken(); @@ -489,11 +484,11 @@ int TDynamicObject::GetPneumatic(bool front, bool red) y = btPneumatic2r.GetStatus(); } z = 0; // brak węży? - if ((x > 0) && (y > 0)) + if (x > 0 && y > 0) z = 3; // dwa - if ((x > 0) && (y == 0)) + if (x > 0 && y == 0) z = 1; // lewy, brak prawego - if ((x == 0) && (y > 0)) + if (x == 0 && y > 0) z = 2; // brak lewego, prawy return z; @@ -507,10 +502,10 @@ void TDynamicObject::SetPneumatic(bool front, bool red) ten = GetPneumatic(front, red); // 1=lewy skos,2=prawy skos,3=dwa proste if (front) if (PrevConnected()) // pojazd od strony sprzęgu 0 - tamten = PrevConnected()->GetPneumatic((PrevConnectedNo() == end::front ? true : false), red); + tamten = PrevConnected()->GetPneumatic(PrevConnectedNo() == end::front ? true : false, red); if (!front) if (NextConnected()) // pojazd od strony sprzęgu 1 - tamten = NextConnected()->GetPneumatic((NextConnectedNo() == end::front ? true : false), red); + tamten = NextConnected()->GetPneumatic(NextConnectedNo() == end::front ? true : false, red); if (ten == tamten) // jeśli układ jest symetryczny switch (ten) { @@ -703,8 +698,8 @@ void TDynamicObject::UpdateMirror( TAnim *pAnim ) { // only animate the mirror if it's located on the same end of the vehicle as the active cab auto const isactive { ( - MoverParameters->CabOccupied > 0 ? ( ( pAnim->iNumber >> 4 ) == end::front ? 1.0 : 0.0 ) : - MoverParameters->CabOccupied < 0 ? ( ( pAnim->iNumber >> 4 ) == end::rear ? 1.0 : 0.0 ) : + MoverParameters->CabOccupied > 0 ? ( pAnim->iNumber >> 4 == end::front ? 1.0 : 0.0 ) : + MoverParameters->CabOccupied < 0 ? ( pAnim->iNumber >> 4 == end::rear ? 1.0 : 0.0 ) : 0.0 ) }; if( pAnim->iNumber & 1 ) @@ -775,16 +770,16 @@ TDynamicObject::toggle_lights() { for( auto §ion : Sections ) { auto const sectionname { section.compartment->pName }; - if( ( sectionname.find( "corridor" ) == 0 ) - || ( sectionname.find( "korytarz" ) == 0 ) ) { + if( sectionname.find("corridor") == 0 + || sectionname.find("korytarz") == 0 ) { // corridors are lit 100% of time section.light_level = 0.75f; } else if( - ( sectionname.find( "compartment" ) == 0 ) - || ( sectionname.find( "przedzial" ) == 0 ) ) { + sectionname.find("compartment") == 0 + || sectionname.find("przedzial") == 0 ) { // compartments are lit with 75% probability - section.light_level = ( Random() < 0.75 ? 0.75f : 0.10f ); + section.light_level = Random() < 0.75 ? 0.75f : 0.10f; } } SectionLightsActive = true; @@ -819,19 +814,19 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) if (vFloor.z > 0.0) mdLoad->GetSMRoot()->SetTranslate(modelShake + vFloor); - if (ObjSqrDist < ( 400 * 400 ) ) // gdy bliżej niż 400m + if (ObjSqrDist < 400 * 400 ) // gdy bliżej niż 400m { for( auto &animation : pAnimations ) { // wykonanie kolejnych animacji - if( ( ObjSqrDist < animation.fMaxDist ) - && ( animation.yUpdate ) ) { + if( ObjSqrDist < animation.fMaxDist + && animation.yUpdate ) { // jeśli zdefiniowana funkcja aktualizacja animacji (położenia submodeli animation.yUpdate( &animation ); } } - if( ( mdModel != nullptr ) - && ( ObjSqrDist < ( 50 * 50 ) ) ) { + if( mdModel != nullptr + && ObjSqrDist < 50 * 50 ) { // gdy bliżej niż 50m // ABu290105: rzucanie pudlem // te animacje wymagają bananów w modelach! @@ -1073,7 +1068,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) if (MoverParameters->Power24vIsAvailable || MoverParameters->Power110vIsAvailable) { // sygnaly konca pociagu if (m_endsignals1.Active()) { - if (TestFlag(MoverParameters->iLights[end::front], ( light::redmarker_left | light::redmarker_right ) ) ) { + if (TestFlag(MoverParameters->iLights[end::front], light::redmarker_left | light::redmarker_right ) ) { m_endsignals1.Turn( true ); btnOn = true; } @@ -1091,7 +1086,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) } } if (m_endsignals2.Active()) { - if (TestFlag(MoverParameters->iLights[end::rear], ( light::redmarker_left | light::redmarker_right ) ) ) { + if (TestFlag(MoverParameters->iLights[end::rear], light::redmarker_left | light::redmarker_right ) ) { m_endsignals2.Turn( true ); btnOn = true; } @@ -1131,13 +1126,13 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) // cooling shutters // NOTE: shutters display _on state when they're closed, _off otherwise - if( ( true == MoverParameters->dizel_heat.water.config.shutters ) - && ( false == MoverParameters->dizel_heat.zaluzje1 ) ) { + if( true == MoverParameters->dizel_heat.water.config.shutters + && false == MoverParameters->dizel_heat.zaluzje1 ) { btShutters1.Turn( true ); btnOn = true; } - if( ( true == MoverParameters->dizel_heat.water_aux.config.shutters ) - && ( false == MoverParameters->dizel_heat.zaluzje2 ) ) { + if( true == MoverParameters->dizel_heat.water_aux.config.shutters + && false == MoverParameters->dizel_heat.zaluzje2 ) { btShutters2.Turn( true ); btnOn = true; } @@ -1145,10 +1140,9 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) // only external models ( external_only_on / external_only_off ) btExteriorOnly.Turn(!bDisplayCab); // display only when cab is not rendered - if( ( false == bDisplayCab ) // edge case, lowpoly may act as a stand-in for the hi-fi cab, so make sure not to show the driver when inside - && ( Mechanik != nullptr ) - && ( ( Mechanik->action() != TAction::actSleep ) - /* || ( MoverParameters->Battery ) */ ) ) { + if( false == bDisplayCab // edge case, lowpoly may act as a stand-in for the hi-fi cab, so make sure not to show the driver when inside + && Mechanik != nullptr + && Mechanik->action() != TAction::actSleep ) { // rysowanie figurki mechanika btMechanik1.Turn(MoverParameters->CabOccupied > 0); btMechanik2.Turn( MoverParameters->CabOccupied < 0 ); @@ -1306,14 +1300,14 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) if( cabsection ) { // check whether we're still processing cab sections auto const §ionname { section.compartment->pName }; - cabsection &= ( ( sectionname.size() >= 4 ) && sectionname.starts_with("cab") ); + cabsection &= sectionname.size() >= 4 && sectionname.starts_with("cab"); } // TODO: add cablight devices auto const sectionlightlevel { section.light_level * ( cabsection ? 1.0f : MoverParameters->CompartmentLights.intensity ) }; sectionlightcolor = glm::vec4( - ( ( ( sectionlightlevel == 0.f ) || ( Global.fLuminance > section.compartment->fLight ) ) ? - glm::vec3( 240.f / 255.f ) : // TBD: save and restore initial submodel diffuse instead of enforcing one? - InteriorLight ), // TODO: per-compartment (type) light color + sectionlightlevel == 0.f || Global.fLuminance > section.compartment->fLight ? + glm::vec3(240.f / 255.f) : // TBD: save and restore initial submodel diffuse instead of enforcing one? + InteriorLight, // TODO: per-compartment (type) light color sectionlightlevel ); section.compartment->SetLightLevel( sectionlightcolor, true ); if( section.load != nullptr ) { @@ -1324,14 +1318,14 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) for( auto const §ion : Sections ) { // section isn't guaranteed to have load model, so check that first if( section.load == nullptr ) { continue; } - section.load->iVisible = ( section.load_chunks_visible > 0 ); + section.load->iVisible = section.load_chunks_visible > 0; // if the section root isn't visible we can skip meddling with its children if( false == section.load->iVisible ) { continue; } // if the section root is visible set the state of section chunks auto *sectionchunk { section.load->ChildGet() }; auto visiblechunkcount { section.load_chunks_visible }; while( sectionchunk != nullptr ) { - sectionchunk->iVisible = ( visiblechunkcount > 0 ); + sectionchunk->iVisible = visiblechunkcount > 0; --visiblechunkcount; sectionchunk = sectionchunk->NextGet(); } @@ -1340,13 +1334,12 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) // driver cabs visibility for( int cabidx = 0; cabidx < LowPolyIntCabs.size(); ++cabidx ) { if( LowPolyIntCabs[ cabidx ] == nullptr ) { continue; } - LowPolyIntCabs[ cabidx ]->iVisible = ( - mdKabina == nullptr ? true : // there's no hi-fi cab + LowPolyIntCabs[ cabidx ]->iVisible = mdKabina == nullptr ? true : // there's no hi-fi cab bDisplayCab == false ? true : // we're in external view simulation::Train == nullptr ? true : // not a player-driven vehicle, implies external view simulation::Train->Dynamic() != this ? true : // not a player-driven vehicle, implies external view JointCabs ? false : // internal view, all cabs share the model so hide them 'all' - ( simulation::Train->iCabn != cabidx ) ); // internal view, hide occupied cab and show others + simulation::Train->iCabn != cabidx; // internal view, hide occupied cab and show others } } // ABu 29.01.05 koniec przeklejenia ************************************* @@ -1457,7 +1450,7 @@ void TDynamicObject::ABuBogies() { // Obracanie wozkow na zakretach. Na razie // uwzględnia tylko zakręty, // bez zadnych gorek i innych przeszkod. - if ((smBogie[0] != nullptr) && (smBogie[1] != nullptr)) + if (smBogie[0] != nullptr && smBogie[1] != nullptr) { // modelRot.z=ABuAcos(Axle0.pPosition-Axle1.pPosition); //kąt obrotu pojazdu // [rad] @@ -1546,19 +1539,19 @@ TDynamicObject::ABuFindObject( int &Foundcoupler, double &Distance, TTrack const */ if( Direction > 0 ) { // jeśli szukanie w kierunku Point2 - objectposition = ( dynamic->RaTranslationGet() ) - myposition; // odległogłość tamtego od szukającego - if( ( objectposition > 0 ) - && ( objectposition < distance ) ) { + objectposition = dynamic->RaTranslationGet() - myposition; // odległogłość tamtego od szukającego + if( objectposition > 0 + && objectposition < distance ) { // gdy jest po właściwej stronie i bliżej niż jakiś wcześniejszy - Foundcoupler = ( dynamic->RaDirectionGet() > 0 ) ? 1 : 0; // to, bo (ScanDir>=0) + Foundcoupler = dynamic->RaDirectionGet() > 0 ? 1 : 0; // to, bo (ScanDir>=0) } else { continue; } } else { - objectposition = myposition - ( dynamic->RaTranslationGet() ); //???-przesunięcie wózka względem Point1 toru - if( ( objectposition > 0 ) - && ( objectposition < distance ) ) { - Foundcoupler = ( dynamic->RaDirectionGet() > 0 ) ? 0 : 1; // odwrotnie, bo (ScanDir<0) + objectposition = myposition - dynamic->RaTranslationGet(); //???-przesunięcie wózka względem Point1 toru + if( objectposition > 0 + && objectposition < distance ) { + Foundcoupler = dynamic->RaDirectionGet() > 0 ? 0 : 1; // odwrotnie, bo (ScanDir<0) } else { continue; } } @@ -1600,7 +1593,7 @@ int TDynamicObject::DettachStatus(int dir) if( MoverParameters->Couplers[ dir ].CouplingFlag == coupling::faux ) { return 0; // jeśli nic nie podłączone, to jest OK } - return (MoverParameters->DettachStatus(dir)); // czy jest w odpowiedniej odległości? + return MoverParameters->DettachStatus(dir); // czy jest w odpowiedniej odległości? } int TDynamicObject::Dettach(int dir) @@ -1676,7 +1669,7 @@ TDynamicObject::couple( int const Side ) { if( MoverParameters->Attach( Side, neighbour.vehicle_end, othervehicleparams, - ( coupler.CouplingFlag | coupling::brakehose ) ) ) { + coupler.CouplingFlag | coupling::brakehose ) ) { SetPneumatic( Side != 0, true ); othervehicle->SetPneumatic( Side != 0, true ); // one coupling type per key press @@ -1692,7 +1685,7 @@ TDynamicObject::couple( int const Side ) { if( MoverParameters->Attach( Side, neighbour.vehicle_end, othervehicleparams, - ( coupler.CouplingFlag | coupling::mainhose ) ) ) { + coupler.CouplingFlag | coupling::mainhose ) ) { SetPneumatic( Side != 0, false ); othervehicle->SetPneumatic( Side != 0, false ); // one coupling type per key press @@ -1702,12 +1695,12 @@ TDynamicObject::couple( int const Side ) { } if( false == TestFlag( MoverParameters->Couplers[ Side ].CouplingFlag, coupling::control ) ) { // ukrotnionko - if( ( ( coupler.AllowedFlag & othercoupler.AllowedFlag & coupling::control ) == coupling::control ) - && ( coupler.control_type == othercoupler.control_type ) ) { + if( (coupler.AllowedFlag & othercoupler.AllowedFlag & coupling::control) == coupling::control + && coupler.control_type == othercoupler.control_type ) { if( MoverParameters->Attach( Side, neighbour.vehicle_end, othervehicleparams, - ( coupler.CouplingFlag | coupling::control ) ) ) { + coupler.CouplingFlag | coupling::control ) ) { // one coupling type per key press return; } @@ -1721,7 +1714,7 @@ TDynamicObject::couple( int const Side ) { if( MoverParameters->Attach( Side, neighbour.vehicle_end, othervehicleparams, - ( coupler.CouplingFlag | coupling::gangway ) ) ) { + coupler.CouplingFlag | coupling::gangway ) ) { // one coupling type per key press return; } @@ -1735,7 +1728,7 @@ TDynamicObject::couple( int const Side ) { if( MoverParameters->Attach( Side, neighbour.vehicle_end, othervehicleparams, - ( coupler.CouplingFlag | coupling::heating ) ) ) { + coupler.CouplingFlag | coupling::heating ) ) { // one coupling type per key press return; } @@ -1747,8 +1740,8 @@ TDynamicObject::couple( int const Side ) { int TDynamicObject::uncouple( int const Side ) { - if( ( DettachStatus( Side ) >= 0 ) - || ( true == TestFlag( MoverParameters->Couplers[ Side ].CouplingFlag, coupling::permanent ) ) ) { + if( DettachStatus(Side) >= 0 + || true == TestFlag(MoverParameters->Couplers[Side].CouplingFlag, coupling::permanent) ) { // can't uncouple, return existing coupling state return MoverParameters->Couplers[ Side ].CouplingFlag; } @@ -1764,8 +1757,8 @@ TDynamicObject::attach_coupler_adapter( int const Side, bool const Enforce ) { // sanity check(s) if( coupler.type() == TCouplerType::Automatic ) { return false; } auto const *neighbour { MoverParameters->Neighbours[ Side ].vehicle }; - if( ( neighbour == nullptr ) - || ( MoverParameters->Neighbours[ Side ].distance > 25.0 ) ) { + if( neighbour == nullptr + || MoverParameters->Neighbours[Side].distance > 25.0 ) { // can only acquire the adapter from a nearby enough vehicle return false; } @@ -1778,8 +1771,8 @@ TDynamicObject::attach_coupler_adapter( int const Side, bool const Enforce ) { // explicit coupler adapter definition overrides default parameters adapterdata = neighbour->m_coupleradapter; } - if( ( MoverParameters->Neighbours[ Side ].distance - adapterdata.position.x < 0.5 ) - && ( false == Enforce ) ) { + if( MoverParameters->Neighbours[Side].distance - adapterdata.position.x < 0.5 + && false == Enforce ) { // arbitrary amount of free room required to install the adapter // NOTE: this also covers cases with established physical connection return false; @@ -1899,7 +1892,7 @@ void TDynamicObject::place_on_track(TTrack *Track, double fDist, bool Reversed) axle.distance = ( Reversed ? -axle.offset : - ( axle.offset + MoverParameters->Dim.L ) ) + fDist; + axle.offset + MoverParameters->Dim.L ) + fDist; } double fAxleDistHalf = fAxleDist * 0.5; // przesuwanie pojazdu tak, aby jego początek był we wskazanym miejcu @@ -1938,7 +1931,7 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" std::string MoreParams // dodatkowe parametry wczytywane w postaci tekstowej ) { // Ustawienie początkowe pojazdu - iDirection = (Reversed ? 0 : 1); // Ra: 0, jeśli ma być wstawiony jako obrócony tyłem + iDirection = Reversed ? 0 : 1; // Ra: 0, jeśli ma być wstawiony jako obrócony tyłem asBaseDir = paths::dynamic + BaseDir + "/"; // McZapkie-310302 asName = Name; std::string asAnimName; // zmienna robocza do wyszukiwania osi i wózków @@ -1983,7 +1976,7 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" MoverParameters->AssignLoad( LoadType, Load ); MoverParameters->ComputeMass(); - bool driveractive = (fVel != 0.0); // jeśli prędkość niezerowa, to aktywujemy ruch + bool driveractive = fVel != 0.0; // jeśli prędkość niezerowa, to aktywujemy ruch if (!MoverParameters->CheckLocomotiveParameters( driveractive, (fVel > 0 ? 1 : -1) * Cab * @@ -2147,8 +2140,8 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" { } } // koniec hamulce - else if( ( ActPar.size() >= 3 ) - && ( ActPar.front() == 'W' ) ) { + else if( ActPar.size() >= 3 + && ActPar.front() == 'W' ) { // wheel ActPar.erase( 0, 1 ); @@ -2188,7 +2181,7 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" auto const indexstart { 1 }; auto const indexend { ActPar.find_first_not_of( "1234567890", indexstart ) }; auto const huntingchance { std::atoi( ActPar.substr( indexstart, indexend ).c_str() ) }; - MoverParameters->TruckHunting = ( Random( 0, 100 ) < huntingchance ); + MoverParameters->TruckHunting = Random(0, 100) < huntingchance; ActPar.erase( 0, indexend ); break; } @@ -2203,8 +2196,8 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" MoverParameters->WheelFlat += fixedflatsize + Random( 0, randomflatsize ); } } // wheel - else if( ( ActPar.size() >= 2 ) - && ( ActPar.front() == 'T' ) ) { + else if( ActPar.size() >= 2 + && ActPar.front() == 'T' ) { // temperature ActPar.erase( 0, 1 ); @@ -2230,8 +2223,8 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" MoverParameters->dizel_HeatSet( Global.AirTemperature ); } } // temperature - else if( ( ActPar.size() >= 2 ) - && ( ActPar.front() == 'L' ) ) { + else if( ActPar.size() >= 2 + && ActPar.front() == 'L' ) { // load ActPar.erase( 0, 1 ); // immediately followed by max load override @@ -2268,12 +2261,11 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" // szerszych w odległości // 1.5m auto const lanefreespace = 0.5 * Track->fTrackWidth - MoverParameters->Dim.W; - MoverParameters->OffsetTrackH = ( - lanefreespace > 1.5 ? + MoverParameters->OffsetTrackH = lanefreespace > 1.5 ? -0.5 * MoverParameters->Dim.W - 0.75 : // wide road, keep near centre with safe margin - ( lanefreespace > 0.1 ? + lanefreespace > 0.1 ? -0.25 * Track->fTrackWidth : // narrow fit, stay on the middle - -0.5 * MoverParameters->Dim.W - 0.075 ) ); // too narrow, just keep some minimal clearance + -0.5 * MoverParameters->Dim.W - 0.075; // too narrow, just keep some minimal clearance } else // jak stoi, to kołem na poboczu i pobieramy szerokość razem z // poboczem, ale nie z @@ -2347,8 +2339,8 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" iInventory[ end::front ] |= m_endsignal13.Active() ? light::redmarker_left : 0; iInventory[ end::rear ] |= m_endsignal22.Active() ? light::redmarker_right : 0; iInventory[ end::rear ] |= m_endsignal23.Active() ? light::redmarker_left : 0; - iInventory[ end::front ] |= m_endsignals1.Active() ? ( light::redmarker_left | light::redmarker_right ) : 0; - iInventory[ end::rear ] |= m_endsignals2.Active() ? ( light::redmarker_left | light::redmarker_right ) : 0; + iInventory[ end::front ] |= m_endsignals1.Active() ? light::redmarker_left | light::redmarker_right : 0; + iInventory[ end::rear ] |= m_endsignals2.Active() ? light::redmarker_left | light::redmarker_right : 0; iInventory[ end::front ] |= m_endtab1.Active() ? light::rearendsignals : 0; // tabliczki blaszane iInventory[ end::rear ] |= m_endtab2.Active() ? light::rearendsignals : 0; iInventory[ end::front ] |= m_headlamp11.Active() ? light::headlight_upper : 0; @@ -2520,8 +2512,8 @@ TDynamicObject::init_sections( TModel3d const *Model, std::string const &Namepre // section names above 10 match prefixX auto const sectionindexname { std::to_string( sectionindex ) }; sectionsubmodel = Model->GetFromName( Nameprefix + sectionindexname ); - if( ( sectionsubmodel == nullptr ) - && ( sectionindex < 10 ) ) { + if( sectionsubmodel == nullptr + && sectionindex < 10 ) { sectionsubmodel = Model->GetFromName( Nameprefix + "0" + sectionindexname ); } if( sectionsubmodel != nullptr ) { @@ -2537,8 +2529,8 @@ TDynamicObject::init_sections( TModel3d const *Model, std::string const &Namepre ++sectioncount; } ++sectionindex; - } while( ( sectionsubmodel != nullptr ) - || ( sectionindex < 2 ) ); // chain can start from prefix00 or prefix01 + } while( sectionsubmodel != nullptr + || sectionindex < 2 ); // chain can start from prefix00 or prefix01 return sectioncount; } @@ -2559,8 +2551,8 @@ TDynamicObject::create_controller( std::string const Type, bool const Trainset ) if( Type == "" ) { return; } // McZapkie-151102: rozkład jazdy czytany z pliku *.txt z katalogu w którym jest sceneria - if( ( Type == "1" ) - || ( Type == "2" ) ) { + if( Type == "1" + || Type == "2" ) { // McZapkie-110303: mechanik i rozklad tylko gdy jest obsada Mechanik = new TController( Controller, this, Aggressive ); @@ -2599,7 +2591,7 @@ void TDynamicObject::Move(double fDistance) // na tym samym torze if (MoverParameters->Vel > 2) //|[km/h]| nie ma sensu zmiana osi, jesli pojazd drga na postoju - iAxleFirst = (MoverParameters->V >= 0.0) ? + iAxleFirst = MoverParameters->V >= 0.0 ? 1 : 0; //[m/s] ?1:0 - aktywna druga oś w kierunku jazdy // aktualnie eventy aktywuje druga oś, żeby AI nie wyłączało sobie semafora @@ -2661,7 +2653,7 @@ void TDynamicObject::Move(double fDistance) vPosition.y += MoverParameters->OffsetTrackV; // te offsety są liczone przez moverparam } // obliczanie pozycji sprzęgów do liczenia zderzeń - auto dir = (0.5 * MoverParameters->Dim.L) * vFront; // wektor sprzęgu + auto dir = 0.5 * MoverParameters->Dim.L * vFront; // wektor sprzęgu vCoulpler[end::front] = vPosition + dir; // współrzędne sprzęgu na początku vCoulpler[end::rear] = vPosition - dir; // współrzędne sprzęgu na końcu // bCameraNear= @@ -2669,7 +2661,7 @@ void TDynamicObject::Move(double fDistance) { // przeliczenie cienia TTrack *t0 = Axle0.GetTrack(); // już po przesunięciu TTrack *t1 = Axle1.GetTrack(); - if ((t0->eEnvironment == e_flat) && (t1->eEnvironment == e_flat)) // może być e_bridge... + if (t0->eEnvironment == e_flat && t1->eEnvironment == e_flat) // może być e_bridge... fShade = 0.0; // standardowe oświetlenie else { // jeżeli te tory mają niestandardowy stopień zacienienia @@ -2760,7 +2752,7 @@ void TDynamicObject::AttachNext(TDynamicObject *Object, int iType) else if( coupler.type() == TCouplerType::Automatic ) { // try to attach adapter to the other vehicle Object->attach_coupler_adapter( - ( othervehicleend != 2 ? othervehicleend : coupler.ConnectedNr ), + othervehicleend != 2 ? othervehicleend : coupler.ConnectedNr, true ); } // update distance to neighbours on account of potentially attached adapter @@ -2825,7 +2817,7 @@ float TDynamicObject::LoadExchangeTime( int const Platforms ) { float TDynamicObject::LoadExchangeTime() const { - if( ( m_exchange.unload_count < 0.01 ) && ( m_exchange.load_count < 0.01 ) ) { return 0.f; } + if( m_exchange.unload_count < 0.01 && m_exchange.load_count < 0.01 ) { return 0.f; } auto const baseexchangetime { m_exchange.unload_count / MoverParameters->UnLoadSpeed + m_exchange.load_count / MoverParameters->LoadSpeed }; auto const nominalexchangespeedfactor { ( m_exchange.platforms == 3 ? 2.f : 1.f ) }; @@ -2839,13 +2831,13 @@ float TDynamicObject::LoadExchangeSpeed() const { // platforms (1:left, 2:right, 3:both) // with exchange performed on both sides waiting times are halved auto exchangespeedfactor { 0.f }; - auto const lewe { ( DirectionGet() > 0 ) ? 1 : 2 }; + auto const lewe { DirectionGet() > 0 ? 1 : 2 }; auto const prawe { 3 - lewe }; if( m_exchange.platforms & lewe ) { - exchangespeedfactor += ( MoverParameters->Doors.instances[side::left].is_open ? 1.f : 0.f ); + exchangespeedfactor += MoverParameters->Doors.instances[side::left].is_open ? 1.f : 0.f; } if( m_exchange.platforms & prawe ) { - exchangespeedfactor += ( MoverParameters->Doors.instances[ side::right ].is_open ? 1.f : 0.f ); + exchangespeedfactor += MoverParameters->Doors.instances[side::right].is_open ? 1.f : 0.f; } return exchangespeedfactor; @@ -2857,7 +2849,7 @@ void TDynamicObject::update_exchange( double const Deltatime ) { // TODO: move offset calculation after initial check, when the loading system is all unified update_load_offset(); - if( ( m_exchange.unload_count < 0.01 ) && ( m_exchange.load_count < 0.01 ) ) { return; } + if( m_exchange.unload_count < 0.01 && m_exchange.load_count < 0.01 ) { return; } if( MoverParameters->Vel < 2.0 ) { @@ -2865,19 +2857,15 @@ void TDynamicObject::update_exchange( double const Deltatime ) { if( exchangespeed < ( m_exchange.platforms == 3 ? 2.f : 1.f ) ) { // the exchange isn't performed at optimal rate, or at all. try to open viable vehicle doors to speed it up - auto const lewe { ( DirectionGet() > 0 ) ? 1 : 2 }; + auto const lewe { DirectionGet() > 0 ? 1 : 2 }; auto const prawe { 3 - lewe }; - if( ( m_exchange.platforms & lewe ) - && ( false == ( - MoverParameters->Doors.instances[side::left].is_open - || MoverParameters->Doors.instances[side::left].is_opening ) ) ) { + if( m_exchange.platforms & lewe + && false == (MoverParameters->Doors.instances[side::left].is_open || MoverParameters->Doors.instances[side::left].is_opening) ) { // try to open left door MoverParameters->OperateDoors( side::left, true, range_t::local ); } - if( ( m_exchange.platforms & prawe ) - && ( false == ( - MoverParameters->Doors.instances[side::right].is_open - || MoverParameters->Doors.instances[side::right].is_opening ) ) ) { + if( m_exchange.platforms & prawe + && false == (MoverParameters->Doors.instances[side::right].is_open || MoverParameters->Doors.instances[side::right].is_opening) ) { // try to open right door MoverParameters->OperateDoors( side::right, true, range_t::local ); } @@ -2886,8 +2874,8 @@ void TDynamicObject::update_exchange( double const Deltatime ) { if( exchangespeed > 0.f ) { m_exchange.time += Deltatime; - while( ( m_exchange.unload_count > 0.01 ) - && ( m_exchange.time >= 1.0 ) ) { + while( m_exchange.unload_count > 0.01 + && m_exchange.time >= 1.0 ) { m_exchange.time -= 1.0; auto const exchangesize = std::min( m_exchange.unload_count, MoverParameters->UnLoadSpeed * exchangespeed ); @@ -2901,8 +2889,8 @@ void TDynamicObject::update_exchange( double const Deltatime ) { // finish any potential unloading operation before adding new load // don't load more than can fit m_exchange.load_count = std::min( m_exchange.load_count, MoverParameters->MaxLoad - MoverParameters->LoadAmount ); - while( ( m_exchange.load_count > 0.01 ) - && ( m_exchange.time >= 1.0 ) ) { + while( m_exchange.load_count > 0.01 + && m_exchange.time >= 1.0 ) { m_exchange.time -= 1.0; auto const exchangesize = std::min( m_exchange.load_count, MoverParameters->LoadSpeed * exchangespeed ); @@ -2922,20 +2910,18 @@ void TDynamicObject::update_exchange( double const Deltatime ) { m_exchange.load_count = 0; } - if( ( m_exchange.unload_count < 0.01 ) - && ( m_exchange.load_count < 0.01 ) ) { + if( m_exchange.unload_count < 0.01 + && m_exchange.load_count < 0.01 ) { MoverParameters->LoadStatus = 4; // if the exchange is completed (or canceled) close the door, if applicable - if( ( MoverParameters->Doors.close_control == control_t::passenger ) - || ( MoverParameters->Doors.close_control == control_t::mixed ) ) { + if( MoverParameters->Doors.close_control == control_t::passenger + || MoverParameters->Doors.close_control == control_t::mixed ) { - if( ( MoverParameters->Vel > 2.0 ) - || ( Random() < ( - // remotely controlled door are more likely to be left open - MoverParameters->Doors.close_control == control_t::passenger ? - 0.75 : - 0.50 ) ) ) { + if( MoverParameters->Vel > 2.0 + || Random() < ( + // remotely controlled door are more likely to be left open + MoverParameters->Doors.close_control == control_t::passenger ? 0.75 : 0.50) ) { MoverParameters->OperateDoors( side::left, false, range_t::local ); MoverParameters->OperateDoors( side::right, false, range_t::local ); @@ -2950,7 +2936,7 @@ void TDynamicObject::update_exchange( double const Deltatime ) { void TDynamicObject::LoadUpdate() { - MoverParameters->LoadStatus &= ( 1 | 2 ); // po zakończeniu będzie równe zero + MoverParameters->LoadStatus &= 1 | 2; // po zakończeniu będzie równe zero // przeładowanie modelu ładunku if( MoverParameters->LoadTypeChange ) { // whether we succeed or not don't try more than once @@ -3039,9 +3025,7 @@ TDynamicObject::shuffle_load_order() { std::stable_partition( std::begin( SectionLoadOrder ), std::end( SectionLoadOrder ), []( vehicle_section const *section ) { - return ( - ( section->compartment->pName.find( "compartment" ) == 0 ) - || ( section->compartment->pName.find( "przedzial" ) == 0 ) ); } ); + return section->compartment->pName.find("compartment") == 0 || section->compartment->pName.find("przedzial") == 0; } ); // NOTE: potentially we're left with a mix of corridor and external section loads // but that's not necessarily a wrong outcome, so we leave it this way for the time being } @@ -3063,21 +3047,16 @@ void TDynamicObject::update_destinations() { auto const lowvoltagepower { ( MoverParameters->Power24vIsAvailable || MoverParameters->Power110vIsAvailable ) }; - DestinationSign.sign->fLight = ( - ( ( DestinationSign.has_light ) && ( lowvoltagepower ) ) ? - 2.0 : - -1.0 ); + DestinationSign.sign->fLight = DestinationSign.has_light && lowvoltagepower ? 2.0 : -1.0; // jak są 4 tekstury wymienne, to nie zmieniać rozkładem if( std::abs( m_materialdata.multi_textures ) >= 4 ) { return; } // TODO: dedicated setting to discern electronic signs, instead of fallback on light presence - m_materialdata.replacable_skins[ 4 ] = ( - ( ( DestinationSign.destination != null_handle ) - && ( ( false == DestinationSign.has_light ) // physical destination signs remain up until manually changed - || ( ( lowvoltagepower ) // lcd signs are off without power - && ( ctOwner != nullptr ) ) ) ) ? // lcd signs are off for carriages without engine, potentially left on a siding - DestinationSign.destination : - DestinationSign.destination_off ); + m_materialdata.replacable_skins[ 4 ] = DestinationSign.destination != null_handle && (false == DestinationSign.has_light // physical destination signs remain up until manually changed + || (lowvoltagepower // lcd signs are off without power + && ctOwner != nullptr)) ? // lcd signs are off for carriages without engine, potentially left on a siding + DestinationSign.destination : + DestinationSign.destination_off; } bool TDynamicObject::Update(double dt, double dt1) @@ -3097,7 +3076,7 @@ bool TDynamicObject::Update(double dt, double dt1) if (Axle0.vAngles.z != Axle1.vAngles.z) { // wyliczenie promienia z obrotów osi - modyfikację zgłosił youBy ts.R = Axle0.vAngles.z - Axle1.vAngles.z; // różnica może dawać stałą ±M_2PI - if( ( ts.R > 15000.0 ) || ( ts.R < -15000.0 ) ) { + if( ts.R > 15000.0 || ts.R < -15000.0 ) { // szkoda czasu na zbyt duże promienie, 4km to promień nie wymagający przechyłki ts.R = 0.0; } @@ -3131,8 +3110,8 @@ bool TDynamicObject::Update(double dt, double dt1) tp.QualityFlag = MyTrack->iQualityFlag; // couplers - if( ( MoverParameters->Couplers[ 0 ].CouplingFlag != coupling::faux ) - && ( MoverParameters->Couplers[ 1 ].CouplingFlag != coupling::faux ) ) { + if( MoverParameters->Couplers[0].CouplingFlag != coupling::faux + && MoverParameters->Couplers[1].CouplingFlag != coupling::faux ) { MoverParameters->InsideConsist = true; } else { @@ -3166,8 +3145,8 @@ bool TDynamicObject::Update(double dt, double dt1) // Ra 2014-07: doraźna blokada logowania zimnych lokomotyw - zrobić to trzeba inaczej if( MoverParameters->Pantographs[end::front].is_active || MoverParameters->Pantographs[end::rear].is_active ) { - if( ( MoverParameters->Mains ) // Ra 15-01: logować tylko, jeśli WS załączony - && ( MoverParameters->GetTrainsetHighVoltage() < 0.1f ) ) { // yB 16-03: i nie jest to asynchron zasilany z daleka + if( MoverParameters->Mains // Ra 15-01: logować tylko, jeśli WS załączony + && MoverParameters->GetTrainsetHighVoltage() < 0.1f ) { // yB 16-03: i nie jest to asynchron zasilany z daleka // Ra 15-01: bezwzględne współrzędne pantografu nie są dostępne więc lepiej się tego nie zaloguje ErrorLog( "Bad traction: " + MoverParameters->Name @@ -3196,20 +3175,20 @@ bool TDynamicObject::Update(double dt, double dt1) if( Mechanik->primary() ) { MoverParameters->EqvtPipePress = GetEPP(); // srednie cisnienie w PG } - if ((Mechanik->primary()) && - ((MoverParameters->EngineType == TEngineType::DieselEngine) || - (MoverParameters->EngineType == TEngineType::DieselElectric)) - && (MoverParameters->EIMCtrlType > 0)) { + if (Mechanik->primary() && + (MoverParameters->EngineType == TEngineType::DieselEngine || + MoverParameters->EngineType == TEngineType::DieselElectric) + && MoverParameters->EIMCtrlType > 0) { MoverParameters->CheckEIMIC(dt1); if (MoverParameters->SpeedCtrl) MoverParameters->CheckSpeedCtrl(dt1); MoverParameters->eimic_real = std::min(MoverParameters->eimic,MoverParameters->eimicSpeedCtrl); MoverParameters->SendCtrlToNext("EIMIC", MoverParameters->eimic_real, MoverParameters->CabActive); } - if( ( Mechanik->primary() ) - && ( MoverParameters->EngineType == TEngineType::ElectricInductionMotor ) ) { + if( Mechanik->primary() + && MoverParameters->EngineType == TEngineType::ElectricInductionMotor ) { // jesli glowny i z asynchronami, to niech steruje hamulcem i napedem lacznie dla calego pociagu/ezt - auto const kier = (DirectionGet() * MoverParameters->CabOccupied > 0); + auto const kier = DirectionGet() * MoverParameters->CabOccupied > 0; auto FED { 0.0 }; auto np { 0 }; auto masa { 0.0 }; @@ -3221,8 +3200,8 @@ bool TDynamicObject::Update(double dt, double dt1) auto Frj { 0.0 }; auto osie { 0 }; // 0a. ustal aktualna nastawe zadania sily napedowej i hamowania - if( ( MoverParameters->Power < 1 ) - && ( ctOwner != nullptr ) ) { + if( MoverParameters->Power < 1 + && ctOwner != nullptr ) { MoverParameters->MainCtrlPos = ctOwner->Controlling()->MainCtrlPos*MoverParameters->MainCtrlPosNo / std::max(1, ctOwner->Controlling()->MainCtrlPosNo); MoverParameters->SpeedCtrlValue = ctOwner->Controlling()->SpeedCtrlValue; MoverParameters->SpeedCtrlUnit.IsActive = ctOwner->Controlling()->SpeedCtrlUnit.IsActive; @@ -3236,7 +3215,7 @@ bool TDynamicObject::Update(double dt, double dt1) eimic = -1.0; MoverParameters->SendCtrlToNext("EIMIC", std::max(0., eimic), MoverParameters->CabActive); auto LBR = std::max(-eimic, 0.); - auto eim_lb = (Mechanik->AIControllFlag || !MoverParameters->LocHandleTimeTraxx ? 0 : MoverParameters->eim_localbrake); + auto eim_lb = Mechanik->AIControllFlag || !MoverParameters->LocHandleTimeTraxx ? 0 : MoverParameters->eim_localbrake; // 1. ustal wymagana sile hamowania calego pociagu // - opoznienie moze byc ustalane na podstawie charakterystyki @@ -3246,7 +3225,7 @@ bool TDynamicObject::Update(double dt, double dt1) // 2. ustal mozliwa do realizacji sile hamowania ED // - w szczegolnosci powinien brac pod uwage rozne sily hamowania for (TDynamicObject *p = GetFirstDynamic(MoverParameters->CabOccupied < 0 ? 1 : 0, 4); p; - (kier ? p = p->Next(4) : p = p->Prev(4))) + kier ? p = p->Next(4) : p = p->Prev(4)) { ++np; masamax += @@ -3264,12 +3243,10 @@ bool TDynamicObject::Update(double dt, double dt1) Nmax / (p->MoverParameters->NAxles * p->MoverParameters->NBpA), p->MoverParameters->MED_Vref) * 1000; // sila hamowania pn - FmaxED += ((p->MoverParameters->Mains) && (p->MoverParameters->DirActive != 0) && - (p->MoverParameters->InvertersRatio == 1.0) && - (p->MoverParameters->eimc[eimc_p_Fh] * p->MoverParameters->NPoweredAxles > - 0) ? - p->MoverParameters->eimc[eimc_p_Fh] * 1000 : - 0); // chwilowy max ED -> do rozdzialu sil + FmaxED += p->MoverParameters->Mains && p->MoverParameters->DirActive != 0 && p->MoverParameters->InvertersRatio == 1.0 && + p->MoverParameters->eimc[eimc_p_Fh] * p->MoverParameters->NPoweredAxles > 0 ? + p->MoverParameters->eimc[eimc_p_Fh] * 1000 : + 0; // chwilowy max ED -> do rozdzialu sil FED -= std::min(p->MoverParameters->eimv[eimv_Fmax], 0.0) * 1000; // chwilowy max ED -> do rozdzialu sil FfulED = std::min(p->MoverParameters->eimv[eimv_Fful], 0.0) * @@ -3282,53 +3259,53 @@ bool TDynamicObject::Update(double dt, double dt1) osie += p->MoverParameters->NAxles; } double RapidMult = 1.0; - if (((MoverParameters->BrakeDelays & (bdelay_P + bdelay_R)) == (bdelay_P + bdelay_R)) - && (MoverParameters->BrakeDelayFlag & bdelay_P)) + if ((MoverParameters->BrakeDelays & bdelay_P + bdelay_R) == bdelay_P + bdelay_R + && MoverParameters->BrakeDelayFlag & bdelay_P) RapidMult = MoverParameters->RapidMult; auto const amax = RapidMult * std::min(FmaxPN / masamax, MoverParameters->MED_amax); Mechanik->fMedAmax = amax; auto doorisopen { - ( false == MoverParameters->Doors.instances[ side::left ].is_closed ) - || ( false == MoverParameters->Doors.instances[ side::right ].is_closed ) + false == MoverParameters->Doors.instances[side::left].is_closed + || false == MoverParameters->Doors.instances[side::right].is_closed || ( MoverParameters->Doors.permit_needed && ( MoverParameters->Doors.instances[ side::left ].open_permit || MoverParameters->Doors.instances[ side::right ].open_permit ) ) }; doorisopen &= !(MoverParameters->ReleaseParkingBySpringBrakeWhenDoorIsOpen && MoverParameters->SpringBrake.IsActive); - if ((MoverParameters->Vel < 0.5) && (eimic < 0 || doorisopen || MoverParameters->Hamulec->GetEDBCP())) + if (MoverParameters->Vel < 0.5 && (eimic < 0 || doorisopen || MoverParameters->Hamulec->GetEDBCP())) { MoverParameters->ShuntMode = true; } if (MoverParameters->ShuntMode) { - MoverParameters->ShuntModeAllow = ( false == doorisopen ) && - (LBR < 0.01); + MoverParameters->ShuntModeAllow = false == doorisopen && + LBR < 0.01; } - if( ( MoverParameters->Vel > 1 ) && ( false == doorisopen ) ) + if( MoverParameters->Vel > 1 && false == doorisopen ) { MoverParameters->ShuntMode = false; - MoverParameters->ShuntModeAllow = (MoverParameters->BrakePress > 0.2) && - (LBR < 0.01); + MoverParameters->ShuntModeAllow = MoverParameters->BrakePress > 0.2 && + LBR < 0.01; } auto Fzad = amax * LBR * masa; - if (((MoverParameters->BrakeCtrlPos == MoverParameters->Handle->GetPos(bh_EB)) - && (MoverParameters->eimc[eimc_p_abed] < 0.001)) || - (MoverParameters->EmergencyValveFlow > 0)) + if ((MoverParameters->BrakeCtrlPos == MoverParameters->Handle->GetPos(bh_EB) + && MoverParameters->eimc[eimc_p_abed] < 0.001) || + MoverParameters->EmergencyValveFlow > 0) Fzad = amax * masa; //pętla bezpieczeństwa - pełne służbowe - if ((MoverParameters->ScndS) && - (MoverParameters->Vel > MoverParameters->eimc[eimc_p_Vh1]) && (FmaxED > 0)) + if (MoverParameters->ScndS && + MoverParameters->Vel > MoverParameters->eimc[eimc_p_Vh1] && FmaxED > 0) { Fzad = std::min(LBR * FmaxED, FfulED); } - if (((MoverParameters->ShuntMode) && (eimic <= 0) || (doorisopen)) /*|| + if (MoverParameters->ShuntMode && eimic <= 0 || doorisopen /*|| (MoverParameters->V * MoverParameters->DirAbsolute < -0.2)*/) { - auto const sbd { ( ( MoverParameters->SpringBrake.IsActive && MoverParameters->ReleaseParkingBySpringBrake ) ? 0.0 : MoverParameters->StopBrakeDecc ) }; + auto const sbd { ( MoverParameters->SpringBrake.IsActive && MoverParameters->ReleaseParkingBySpringBrake ? 0.0 : MoverParameters->StopBrakeDecc ) }; Fzad = std::max( Fzad, sbd * masa ); } - if ((Fzad > 1) && (!MEDLogFile.is_open()) && (MoverParameters->Vel > 1)) + if (Fzad > 1 && !MEDLogFile.is_open() && MoverParameters->Vel > 1) { MEDLogFile.open( "MEDLOGS/" + MoverParameters->Name + "_" + std::to_string( ++MEDLogCount ) + ".csv", @@ -3344,9 +3321,9 @@ bool TDynamicObject::Update(double dt, double dt1) MEDLogTime = 0; } auto FzadED { 0.0 }; - if( ( LBR > MoverParameters->MED_MinBrakeReqED ) + if( LBR > MoverParameters->MED_MinBrakeReqED && ( MoverParameters->BrakeHandle == TBrakeHandle::MHZ_EN57 ? - ( ( MoverParameters->BrakeOpModeFlag & bom_MED ) != 0 ) : + (MoverParameters->BrakeOpModeFlag & bom_MED) != 0 : MoverParameters->EpFuse ) ) { FzadED = std::min( Fzad, FmaxED ); } @@ -3370,13 +3347,11 @@ bool TDynamicObject::Update(double dt, double dt1) else { FzadED = std::min(FzadED, MED_oldFED); - MoverParameters->MED_ED_DelayTimer = (FrED > 0 ? - -MoverParameters->MED_ED_Delay2 : - -MoverParameters->MED_ED_Delay1); + MoverParameters->MED_ED_DelayTimer = FrED > 0 ? -MoverParameters->MED_ED_Delay2 : -MoverParameters->MED_ED_Delay1; } } - if ((MoverParameters->BrakeCtrlPos == MoverParameters->Handle->GetPos(bh_EB)) - && (MoverParameters->eimc[eimc_p_abed] < 0.001)) + if (MoverParameters->BrakeCtrlPos == MoverParameters->Handle->GetPos(bh_EB) + && MoverParameters->eimc[eimc_p_abed] < 0.001) FzadED = 0; //pętla bezpieczeństwa - bez ED auto const FzadPN = Fzad - FrED * MoverParameters->MED_FrED_factor; //np = 0; @@ -3403,7 +3378,7 @@ bool TDynamicObject::Update(double dt, double dt1) // 1. najpierw daj kazdemu tyle samo int i = 0; for (TDynamicObject *p = GetFirstDynamic(MoverParameters->CabOccupied < 0 ? 1 : 0, 4); p; - p = (kier == true ? p->Next(4) : p->Prev(4)) ) + p = kier == true ? p->Next(4) : p->Prev(4) ) { auto const Nmax = ((p->MoverParameters->P2FTrans * p->MoverParameters->MaxBrakePress[0] - p->MoverParameters->BrakeCylSpring) * @@ -3417,9 +3392,9 @@ bool TDynamicObject::Update(double dt, double dt1) 1000; // sila hamowania pn PrzekrF[i] = false; - FzED[i] = (FmaxED > 0 ? FzadED / FmaxED : 0); + FzED[i] = FmaxED > 0 ? FzadED / FmaxED : 0; p->MoverParameters->AnPos = - (MoverParameters->ScndS ? LBR : FzED[i]); + MoverParameters->ScndS ? LBR : FzED[i]; FzEP[ i ] = static_cast( FzadPN * p->MoverParameters->NAxles ) / static_cast( osie ); ++i; p->MoverParameters->ShuntMode = MoverParameters->ShuntMode; @@ -3431,13 +3406,11 @@ bool TDynamicObject::Update(double dt, double dt1) i = 0; float przek = 0; for (TDynamicObject *p = GetFirstDynamic(MoverParameters->CabOccupied < 0 ? 1 : 0, 4); p; - p = (kier == true ? p->Next(4) : p->Prev(4)) ) + p = kier == true ? p->Next(4) : p->Prev(4) ) { - if ((FzEP[i] > 0.01) && - (FzEP[i] > - p->MoverParameters->TotalMass * p->MoverParameters->eimc[eimc_p_eped] + - std::min(p->MoverParameters->eimv[eimv_Fmax], 0.) * 1000) && - (!PrzekrF[i])) + if (FzEP[i] > 0.01 && + FzEP[i] > p->MoverParameters->TotalMass * p->MoverParameters->eimc[eimc_p_eped] + std::min(p->MoverParameters->eimv[eimv_Fmax], 0.) * 1000 && + !PrzekrF[i]) { float przek1 = -std::min(p->MoverParameters->eimv[eimv_Fmax], 0.) * 1000 + FzEP[i] - @@ -3457,7 +3430,7 @@ bool TDynamicObject::Update(double dt, double dt1) i = 0; przek = przek / (np - nPrzekrF); for (TDynamicObject *p = GetFirstDynamic(MoverParameters->CabOccupied < 0 ? 1 : 0, 4); p; - (true == kier ? p = p->Next(4) : p = p->Prev(4))) + true == kier ? p = p->Next(4) : p = p->Prev(4)) { if (!PrzekrF[i]) { @@ -3468,7 +3441,7 @@ bool TDynamicObject::Update(double dt, double dt1) } i = 0; for (TDynamicObject *p = GetFirstDynamic(MoverParameters->CabOccupied < 0 ? 1 : 0, 4); p; - (true == kier ? p = p->Next(4) : p = p->Prev(4))) + true == kier ? p = p->Next(4) : p = p->Prev(4)) { float Nmax = ((p->MoverParameters->P2FTrans * p->MoverParameters->MaxBrakePress[0] - p->MoverParameters->BrakeCylSpring) * @@ -3479,8 +3452,8 @@ bool TDynamicObject::Update(double dt, double dt1) p->MoverParameters->MED_EPVC_CurrentTime = 0; else p->MoverParameters->MED_EPVC_CurrentTime += dt1; - bool EPVC = ((p->MoverParameters->MED_EPVC) && ((p->MoverParameters->MED_EPVC_Time < 0) || (p->MoverParameters->MED_EPVC_CurrentTime < p->MoverParameters->MED_EPVC_Time))); - float VelC = (EPVC ? std::clamp(p->MoverParameters->Vel, p->MoverParameters->MED_Vmin, p->MoverParameters->MED_Vmax) : p->MoverParameters->MED_Vref);//korekcja EP po prędkości + bool EPVC = p->MoverParameters->MED_EPVC && (p->MoverParameters->MED_EPVC_Time < 0 || p->MoverParameters->MED_EPVC_CurrentTime < p->MoverParameters->MED_EPVC_Time); + float VelC = EPVC ? std::clamp(p->MoverParameters->Vel, p->MoverParameters->MED_Vmin, p->MoverParameters->MED_Vmax) : p->MoverParameters->MED_Vref;//korekcja EP po prędkości float FmaxPoj = Nmax * p->MoverParameters->Hamulec->GetFC( Nmax / (p->MoverParameters->NAxles * p->MoverParameters->NBpA), VelC) * @@ -3521,7 +3494,7 @@ bool TDynamicObject::Update(double dt, double dt1) MEDLogFile << MEDLogTime << "\t" << MoverParameters->Vel << "\t" << masa*0.001 << "\t" << osie << "\t" << FmaxPN*0.001 << "\t" << FmaxED*0.001 << "\t" << FfulED*0.001 << "\t" << FrED*0.001 << "\t" << Fzad*0.001 << "\t" << FzadED*0.001 << "\t" << FzadPN*0.001; for (TDynamicObject *p = GetFirstDynamic(MoverParameters->CabOccupied < 0 ? 1 : 0, 4); p; - (true == kier ? p = p->Next(4) : p = p->Prev(4))) + true == kier ? p = p->Next(4) : p = p->Prev(4)) { MEDLogFile << "\t" << p->MoverParameters->BrakePress; } @@ -3532,7 +3505,7 @@ bool TDynamicObject::Update(double dt, double dt1) } MEDLogTime += dt1; - if ((MoverParameters->Vel < 0.1) || (MoverParameters->MainCtrlPowerPos() > 0)) + if (MoverParameters->Vel < 0.1 || MoverParameters->MainCtrlPowerPos() > 0) { MEDLogInactiveTime += dt1; } @@ -3561,14 +3534,14 @@ bool TDynamicObject::Update(double dt, double dt1) // fragment "z EXE Kursa" if( MoverParameters->Mains ) { // nie wchodzić w funkcję bez potrzeby - if( ( false == ( MoverParameters->Power24vIsAvailable || MoverParameters->Power110vIsAvailable ) ) + if( false == (MoverParameters->Power24vIsAvailable || MoverParameters->Power110vIsAvailable) /* // NOTE: disabled on account of multi-unit setups, where the unmanned unit wouldn't be affected && ( Controller == Humandriver ) */ - && ( MoverParameters->EngineType != TEngineType::DieselEngine ) - && ( MoverParameters->EngineType != TEngineType::WheelsDriven ) ) { // jeśli bateria wyłączona, a nie diesel ani drezyna reczna - if( MoverParameters->MainSwitch( false, ( MoverParameters->TrainType == dt_EZT ? range_t::unit : range_t::local ) ) ) { + && MoverParameters->EngineType != TEngineType::DieselEngine + && MoverParameters->EngineType != TEngineType::WheelsDriven ) { // jeśli bateria wyłączona, a nie diesel ani drezyna reczna + if( MoverParameters->MainSwitch( false, MoverParameters->TrainType == dt_EZT ? range_t::unit : range_t::local ) ) { // wyłączyć zasilanie // NOTE: we turn off entire EMU, but only the affected unit for other multi-unit consists MoverParameters->EventFlag = true; @@ -3601,8 +3574,8 @@ bool TDynamicObject::Update(double dt, double dt1) // dodanie aktualnego przemieszczenia Mechanik->MoveDistanceAdd( dDOMoveLen ); } - if( ( simulation::Train != nullptr ) - && ( simulation::Train->Dynamic() == this ) ) { + if( simulation::Train != nullptr + && simulation::Train->Dynamic() == this ) { // update distance meter in user-controlled cab // TBD: place the meter on mover logic level? simulation::Train->add_distance( dDOMoveLen ); @@ -3658,20 +3631,15 @@ bool TDynamicObject::Update(double dt, double dt1) auto const directioninconsist { ( ctOwner == nullptr ? 1 : - ( ctOwner->Vehicle()->DirectionGet() == DirectionGet() ? - 1 : - -1 ) ) }; + ctOwner->Vehicle()->DirectionGet() == DirectionGet() ? 1 : -1 ) }; for( auto &axle : m_axlesounds ) { axle.distance += dDOMoveLen * directioninconsist; - if( ( axle.distance < 0 ) - || ( axle.distance > dRailLength ) ) { + if( axle.distance < 0 + || axle.distance > dRailLength ) { axle.distance = clamp_circular( axle.distance, dRailLength ); if( MoverParameters->Vel > 0.1 ) { // NOTE: for combined clatter sound we supply 1/100th of actual value, as the sound module converts does the opposite, converting received (typically) 0-1 values to 0-100 range - auto const frequency = ( - true == axle.clatter.is_combined() ? - MoverParameters->Vel * 0.01 : - 1.0 ); + auto const frequency = true == axle.clatter.is_combined() ? MoverParameters->Vel * 0.01 : 1.0; axle.clatter .pitch( frequency ) .gain( volume ) @@ -3681,7 +3649,7 @@ bool TDynamicObject::Update(double dt, double dt1) // MoverParameters->AccVert += (MoverParameters->Vel*0.1f) * static double minV, maxV; std::tie(minV, maxV) = std::minmax(MoverParameters->Vmax, MoverParameters->Vmax - (MoverParameters->Vel + MoverParameters->Vmax * 0.32f)); - double precalculatedValue = (std::clamp(0.0, minV, maxV)) * .05f * (MyTrack->iDamageFlag * 0.25f); + double precalculatedValue = std::clamp(0.0, minV, maxV) * .05f * (MyTrack->iDamageFlag * 0.25f); if (MyTrack->eType == tt_Normal) { std::tie(minV, maxV) = std::minmax(4.0, precalculatedValue); @@ -3690,7 +3658,7 @@ bool TDynamicObject::Update(double dt, double dt1) else if (MyTrack->eType == tt_Switch) { std::tie(minV, maxV) = std::minmax(1.0, precalculatedValue); - double accHorizontal = std::clamp(0.0, minV, maxV) * ((axleindex % 2) != 0 ? 1 : -1); + double accHorizontal = std::clamp(0.0, minV, maxV) * (axleindex % 2 != 0 ? 1 : -1); MoverParameters->AccS += accHorizontal; MoverParameters->AccN += accHorizontal; std::tie(minV, maxV) = std::minmax(2.0, precalculatedValue); @@ -3748,7 +3716,7 @@ bool TDynamicObject::Update(double dt, double dt1) double PantDiff; TAnimPant *p; // wskaźnik do obiektu danych pantografu double fCurrent = ( - ( MoverParameters->DynamicBrakeFlag && MoverParameters->ResistorsFlag ) ? + MoverParameters->DynamicBrakeFlag && MoverParameters->ResistorsFlag ? 0 : std::abs( MoverParameters->Itot ) * MoverParameters->IsVehicleEIMBrakingFactor() ) + MoverParameters->TotalCurrent; // prąd pobierany przez pojazd - bez sensu z tym (TotalCurrent) @@ -3774,9 +3742,9 @@ bool TDynamicObject::Update(double dt, double dt1) } } else { - if( ( pantograph->hvPowerWire != nullptr ) - && ( true == MoverParameters->Pantographs[ end::front ].is_active ) - && ( pantograph->PantTraction - pantograph->PantWys < 0.01 ) ) { // tolerancja niedolegania + if( pantograph->hvPowerWire != nullptr + && true == MoverParameters->Pantographs[end::front].is_active + && pantograph->PantTraction - pantograph->PantWys < 0.01 ) { // tolerancja niedolegania ++activepantographs; } } @@ -3806,16 +3774,16 @@ bool TDynamicObject::Update(double dt, double dt1) switch (i) // numer pantografu { // trzeba usunąć to rozróżnienie case 0: - if( ( Global.bLiveTraction == false ) - && ( p->hvPowerWire == nullptr ) ) { + if (Global.bLiveTraction == false + && p->hvPowerWire == nullptr ) { // jeśli nie ma drutu, może pooszukiwać MoverParameters->PantFrontVolt = - ( p->PantWys >= 1.2 ) ? + p->PantWys >= 1.2 ? 0.95 * MoverParameters->EnginePowerSource.MaxVoltage : 0.0; } - else if( ( true == MoverParameters->Pantographs[ end::front ].is_active ) - && ( PantDiff < 0.01 ) ) // tolerancja niedolegania + else if( true == MoverParameters->Pantographs[end::front].is_active + && PantDiff < 0.01 ) // tolerancja niedolegania { if (p->hvPowerWire) { auto const lastvoltage { MoverParameters->PantFrontVolt }; @@ -3831,8 +3799,8 @@ bool TDynamicObject::Update(double dt, double dt1) } } // TODO: refactor reaction to voltage change to mover as sound event for specific pantograph - if( ( lastvoltage == 0.0 ) - && ( MoverParameters->PantFrontVolt > 0.0 ) ) { + if( lastvoltage == 0.0 + && MoverParameters->PantFrontVolt > 0.0 ) { for( auto &pantograph : m_pantographsounds ) { if( pantograph.sPantUp.offset().z > 0 ) { // limit to pantographs located in the front half of the vehicle @@ -3846,19 +3814,19 @@ bool TDynamicObject::Update(double dt, double dt1) } else MoverParameters->PantFrontVolt = 0.0; - ( ( fPantCurrent > 0.0 ) ? MoverParameters->EnergyMeter.first : MoverParameters->EnergyMeter.second ) += MoverParameters->PantRearVolt * fPantCurrent * dt1 / 3600000.0; + ( fPantCurrent > 0.0 ? MoverParameters->EnergyMeter.first : MoverParameters->EnergyMeter.second ) += MoverParameters->PantRearVolt * fPantCurrent * dt1 / 3600000.0; break; case 1: - if( ( false == Global.bLiveTraction ) - && ( nullptr == p->hvPowerWire ) ) { + if( false == Global.bLiveTraction + && nullptr == p->hvPowerWire ) { // jeśli nie ma drutu, może pooszukiwać MoverParameters->PantRearVolt = - ( p->PantWys >= 1.2 ) ? + p->PantWys >= 1.2 ? 0.95 * MoverParameters->EnginePowerSource.MaxVoltage : 0.0; } - else if ( ( true == MoverParameters->Pantographs[ end::rear ].is_active ) - && ( PantDiff < 0.01 ) ) + else if ( true == MoverParameters->Pantographs[end::rear].is_active + && PantDiff < 0.01 ) { if (p->hvPowerWire) { auto const lastvoltage { MoverParameters->PantRearVolt }; @@ -3874,8 +3842,8 @@ bool TDynamicObject::Update(double dt, double dt1) } } // TODO: refactor reaction to voltage change to mover as sound event for specific pantograph - if( ( lastvoltage == 0.0 ) - && ( MoverParameters->PantRearVolt > 0.0 ) ) { + if( lastvoltage == 0.0 + && MoverParameters->PantRearVolt > 0.0 ) { for( auto &pantograph : m_pantographsounds ) { if( pantograph.sPantUp.offset().z < 0 ) { // limit to pantographs located in the rear half of the vehicle @@ -3891,7 +3859,7 @@ bool TDynamicObject::Update(double dt, double dt1) // Global.iPause ^= 2; MoverParameters->PantRearVolt = 0.0; } - ( ( fPantCurrent > 0.0 ) ? MoverParameters->EnergyMeter.first : MoverParameters->EnergyMeter.second ) += MoverParameters->PantFrontVolt * fPantCurrent * dt1 / 3600000.0; + ( fPantCurrent > 0.0 ? MoverParameters->EnergyMeter.first : MoverParameters->EnergyMeter.second ) += MoverParameters->PantFrontVolt * fPantCurrent * dt1 / 3600000.0; break; } // pozostałe na razie nie obsługiwane if( MoverParameters->PantPress > ( @@ -3900,7 +3868,7 @@ bool TDynamicObject::Update(double dt, double dt1) 3.45 ) ) { // z EXE Kursa // Ra: wysokość zależy od ciśnienia !!! - pantspeedfactor = 0.015 * ( MoverParameters->PantPress ) * dt1; + pantspeedfactor = 0.015 * MoverParameters->PantPress * dt1; } else { pantspeedfactor = 0.0; @@ -3910,8 +3878,8 @@ bool TDynamicObject::Update(double dt, double dt1) } pantspeedfactor = std::max( 0.0, pantspeedfactor ); k = p->fAngleL; - if( ( pantspeedfactor > 0.0 ) - && ( MoverParameters->Pantographs[i].is_active ) )// jeśli ma być podniesiony + if( pantspeedfactor > 0.0 + && MoverParameters->Pantographs[i].is_active )// jeśli ma być podniesiony { if (PantDiff > 0.001) // jeśli nie dolega do drutu { // jeśli poprzednia wysokość jest mniejsza niż pożądana, zwiększyć kąt dolnego @@ -4088,12 +4056,12 @@ bool TDynamicObject::Update(double dt, double dt1) // rozroznienie kabinowe if (MoverParameters->CabActive == 1) { - wipersActive = ((bytesum & (1 << i)) != 0) && MoverParameters->Battery; + wipersActive = (bytesum & 1 << i) != 0 && MoverParameters->Battery; } else if (MoverParameters->CabActive == -1) { // odwroconie indexow wycieraczek - wipersActive = ((bytesum & (1 << dWiperPos.size() - 1 - i)) != 0) && MoverParameters->Battery; + wipersActive = (bytesum & 1 << dWiperPos.size() - 1 - i) != 0 && MoverParameters->Battery; } else { wipersActive = false; @@ -4108,7 +4076,7 @@ bool TDynamicObject::Update(double dt, double dt1) { if (dWiperPos[i] > 0.0 && !wipersActive) // bezwzgledny powrot do zera { - dWiperPos[i] = std::max(0.0, dWiperPos[i] - (1.f / currentWiperParams.WiperSpeed) * dt1); + dWiperPos[i] = std::max(0.0, dWiperPos[i] - 1.f / currentWiperParams.WiperSpeed * dt1); } else { @@ -4120,7 +4088,7 @@ bool TDynamicObject::Update(double dt, double dt1) sWiperFromPark.play(sound_flags::exclusive); sWiperFromParkPlayed = true; } - dWiperPos[i] = std::min(1.0, dWiperPos[i] + (1.f / currentWiperParams.WiperSpeed) * dt1); + dWiperPos[i] = std::min(1.0, dWiperPos[i] + 1.f / currentWiperParams.WiperSpeed * dt1); } if (dWiperPos[i] > 0.0 && wiperDirection[i] && wiperOutTimer[i] > currentWiperParams.outBackDelay) // return back @@ -4130,7 +4098,7 @@ bool TDynamicObject::Update(double dt, double dt1) sWiperToPark.play(sound_flags::exclusive); sWiperToParkPlayed = true; } - dWiperPos[i] = std::max(0.0, dWiperPos[i] - (1.f / currentWiperParams.WiperSpeed) * dt1); + dWiperPos[i] = std::max(0.0, dWiperPos[i] - 1.f / currentWiperParams.WiperSpeed * dt1); } if (dWiperPos[i] >= 1.0) // we reached end { @@ -4157,9 +4125,9 @@ bool TDynamicObject::Update(double dt, double dt1) // mirrors - if( (MoverParameters->Vel > MoverParameters->MirrorVelClose) - || (MoverParameters->CabActive == 0) && (activation::mirrors) - || (MoverParameters->MirrorForbidden) ) { + if( MoverParameters->Vel > MoverParameters->MirrorVelClose + || MoverParameters->CabActive == 0 && activation::mirrors + || MoverParameters->MirrorForbidden ) { // automatically fold mirrors when above velocity threshold if( dMirrorMoveL > 0.0 ) { dMirrorMoveL = std::max( @@ -4174,14 +4142,14 @@ bool TDynamicObject::Update(double dt, double dt1) } else { // unfold mirror on the side with open doors, if not moving too fast - if( ( dMirrorMoveL < 1.0 ) - && ( true == MoverParameters->Doors.instances[side::left].open_permit ) ) { + if( dMirrorMoveL < 1.0 + && true == MoverParameters->Doors.instances[side::left].open_permit ) { dMirrorMoveL = std::min( 1.0, dMirrorMoveL + 1.0 * dt1 ); } - if( ( dMirrorMoveR < 1.0 ) - && ( true == MoverParameters->Doors.instances[side::right].open_permit ) ) { + if( dMirrorMoveR < 1.0 + && true == MoverParameters->Doors.instances[side::right].open_permit ) { dMirrorMoveR = std::min( 1.0, dMirrorMoveR + 1.0 * dt1 ); @@ -4190,9 +4158,9 @@ bool TDynamicObject::Update(double dt, double dt1) // compartment lights // if the vehicle has a controller, we base the light state on state of the controller otherwise we check the vehicle itself - if( ( ctOwner != nullptr ? SectionLightsActive != MoverParameters->CompartmentLights.is_active : - Mechanik != nullptr ? SectionLightsActive != MoverParameters->CompartmentLights.is_active : - SectionLightsActive ) ) { // without controller switch the lights off + if( ctOwner != nullptr ? SectionLightsActive != MoverParameters->CompartmentLights.is_active : + Mechanik != nullptr ? SectionLightsActive != MoverParameters->CompartmentLights.is_active : + SectionLightsActive ) { // without controller switch the lights off toggle_lights(); } @@ -4368,9 +4336,9 @@ void TDynamicObject::RenderSounds() { if( false == simulation::is_ready ) { return; } if( Global.iPause != 0 ) { return; } - if( ( m_startjoltplayed ) - && ( ( std::abs( MoverParameters->AccSVBased ) < 0.01 ) - || ( GetVelocity() < 0.01 ) ) ) { + if( m_startjoltplayed + && ( std::abs(MoverParameters->AccSVBased) < 0.01 + || GetVelocity() < 0.01 ) ) { // if the vehicle comes to a stop set the movement jolt to play when it starts moving again m_startjoltplayed = false; } @@ -4387,7 +4355,7 @@ void TDynamicObject::RenderSounds() { auto const voltage { std::max( MoverParameters->GetTrainsetHighVoltage(), MoverParameters->PantographVoltage ) }; if( voltage > 0.0 ) { // NOTE: we do sound modulation here to avoid sudden jump on voltage loss - frequency = ( voltage / ( MoverParameters->NominalVoltage * MoverParameters->RList[ MoverParameters->RlistSize ].Mn ) ); + frequency = voltage / (MoverParameters->NominalVoltage * MoverParameters->RList[MoverParameters->RlistSize].Mn); frequency *= sConverter.m_frequencyfactor + sConverter.m_frequencyoffset; sConverter.pitch( std::clamp( frequency, 0.75, 1.25 ) ); // arbitrary limits ) } @@ -4463,10 +4431,10 @@ void TDynamicObject::RenderSounds() { // heater sound { - auto const isdieselenginepowered { ( MoverParameters->EngineType == TEngineType::DieselElectric ) || ( MoverParameters->EngineType == TEngineType::DieselEngine ) }; - if( ( true == MoverParameters->Heating ) - && ( ( false == isdieselenginepowered ) - || ( std::abs( MoverParameters->enrot ) > 0.01 ) ) ) { + auto const isdieselenginepowered { MoverParameters->EngineType == TEngineType::DieselElectric || MoverParameters->EngineType == TEngineType::DieselEngine }; + if( true == MoverParameters->Heating + && ( false == isdieselenginepowered + || std::abs(MoverParameters->enrot) > 0.01 ) ) { sHeater .pitch( true == sHeater.is_combined() ? std::abs( MoverParameters->enrot ) * 60.f * 0.01f : @@ -4520,7 +4488,7 @@ void TDynamicObject::RenderSounds() { } // epbrake - epcompact - if (( MoverParameters->BrakeSystem == TBrakeSystem::ElectroPneumatic ) && ( MoverParameters->LocHandle )) { + if (MoverParameters->BrakeSystem == TBrakeSystem::ElectroPneumatic && MoverParameters->LocHandle) { auto const epbrakepressureratio{ std::min( std::max( 0.0, MoverParameters->LocHandle->GetCP() ) / std::max( 1.0, MoverParameters->MaxBrakePress[0] ), m_epbrakepressurechangedectimer > -1.0f ? std::max( MoverParameters->LocalBrakePosAEIM, MoverParameters->Hamulec->GetEDBCP() / MoverParameters->MaxBrakePress[3]) : @@ -4557,7 +4525,7 @@ void TDynamicObject::RenderSounds() { m_epbrakepressurechangedectimer = 0; } } - if ( ( m_epbrakepressurechangeinctimer == 0 ) || ( m_epbrakepressurechangedectimer == 0 ) ) + if ( m_epbrakepressurechangeinctimer == 0 || m_epbrakepressurechangedectimer == 0 ) m_lastepbrakepressure = std::min( MoverParameters->LocHandle->GetCP(), MoverParameters->LocalBrakePosAEIM * std::max( 1.0, MoverParameters->MaxBrakePress[0] ) ); } @@ -4565,10 +4533,7 @@ void TDynamicObject::RenderSounds() { // emergency brake if( MoverParameters->EmergencyValveFlow > 0.025 ) { // smooth out air flow rate - m_emergencybrakeflow = ( - m_emergencybrakeflow == 0.0 ? - MoverParameters->EmergencyValveFlow : - std::lerp( m_emergencybrakeflow, MoverParameters->EmergencyValveFlow, 0.1 ) ); + m_emergencybrakeflow = m_emergencybrakeflow == 0.0 ? MoverParameters->EmergencyValveFlow : std::lerp(m_emergencybrakeflow, MoverParameters->EmergencyValveFlow, 0.1); // scale volume based on the flow rate and on the pressure in the main pipe auto const flowpressure { std::clamp( m_emergencybrakeflow, 0.0, 1.0 ) + std::clamp( 0.1 * MoverParameters->PipePress, 0.0, 0.5 ) }; m_emergencybrake @@ -4590,7 +4555,7 @@ void TDynamicObject::RenderSounds() { m_lastbrakepressure = MoverParameters->BrakePress; // ensure some basic level of volume and scale it up depending on pressure in the cylinder; scale this by the air release rate volume = rsUnbrake.m_amplitudefactor * m_brakepressurechange * ( 0.25 + 0.75 * brakepressureratio ); - if( ( m_brakepressurechange > 0.05 ) && ( brakepressureratio > 0.05 ) ) { + if( m_brakepressurechange > 0.05 && brakepressureratio > 0.05 ) { rsUnbrake .gain( volume ) .play( sound_flags::exclusive | sound_flags::looping ); @@ -4620,8 +4585,8 @@ void TDynamicObject::RenderSounds() { // slipping wheels if( MoverParameters->SlippingWheels ) { - if( ( MoverParameters->UnitBrakeForce > 100.0 ) - && ( GetVelocity() > 1.0 ) ) { + if( MoverParameters->UnitBrakeForce > 100.0 + && GetVelocity() > 1.0 ) { auto const velocitydifference{ GetVelocity() / MoverParameters->Vmax }; rsSlippery @@ -4644,8 +4609,8 @@ void TDynamicObject::RenderSounds() { // brakes auto brakeforceratio{ 0.0 }; if( //( false == mvOccupied->SlippingWheels ) && - ( MoverParameters->UnitBrakeForce > 10.0 ) - && ( MoverParameters->Vel > 0.05 ) ) { + MoverParameters->UnitBrakeForce > 10.0 + && MoverParameters->Vel > 0.05 ) { brakeforceratio = std::clamp( @@ -4653,7 +4618,7 @@ void TDynamicObject::RenderSounds() { 0.0, 1.0 ); rsBrake .pitch( rsBrake.m_frequencyoffset + MoverParameters->Vel * rsBrake.m_frequencyfactor ) - .gain( rsBrake.m_amplitudeoffset + std::sqrt( brakeforceratio * std::lerp( 0.4, 1.0, ( MoverParameters->Vel / ( 1 + MoverParameters->Vmax ) ) ) ) * rsBrake.m_amplitudefactor ) + .gain( rsBrake.m_amplitudeoffset + std::sqrt( brakeforceratio * std::lerp( 0.4, 1.0, MoverParameters->Vel / (1 + MoverParameters->Vmax) ) ) * rsBrake.m_amplitudefactor ) .play( sound_flags::exclusive | sound_flags::looping ); } else { @@ -4683,7 +4648,7 @@ void TDynamicObject::RenderSounds() { } else { // don't stop the sound too abruptly - volume = std::max( 0.0, rsPisk.gain() - ( rsPisk.gain() * 2.5 * dt ) ); + volume = std::max( 0.0, rsPisk.gain() - rsPisk.gain() * 2.5 * dt ); rsPisk.gain( volume ); } if( volume < 0.05 ) { @@ -4722,8 +4687,8 @@ void TDynamicObject::RenderSounds() { auto const lowvoltagepower { MoverParameters->Power24vIsAvailable || MoverParameters->Power110vIsAvailable }; for( auto &doorspeaker : m_doorspeakers ) { // TBD, TODO: per-location door state triggers? - if( ( MoverParameters->DepartureSignal ) - && ( lowvoltagepower ) + if( MoverParameters->DepartureSignal + && lowvoltagepower /* || ( ( MoverParameters->DoorCloseCtrl = control::autonomous ) && ( ( ( false == MoverParameters->DoorLeftOpened ) && ( dDoorMoveL > 0.0 ) ) @@ -4744,8 +4709,8 @@ void TDynamicObject::RenderSounds() { auto const lowvoltagepower { MoverParameters->Power24vIsAvailable || MoverParameters->Power110vIsAvailable }; if( lowvoltagepower ) { // system is powered up, can play queued announcements - if( ( false == m_pasystem.announcement_queue.empty() ) - && ( false == m_pasystem.announcement.is_playing() ) ) { + if( false == m_pasystem.announcement_queue.empty() + && false == m_pasystem.announcement.is_playing() ) { // pull first sound from the queue m_pasystem.announcement = m_pasystem.announcement_queue.front(); m_pasystem.announcement.owner( this ); @@ -4772,8 +4737,8 @@ void TDynamicObject::RenderSounds() { if( true == door.is_opening ) { // door sounds - if( ( false == door.step_unfolding ) // no wait if no doorstep - || ( MoverParameters->Doors.step_type == 2 ) ) { // no wait for rotating doorstep + if( false == door.step_unfolding // no wait if no doorstep + || MoverParameters->Doors.step_type == 2 ) { // no wait for rotating doorstep if( door.position < 0.5f ) { // safety measure, to keep slightly too short sounds from repeating for( auto &doorsounds : m_doorsounds ) { if( doorsounds.placement == side ) { @@ -4837,10 +4802,10 @@ void TDynamicObject::RenderSounds() { { // for moving vehicle combine regular horn activation flag with emergency brake horn activation flag, if the brake is active auto const warningsignal { ( - ( MoverParameters->Vel > 0.5 ) && ( MoverParameters->AlarmChainFlag ) ? + MoverParameters->Vel > 0.5 && MoverParameters->AlarmChainFlag ? MoverParameters->EmergencyBrakeWarningSignal : 0 ) - | ( MoverParameters->WarningSignal ) }; + | MoverParameters->WarningSignal }; if( TestFlag( warningsignal, 1 ) ) { sHorn1.play( sound_flags::exclusive | sound_flags::looping ); @@ -4862,9 +4827,9 @@ void TDynamicObject::RenderSounds() { } } // szum w czasie jazdy - if( ( GetVelocity() > 0.5 ) + if( GetVelocity() > 0.5 #ifdef EU07_SOUND_BOGIESOUNDS - && ( false == m_bogiesounds.empty() ) + && false == m_bogiesounds.empty() #endif && ( // compound test whether the vehicle belongs to user-driven consist (as these don't emit outer noise in cab view) FreeFlyModeFlag ? true : // in external view all vehicles emit outer noise @@ -4966,11 +4931,11 @@ void TDynamicObject::RenderSounds() { // flat spot sound if( MoverParameters->CategoryFlag == 1 ) { // trains only - if( ( GetVelocity() > 1.0 ) - && ( MoverParameters->WheelFlat > 5.0 ) ) { + if( GetVelocity() > 1.0 + && MoverParameters->WheelFlat > 5.0 ) { m_wheelflat .pitch( m_wheelflat.m_frequencyoffset + std::abs( MoverParameters->nrot ) * m_wheelflat.m_frequencyfactor ) - .gain( m_wheelflat.m_amplitudeoffset + m_wheelflat.m_amplitudefactor * ( ( 1.0 + ( MoverParameters->Vel / MoverParameters->Vmax ) + std::clamp( MoverParameters->WheelFlat / 60.0, 0.0, 1.0 ) ) / 3.0 ) ) + .gain( m_wheelflat.m_amplitudeoffset + m_wheelflat.m_amplitudefactor * ( ( 1.0 + MoverParameters->Vel / MoverParameters->Vmax + std::clamp( MoverParameters->WheelFlat / 60.0, 0.0, 1.0 ) ) / 3.0 ) ) .play( sound_flags::exclusive | sound_flags::looping ); } else { @@ -4979,9 +4944,9 @@ void TDynamicObject::RenderSounds() { } // youBy: dzwiek ostrych lukow i ciasnych zwrotek - if( ( MoverParameters->Vel > 5.0 ) - && ( ts.R * ts.R > 1.0 ) - && ( std::abs( ts.R ) < 15000.0 ) ) { + if( MoverParameters->Vel > 5.0 + && ts.R * ts.R > 1.0 + && std::abs(ts.R) < 15000.0 ) { // scale volume with curve radius and vehicle speed volume = std::abs( MoverParameters->AccN ) // * MoverParameters->AccN @@ -4990,7 +4955,7 @@ void TDynamicObject::RenderSounds() { std::clamp( MoverParameters->Vel / 40.0, 0.0, 1.0 ) ) - * ( ( ( MyTrack->eType == tt_Switch ) && ( std::abs( ts.R ) < 1500.0 ) ) ? 100.0 : 1.0 ); + * ( MyTrack->eType == tt_Switch && std::abs(ts.R) < 1500.0 ? 100.0 : 1.0 ); } else { volume = 0; @@ -5011,9 +4976,9 @@ void TDynamicObject::RenderSounds() { // movement start jolt if( false == m_startjoltplayed ) { auto const velocity { GetVelocity() }; - if( ( MoverParameters->V > 0.0 ? ( MoverParameters->AccSVBased > 0.1 ) : ( MoverParameters->AccSVBased < 0.1 ) ) - && ( velocity > 1.0 ) - && ( velocity < 15.0 ) ) { + if( ( MoverParameters->V > 0.0 ? MoverParameters->AccSVBased > 0.1 : MoverParameters->AccSVBased < 0.1 ) + && velocity > 1.0 + && velocity < 15.0 ) { m_startjolt.play( sound_flags::exclusive ); m_startjoltplayed = true; } @@ -5172,10 +5137,7 @@ double TDynamicObject::tracing_offset() const { auto const axletoend{ ( GetLength() - fAxleDist ) * 0.5 }; - return ( - iAxleFirst ? - axletoend : - axletoend + iDirection * fAxleDist ); + return iAxleFirst ? axletoend : axletoend + iDirection * fAxleDist; } // TODO: compute and cache radius during vehicle initialization @@ -5282,7 +5244,7 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co iAnimType[co] = 0; } ++co; - } while ( (ile >= 0) && (co < ANIM_TYPES) ); //-1 to znacznik końca + } while ( ile >= 0 && co < ANIM_TYPES ); //-1 to znacznik końca pAnimations.resize( iAnimations ); int i, j, k = 0, sm = 0; @@ -5338,8 +5300,8 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co // each value is a name of additional 3d model // value can be optionally set of values enclosed in "[]" in which case one value will be picked randomly // TBD: reconsider something more yaml-compliant and/or ability to define offset and rotation - while( ( ( token = deserialize_random_set( parser ) ) != "" ) - && ( token != "}" ) ) { + while( (token = deserialize_random_set(parser)) != "" + && token != "}" ) { if( token == "{" ) { continue; } replace_slashes( token ); Global.asCurrentTexturePath = asBaseDir; // biezaca sciezka do tekstur to dynamic/... @@ -5354,8 +5316,8 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co // default load visualization models overrides // content provided as "key: value" pairs together enclosed in "{}" // value can be optionally set of values enclosed in "[]" in which case one value will be picked randomly - while( ( ( token = parser.getToken() ) != "" ) - && ( token != "}" ) ) { + while( (token = parser.getToken()) != "" + && token != "}" ) { if( token.back() == ':' ) { auto loadmodel { deserialize_random_set( parser ) }; replace_slashes( loadmodel ); @@ -5404,19 +5366,19 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co j = 1; k = 0; m = 0; // numer osi; kolejny znak; ile osi danego typu; która średnica - if ((MoverParameters->WheelDiameterL != MoverParameters->WheelDiameter) || - (MoverParameters->WheelDiameterT != MoverParameters->WheelDiameter)) + if (MoverParameters->WheelDiameterL != MoverParameters->WheelDiameter || + MoverParameters->WheelDiameterT != MoverParameters->WheelDiameter) { // obsługa różnych średnic, o ile występują - while ((i < iAnimType[ANIM_WHEELS]) && - (j <= MoverParameters->AxleArangement.length())) + while (i < iAnimType[ANIM_WHEELS] && + j <= MoverParameters->AxleArangement.length()) { // wersja ze wskaźnikami jest bardziej elastyczna na nietypowe układy - if ((k >= 'A') && (k <= 'J')) // 10 chyba maksimum? + if (k >= 'A' && k <= 'J') // 10 chyba maksimum? { pAnimations[i++].dWheelAngle = 1; // obrót osi napędzających --k; // następna będzie albo taka sama, albo bierzemy kolejny znak m = 2; // następujące toczne będą miały inną średnicę } - else if ((k >= '1') && (k <= '9')) + else if (k >= '1' && k <= '9') { pAnimations[i++].dWheelAngle = m; // obrót osi tocznych --k; // następna będzie albo taka sama, albo bierzemy kolejny znak @@ -5508,7 +5470,7 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co { // gdy ktoś przesadził ze skalowaniem pants[i].fParamPants->fHeight = 0.0; // niech będzie odczyt z pantfactors: ErrorLog( - "Bad model: " + asModel + ", scale of " + (sm->pName) + " is " + std::to_string(100.0 * det) + "%", + "Bad model: " + asModel + ", scale of " + sm->pName + " is " + std::to_string(100.0 * det) + "%", logtype::model ); } } @@ -5627,8 +5589,8 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co if( pant1h > 0.5 ) { pant1h = pant2h; // tu może być zbyt duża wartość } - if ((pant1x < 0) && - (pant2x > 0)) // pierwsza powinna być dodatnia, a druga ujemna + if (pant1x < 0 && + pant2x > 0) // pierwsza powinna być dodatnia, a druga ujemna { pant1x = -pant1x; pant2x = -pant2x; @@ -5636,7 +5598,7 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co if( pants ) { for( int i = 0; i < iAnimType[ ANIM_PANTS ]; ++i ) { // przepisanie współczynników do pantografów (na razie nie będzie lepiej) - auto &pantograph { *(pants[ i ].fParamPants) }; + auto &pantograph { *pants[i].fParamPants }; pantograph.fAngleL = pantograph.fAngleL0; // początkowy kąt dolnego ramienia pantograph.fAngleU = pantograph.fAngleU0; // początkowy kąt @@ -5647,11 +5609,11 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co if( pantograph.fHeight == 0.0 ) // gdy jest nieprawdopodobna wartość (np. nie znaleziony ślizg) { // gdy pomiary modelu nie udały się, odczyt podanych parametrów z MMD pantograph.vPos.x = - ( i & 1 ) ? + i & 1 ? pant2x : pant1x; pantograph.fHeight = - ( i & 1 ) ? + i & 1 ? pant2h : pant1h; // wysokość ślizgu jest zapisana w MMD } @@ -5915,8 +5877,8 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co } } - } while( ( token != "" ) - && ( token != "endmodels" ) ); + } while( token != "" + && token != "endmodels" ); if( false == MoverParameters->LoadAttributes.empty() ) { // Ra: tu wczytywanie modelu ładunku jest w porządku @@ -5942,8 +5904,8 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co double dSDist; parser.getTokens( 1, false ); parser >> dSDist; - while( ( ( token = parser.getToken() ) != "" ) - && ( token != "end" ) ) { + while( (token = parser.getToken()) != "" + && token != "end" ) { // add another axle entry to the list axle_sounds axle { 0, @@ -5958,19 +5920,18 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co std::sort( std::begin( m_axlesounds ), std::end( m_axlesounds ), []( axle_sounds const &Left, axle_sounds const &Right ) { - return ( Left.offset > Right.offset ); } ); + return Left.offset > Right.offset; } ); } - else if( ( token == "engine:" ) - && ( MoverParameters->Power > 0 ) ) { + else if( token == "engine:" + && MoverParameters->Power > 0 ) { // plik z dzwiekiem silnika, mnozniki i ofsety amp. i czest. m_powertrainsounds.engine.deserialize( parser, sound_type::single, sound_parameters::range | sound_parameters::amplitude | sound_parameters::frequency ); m_powertrainsounds.engine.owner( this ); - auto const amplitudedivisor = static_cast( ( - MoverParameters->EngineType == TEngineType::DieselEngine ? 1 : - MoverParameters->EngineType == TEngineType::DieselElectric ? 1 : - MoverParameters->nmax * 60 + MoverParameters->Power * 3 ) ); + auto const amplitudedivisor = static_cast( MoverParameters->EngineType == TEngineType::DieselEngine ? 1 : + MoverParameters->EngineType == TEngineType::DieselElectric ? 1 : + MoverParameters->nmax * 60 + MoverParameters->Power * 3 ); m_powertrainsounds.engine.m_amplitudefactor /= amplitudedivisor; } else if (token == "fakeengine:") { @@ -6004,7 +5965,7 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co m_powertrainsounds.water_heater.owner( this ); } - else if( ( token == "tractionmotor:" ) && ( MoverParameters->Power > 0 ) ) { + else if( token == "tractionmotor:" && MoverParameters->Power > 0 ) { // plik z dzwiekiem silnika, mnozniki i ofsety amp. i czest. sound_source motortemplate { sound_placement::external }; motortemplate.deserialize( parser, sound_type::single, sound_parameters::range | sound_parameters::amplitude | sound_parameters::frequency ); @@ -6032,7 +5993,7 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co } } - else if( ( token == "tractionacmotor:" ) && ( MoverParameters->Power > 0 ) ) { + else if( token == "tractionacmotor:" && MoverParameters->Power > 0 ) { // plik z dzwiekiem silnika, mnozniki i ofsety amp. i czest. sound_source motortemplate { sound_placement::external }; motortemplate.deserialize( parser, sound_type::single, sound_parameters::range | sound_parameters::amplitude | sound_parameters::frequency ); @@ -6134,7 +6095,7 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co rsBrake.deserialize( parser, sound_type::single, sound_parameters::amplitude | sound_parameters::frequency ); rsBrake.owner( this ); // NOTE: can't pre-calculate amplitude normalization based on max brake force, as this varies depending on vehicle speed - rsBrake.m_frequencyfactor /= ( 1 + MoverParameters->Vmax ); + rsBrake.m_frequencyfactor /= 1 + MoverParameters->Vmax; } else if( token == "brake:" ) { @@ -6430,8 +6391,8 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co noisetemplate.deserialize( parser, sound_type::single, sound_parameters::amplitude | sound_parameters::frequency, MoverParameters->Vmax ); noisetemplate.owner( this ); - noisetemplate.m_amplitudefactor /= ( 1 + MoverParameters->Vmax ); - noisetemplate.m_frequencyfactor /= ( 1 + MoverParameters->Vmax ); + noisetemplate.m_amplitudefactor /= 1 + MoverParameters->Vmax; + noisetemplate.m_frequencyfactor /= 1 + MoverParameters->Vmax; #ifdef EU07_SOUND_BOGIESOUNDS if( true == m_bogiesounds.empty() ) { // fallback for cases without specified noise locations, convert sound template to a single sound source @@ -6480,8 +6441,8 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co { "next_stop:", announcement_t::next }, { "destination:", announcement_t::destination }, { "chime:", announcement_t::chime } }; - while( ( ( token = parser.getToken() ) != "" ) - && ( token != "}" ) ) { + while( (token = parser.getToken()) != "" + && token != "}" ) { if( token.back() == ':' ) { if( token == "soundproofing:" ) { @@ -6534,8 +6495,8 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co } } - } while( ( token != "" ) - && ( token != "endsounds" ) ); + } while( token != "" + && token != "endsounds" ); } // sounds: @@ -6546,8 +6507,8 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co if( token == "doors:" ) { // a list of pairs: offset along vehicle's z-axis and sides on which the door is present; followed with "end" - while( ( ( token = parser.getToken() ) != "" ) - && ( token != "end" ) ) { + while( (token = parser.getToken()) != "" + && token != "end" ) { // vehicle faces +Z in 'its' space, for door locations negative value means ahead of centre auto const offset { std::atof( token.c_str() ) * -1.f }; // recognized side specifications are "right", "left" and "both" @@ -6555,8 +6516,8 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co // NOTE: we skip setting owner of the sounds, it'll be done during individual sound deserialization door_sounds door; // add entries to the list: - if( ( sides == "both" ) - || ( sides == "left" ) ) { + if( sides == "both" + || sides == "left" ) { // left... auto const location { glm::vec3 { MoverParameters->Dim.W * 0.5f, MoverParameters->Dim.H * 0.5f, offset } }; door.placement = side::left; @@ -6569,8 +6530,8 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co door.permit_granted.offset( location ); m_doorsounds.emplace_back( door ); } - if( ( sides == "both" ) - || ( sides == "right" ) ) { + if( sides == "both" + || sides == "right" ) { // ...and right auto const location { glm::vec3 { MoverParameters->Dim.W * -0.5f, 2.f, offset } }; door.placement = side::right; @@ -6592,8 +6553,8 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co else if( token == "tractionmotors:" ) { // a list of offsets along vehicle's z-axis; followed with "end" - while( ( ( token = parser.getToken() ) != "" ) - && ( token != "end" ) ) { + while( (token = parser.getToken()) != "" + && token != "end" ) { // vehicle faces +Z in 'its' space, for motor locations negative value means ahead of centre auto const offset { std::atof( token.c_str() ) * -1.f }; // NOTE: we skip setting owner of the sounds, it'll be done during individual sound deserialization @@ -6613,8 +6574,8 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co else if( token == "bogies:" ) { // a list of offsets along vehicle's z-axis; followed with "end" - while( ( ( token = parser.getToken() ) != "" ) - && ( token != "end" ) ) { + while( (token = parser.getToken()) != "" + && token != "end" ) { // vehicle faces +Z in 'its' space, for bogie locations negative value means ahead of centre auto const offset { std::atof( token.c_str() ) * -1.f }; // NOTE: we skip setting owner of the sounds, it'll be done during individual sound deserialization @@ -6628,8 +6589,8 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co } } - } while( ( token != "" ) - && ( token != "endlocations" ) ); + } while( token != "" + && token != "endlocations" ); } // locations: @@ -6664,7 +6625,7 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co m_powertrainsounds.rsEngageSlippery.deserialize( parser, sound_type::single, sound_parameters::amplitude | sound_parameters::frequency ); m_powertrainsounds.rsEngageSlippery.owner( this ); - m_powertrainsounds.rsEngageSlippery.m_frequencyfactor /= ( 1 + MoverParameters->nmax ); + m_powertrainsounds.rsEngageSlippery.m_frequencyfactor /= 1 + MoverParameters->nmax; } // dzwieki wycieraczkuf @@ -6737,7 +6698,7 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co rsSlippery.deserialize( parser, sound_type::single, sound_parameters::amplitude ); rsSlippery.owner( this ); - rsSlippery.m_amplitudefactor /= ( 1 + MoverParameters->Vmax ); + rsSlippery.m_amplitudefactor /= 1 + MoverParameters->Vmax; } // coupler sounds else if( token == "couplerattach:" ) { @@ -6976,8 +6937,8 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co else if( token == "pydestinationsign:" ) { DestinationSign.deserialize( parser ); // supply vehicle folder as script path if none is provided - if( ( false == DestinationSign.script.empty() ) - && ( substr_path( DestinationSign.script ).empty() ) ) { + if( false == DestinationSign.script.empty() + && substr_path(DestinationSign.script).empty() ) { DestinationSign.script = asBaseDir + DestinationSign.script; } } @@ -7000,7 +6961,7 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co if( ReplacableSkin != "none" ) { // potentially set blank destination texture - DestinationSign.destination_off = DestinationFind( ( DestinationSign.background.empty() ? "nowhere" : DestinationSign.background ) ); + DestinationSign.destination_off = DestinationFind( DestinationSign.background.empty() ? "nowhere" : DestinationSign.background ); } // assign default samples to sound emitters which weren't included in the config file @@ -7182,8 +7143,8 @@ void TDynamicObject::RadioStop() { // zatrzymanie pojazdu if( Mechanik ) { // o ile ktoś go prowadzi - if( ( MoverParameters->SecuritySystem.radiostop_available() ) - && ( MoverParameters->Radio ) ) { + if( MoverParameters->SecuritySystem.radiostop_available() + && MoverParameters->Radio ) { // jeśli pojazd ma RadioStop i jest on aktywny // HACK cast until math types unification glm::dvec3 pos = static_cast(vPosition); @@ -7273,7 +7234,7 @@ void TDynamicObject::Damage(char flag) void TDynamicObject::SetLights() { auto const isfrontcaboccupied { MoverParameters->CabOccupied * DirectionGet() >= 0 }; - int const automaticmarkers { MoverParameters->CabActive == 0 && ( MoverParameters->InactiveCabFlag & activation::redmarkers ) + int const automaticmarkers { MoverParameters->CabActive == 0 && MoverParameters->InactiveCabFlag & activation::redmarkers ? light::redmarker_left + light::redmarker_right : 0 }; int const front { ( isfrontcaboccupied ? end::front : end::rear ) }; int const rear { 1 - front }; @@ -7293,9 +7254,9 @@ void TDynamicObject::SetLights() { } vehicle->RaLightsSet( - ( frontvehicle == nullptr ? frontlights : 0 ), - ( rearvehicle == nullptr ? rearlights : 0 ) ); - vehicle = ( isfrontcaboccupied ? vehicle->Next( coupling::control ) : vehicle->Prev( coupling::control ) ); + frontvehicle == nullptr ? frontlights : 0, + rearvehicle == nullptr ? rearlights : 0 ); + vehicle = isfrontcaboccupied ? vehicle->Next(coupling::control) : vehicle->Prev(coupling::control); } }; @@ -7322,7 +7283,7 @@ void TDynamicObject::RaLightsSet(int head, int rear) end::rear : end::front ) ] & ( light::redmarker_left | light::redmarker_right ) ) { // czy ma jakieś światła czerowone od danej strony - rear = ( light::redmarker_left | light::redmarker_right ); // dwa światła czerwone + rear = light::redmarker_left | light::redmarker_right; // dwa światła czerwone } else { rear = light::rearendsignals; // tablice blaszane @@ -7331,7 +7292,7 @@ void TDynamicObject::RaLightsSet(int head, int rear) // w zależności od kierunku pojazdu w składzie if( head >= 0 ) { auto const vehicleend { iDirection > 0 ? end::front : end::rear }; - MoverParameters->iLights[ vehicleend ] = ( head & iInventory[ vehicleend ] ); + MoverParameters->iLights[ vehicleend ] = head & iInventory[vehicleend]; bool tLeft = MoverParameters->iLights[vehicleend] & (light::auxiliary_left | light::headlight_left); // roboczo czy jakiekolwiek swiatlo z lewej jest zapalone bool tRight = MoverParameters->iLights[vehicleend] & (light::auxiliary_right | light::headlight_right); // a tu z prawej if (Controller == Humandriver) { @@ -7390,7 +7351,7 @@ void TDynamicObject::RaLightsSet(int head, int rear) } if( rear >= 0 ) { auto const vehicleend{ iDirection > 0 ? end::rear : end::front }; - MoverParameters->iLights[ vehicleend ] = ( rear & iInventory[ vehicleend ] ); + MoverParameters->iLights[ vehicleend ] = rear & iInventory[vehicleend]; } }; @@ -7465,9 +7426,8 @@ bool TDynamicObject::has_signal_pc1_on() const { auto const hasauxiliarylights { ( equippedlights & ( light::auxiliary_left | light::auxiliary_right ) ) != 0 }; auto const activelights { MoverParameters->iLights[ vehicleend ] }; - return ( ( ( pattern != 0 ) && ( activelights == pattern ) ) - || ( ( hasauxiliarylights ) && ( activelights == patternfallback ) ) - || ( ( pattern == 0 ) && ( patternfallback == 0 ) && ( activelights == light::rearendsignals ) ) ); // pc4 + return (pattern != 0 && activelights == pattern) || (hasauxiliarylights && activelights == patternfallback) || + (pattern == 0 && patternfallback == 0 && activelights == light::rearendsignals); // pc4 } bool TDynamicObject::has_signal_pc2_on() const { @@ -7479,8 +7439,7 @@ bool TDynamicObject::has_signal_pc2_on() const { auto const hasauxiliarylights { ( equippedlights & ( light::auxiliary_left | light::auxiliary_right ) ) != 0 }; auto const activelights { MoverParameters->iLights[ vehicleend ] }; - return ( ( activelights == pattern ) - || ( hasauxiliarylights && ( activelights == patternfallback ) ) ); + return activelights == pattern || (hasauxiliarylights && activelights == patternfallback); } bool TDynamicObject::has_signal_pc5_on() const { @@ -7488,11 +7447,10 @@ bool TDynamicObject::has_signal_pc5_on() const { auto const vehicleend { iDirection > 0 ? end::rear : end::front }; auto const equippedlights { iInventory[ vehicleend ] }; auto const pattern { equippedlights & ( light::redmarker_left | light::redmarker_right ) }; - auto const patternfallback { equippedlights & ( light::rearendsignals ) }; + auto const patternfallback { equippedlights & light::rearendsignals }; auto const activelights { MoverParameters->iLights[ vehicleend ] }; - return ( ( ( pattern != 0 ) && ( activelights == pattern ) ) - || ( ( patternfallback != 0 ) && ( activelights == patternfallback ) ) ); + return (pattern != 0 && activelights == pattern) || (patternfallback != 0 && activelights == patternfallback); } bool TDynamicObject::has_signal_on( int const Side, int const Pattern ) const { @@ -7502,17 +7460,17 @@ bool TDynamicObject::has_signal_on( int const Side, int const Pattern ) const { return ( MoverParameters->iLights[ vehicleend ] == pattern ); */ - return ( MoverParameters->iLights[ Side ] == ( Pattern & iInventory[ Side ] ) ); + return MoverParameters->iLights[Side] == (Pattern & iInventory[Side]); } int TDynamicObject::DirectionSet(int d) { // ustawienie kierunku w składzie (wykonuje AI) auto const lastdirection { iDirection }; - iDirection = ( d > 0 ) ? 1 : 0; // d:1=zgodny,-1=przeciwny; iDirection:1=zgodny,0=przeciwny; + iDirection = d > 0 ? 1 : 0; // d:1=zgodny,-1=przeciwny; iDirection:1=zgodny,0=przeciwny; if( iDirection != lastdirection ) { // direction was flipped, switch recorded servicable platform sides for potentially ongoing load exchange - auto const left { ( lastdirection > 0 ) ? 1 : 2 }; + auto const left { lastdirection > 0 ? 1 : 2 }; auto const right { 3 - left }; m_exchange.platforms = ( ( m_exchange.platforms & left ) != 0 ? right : 0 ) @@ -7525,7 +7483,7 @@ int TDynamicObject::DirectionSet(int d) update_neighbours(); } // informacja o położeniu następnego - return 1 - ( ( iDirection > 0 ) ? NextConnectedNo() : PrevConnectedNo() ); + return 1 - ( iDirection > 0 ? NextConnectedNo() : PrevConnectedNo() ); }; // wskaźnik na poprzedni, nawet wirtualny @@ -7533,14 +7491,10 @@ TDynamicObject * TDynamicObject::PrevAny() const { return MoverParameters->Neighbours[ iDirection ^ 1 ].vehicle; } TDynamicObject * TDynamicObject::Prev(int C) const { - return ( (MoverParameters->Couplers[ iDirection ^ 1 ].CouplingFlag & C) ? - MoverParameters->Neighbours[ iDirection ^ 1 ].vehicle : - nullptr );// gdy sprzęg wirtualny, to jakby nic nie było + return MoverParameters->Couplers[iDirection ^ 1].CouplingFlag & C ? MoverParameters->Neighbours[iDirection ^ 1].vehicle : nullptr;// gdy sprzęg wirtualny, to jakby nic nie było } TDynamicObject * TDynamicObject::Next(int C) const { - return ( (MoverParameters->Couplers[ iDirection ].CouplingFlag & C) ? - MoverParameters->Neighbours[ iDirection ].vehicle : - nullptr );// gdy sprzęg wirtualny, to jakby nic nie było + return MoverParameters->Couplers[iDirection].CouplingFlag & C ? MoverParameters->Neighbours[iDirection].vehicle : nullptr;// gdy sprzęg wirtualny, to jakby nic nie było } // checks whether there's unbroken connection of specified type to specified vehicle @@ -7596,8 +7550,8 @@ TDynamicObject::update_neighbours() { auto &neighbour { MoverParameters->Neighbours[ end ] }; auto const &coupler { MoverParameters->Couplers[ end ] }; - if( ( coupler.Connected != nullptr ) - && ( neighbour.vehicle != nullptr ) ) { + if( coupler.Connected != nullptr + && neighbour.vehicle != nullptr ) { // physical connection with another vehicle locks down collision source on this end // neighbour.vehicle = coupler.Connected; // neighbour.vehicle_end = coupler.ConnectedNr; @@ -7621,8 +7575,8 @@ TDynamicObject::update_neighbours() { neighbour.vehicle_end = std::get( lookup ); neighbour.distance = std::get( lookup ); - if( ( neighbour.vehicle ) - && ( neighbour.distance < ( neighbour.vehicle->MoverParameters->CategoryFlag == 2 ? 50 : 100 ) ) ) { + if( neighbour.vehicle + && neighbour.distance < (neighbour.vehicle->MoverParameters->CategoryFlag == 2 ? 50 : 100) ) { // at short distances (re)calculate range between couplers directly neighbour.distance = TMoverParameters::CouplerDist( MoverParameters, neighbour.vehicle->MoverParameters ); // take into account potential adapters attached to the couplers @@ -7732,8 +7686,7 @@ TDynamicObject * TDynamicObject::FindPowered() // problematyczna może być kwestia wybranej kabiny (w silnikowym...) // jeśli silnikowy będzie zapięty odwrotnie (tzn. -1), to i tak powinno jeździć dobrze // również hamowanie wykonuje się zaworem w członie, a nie w silnikowym... - auto const coupling { ( - ( MoverParameters->TrainType == dt_EZT ) || ( MoverParameters->TrainType == dt_DMU ) ) ? + auto const coupling { MoverParameters->TrainType == dt_EZT || MoverParameters->TrainType == dt_DMU ? coupling::permanent : coupling::control }; @@ -7741,9 +7694,9 @@ TDynamicObject * TDynamicObject::FindPowered() find_vehicle( coupling, []( TDynamicObject * vehicle ) { - return ( vehicle->MoverParameters->Power > 1.0 ); } ) }; + return vehicle->MoverParameters->Power > 1.0; } ) }; - return( lookup != nullptr ? lookup : this ); // always return valid vehicle for backward compatibility + return lookup != nullptr ? lookup : this; // always return valid vehicle for backward compatibility } TDynamicObject * @@ -7757,9 +7710,7 @@ TDynamicObject::FindPantographCarrier() { find_vehicle( coupling, []( TDynamicObject * vehicle ) { - return ( - ( vehicle->MoverParameters->EnginePowerSource.SourceType == TPowerSource::CurrentCollector ) - && ( vehicle->MoverParameters->EnginePowerSource.CollectorParameters.CollectorsNo > 0 ) ); } ); + return vehicle->MoverParameters->EnginePowerSource.SourceType == TPowerSource::CurrentCollector && vehicle->MoverParameters->EnginePowerSource.CollectorParameters.CollectorsNo > 0; } ); if( result != nullptr ) { return result; } @@ -7956,8 +7907,8 @@ void TDynamicObject::announce( announcement_t const Announcement, bool const Chi goto followup; } // potentially precede the announcement with a chime... - if( ( true == playchime ) - && ( false == announcements[ static_cast( announcement_t::chime ) ].empty() ) ) { + if( true == playchime + && false == announcements[static_cast(announcement_t::chime)].empty() ) { m_pasystem.announcement_queue.emplace_back( announcements[ static_cast( announcement_t::chime ) ] ); playchime = false; } @@ -8013,12 +7964,13 @@ TDynamicObject::update_shake( double const Timedelta ) { if( Global.iSlowMotion == 0 ) { // musi być pełna prędkość glm::dvec3 shakevector; - if( ( MoverParameters->EngineType == TEngineType::DieselElectric ) - || ( MoverParameters->EngineType == TEngineType::DieselEngine ) ) { + if( MoverParameters->EngineType == TEngineType::DieselElectric + || MoverParameters->EngineType == TEngineType::DieselEngine ) { if( std::abs( MoverParameters->enrot ) > 0.0 ) { // engine vibration shakevector.x += - ( std::sin( MoverParameters->eAngle * 4.0 ) * Timedelta * EngineShake.scale ) + std::sin(MoverParameters->eAngle * 4.0) * Timedelta * + EngineShake.scale // fade in with rpm above threshold * std::clamp( ( MoverParameters->enrot - EngineShake.fadein_offset ) * EngineShake.fadein_factor, @@ -8032,8 +7984,8 @@ TDynamicObject::update_shake( double const Timedelta ) { } } - if( ( HuntingShake.fadein_begin > 0.f ) - && ( true == MoverParameters->TruckHunting ) ) { + if( HuntingShake.fadein_begin > 0.f + && true == MoverParameters->TruckHunting ) { // hunting oscillation HuntingAngle = clamp_circular( HuntingAngle + 4.0 * HuntingShake.frequency * Timedelta * MoverParameters->Vel, 360.0 ); auto const huntingamount = @@ -8043,9 +7995,9 @@ TDynamicObject::update_shake( double const Timedelta ) { ( MoverParameters->Vel - HuntingShake.fadein_begin ) / ( HuntingShake.fadein_end - HuntingShake.fadein_begin ), 0.0, 1.0 ) ); shakevector.x += - ( std::sin( glm::radians( HuntingAngle ) ) * Timedelta * HuntingShake.scale ) + std::sin(glm::radians(HuntingAngle)) * Timedelta * HuntingShake.scale * huntingamount; - IsHunting = ( huntingamount > 0.025 ); + IsHunting = huntingamount > 0.025; } if (FreeFlyModeFlag) @@ -8066,16 +8018,16 @@ TDynamicObject::update_shake( double const Timedelta ) { // extra shake at increased velocity shake += ShakeSpring.ComputateForces( glm::dvec3( - ( LocalRandom( iVel * 2 ) - iVel ) / ( ( iVel * 2 ) * 4 ) * BaseShake.jolt_scale.x, - ( LocalRandom( iVel * 2 ) - iVel ) / ( ( iVel * 2 ) * 4 ) * BaseShake.jolt_scale.y, - ( LocalRandom( iVel * 2 ) - iVel ) / ( ( iVel * 2 ) * 4 ) * BaseShake.jolt_scale.z ) + ( LocalRandom( iVel * 2 ) - iVel ) / ( iVel * 2 * 4 ) * BaseShake.jolt_scale.x, + ( LocalRandom( iVel * 2 ) - iVel ) / ( iVel * 2 * 4 ) * BaseShake.jolt_scale.y, + ( LocalRandom( iVel * 2 ) - iVel ) / ( iVel * 2 * 4 ) * BaseShake.jolt_scale.z ) // * (( 200 - DynamicObject->MyTrack->iQualityFlag ) * 0.0075 ) // scale to 75-150% based on track quality * 1.25, ShakeState.offset ); } shake *= 0.85; - ShakeState.velocity -= ( shake + ShakeState.velocity * 100.0 ) * (double)( BaseShake.jolt_scale.x + BaseShake.jolt_scale.y + BaseShake.jolt_scale.z ) / ( 200.0 ); + ShakeState.velocity -= ( shake + ShakeState.velocity * 100.0 ) * (double)( BaseShake.jolt_scale.x + BaseShake.jolt_scale.y + BaseShake.jolt_scale.z ) / 200.0; // McZapkie: ShakeState.offset += ShakeState.velocity * Timedelta; @@ -8196,9 +8148,9 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub // main engine sound if( true == Vehicle.Mains ) { - if( ( std::abs( Vehicle.enrot ) > 0.01 ) + if( std::abs(Vehicle.enrot) > 0.01 // McZapkie-280503: zeby dla dumb dzialal silnik na jalowych obrotach - || ( Vehicle.EngineType == TEngineType::Dumb ) ) { + || Vehicle.EngineType == TEngineType::Dumb ) { // frequency calculation auto const normalizer { ( @@ -8230,10 +8182,8 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub } case TEngineType::DieselEngine: { if( Vehicle.enrot > 0.0 ) { - volume = ( - Vehicle.EnginePower > 0 ? - engine.m_amplitudeoffset + engine.m_amplitudefactor * Vehicle.dizel_fill : - engine.m_amplitudeoffset + engine.m_amplitudefactor * std::fabs( Vehicle.enrot / Vehicle.dizel_nmax ) ); + volume = Vehicle.EnginePower > 0 ? engine.m_amplitudeoffset + engine.m_amplitudefactor * Vehicle.dizel_fill : + engine.m_amplitudeoffset + engine.m_amplitudefactor * std::fabs(Vehicle.enrot / Vehicle.dizel_nmax); } break; } @@ -8248,8 +8198,8 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub if( engine_volume >= 0.05 ) { auto enginerevvolume { 0.f }; - if( ( Vehicle.EngineType == TEngineType::DieselElectric ) - || ( Vehicle.EngineType == TEngineType::DieselEngine ) ) { + if( Vehicle.EngineType == TEngineType::DieselElectric + || Vehicle.EngineType == TEngineType::DieselEngine ) { // diesel engine revolutions increase; it can potentially decrease volume of base engine sound if( engine_revs_last != -1.f ) { // calculate potential recent increase of engine revolutions @@ -8257,8 +8207,8 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub auto const revolutionsdifference { revolutionsperminute - engine_revs_last }; auto const idlerevolutionsthreshold { 1.01 * Vehicle.EngineIdleRPM() }; engine_revs_change = std::max( 0.0, engine_revs_change - 2.5 * Deltatime ); - if( ( revolutionsperminute > idlerevolutionsthreshold ) - && ( revolutionsdifference > 1.0 * Deltatime ) ) { + if( revolutionsperminute > idlerevolutionsthreshold + && revolutionsdifference > 1.0 * Deltatime ) { engine_revs_change = std::clamp( engine_revs_change + 5.0 * Deltatime, 0.0, 1.25 ); } enginerevvolume = 0.8 * engine_revs_change; @@ -8284,7 +8234,7 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub // multi-part revving sound pieces replace base engine sound, single revving simply gets mixed with the base auto const enginevolume { ( - ( ( enginerevvolume > 0.02 ) && ( true == engine_revving.is_combined() ) ) ? + enginerevvolume > 0.02 && true == engine_revving.is_combined() ? std::max( 0.0, engine_volume - enginerevvolume ) : engine_volume ) }; engine @@ -8318,24 +8268,18 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub // youBy - przenioslem, bo diesel tez moze miec turbo if( Vehicle.TurboTest > 0 ) { // udawanie turbo: - auto const pitch_diesel{(Vehicle.EngineType == TEngineType::DieselEngine || Vehicle.EngineType == TEngineType::DieselElectric) ? Vehicle.enrot / Vehicle.dizel_nmax * Vehicle.dizel_fill : 1}; + auto const pitch_diesel{Vehicle.EngineType == TEngineType::DieselEngine || Vehicle.EngineType == TEngineType::DieselElectric ? Vehicle.enrot / Vehicle.dizel_nmax * Vehicle.dizel_fill : 1}; auto const goalpitch { std::max( 0.025, ( /*engine_volume **/ pitch_diesel + engine_turbo.m_frequencyoffset ) * engine_turbo.m_frequencyfactor ) }; auto const goalvolume { ( - ( ( Vehicle.MainCtrlPos >= Vehicle.TurboTest ) && ( Vehicle.enrot > 0.1 ) ) ? + Vehicle.MainCtrlPos >= Vehicle.TurboTest && Vehicle.enrot > 0.1 ? std::max( 0.0, ( engine_turbo_pitch + engine_turbo.m_amplitudeoffset ) * engine_turbo.m_amplitudefactor ) : 0.0 ) }; auto const currentvolume { engine_turbo.gain() }; auto const changerate { 0.4 * Deltatime }; - engine_turbo_pitch = ( - engine_turbo_pitch > goalpitch ? - std::max( goalpitch, engine_turbo_pitch - changerate * 0.5 ) : - std::min( goalpitch, engine_turbo_pitch + changerate ) ); + engine_turbo_pitch = engine_turbo_pitch > goalpitch ? std::max(goalpitch, engine_turbo_pitch - changerate * 0.5) : std::min(goalpitch, engine_turbo_pitch + changerate); - volume = ( - currentvolume > goalvolume ? - std::max( goalvolume, currentvolume - changerate ) : - std::min( goalvolume, currentvolume + changerate ) ); + volume = currentvolume > goalvolume ? std::max(goalvolume, currentvolume - changerate) : std::min(goalvolume, currentvolume + changerate); engine_turbo .pitch( 0.4 + engine_turbo_pitch * 0.4 ) @@ -8352,14 +8296,11 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub if( Vehicle.dizel_engage > 0.1 ) { if( std::abs( Vehicle.dizel_engagedeltaomega ) > 0.2 ) { frequency = rsEngageSlippery.m_frequencyoffset + rsEngageSlippery.m_frequencyfactor * std::fabs( Vehicle.dizel_engagedeltaomega ); - volume = rsEngageSlippery.m_amplitudeoffset + rsEngageSlippery.m_amplitudefactor * ( Vehicle.dizel_engage ); + volume = rsEngageSlippery.m_amplitudeoffset + rsEngageSlippery.m_amplitudefactor * Vehicle.dizel_engage; } else { frequency = 1.f; // rsEngageSlippery.FA+0.7*rsEngageSlippery.FM*(fabs(mvControlled->enrot)+mvControlled->nmax); - volume = ( - Vehicle.dizel_engage > 0.2 ? - rsEngageSlippery.m_amplitudeoffset + 0.2 * rsEngageSlippery.m_amplitudefactor * ( Vehicle.enrot / Vehicle.nmax ) : - 0.f ); + volume = Vehicle.dizel_engage > 0.2 ? rsEngageSlippery.m_amplitudeoffset + 0.2 * rsEngageSlippery.m_amplitudefactor * (Vehicle.enrot / Vehicle.nmax) : 0.f; } rsEngageSlippery @@ -8378,7 +8319,7 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub .pitch(retarder.m_frequencyoffset + speed * retarder.m_frequencyfactor) .gain(retarder.m_amplitudeoffset + Vehicle.hydro_R_Fill * retarder.m_amplitudefactor); - if ((retarder.gain() > 0.01)&&(speed > 1)&&(Vehicle.hydro_R_ClutchActive)) { + if (retarder.gain() > 0.01 && speed > 1 && Vehicle.hydro_R_ClutchActive) { retarder.play(sound_flags::exclusive | sound_flags::looping); } else { @@ -8430,8 +8371,8 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub if( Vehicle.EngineType == TEngineType::ElectricSeriesMotor ) { // volume variation - if( ( volume < 1.0 ) - && ( Vehicle.EnginePower < 100 ) ) { + if( volume < 1.0 + && Vehicle.EnginePower < 100 ) { auto const volumevariation { LocalRandom( 100 ) * Vehicle.enrot / ( 1 + Vehicle.nmax ) }; if( volumevariation < 2 ) { @@ -8439,8 +8380,8 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub } } - if( ( Vehicle.DynamicBrakeFlag ) - && ( Vehicle.EnginePower > 0.1 ) ) { + if( Vehicle.DynamicBrakeFlag + && Vehicle.EnginePower > 0.1 ) { // Szociu - 29012012 - jeżeli uruchomiony jest hamulec elektrodynamiczny, odtwarzany jest dźwięk silnika volume += 0.8; } @@ -8506,7 +8447,7 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub // TODO: for the sounds with provided bookends invoke stop() when the stop is triggered and revolutions start dropping, instead of after full stop if( blower.revolutions > 1 ) { // NOTE: for motorblowers with fixed speed if the sound has defined bookends we skip revolutions-based part of frequency/volume adjustments - auto const revolutionmodifier { ( Vehicle.MotorBlowers[ end::front ].speed < 0.f ) && ( blowersound.has_bookends() ) ? 1.f : blower.revolutions }; + auto const revolutionmodifier { Vehicle.MotorBlowers[end::front].speed < 0.f && blowersound.has_bookends() ? 1.f : blower.revolutions }; blowersound .pitch( true == blowersound.is_combined() ? @@ -8548,8 +8489,8 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub rsWentylator.stop(); } // radiator fan sounds - if( ( Vehicle.EngineType == TEngineType::DieselEngine ) - || ( Vehicle.EngineType == TEngineType::DieselElectric ) ) { + if( Vehicle.EngineType == TEngineType::DieselEngine + || Vehicle.EngineType == TEngineType::DieselElectric ) { if( Vehicle.dizel_heat.rpmw > 0.1 ) { // NOTE: fan speed tends to max out at ~100 rpm; by default we try to get pitch range of 0.5-1.5 and volume range of 0.5-1.0 @@ -8651,7 +8592,7 @@ vehicle_table::update( double Deltatime, int Iterationcount ) { } if( Iterationcount > 1 ) { // ABu: ponizsze wykonujemy tylko jesli wiecej niz jedna iteracja - for( int iteration = 0; iteration < ( Iterationcount - 1 ); ++iteration ) { + for( int iteration = 0; iteration < Iterationcount - 1; ++iteration ) { for( auto *vehicle : m_items ) { vehicle->UpdateForce( Deltatime ); } @@ -8688,7 +8629,7 @@ vehicle_table::update_traction( TDynamicObject *Vehicle ) { auto *pantograph { Vehicle->pants[ pantographindex ].fParamPants }; if( true == Vehicle->MoverParameters->Pantographs[ pantographindex ].is_active ) { // jeśli pantograf podniesiony - auto const pant0 { position + ( vLeft * pantograph->vPos.z ) + ( vUp * pantograph->vPos.y ) + ( vFront * pantograph->vPos.x ) }; + auto const pant0 { position + vLeft * pantograph->vPos.z + vUp * pantograph->vPos.y + vFront * pantograph->vPos.x }; if( pantograph->hvPowerWire != nullptr ) { // jeżeli znamy drut z poprzedniego przebiegu for( int attempts = 0; attempts < 30; ++attempts ) { @@ -8756,8 +8697,8 @@ vehicle_table::update_traction( TDynamicObject *Vehicle ) { simulation::Region->update_traction( Vehicle, pantographindex ); } - if( ( pantograph->hvPowerWire == nullptr ) - && ( false == Global.bLiveTraction ) ) { + if( pantograph->hvPowerWire == nullptr + && false == Global.bLiveTraction ) { // jeśli drut nie znaleziony ale można oszukiwać to dajemy coś tam dla picu Vehicle->pants[ pantographindex ].fParamPants->PantTraction = 1.4; } @@ -8774,8 +8715,8 @@ void vehicle_table::DynamicList( bool const Onlycontrolled ) const { // odesłanie nazw pojazdów dostępnych na scenerii (nazwy, szczególnie wagonów, mogą się powtarzać!) for( auto const *vehicle : m_items ) { - if( ( false == Onlycontrolled ) - || ( vehicle->Mechanik != nullptr ) ) { + if( false == Onlycontrolled + || vehicle->Mechanik != nullptr ) { // same nazwy pojazdów multiplayer::WyslijString( vehicle->asName, 6 ); } @@ -8819,12 +8760,12 @@ vehicle_table::erase_disabled() { ++vehicleiter; } else { - if( ( vehicle->MyTrack != nullptr ) - && ( true == vehicle->MyTrack->RemoveDynamicObject( vehicle ) ) ) { + if( vehicle->MyTrack != nullptr + && true == vehicle->MyTrack->RemoveDynamicObject(vehicle) ) { vehicle->MyTrack = nullptr; } - if( ( simulation::Train != nullptr ) - && ( simulation::Train->Dynamic() == vehicle ) ) { + if( simulation::Train != nullptr + && simulation::Train->Dynamic() == vehicle ) { // clear potential train binding // TBD, TODO: kill vehicle sounds simulation::Train = nullptr; diff --git a/vehicle/DynObj.h b/vehicle/DynObj.h index f8204406..f8f2ce78 100644 --- a/vehicle/DynObj.h +++ b/vehicle/DynObj.h @@ -712,7 +712,7 @@ private: Axle1.pPosition : Axle0.pPosition; }; inline double Roll() { - return ( ( Axle1.GetRoll() + Axle0.GetRoll() ) ); } + return Axle1.GetRoll() + Axle0.GetRoll(); } /* // TODO: check if scanning takes into account direction when selecting axle // if it does, replace the version above @@ -743,16 +743,14 @@ private: // calculates distance between event-starting axle and front of the vehicle double tracing_offset() const; inline TTrack * GetTrack() { - return (iAxleFirst ? - Axle1.GetTrack() : - Axle0.GetTrack()); }; + return iAxleFirst ? Axle1.GetTrack() : Axle0.GetTrack(); }; // McZapkie-260202 void LoadMMediaFile(std::string const &TypeName, std::string const &ReplacableSkin); TModel3d *LoadMMediaFile_mdload( std::string const &Name ) const; inline double ABuGetDirection() const { // ABu. - return (Axle1.GetTrack() == MyTrack ? Axle1.GetDirection() : Axle0.GetDirection()); }; + return Axle1.GetTrack() == MyTrack ? Axle1.GetDirection() : Axle0.GetDirection(); }; // zwraca kierunek pojazdu na torze z aktywną osą inline double RaDirectionGet() const { return iAxleFirst ? diff --git a/vehicle/Gauge.cpp b/vehicle/Gauge.cpp index 1b68561b..a510b05f 100644 --- a/vehicle/Gauge.cpp +++ b/vehicle/Gauge.cpp @@ -49,18 +49,18 @@ void TGauge::Init(TSubModel *Submodel, TSubModel *Submodelon, TGaugeAnimation Ty auto *sm { ( SubModel ? SubModel->ChildGet() : nullptr ) }; while( sm != nullptr ) { // pętla po submodelach potomnych i obracanie ich o kąt zależy od cyfry w (fValue) - if( ( sm->pName.size() )// musi mieć niepustą nazwę - && ( std::isdigit( sm->pName[ 0 ] ) ) ) { + if( sm->pName.size() // musi mieć niepustą nazwę + && std::isdigit(sm->pName[0]) ) { sm->WillBeAnimated(); // wyłączenie optymalizacji } sm = sm->NextGet(); } // do the same for the active version - sm = ( SubModelOn ? SubModelOn->ChildGet() : nullptr ); + sm = SubModelOn ? SubModelOn->ChildGet() : nullptr; while( sm != nullptr ) { // pętla po submodelach potomnych i obracanie ich o kąt zależy od cyfry w (fValue) - if( ( sm->pName.size() )// musi mieć niepustą nazwę - && ( std::isdigit( sm->pName[ 0 ] ) ) ) { + if( sm->pName.size() // musi mieć niepustą nazwę + && std::isdigit(sm->pName[0]) ) { sm->WillBeAnimated(); // wyłączenie optymalizacji } sm = sm->NextGet(); @@ -113,8 +113,8 @@ void TGauge::Load( cParser &Parser, TDynamicObject const *Owner, double const mu >> scale >> offset >> friction; - if( ( gaugetypename == "rotvar" ) - || ( gaugetypename == "movvar" ) ) { + if( gaugetypename == "rotvar" + || gaugetypename == "movvar" ) { interpolatescale = true; Parser.getTokens( 2, false ); Parser @@ -132,8 +132,8 @@ void TGauge::Load( cParser &Parser, TDynamicObject const *Owner, double const mu >> scale >> offset >> friction; - if( ( gaugetypename == "rotvar" ) - || ( gaugetypename == "movvar" ) ) { + if( gaugetypename == "rotvar" + || gaugetypename == "movvar" ) { interpolatescale = true; Parser.getTokens( 2, false ); Parser @@ -186,13 +186,13 @@ void TGauge::Load( cParser &Parser, TDynamicObject const *Owner, double const mu TSubModel *submodel { nullptr }; std::array sources { Owner->mdKabina, Owner->mdLowPolyInt }; for( auto const *source : sources ) { - if( ( source != nullptr ) + if( source != nullptr && ( submodel = source->GetFromName( submodelname ) ) != nullptr ) { // got what we wanted, bail out break; } // there's a possibility the default submodel was named with _off suffix - if( ( source != nullptr ) + if( source != nullptr && ( submodel = source->GetFromName( submodelname + "_off" ) ) != nullptr ) { // got what we wanted, bail out break; @@ -204,7 +204,7 @@ void TGauge::Load( cParser &Parser, TDynamicObject const *Owner, double const mu // see if we can locate optional submodel for active state, with _on suffix TSubModel *submodelon { nullptr }; for( auto const *source : sources ) { - if( ( source != nullptr ) + if( source != nullptr && ( submodelon = source->GetFromName( submodelname + "_on" ) ) != nullptr ) { // got what we wanted, bail out break; @@ -220,10 +220,7 @@ void TGauge::Load( cParser &Parser, TDynamicObject const *Owner, double const mu { "dgt", TGaugeAnimation::gt_Digital } }; auto lookup = gaugetypes.find( gaugetypename ); - auto const type = ( - lookup != gaugetypes.end() ? - lookup->second : - TGaugeAnimation::gt_Unknown ); + auto const type = lookup != gaugetypes.end() ? lookup->second : TGaugeAnimation::gt_Unknown; Init( submodel, submodelon, type, scale, offset, friction, 0, endvalue, endscale, interpolatescale ); @@ -235,18 +232,17 @@ TGauge::Load_mapping( cParser &Input, TGauge::scratch_data &Scratchpad ) { // token can be a key or block end auto 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 == "type:" ) { auto const gaugetype { Input.getToken( true, "\n\r\t ,;" ) }; - m_type = ( - gaugetype == "push" ? TGaugeType::push : - gaugetype == "impulse" ? TGaugeType::push : - gaugetype == "return" ? TGaugeType::push : - gaugetype == "delayed" ? TGaugeType::push_delayed : - gaugetype == "pushtoggle" ? TGaugeType::pushtoggle : - gaugetype == "toggle" ? TGaugeType::toggle : - TGaugeType::toggle ); // default + m_type = gaugetype == "push" ? TGaugeType::push : + gaugetype == "impulse" ? TGaugeType::push : + gaugetype == "return" ? TGaugeType::push : + gaugetype == "delayed" ? TGaugeType::push_delayed : + gaugetype == "pushtoggle" ? TGaugeType::pushtoggle : + gaugetype == "toggle" ? TGaugeType::toggle : + TGaugeType::toggle; // default } else if( key == "soundinc:" ) { m_soundfxincrease.deserialize( Input, sound_type::single ); @@ -363,7 +359,7 @@ void TGauge::Update( bool const Power ) { // TODO: remove passing manually power state when LD is in place if( m_value != m_targetvalue ) { float dt = Timer::GetDeltaTime(); - if( ( m_friction > 0 ) && ( dt < 0.5 * m_friction ) ) { + if( m_friction > 0 && dt < 0.5 * m_friction ) { // McZapkie-281102: zabezpieczenie przed oscylacjami dla dlugich czasow m_value += dt * ( m_targetvalue - m_value ) / m_friction; if( std::abs( m_targetvalue - m_value ) <= 0.0001 ) { @@ -388,7 +384,7 @@ void TGauge::Update( bool const Power ) { if( SubModelOn != nullptr ) { SubModelOn->iVisible = m_state; if( SubModel != nullptr ) { - SubModel->iVisible = ( !m_state ); + SubModel->iVisible = !m_state; } } // update submodel animations @@ -437,7 +433,7 @@ void TGauge::UpdateValue() break; } case 'b': { - UpdateValue( ( *bData ? 1.f : 0.f ) ); + UpdateValue( *bData ? 1.f : 0.f ); break; } default: { @@ -453,16 +449,7 @@ void TGauge::AssignState( bool const *State ) { float TGauge::GetScaledValue() const { - return ( - ( false == m_interpolatescale ) ? - m_value * m_scale + m_offset : - m_value - * std::lerp( - m_scale, m_endscale, - std::clamp( - m_value / m_endvalue, - 0.f, 1.f ) ) - + m_offset ); + return false == m_interpolatescale ? m_value * m_scale + m_offset : m_value * std::lerp(m_scale, m_endscale, std::clamp(m_value / m_endvalue, 0.f, 1.f)) + m_offset; } void @@ -498,8 +485,8 @@ TGauge::UpdateAnimation( TSubModel *Submodel ) { */ std::string n( "000000000" + std::to_string( static_cast( std::floor( GetScaledValue() ) ) ) ); if( n.length() > 10 ) { n.erase( 0, n.length() - 10 ); } // also dumb but should work for now do { // pętla po submodelach potomnych i obracanie ich o kąt zależy od cyfry w (fValue) - if( ( sm->pName.size() ) - && ( std::isdigit( sm->pName[ 0 ] ) ) ) { + if( sm->pName.size() + && std::isdigit(sm->pName[0]) ) { sm->SetRotate( float3( 0, 1, 0 ), -36.0 * ( n[ '0' + 9 - sm->pName[ 0 ] ] - '0' ) ); @@ -518,10 +505,7 @@ TGauge::UpdateAnimation( TSubModel *Submodel ) { glm::vec3 TGauge::model_offset() const { - return ( - SubModel != nullptr ? - SubModel->offset( 1.f ) : - glm::vec3() ); + return SubModel != nullptr ? SubModel->offset(1.f) : glm::vec3(); } TGaugeType diff --git a/vehicle/Gauge.h b/vehicle/Gauge.h index c8302666..bf0f83c3 100644 --- a/vehicle/Gauge.h +++ b/vehicle/Gauge.h @@ -25,9 +25,9 @@ enum class TGaugeType : int { toggle = 1 << 0, push = 1 << 1, delayed = 1 << 2, - pushtoggle = ( toggle | push ), - push_delayed = ( push | delayed ), - pushtoggle_delayed = ( toggle | push | delayed ) + pushtoggle = toggle | push, + push_delayed = push | delayed, + pushtoggle_delayed = toggle | push | delayed }; // animowany wskaźnik, mogący przyjmować wiele stanów pośrednich diff --git a/vehicle/Train.cpp b/vehicle/Train.cpp index a00c8a1b..d010f2dc 100644 --- a/vehicle/Train.cpp +++ b/vehicle/Train.cpp @@ -78,7 +78,7 @@ std::string control_mapper::find(TSubModel const *Control) const bool control_mapper::contains(std::string const Control) const { - return (m_names.find(Control) != m_names.end()); + return m_names.find(Control) != m_names.end(); } void TTrain::screen_entry::deserialize(cParser &Input) @@ -95,7 +95,7 @@ bool TTrain::screen_entry::deserialize_mapping(cParser &Input) // token can be a key or block end auto const key{Input.getToken(true, "\n\r\t ,;[]")}; - if ((true == key.empty()) || (key == "}")) + if (true == key.empty() || key == "}") { return false; } @@ -654,7 +654,7 @@ bool TTrain::Init(TDynamicObject *NewDynamicObject, bool e3d) fMainRelayTimer = 0; // Hunter, do k...y nędzy, ustawiaj wartości początkowe zmiennych! - iCabn = (mvOccupied->CabOccupied > 0 ? 1 : mvOccupied->CabOccupied < 0 ? 2 : 0); + iCabn = mvOccupied->CabOccupied > 0 ? 1 : mvOccupied->CabOccupied < 0 ? 2 : 0; { Global.CurrentMaxTextureSize = Global.iMaxCabTextureSize; @@ -696,7 +696,7 @@ bool TTrain::Init(TDynamicObject *NewDynamicObject, bool e3d) std::shared_ptr TTrain::GetTrainState(dictionary_source const &Extraparameters) { - if ((mvOccupied == nullptr) || (mvControlled == nullptr)) + if (mvOccupied == nullptr || mvControlled == nullptr) { return nullptr; } @@ -714,8 +714,8 @@ std::shared_ptr TTrain::GetTrainState(dictionary_source const // basic systems state data dict->insert("battery", mvOccupied->Power24vIsAvailable); dict->insert("linebreaker", mvControlled->Mains); - dict->insert("main_init", (mvControlled->MainsInitTimeCountdown < mvControlled->MainsInitTime) && (mvControlled->MainsInitTimeCountdown > 0.0)); - dict->insert("main_ready", (false == mvControlled->Mains) && (fHVoltage > 0.0) && (mvControlled->MainsInitTimeCountdown <= 0.0)); + dict->insert("main_init", mvControlled->MainsInitTimeCountdown < mvControlled->MainsInitTime && mvControlled->MainsInitTimeCountdown > 0.0); + dict->insert("main_ready", false == mvControlled->Mains && fHVoltage > 0.0 && mvControlled->MainsInitTimeCountdown <= 0.0); dict->insert("converter", mvOccupied->Power110vIsAvailable); dict->insert("converter_overload", mvControlled->ConvOvldFlag); dict->insert("compress", mvControlled->CompressorFlag); @@ -760,15 +760,15 @@ std::shared_ptr TTrain::GetTrainState(dictionary_source const dict->insert("speedctrlactive", mvOccupied->SpeedCtrlUnit.IsActive); dict->insert("speedctrlstandby", mvOccupied->SpeedCtrlUnit.Standby); // brakes - dict->insert("manual_brake", (mvOccupied->ManualBrakePos > 0)); - bool const bEP = (mvControlled->LocHandle->GetCP() > 0.2) || (fEIMParams[0][5] > 0.01); + dict->insert("manual_brake", mvOccupied->ManualBrakePos > 0); + bool const bEP = mvControlled->LocHandle->GetCP() > 0.2 || fEIMParams[0][5] > 0.01; dict->insert("dir_brake", bEP); bool bPN{false}; - if ((typeid(*mvOccupied->Hamulec) == typeid(TLSt)) || (typeid(*mvOccupied->Hamulec) == typeid(TEStED))) + if (typeid(*mvOccupied->Hamulec) == typeid(TLSt) || typeid(*mvOccupied->Hamulec) == typeid(TEStED)) { TBrake *temp_ham = mvOccupied->Hamulec.get(); - bPN = (static_cast(temp_ham)->GetEDBCP() > 0.2); + bPN = static_cast(temp_ham)->GetEDBCP() > 0.2; } dict->insert("indir_brake", bPN); dict->insert("emergency_brake", mvOccupied->AlarmChainFlag); @@ -785,7 +785,7 @@ std::shared_ptr TTrain::GetTrainState(dictionary_source const { if (idx != 3) { - dict->insert("universal" + std::to_string(idx), (ggUniversals[idx].GetValue() > 0.5)); + dict->insert("universal" + std::to_string(idx), ggUniversals[idx].GetValue() > 0.5); } } dict->insert("radio", mvOccupied->Radio); @@ -817,27 +817,27 @@ std::shared_ptr TTrain::GetTrainState(dictionary_source const char const *TXTP[7] = {"bc", "bp", "sp", "cp", "rp", "mass", "spring"}; char const *TXTB[2] = {"spring_active", "spring_shutoff"}; for (int j = 0; j < 10; ++j) - dict->insert(("eimp_t_" + std::string(TXTT[j])), fEIMParams[0][j]); + dict->insert("eimp_t_" + std::string(TXTT[j]), fEIMParams[0][j]); for (int i = 0; i < 8; ++i) { auto const idx{std::to_string(i + 1)}; for (int j = 0; j < 10; ++j) - dict->insert(("eimp_c" + idx + "_" + std::string(TXTC[j])), fEIMParams[i + 1][j]); + dict->insert("eimp_c" + idx + "_" + std::string(TXTC[j]), fEIMParams[i + 1][j]); for (int j = 0; j < 10; ++j) - dict->insert(("diesel_param_" + idx + "_" + std::string(TXTD[j])), fDieselParams[i + 1][j]); + dict->insert("diesel_param_" + idx + "_" + std::string(TXTD[j]), fDieselParams[i + 1][j]); - dict->insert(("eimp_c" + idx + "_ms"), bMains[i]); - dict->insert(("eimp_c" + idx + "_cv"), fCntVol[i]); - dict->insert(("eimp_c" + idx + "_fuse"), bFuse[i]); - dict->insert(("eimp_c" + idx + "_batt"), bBatt[i]); - dict->insert(("eimp_c" + idx + "_conv"), bConv[i]); - dict->insert(("eimp_c" + idx + "_heat"), bHeat[i]); + dict->insert("eimp_c" + idx + "_ms", bMains[i]); + dict->insert("eimp_c" + idx + "_cv", fCntVol[i]); + dict->insert("eimp_c" + idx + "_fuse", bFuse[i]); + dict->insert("eimp_c" + idx + "_batt", bBatt[i]); + dict->insert("eimp_c" + idx + "_conv", bConv[i]); + dict->insert("eimp_c" + idx + "_heat", bHeat[i]); - dict->insert(("eimp_u" + idx + "_pf"), bPants[i][0]); - dict->insert(("eimp_u" + idx + "_pr"), bPants[i][1]); - dict->insert(("eimp_u" + idx + "_comp_a"), bComp[i][0]); - dict->insert(("eimp_u" + idx + "_comp_w"), bComp[i][1]); + dict->insert("eimp_u" + idx + "_pf", bPants[i][0]); + dict->insert("eimp_u" + idx + "_pr", bPants[i][1]); + dict->insert("eimp_u" + idx + "_comp_a", bComp[i][0]); + dict->insert("eimp_u" + idx + "_comp_w", bComp[i][1]); } dict->insert("compressors_no", (int)bCompressors.size()); @@ -849,7 +849,7 @@ std::shared_ptr TTrain::GetTrainState(dictionary_source const dict->insert("compressors_" + idx + "_car_no", std::get<2>(bCompressors[i])); } - bool kier = (DynamicObject->DirectionGet() * mvOccupied->CabOccupied > 0); + bool kier = DynamicObject->DirectionGet() * mvOccupied->CabOccupied > 0; TDynamicObject *p = DynamicObject->GetFirstDynamic(mvOccupied->CabOccupied < 0 ? end::rear : end::front, 4); int in = 0; while (p && in < 8) @@ -857,25 +857,25 @@ std::shared_ptr TTrain::GetTrainState(dictionary_source const if (p->MoverParameters->eimc[eimc_p_Pmax] > 1) { in++; - dict->insert(("eimp_c" + std::to_string(in) + "_invno"), p->MoverParameters->InvertersNo); + dict->insert("eimp_c" + std::to_string(in) + "_invno", p->MoverParameters->InvertersNo); for (int j = 0; j < p->MoverParameters->InvertersNo; j++) { - dict->insert(("eimp_c" + std::to_string(in) + "_inv" + std::to_string(j + 1) + "_act"), p->MoverParameters->Inverters[j].IsActive); - dict->insert(("eimp_c" + std::to_string(in) + "_inv" + std::to_string(j + 1) + "_error"), p->MoverParameters->Inverters[j].Error); - dict->insert(("eimp_c" + std::to_string(in) + "_inv" + std::to_string(j + 1) + "_allow"), p->MoverParameters->Inverters[j].Activate); + dict->insert("eimp_c" + std::to_string(in) + "_inv" + std::to_string(j + 1) + "_act", p->MoverParameters->Inverters[j].IsActive); + dict->insert("eimp_c" + std::to_string(in) + "_inv" + std::to_string(j + 1) + "_error", p->MoverParameters->Inverters[j].Error); + dict->insert("eimp_c" + std::to_string(in) + "_inv" + std::to_string(j + 1) + "_allow", p->MoverParameters->Inverters[j].Activate); } } - p = (kier ? p->Next(4) : p->Prev(4)); + p = kier ? p->Next(4) : p->Prev(4); } for (int i = 0; i < 20; ++i) { for (int j = 0; j < 7; ++j) { - dict->insert(("eimp_pn" + std::to_string(i + 1) + "_" + TXTP[j]), fPress[i][j]); + dict->insert("eimp_pn" + std::to_string(i + 1) + "_" + TXTP[j], fPress[i][j]); } for (int j = 0; j < 2; ++j) { - dict->insert(("brakes_" + std::to_string(i + 1) + "_" + TXTB[j]), bBrakes[i][j]); + dict->insert("brakes_" + std::to_string(i + 1) + "_" + TXTB[j], bBrakes[i][j]); } } // multi-unit state data @@ -886,15 +886,15 @@ std::shared_ptr TTrain::GetTrainState(dictionary_source const for (int i = 0; i < 20; i++) { auto const caridx{std::to_string(i + 1)}; - dict->insert(("doors_" + caridx), bDoors[i][0]); - dict->insert(("doors_l_" + caridx), bDoors[i][1]); - dict->insert(("doors_r_" + caridx), bDoors[i][2]); - dict->insert(("doorstep_l_" + caridx), bDoors[i][3]); - dict->insert(("doorstep_r_" + caridx), bDoors[i][4]); - dict->insert(("doors_no_" + caridx), iDoorNo[i]); - dict->insert(("code_" + caridx), (std::to_string(iUnits[i]) + cCode[i])); - dict->insert(("car_name" + caridx), asCarName[i]); - dict->insert(("slip_" + caridx), bSlip[i]); + dict->insert("doors_" + caridx, bDoors[i][0]); + dict->insert("doors_l_" + caridx, bDoors[i][1]); + dict->insert("doors_r_" + caridx, bDoors[i][2]); + dict->insert("doorstep_l_" + caridx, bDoors[i][3]); + dict->insert("doorstep_r_" + caridx, bDoors[i][4]); + dict->insert("doors_no_" + caridx, iDoorNo[i]); + dict->insert("code_" + caridx, std::to_string(iUnits[i]) + cCode[i]); + dict->insert("car_name" + caridx, asCarName[i]); + dict->insert("slip_" + caridx, bSlip[i]); } // ai state data auto const *driver{(DynamicObject->ctOwner != nullptr ? DynamicObject->ctOwner : DynamicObject->Mechanik)}; @@ -951,7 +951,7 @@ TTrain::state_t TTrain::get_state() const static_cast(mvOccupied->BrakePress), static_cast(mvPantographUnit->PantPress), fHVoltage, - {fHCurrent[(mvControlled->TrainType & dt_EZT) ? 0 : 1], fHCurrent[2], fHCurrent[3]}, + {fHCurrent[mvControlled->TrainType & dt_EZT ? 0 : 1], fHCurrent[2], fHCurrent[3]}, ggLVoltage.GetValue(), mvOccupied->DistCounter, static_cast(RadioChannel()), @@ -974,21 +974,21 @@ TTrain::state_t TTrain::get_state() const bool TTrain::is_eztoer() const { - return ((mvControlled->TrainType == dt_EZT) && (mvOccupied->BrakeSubsystem == TBrakeSubSystem::ss_ESt) && (mvControlled->Power24vIsAvailable == true) && (mvControlled->EpFuse == true) && - (mvControlled->DirActive != 0)); // od yB + return mvControlled->TrainType == dt_EZT && mvOccupied->BrakeSubsystem == TBrakeSubSystem::ss_ESt && mvControlled->Power24vIsAvailable == true && mvControlled->EpFuse == true && + mvControlled->DirActive != 0; // od yB } // mover master controller to specified position void TTrain::set_master_controller(double const Position) { - auto positionchange{std::min(Position, (mvControlled->CoupledCtrl ? mvControlled->MainCtrlPosNo + mvControlled->ScndCtrlPosNo : mvControlled->MainCtrlPosNo)) - + auto positionchange{std::min(Position, mvControlled->CoupledCtrl ? mvControlled->MainCtrlPosNo + mvControlled->ScndCtrlPosNo : mvControlled->MainCtrlPosNo) - (mvControlled->CoupledCtrl ? mvControlled->MainCtrlPos + mvControlled->ScndCtrlPos : mvControlled->MainCtrlPos)}; - while ((positionchange < 0) && (true == mvControlled->DecMainCtrl(1))) + while (positionchange < 0 && true == mvControlled->DecMainCtrl(1)) { ++positionchange; } - while ((positionchange > 0) && (true == mvControlled->IncMainCtrl(1))) + while (positionchange > 0 && true == mvControlled->IncMainCtrl(1)) { --positionchange; } @@ -1006,7 +1006,7 @@ void TTrain::set_train_brake(double const Position) return; } - if ((true == is_eztoer()) && (false == (((originalbrakeposition / 100 == 0) || (originalbrakeposition / 100 >= 5)) && ((mvOccupied->BrakeCtrlPos == 0) || (mvOccupied->BrakeCtrlPos >= 5))))) + if (true == is_eztoer() && false == ((originalbrakeposition / 100 == 0 || originalbrakeposition / 100 >= 5) && (mvOccupied->BrakeCtrlPos == 0 || mvOccupied->BrakeCtrlPos >= 5))) { // sound feedback if the lever movement activates one of the switches if (dsbPneumaticSwitch) @@ -1019,8 +1019,8 @@ void TTrain::set_train_brake(double const Position) void TTrain::zero_charging_train_brake() { - if ((mvOccupied->BrakeCtrlPos == -1) && (DynamicObject->Controller != AIdriver) && (Global.iFeedbackMode < 3) && - ((mvOccupied->BrakeHandle == TBrakeHandle::FVel6) || (mvOccupied->BrakeHandle == TBrakeHandle::MHZ_EN57) || (mvOccupied->BrakeHandle == TBrakeHandle::MHZ_K8P))) + if (mvOccupied->BrakeCtrlPos == -1 && DynamicObject->Controller != AIdriver && Global.iFeedbackMode < 3 && + (mvOccupied->BrakeHandle == TBrakeHandle::FVel6 || mvOccupied->BrakeHandle == TBrakeHandle::MHZ_EN57 || mvOccupied->BrakeHandle == TBrakeHandle::MHZ_K8P)) { // Odskakiwanie hamulce EP set_train_brake(0); @@ -1038,15 +1038,15 @@ void TTrain::set_train_brake_speed(TDynamicObject *Vehicle, int const Speed) { if (ggBrakeProfileCtrl.SubModel != nullptr) { - ggBrakeProfileCtrl.UpdateValue(((mvOccupied->BrakeDelayFlag & bdelay_R) != 0 ? 2.0 : mvOccupied->BrakeDelayFlag - 1), dsbSwitch); + ggBrakeProfileCtrl.UpdateValue((mvOccupied->BrakeDelayFlag & bdelay_R) != 0 ? 2.0 : mvOccupied->BrakeDelayFlag - 1, dsbSwitch); } if (ggBrakeProfileG.SubModel != nullptr) { - ggBrakeProfileG.UpdateValue((mvOccupied->BrakeDelayFlag == bdelay_G ? 1.0 : 0.0), dsbSwitch); + ggBrakeProfileG.UpdateValue(mvOccupied->BrakeDelayFlag == bdelay_G ? 1.0 : 0.0, dsbSwitch); } if (ggBrakeProfileR.SubModel != nullptr) { - ggBrakeProfileR.UpdateValue(((mvOccupied->BrakeDelayFlag & bdelay_R) != 0 ? 1.0 : 0.0), dsbSwitch); + ggBrakeProfileR.UpdateValue((mvOccupied->BrakeDelayFlag & bdelay_R) != 0 ? 1.0 : 0.0, dsbSwitch); } } } @@ -1055,15 +1055,15 @@ void TTrain::set_train_brake_speed(TDynamicObject *Vehicle, int const Speed) void TTrain::set_paired_open_motor_connectors_button(bool const State) { - if ((mvControlled->TrainType == dt_ET41) || (mvControlled->TrainType == dt_ET42)) + if (mvControlled->TrainType == dt_ET41 || mvControlled->TrainType == dt_ET42) { // crude implementation of the button affecting entire unit for multi-unit engines // TODO: rework it into part of standard command propagation system - if ((mvControlled->Couplers[end::front].Connected != nullptr) && (true == TestFlag(mvControlled->Couplers[end::front].CouplingFlag, coupling::permanent))) + if (mvControlled->Couplers[end::front].Connected != nullptr && true == TestFlag(mvControlled->Couplers[end::front].CouplingFlag, coupling::permanent)) { mvControlled->Couplers[end::front].Connected->StLinSwitchOff = State; } - if ((mvControlled->Couplers[end::rear].Connected != nullptr) && (true == TestFlag(mvControlled->Couplers[end::rear].CouplingFlag, coupling::permanent))) + if (mvControlled->Couplers[end::rear].Connected != nullptr && true == TestFlag(mvControlled->Couplers[end::rear].CouplingFlag, coupling::permanent)) { mvControlled->Couplers[end::rear].Connected->StLinSwitchOff = State; } @@ -1145,7 +1145,7 @@ void TTrain::OnCommand_jointcontrollerset(TTrain *Train, command_data const &Com } else { - auto const negativeRange{std::clamp(1.0 - (Command.param1 * 2), 0.0, 1.0)}; + auto const negativeRange{std::clamp(1.0 - Command.param1 * 2, 0.0, 1.0)}; if (Train->mvControlled->SplitEDPneumaticBrake) { // negative range of jointctrl drives only ED braking, local pneumatic brake stays untouched. @@ -1181,8 +1181,8 @@ void TTrain::OnCommand_mastercontrollerincrease(TTrain *Train, command_data cons auto const splitMode{Train->mvControlled->SplitEDPneumaticBrake}; // when SplitEDPneumaticBrake is true the joint controller's negative range maps // to the dedicated dynamic-brake lever (DynamicBrakeCtrl) rather than to LocalBrake - auto const negativeRangeActive{splitMode ? (Train->mvControlled->DynamicBrakeCtrlPos > 0.0) : (Train->mvOccupied->LocalBrakePosA > 0.0)}; - if ((Train->ggJointCtrl.SubModel != nullptr) && negativeRangeActive) + auto const negativeRangeActive{splitMode ? Train->mvControlled->DynamicBrakeCtrlPos > 0.0 : Train->mvOccupied->LocalBrakePosA > 0.0}; + if (Train->ggJointCtrl.SubModel != nullptr && negativeRangeActive) { if (splitMode) { @@ -1215,8 +1215,8 @@ void TTrain::OnCommand_mastercontrollerincreasefast(TTrain *Train, command_data { // on press or hold auto const splitMode{Train->mvControlled->SplitEDPneumaticBrake}; - auto const negativeRangeActive{splitMode ? (Train->mvControlled->DynamicBrakeCtrlPos > 0.0) : (Train->mvOccupied->LocalBrakePosA > 0.0)}; - if ((Train->ggJointCtrl.SubModel != nullptr) && negativeRangeActive) + auto const negativeRangeActive{splitMode ? Train->mvControlled->DynamicBrakeCtrlPos > 0.0 : Train->mvOccupied->LocalBrakePosA > 0.0}; + if (Train->ggJointCtrl.SubModel != nullptr && negativeRangeActive) { if (splitMode) { @@ -1249,7 +1249,7 @@ void TTrain::OnCommand_mastercontrollerdecrease(TTrain *Train, command_data cons { // on press or hold auto const splitMode{Train->mvControlled->SplitEDPneumaticBrake}; - if ((Train->ggJointCtrl.SubModel != nullptr) && (Train->mvControlled->IsMainCtrlNoPowerPos())) + if (Train->ggJointCtrl.SubModel != nullptr && Train->mvControlled->IsMainCtrlNoPowerPos()) { // negative range of jointctrl: ED brake when split, otherwise pneumatic local brake if (splitMode) @@ -1283,7 +1283,7 @@ void TTrain::OnCommand_mastercontrollerdecreasefast(TTrain *Train, command_data { // on press or hold auto const splitMode{Train->mvControlled->SplitEDPneumaticBrake}; - if ((Train->ggJointCtrl.SubModel != nullptr) && (Train->mvControlled->IsMainCtrlNoPowerPos())) + if (Train->ggJointCtrl.SubModel != nullptr && Train->mvControlled->IsMainCtrlNoPowerPos()) { if (splitMode) { @@ -1404,7 +1404,7 @@ void TTrain::OnCommand_DynamicBrakeControllerSet(TTrain *Train, command_data con void TTrain::OnCommand_secondcontrollerincrease(TTrain *Train, command_data const &Command) { - if ((Train->mvControlled->EngineType == TEngineType::DieselElectric) && (true == Train->mvControlled->ShuntModeAllow) && (true == Train->mvControlled->ShuntMode)) + if (Train->mvControlled->EngineType == TEngineType::DieselElectric && true == Train->mvControlled->ShuntModeAllow && true == Train->mvControlled->ShuntMode) { if (Command.action != GLFW_RELEASE) { @@ -1436,12 +1436,12 @@ void TTrain::OnCommand_secondcontrollerincrease(TTrain *Train, command_data cons { auto const activeposition{Train->ggScndCtrl.is_toggle() ? 1.f : 1.f}; auto const neutralposition{Train->ggScndCtrl.is_toggle() ? 0.5f : 0.f}; - Train->ggScndCtrl.UpdateValue(((Command.action == GLFW_RELEASE) ? neutralposition : activeposition), Train->dsbSwitch); + Train->ggScndCtrl.UpdateValue(Command.action == GLFW_RELEASE ? neutralposition : activeposition, Train->dsbSwitch); } // potentially animate tempomat button - if ((Train->ggScndCtrlButton.is_push()) && (Train->mvControlled->ScndCtrlPos <= 1)) + if (Train->ggScndCtrlButton.is_push() && Train->mvControlled->ScndCtrlPos <= 1) { - Train->ggScndCtrlButton.UpdateValue(((Command.action == GLFW_RELEASE) ? 0.f : 1.f), Train->dsbSwitch); + Train->ggScndCtrlButton.UpdateValue(Command.action == GLFW_RELEASE ? 0.f : 1.f, Train->dsbSwitch); } } } @@ -1452,7 +1452,7 @@ void TTrain::OnCommand_secondcontrollerincreasefast(TTrain *Train, command_data if (Command.action != GLFW_RELEASE) { // on press or hold - if ((Train->mvControlled->EngineType == TEngineType::DieselElectric) && (true == Train->mvControlled->ShuntMode)) + if (Train->mvControlled->EngineType == TEngineType::DieselElectric && true == Train->mvControlled->ShuntMode) { Train->mvControlled->AnPos = 1.0; } @@ -1609,7 +1609,7 @@ void TTrain::OnCommand_mucurrentindicatorothersourceactivate(TTrain *Train, comm void TTrain::OnCommand_secondcontrollerdecrease(TTrain *Train, command_data const &Command) { - if ((Train->mvControlled->EngineType == TEngineType::DieselElectric) && (true == Train->mvControlled->ShuntMode)) + if (Train->mvControlled->EngineType == TEngineType::DieselElectric && true == Train->mvControlled->ShuntMode) { if (Command.action != GLFW_RELEASE) { @@ -1645,18 +1645,18 @@ void TTrain::OnCommand_secondcontrollerdecrease(TTrain *Train, command_data cons { auto const activeposition{Train->ggScndCtrl.is_toggle() ? 0.f : 1.f}; auto const neutralposition{Train->ggScndCtrl.is_toggle() ? 0.5f : 0.f}; - Train->ggScndCtrl.UpdateValue(((Command.action == GLFW_RELEASE) ? neutralposition : activeposition), Train->dsbSwitch); + Train->ggScndCtrl.UpdateValue(Command.action == GLFW_RELEASE ? neutralposition : activeposition, Train->dsbSwitch); } // potentially animate tempomat button - if ((Train->ggScndCtrlButton.is_push()) && (Train->mvControlled->ScndCtrlPos <= 1)) + if (Train->ggScndCtrlButton.is_push() && Train->mvControlled->ScndCtrlPos <= 1) { if (Train->m_controlmapper.contains("tempomatoff_sw:")) { - Train->ggScndCtrlOffButton.UpdateValue(((Command.action == GLFW_RELEASE) ? 0.f : 1.f), Train->dsbSwitch); + Train->ggScndCtrlOffButton.UpdateValue(Command.action == GLFW_RELEASE ? 0.f : 1.f, Train->dsbSwitch); } else { - Train->ggScndCtrlButton.UpdateValue(((Command.action == GLFW_RELEASE) ? 0.f : 1.f), Train->dsbSwitch); + Train->ggScndCtrlButton.UpdateValue(Command.action == GLFW_RELEASE ? 0.f : 1.f, Train->dsbSwitch); } } } @@ -1668,7 +1668,7 @@ void TTrain::OnCommand_secondcontrollerdecreasefast(TTrain *Train, command_data if (Command.action != GLFW_RELEASE) { // on press or hold - if ((Train->mvControlled->EngineType == TEngineType::DieselElectric) && (true == Train->mvControlled->ShuntMode)) + if (Train->mvControlled->EngineType == TEngineType::DieselElectric && true == Train->mvControlled->ShuntMode) { Train->mvControlled->AnPos = 0.0; } @@ -1690,20 +1690,21 @@ void TTrain::OnCommand_secondcontrollerset(TTrain *Train, command_data const &Co (targetposition < Train->mvControlled->ScndCtrlPos ? 0.f : targetposition > Train->mvControlled->ScndCtrlPos ? 1.f : Train->ggScndCtrl.GetDesiredValue()) : // leave the control in its current position if it hits the limit - (targetposition == 0 ? 0.f : 1.f)}; + targetposition == 0 ? 0.f : + 1.f}; auto const neutralposition{Train->ggScndCtrl.is_toggle() ? 0.5f : 0.f}; - Train->ggScndCtrl.UpdateValue(((Command.action == GLFW_RELEASE) ? neutralposition : activeposition), Train->dsbSwitch); + Train->ggScndCtrl.UpdateValue(Command.action == GLFW_RELEASE ? neutralposition : activeposition, Train->dsbSwitch); } // update control value if (Command.action != GLFW_RELEASE) { // on press or hold - while ((targetposition < Train->mvControlled->GetVirtualScndPos()) && (true == Train->mvControlled->DecScndCtrl(1))) + while (targetposition < Train->mvControlled->GetVirtualScndPos() && true == Train->mvControlled->DecScndCtrl(1)) { // all work is done in the header ; } - while ((targetposition > Train->mvControlled->GetVirtualScndPos()) && (true == Train->mvControlled->IncScndCtrl(1))) + while (targetposition > Train->mvControlled->GetVirtualScndPos() && true == Train->mvControlled->IncScndCtrl(1)) { // all work is done in the header ; @@ -1720,16 +1721,16 @@ void TTrain::OnCommand_independentbrakeincrease(TTrain *Train, command_data cons // when SplitEDPneumaticBrake is active the local brake key always operates // the pneumatic local brake directly, never piggy-backing on the joint controller auto const splitMode{Train->mvControlled->SplitEDPneumaticBrake}; - auto const useStepped{(Train->ggJointCtrl.SubModel != nullptr) && !splitMode}; + auto const useStepped{Train->ggJointCtrl.SubModel != nullptr && !splitMode}; if (Train->mvOccupied->LocalBrake != TLocalBrake::ManualBrake) { - if ((false == splitMode) && (Train->ggJointCtrl.SubModel != nullptr) && (Train->mvOccupied->MainCtrlPos > 0)) + if (false == splitMode && Train->ggJointCtrl.SubModel != nullptr && Train->mvOccupied->MainCtrlPos > 0) { OnCommand_mastercontrollerdecrease(Train, Command); } else { - Train->mvOccupied->IncLocalBrakeLevel(useStepped ? 1 : (Global.brake_speed * Command.time_delta * LocalBrakePosNo)); + Train->mvOccupied->IncLocalBrakeLevel(useStepped ? 1 : Global.brake_speed * Command.time_delta * LocalBrakePosNo); if (useStepped) { Train->m_mastercontrollerinuse = true; @@ -1746,10 +1747,10 @@ void TTrain::OnCommand_independentbrakeincreasefast(TTrain *Train, command_data { auto const splitMode{Train->mvControlled->SplitEDPneumaticBrake}; - auto const useJointAnim{(Train->ggJointCtrl.SubModel != nullptr) && !splitMode}; + auto const useJointAnim{Train->ggJointCtrl.SubModel != nullptr && !splitMode}; if (Train->mvOccupied->LocalBrake != TLocalBrake::ManualBrake) { - if ((false == splitMode) && (Train->ggJointCtrl.SubModel != nullptr) && (Train->mvOccupied->MainCtrlPos > 0)) + if (false == splitMode && Train->ggJointCtrl.SubModel != nullptr && Train->mvOccupied->MainCtrlPos > 0) { OnCommand_mastercontrollerdecreasefast(Train, Command); } @@ -1772,19 +1773,19 @@ void TTrain::OnCommand_independentbrakedecrease(TTrain *Train, command_data cons { auto const splitMode{Train->mvControlled->SplitEDPneumaticBrake}; - auto const useStepped{(Train->ggJointCtrl.SubModel != nullptr) && !splitMode}; - if ((Train->mvOccupied->LocalBrake != TLocalBrake::ManualBrake) + auto const useStepped{Train->ggJointCtrl.SubModel != nullptr && !splitMode}; + if (Train->mvOccupied->LocalBrake != TLocalBrake::ManualBrake // Ra 1014-06: AI potrafi zahamować pomocniczym mimo jego braku - odhamować jakoś trzeba // TODO: sort AI out so it doesn't do things it doesn't have equipment for - || (Train->mvOccupied->LocalBrakePosA > 0)) + || Train->mvOccupied->LocalBrakePosA > 0) { - if ((false == splitMode) && (Train->ggJointCtrl.SubModel != nullptr) && (Train->mvOccupied->LocalBrakePosA == 0.0)) + if (false == splitMode && Train->ggJointCtrl.SubModel != nullptr && Train->mvOccupied->LocalBrakePosA == 0.0) { OnCommand_mastercontrollerincrease(Train, Command); } else { - Train->mvOccupied->DecLocalBrakeLevel(useStepped ? 1 : (Global.brake_speed * Command.time_delta * LocalBrakePosNo)); + Train->mvOccupied->DecLocalBrakeLevel(useStepped ? 1 : Global.brake_speed * Command.time_delta * LocalBrakePosNo); if (useStepped) { Train->m_mastercontrollerinuse = true; @@ -1801,13 +1802,13 @@ void TTrain::OnCommand_independentbrakedecreasefast(TTrain *Train, command_data { auto const splitMode{Train->mvControlled->SplitEDPneumaticBrake}; - auto const useJointAnim{(Train->ggJointCtrl.SubModel != nullptr) && !splitMode}; - if ((Train->mvOccupied->LocalBrake != TLocalBrake::ManualBrake) + auto const useJointAnim{Train->ggJointCtrl.SubModel != nullptr && !splitMode}; + if (Train->mvOccupied->LocalBrake != TLocalBrake::ManualBrake // Ra 1014-06: AI potrafi zahamować pomocniczym mimo jego braku - odhamować jakoś trzeba // TODO: sort AI out so it doesn't do things it doesn't have equipment for - || (Train->mvOccupied->LocalBrakePosA > 0)) + || Train->mvOccupied->LocalBrakePosA > 0) { - if ((false == splitMode) && (Train->ggJointCtrl.SubModel != nullptr) && (Train->mvOccupied->LocalBrakePosA == 0.0)) + if (false == splitMode && Train->ggJointCtrl.SubModel != nullptr && Train->mvOccupied->LocalBrakePosA == 0.0) { OnCommand_mastercontrollerincreasefast(Train, Command); } @@ -1829,7 +1830,7 @@ void TTrain::OnCommand_independentbrakeset(TTrain *Train, command_data const &Co if (Command.action != GLFW_RELEASE) { - Train->mvOccupied->LocalBrakePosA = (std::clamp(Command.param1, 0.0, 1.0)); + Train->mvOccupied->LocalBrakePosA = std::clamp(Command.param1, 0.0, 1.0); } /* Train->mvControlled->LocalBrakePos = ( @@ -1850,10 +1851,10 @@ void TTrain::OnCommand_independentbrakebailoff(TTrain *Train, command_data const { // TODO: check if this set of conditions can be simplified. // it'd be more flexible to have an attribute indicating whether bail off position is supported - if ((Train->mvControlled->TrainType != dt_EZT) && - ((Train->mvControlled->EngineType == TEngineType::ElectricSeriesMotor) || (Train->mvControlled->EngineType == TEngineType::DieselElectric) || - (Train->mvControlled->EngineType == TEngineType::ElectricInductionMotor)) && - (Train->mvOccupied->BrakeCtrlPosNo > 0)) + if (Train->mvControlled->TrainType != dt_EZT && + (Train->mvControlled->EngineType == TEngineType::ElectricSeriesMotor || Train->mvControlled->EngineType == TEngineType::DieselElectric || + Train->mvControlled->EngineType == TEngineType::ElectricInductionMotor) && + Train->mvOccupied->BrakeCtrlPosNo > 0) { if (Command.action == GLFW_PRESS) @@ -2034,7 +2035,7 @@ void TTrain::OnCommand_trainbrakeservice(TTrain *Train, command_data const &Comm if (Command.action == GLFW_PRESS) { - Train->set_train_brake((Train->mvOccupied->BrakeCtrlPosNo / 2 + (Train->mvOccupied->BrakeHandle == TBrakeHandle::FV4a ? 1 : 0))); + Train->set_train_brake(Train->mvOccupied->BrakeCtrlPosNo / 2 + (Train->mvOccupied->BrakeHandle == TBrakeHandle::FV4a ? 1 : 0)); } } @@ -2156,7 +2157,7 @@ void TTrain::OnCommand_manualbrakeincrease(TTrain *Train, command_data const &Co return; } - if ((vehicle->MoverParameters->LocalBrake == TLocalBrake::ManualBrake) || (vehicle->MoverParameters->MBrake == true)) + if (vehicle->MoverParameters->LocalBrake == TLocalBrake::ManualBrake || vehicle->MoverParameters->MBrake == true) { vehicle->MoverParameters->IncManualBrakeLevel(1); @@ -2176,7 +2177,7 @@ void TTrain::OnCommand_manualbrakedecrease(TTrain *Train, command_data const &Co return; } - if ((vehicle->MoverParameters->LocalBrake == TLocalBrake::ManualBrake) || (vehicle->MoverParameters->MBrake == true)) + if (vehicle->MoverParameters->LocalBrake == TLocalBrake::ManualBrake || vehicle->MoverParameters->MBrake == true) { vehicle->MoverParameters->DecManualBrakeLevel(1); @@ -2262,7 +2263,7 @@ void TTrain::OnCommand_wheelspinbrakeactivate(TTrain *Train, command_data const // visual feedback Train->ggAntiSlipButton.UpdateValue(1.0, Train->dsbPneumaticSwitch); - if ((Train->mvOccupied->BrakeHandle == TBrakeHandle::St113) && (Train->mvControlled->EpFuse == true)) + if (Train->mvOccupied->BrakeHandle == TBrakeHandle::St113 && Train->mvControlled->EpFuse == true) { Train->mvOccupied->SwitchEPBrake(1); } @@ -2429,9 +2430,9 @@ void TTrain::OnCommand_epbrakecontroltoggle(TTrain *Train, command_data const &C }; } // visual feedback - Train->ggEPFuseButton.UpdateValue((ispush ? 1.0f : // push or pushtoggle - Train->mvOccupied->EpFuse ? 1.0f : - 0.0f), // toggle + Train->ggEPFuseButton.UpdateValue(ispush ? 1.0f : // push or pushtoggle + Train->mvOccupied->EpFuse ? 1.0f : + 0.0f, // toggle Train->dsbSwitch); } else if (Command.action == GLFW_RELEASE) @@ -2450,7 +2451,7 @@ void TTrain::OnCommand_trainbrakeoperationmodeincrease(TTrain *Train, command_da if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - if (((Train->mvOccupied->BrakeOpModeFlag << 1) & Train->mvOccupied->BrakeOpModes) != 0) + if ((Train->mvOccupied->BrakeOpModeFlag << 1 & Train->mvOccupied->BrakeOpModes) != 0) { // next mode Train->mvOccupied->BrakeOpModeFlag <<= 1; @@ -2466,7 +2467,7 @@ void TTrain::OnCommand_trainbrakeoperationmodedecrease(TTrain *Train, command_da if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - if (((Train->mvOccupied->BrakeOpModeFlag >> 1) & Train->mvOccupied->BrakeOpModes) != 0) + if ((Train->mvOccupied->BrakeOpModeFlag >> 1 & Train->mvOccupied->BrakeOpModes) != 0) { // previous mode Train->mvOccupied->BrakeOpModeFlag >>= 1; @@ -2493,7 +2494,7 @@ void TTrain::OnCommand_brakeactingspeedincrease(TTrain *Train, command_data cons // can't speed it up any more than this return; } - auto const fasterbrakesetting = (vehicle->MoverParameters->BrakeDelayFlag < bdelay_R ? vehicle->MoverParameters->BrakeDelayFlag << 1 : vehicle->MoverParameters->BrakeDelayFlag | bdelay_M); + auto const fasterbrakesetting = vehicle->MoverParameters->BrakeDelayFlag < bdelay_R ? vehicle->MoverParameters->BrakeDelayFlag << 1 : vehicle->MoverParameters->BrakeDelayFlag | bdelay_M; Train->set_train_brake_speed(vehicle, fasterbrakesetting); } @@ -2516,7 +2517,7 @@ void TTrain::OnCommand_brakeactingspeeddecrease(TTrain *Train, command_data cons // can't slow it down any more than this return; } - auto const slowerbrakesetting = (vehicle->MoverParameters->BrakeDelayFlag < bdelay_M ? vehicle->MoverParameters->BrakeDelayFlag >> 1 : vehicle->MoverParameters->BrakeDelayFlag ^ bdelay_M); + auto const slowerbrakesetting = vehicle->MoverParameters->BrakeDelayFlag < bdelay_M ? vehicle->MoverParameters->BrakeDelayFlag >> 1 : vehicle->MoverParameters->BrakeDelayFlag ^ bdelay_M; Train->set_train_brake_speed(vehicle, slowerbrakesetting); } @@ -2573,7 +2574,7 @@ void TTrain::OnCommand_brakeactingspeedsetrapid(TTrain *Train, command_data cons void TTrain::OnCommand_brakeloadcompensationincrease(TTrain *Train, command_data const &Command) { - if ((true == Command.freefly) && (Command.action == GLFW_PRESS)) + if (true == Command.freefly && Command.action == GLFW_PRESS) { auto *vehicle{Train->find_nearest_consist_vehicle(Command.freefly, Command.location)}; if (vehicle != nullptr) @@ -2586,7 +2587,7 @@ void TTrain::OnCommand_brakeloadcompensationincrease(TTrain *Train, command_data void TTrain::OnCommand_brakeloadcompensationdecrease(TTrain *Train, command_data const &Command) { - if ((true == Command.freefly) && (Command.action == GLFW_PRESS)) + if (true == Command.freefly && Command.action == GLFW_PRESS) { auto *vehicle{Train->find_nearest_consist_vehicle(Command.freefly, Command.location)}; if (vehicle != nullptr) @@ -2674,7 +2675,7 @@ void TTrain::OnCommand_reverserincrease(TTrain *Train, command_data const &Comma if (Train->mvOccupied->DirectionForward()) { // aktualizacja skrajnych pojazdów w składzie - if ((Train->mvOccupied->DirActive) && (Train->DynamicObject->Mechanik)) + if (Train->mvOccupied->DirActive && Train->DynamicObject->Mechanik) { Train->DynamicObject->Mechanik->DirectionChange(); @@ -2699,7 +2700,7 @@ void TTrain::OnCommand_reverserdecrease(TTrain *Train, command_data const &Comma if (Train->mvOccupied->DirectionBackward()) { // aktualizacja skrajnych pojazdów w składzie - if ((Train->mvOccupied->DirActive) && (Train->DynamicObject->Mechanik)) + if (Train->mvOccupied->DirActive && Train->DynamicObject->Mechanik) { Train->DynamicObject->Mechanik->DirectionChange(); @@ -2728,12 +2729,12 @@ void TTrain::OnCommand_reverserforwardhigh(TTrain *Train, command_data const &Co if (Train->mvOccupied->DirActive < 1) { - while ((Train->mvOccupied->DirActive < 1) && (true == Train->mvOccupied->DirectionForward())) + while (Train->mvOccupied->DirActive < 1 && true == Train->mvOccupied->DirectionForward()) { // all work is done in the header } // aktualizacja skrajnych pojazdów w składzie - if ((Train->mvOccupied->DirActive == 1) && (Train->DynamicObject->Mechanik)) + if (Train->mvOccupied->DirActive == 1 && Train->DynamicObject->Mechanik) { Train->DynamicObject->Mechanik->DirectionChange(); @@ -2764,12 +2765,12 @@ void TTrain::OnCommand_reverserforward(TTrain *Train, command_data const &Comman if (Train->mvOccupied->DirActive == 0) { - while ((Train->mvOccupied->DirActive < 1) && (true == Train->mvOccupied->DirectionForward())) + while (Train->mvOccupied->DirActive < 1 && true == Train->mvOccupied->DirectionForward()) { // all work is done in the header } // aktualizacja skrajnych pojazdów w składzie - if ((Train->mvOccupied->DirActive == 1) && (Train->DynamicObject->Mechanik)) + if (Train->mvOccupied->DirActive == 1 && Train->DynamicObject->Mechanik) { Train->DynamicObject->Mechanik->DirectionChange(); @@ -2798,11 +2799,11 @@ void TTrain::OnCommand_reverserneutral(TTrain *Train, command_data const &Comman } // visual feedback Train->ggDirNeutralButton.UpdateValue(1.0, Train->dsbSwitch); - while ((Train->mvOccupied->DirActive < 0) && (true == Train->mvOccupied->DirectionForward())) + while (Train->mvOccupied->DirActive < 0 && true == Train->mvOccupied->DirectionForward()) { // all work is done in the header } - while ((Train->mvOccupied->DirActive > 0) && (true == Train->mvOccupied->DirectionBackward())) + while (Train->mvOccupied->DirActive > 0 && true == Train->mvOccupied->DirectionBackward()) { // all work is done in the header } @@ -2831,12 +2832,12 @@ void TTrain::OnCommand_reverserbackward(TTrain *Train, command_data const &Comma if (Train->mvOccupied->DirActive == 0) { - while ((Train->mvOccupied->DirActive > -1) && (true == Train->mvOccupied->DirectionBackward())) + while (Train->mvOccupied->DirActive > -1 && true == Train->mvOccupied->DirectionBackward()) { // all work is done in the header } // aktualizacja skrajnych pojazdów w składzie - if ((Train->mvOccupied->DirActive == -1) && (Train->DynamicObject->Mechanik)) + if (Train->mvOccupied->DirActive == -1 && Train->DynamicObject->Mechanik) { Train->DynamicObject->Mechanik->DirectionChange(); @@ -3132,7 +3133,7 @@ void TTrain::OnCommand_cabactivationdisable(TTrain *Train, command_data const &C } Train->mvOccupied->CabDeactivisation(); - if ((Train->mvOccupied->LightsPosNo > 0) && (Train->mvOccupied->InactiveCabFlag & activation::redmarkers)) + if (Train->mvOccupied->LightsPosNo > 0 && Train->mvOccupied->InactiveCabFlag & activation::redmarkers) { Train->Dynamic()->SetLights(); } @@ -3176,7 +3177,7 @@ void TTrain::OnCommand_pantographtogglefront(TTrain *Train, command_data const & if (Train->mvOccupied->PantSwitchType == "impulse") { auto const ismanual{Train->iCabn == 0}; - Train->mvOccupied->OperatePantographValve(end::front, operation_t::none, (ismanual ? range_t::local : range_t::consist)); + Train->mvOccupied->OperatePantographValve(end::front, operation_t::none, ismanual ? range_t::local : range_t::consist); } } } @@ -3210,7 +3211,7 @@ void TTrain::OnCommand_pantographtogglerear(TTrain *Train, command_data const &C if (Train->mvOccupied->PantSwitchType == "impulse") { auto const ismanual{Train->iCabn == 0}; - Train->mvOccupied->OperatePantographValve(end::rear, operation_t::none, (ismanual ? range_t::local : range_t::consist)); + Train->mvOccupied->OperatePantographValve(end::rear, operation_t::none, ismanual ? range_t::local : range_t::consist); } } } @@ -3224,7 +3225,7 @@ void TTrain::OnCommand_pantographraisefront(TTrain *Train, command_data const &C return; } // prevent operation without submodel outside of engine compartment - if ((Train->iCabn != 0) && (false == Train->m_controlmapper.contains("pantfront_sw:"))) + if (Train->iCabn != 0 && false == Train->m_controlmapper.contains("pantfront_sw:")) { return; } @@ -3234,8 +3235,8 @@ void TTrain::OnCommand_pantographraisefront(TTrain *Train, command_data const &C // only reacting to press, so the switch doesn't flip back and forth if key is held down // HACK: don't propagate pantograph commands issued from engine compartment, these are presumed to be manually moved levers auto const ismanual{Train->iCabn == 0}; - Train->mvOccupied->OperatePantographValve(end::front, (Train->mvOccupied->PantSwitchType == "impulse" ? operation_t::enable_on : operation_t::enable), - (ismanual ? range_t::local : range_t::consist)); + Train->mvOccupied->OperatePantographValve(end::front, Train->mvOccupied->PantSwitchType == "impulse" ? operation_t::enable_on : operation_t::enable, + ismanual ? range_t::local : range_t::consist); } else if (Command.action == GLFW_RELEASE) { @@ -3253,7 +3254,7 @@ void TTrain::OnCommand_pantographraiserear(TTrain *Train, command_data const &Co return; } // prevent operation without submodel outside of engine compartment - if ((Train->iCabn != 0) && (false == Train->m_controlmapper.contains("pantrear_sw:"))) + if (Train->iCabn != 0 && false == Train->m_controlmapper.contains("pantrear_sw:")) { return; } @@ -3263,8 +3264,8 @@ void TTrain::OnCommand_pantographraiserear(TTrain *Train, command_data const &Co // only reacting to press, so the switch doesn't flip back and forth if key is held down // HACK: don't propagate pantograph commands issued from engine compartment, these are presumed to be manually moved levers auto const ismanual{Train->iCabn == 0}; - Train->mvOccupied->OperatePantographValve(end::rear, (Train->mvOccupied->PantSwitchType == "impulse" ? operation_t::enable_on : operation_t::enable), - (ismanual ? range_t::local : range_t::consist)); + Train->mvOccupied->OperatePantographValve(end::rear, Train->mvOccupied->PantSwitchType == "impulse" ? operation_t::enable_on : operation_t::enable, + ismanual ? range_t::local : range_t::consist); } else if (Command.action == GLFW_RELEASE) { @@ -3282,7 +3283,7 @@ void TTrain::OnCommand_pantographlowerfront(TTrain *Train, command_data const &C return; } // prevent operation without submodel outside of engine compartment - if ((Train->iCabn != 0) && (false == Train->m_controlmapper.contains(Train->mvOccupied->PantSwitchType == "impulse" ? "pantfrontoff_sw:" : "pantfront_sw:"))) + if (Train->iCabn != 0 && false == Train->m_controlmapper.contains(Train->mvOccupied->PantSwitchType == "impulse" ? "pantfrontoff_sw:" : "pantfront_sw:")) { return; } @@ -3292,8 +3293,8 @@ void TTrain::OnCommand_pantographlowerfront(TTrain *Train, command_data const &C // only reacting to press, so the switch doesn't flip back and forth if key is held down // HACK: don't propagate pantograph commands issued from engine compartment, these are presumed to be manually moved levers auto const ismanual{Train->iCabn == 0}; - Train->mvOccupied->OperatePantographValve(end::front, (Train->mvOccupied->PantSwitchType == "impulse" ? operation_t::disable_on : operation_t::disable), - (ismanual ? range_t::local : range_t::consist)); + Train->mvOccupied->OperatePantographValve(end::front, Train->mvOccupied->PantSwitchType == "impulse" ? operation_t::disable_on : operation_t::disable, + ismanual ? range_t::local : range_t::consist); } else if (Command.action == GLFW_RELEASE) { @@ -3311,7 +3312,7 @@ void TTrain::OnCommand_pantographlowerrear(TTrain *Train, command_data const &Co return; } - if ((Train->iCabn != 0) && (false == Train->m_controlmapper.contains(Train->mvOccupied->PantSwitchType == "impulse" ? "pantrearoff_sw:" : "pantrear_sw:"))) + if (Train->iCabn != 0 && false == Train->m_controlmapper.contains(Train->mvOccupied->PantSwitchType == "impulse" ? "pantrearoff_sw:" : "pantrear_sw:")) { return; } @@ -3321,8 +3322,8 @@ void TTrain::OnCommand_pantographlowerrear(TTrain *Train, command_data const &Co // only reacting to press, so the switch doesn't flip back and forth if key is held down // HACK: don't propagate pantograph commands issued from engine compartment, these are presumed to be manually moved levers auto const ismanual{Train->iCabn == 0}; - Train->mvOccupied->OperatePantographValve(end::rear, (Train->mvOccupied->PantSwitchType == "impulse" ? operation_t::disable_on : operation_t::disable), - (ismanual ? range_t::local : range_t::consist)); + Train->mvOccupied->OperatePantographValve(end::rear, Train->mvOccupied->PantSwitchType == "impulse" ? operation_t::disable_on : operation_t::disable, + ismanual ? range_t::local : range_t::consist); } else if (Command.action == GLFW_RELEASE) { @@ -3356,7 +3357,7 @@ void TTrain::OnCommand_pantographlowerall(TTrain *Train, command_data const &Com { Train->mvPantographUnit->DropAllPantographs(false == Train->mvPantographUnit->PantAllDown); // visual feedback - Train->ggPantAllDownButton.UpdateValue((Train->mvPantographUnit->PantAllDown ? 1.0 : 0.0), Train->dsbSwitch); + Train->ggPantAllDownButton.UpdateValue(Train->mvPantographUnit->PantAllDown ? 1.0 : 0.0, Train->dsbSwitch); } } else @@ -3364,7 +3365,7 @@ void TTrain::OnCommand_pantographlowerall(TTrain *Train, command_data const &Com // impulse switch Train->mvControlled->DropAllPantographs(Command.action == GLFW_PRESS); // visual feedback - Train->ggPantAllDownButton.UpdateValue((Command.action == GLFW_PRESS ? 1.0 : 0.0), Train->dsbSwitch); + Train->ggPantAllDownButton.UpdateValue(Command.action == GLFW_PRESS ? 1.0 : 0.0, Train->dsbSwitch); } } @@ -3522,8 +3523,8 @@ void TTrain::update_pantograph_valves() // check desired states for both pantographs; value: whether the pantograph should be raised auto const frontstate{preset & (swapends ? 2 : 1)}; auto const rearstate{preset & (swapends ? 1 : 2)}; - mvOccupied->OperatePantographValve(end::front, (frontstate ? operation_t::enable : operation_t::disable)); - mvOccupied->OperatePantographValve(end::rear, (rearstate ? operation_t::enable : operation_t::disable)); + mvOccupied->OperatePantographValve(end::front, frontstate ? operation_t::enable : operation_t::disable); + mvOccupied->OperatePantographValve(end::rear, rearstate ? operation_t::enable : operation_t::disable); } void TTrain::change_pantograph_selection(int const Change) @@ -3640,7 +3641,7 @@ void TTrain::OnCommand_pantographcompressorvalvetoggle(TTrain *Train, command_da void TTrain::OnCommand_pantographcompressorvalveenable(TTrain *Train, command_data const &Command) { - auto const valveispresent{(Train->ggPantCompressorValve.SubModel != nullptr) || ((Train->mvOccupied == Train->mvPantographUnit) && (Train->iCabn == 0))}; + auto const valveispresent{Train->ggPantCompressorValve.SubModel != nullptr || (Train->mvOccupied == Train->mvPantographUnit && Train->iCabn == 0)}; if (false == valveispresent) { @@ -3661,7 +3662,7 @@ void TTrain::OnCommand_pantographcompressorvalveenable(TTrain *Train, command_da void TTrain::OnCommand_pantographcompressorvalvedisable(TTrain *Train, command_data const &Command) { - auto const valveispresent{(Train->ggPantCompressorValve.SubModel != nullptr) || ((Train->mvOccupied == Train->mvPantographUnit) && (Train->iCabn == 0))}; + auto const valveispresent{Train->ggPantCompressorValve.SubModel != nullptr || (Train->mvOccupied == Train->mvPantographUnit && Train->iCabn == 0)}; if (false == valveispresent) { @@ -3683,7 +3684,7 @@ void TTrain::OnCommand_pantographcompressoractivate(TTrain *Train, command_data { // tylko w maszynowym, unless actual device is present - auto const switchispresent{(Train->m_controlmapper.contains("pantcompressor_sw:")) || ((Train->mvOccupied == Train->mvPantographUnit) && (Train->iCabn == 0))}; + auto const switchispresent{Train->m_controlmapper.contains("pantcompressor_sw:") || (Train->mvOccupied == Train->mvPantographUnit && Train->iCabn == 0)}; if (false == switchispresent) { return; @@ -3692,7 +3693,7 @@ void TTrain::OnCommand_pantographcompressoractivate(TTrain *Train, command_data if (Command.action != GLFW_RELEASE) { // press or hold to activate - if ((Train->mvPantographUnit->PantPress < 4.8) && (true == Train->mvPantographUnit->Power24vIsAvailable)) + if (Train->mvPantographUnit->PantPress < 4.8 && true == Train->mvPantographUnit->Power24vIsAvailable) { // needs live power source and low enough pressure to work Train->mvPantographUnit->PantCompFlag = true; @@ -3730,7 +3731,7 @@ void TTrain::OnCommand_linebreakertoggle(TTrain *Train, command_data const &Comm else if (Command.action == GLFW_RELEASE) { // release... - if ((Train->ggMainOnButton.SubModel != nullptr) || (Train->ggMainButton.type() != TGaugeType::toggle)) + if (Train->ggMainOnButton.SubModel != nullptr || Train->ggMainButton.type() != TGaugeType::toggle) { // only impulse switches react to release events // NOTE: we presume dedicated state switch is of impulse type @@ -3801,7 +3802,7 @@ void TTrain::OnCommand_linebreakeropen(TTrain *Train, command_data const &Comman // and the two-state switch too, for good measure if (Train->ggMainButton.SubModel != nullptr) { - Train->ggMainButton.UpdateValue((Train->ggMainButton.type() != TGaugeType::toggle ? 0.5 : 0.0), Train->dsbSwitch); + Train->ggMainButton.UpdateValue(Train->ggMainButton.type() != TGaugeType::toggle ? 0.5 : 0.0, Train->dsbSwitch); } } } @@ -3860,7 +3861,7 @@ void TTrain::OnCommand_linebreakerclose(TTrain *Train, command_data const &Comma if (Train->mvControlled->EngineType == TEngineType::ElectricSeriesMotor) { // try to finalize state change of the line breaker, set the state based on the outcome - Train->m_linebreakerstate = (Train->mvControlled->MainSwitch(true) ? 1 : 0); + Train->m_linebreakerstate = Train->mvControlled->MainSwitch(true) ? 1 : 0; } } // on button release reset the closing timer @@ -4385,7 +4386,7 @@ void TTrain::OnCommand_convertertoggle(TTrain *Train, command_data const &Comman // only reacting to press, so the switch doesn't flip back and forth if key is held down auto const overloadrelayisopen{(Train->Dynamic()->Mechanik != nullptr ? Train->Dynamic()->Mechanik->IsAnyConverterOverloadRelayOpen : Train->mvOccupied->ConvOvldFlag)}; - if (Train->mvOccupied->ConvSwitchType != "impulse" ? Train->ggConverterButton.GetValue() < 0.5 : ((false == Train->mvOccupied->Power110vIsAvailable) && (false == overloadrelayisopen))) + if (Train->mvOccupied->ConvSwitchType != "impulse" ? Train->ggConverterButton.GetValue() < 0.5 : false == Train->mvOccupied->Power110vIsAvailable && false == overloadrelayisopen) { // turn on OnCommand_converterenable(Train, Command); @@ -4418,7 +4419,7 @@ void TTrain::OnCommand_converterenable(TTrain *Train, command_data const &Comman // impulse type switch has no effect if there's no power // NOTE: this is most likely setup wrong, but the whole thing is smoke and mirrors anyway - if ((Train->mvOccupied->ConvSwitchType != "impulse") || (Train->mvControlled->Mains)) + if (Train->mvOccupied->ConvSwitchType != "impulse" || Train->mvControlled->Mains) { // won't start if the line breaker button is still held Train->mvOccupied->ConverterSwitch(true); @@ -4468,7 +4469,7 @@ void TTrain::OnCommand_convertertogglelocal(TTrain *Train, command_data const &C if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - if ((false == Train->mvOccupied->ConverterAllowLocal) && (Train->ggConverterLocalButton.GetValue() < 0.5)) + if (false == Train->mvOccupied->ConverterAllowLocal && Train->ggConverterLocalButton.GetValue() < 0.5) { // turn on // visual feedback @@ -4673,7 +4674,7 @@ void TTrain::OnCommand_compressorpresetactivatenext(TTrain *Train, command_data return; } - Train->mvOccupied->ChangeCompressorPreset((Command.action == GLFW_PRESS ? Train->mvOccupied->CompressorListDefPos + 1 : Train->mvOccupied->CompressorListDefPos)); + Train->mvOccupied->ChangeCompressorPreset(Command.action == GLFW_PRESS ? Train->mvOccupied->CompressorListDefPos + 1 : Train->mvOccupied->CompressorListDefPos); // visual feedback Train->ggCompressorListButton.UpdateValue(Train->mvOccupied->CompressorListPos - 1, Train->dsbSwitch); } @@ -4685,10 +4686,10 @@ void TTrain::OnCommand_compressorpresetactivatenext(TTrain *Train, command_data return; } - if ((Train->mvOccupied->CompressorListPos < Train->mvOccupied->CompressorListPosNo) || (true == Train->mvOccupied->CompressorListWrap)) + if (Train->mvOccupied->CompressorListPos < Train->mvOccupied->CompressorListPosNo || true == Train->mvOccupied->CompressorListWrap) { // active light preset is stored as value in range 1-LigthPosNo - Train->mvOccupied->ChangeCompressorPreset((Train->mvOccupied->CompressorListPos < Train->mvOccupied->CompressorListPosNo ? Train->mvOccupied->CompressorListPos + 1 : 1)); // wrap mode + Train->mvOccupied->ChangeCompressorPreset(Train->mvOccupied->CompressorListPos < Train->mvOccupied->CompressorListPosNo ? Train->mvOccupied->CompressorListPos + 1 : 1); // wrap mode // visual feedback Train->ggCompressorListButton.UpdateValue(Train->mvOccupied->CompressorListPos - 1, Train->dsbSwitch); } @@ -4713,10 +4714,10 @@ void TTrain::OnCommand_compressorpresetactivateprevious(TTrain *Train, command_d return; } - if ((Train->mvOccupied->CompressorListPos > 1) || (true == Train->mvOccupied->CompressorListWrap)) + if (Train->mvOccupied->CompressorListPos > 1 || true == Train->mvOccupied->CompressorListWrap) { // active light preset is stored as value in range 1-LigthPosNo - Train->mvOccupied->ChangeCompressorPreset((Train->mvOccupied->CompressorListPos > 1 ? Train->mvOccupied->CompressorListPos - 1 : Train->mvOccupied->CompressorListPosNo)); // wrap mode + Train->mvOccupied->ChangeCompressorPreset(Train->mvOccupied->CompressorListPos > 1 ? Train->mvOccupied->CompressorListPos - 1 : Train->mvOccupied->CompressorListPosNo); // wrap mode // visual feedback if (Train->ggCompressorListButton.SubModel != nullptr) @@ -5005,7 +5006,7 @@ void TTrain::OnCommand_coolingfanstoggle(TTrain *Train, command_data const &Comm return; } - Train->mvControlled->RVentForceOn = (!Train->mvControlled->RVentForceOn); + Train->mvControlled->RVentForceOn = !Train->mvControlled->RVentForceOn; } void TTrain::OnCommand_motorconnectorsopen(TTrain *Train, command_data const &Command) @@ -5090,7 +5091,7 @@ void TTrain::OnCommand_motorconnectorsclose(TTrain *Train, command_data const &C void TTrain::OnCommand_motordisconnect(TTrain *Train, command_data const &Command) { - if ((Train->mvControlled->TrainType == dt_EZT ? (Train->mvControlled != Train->mvOccupied) : (Train->iCabn != 0))) + if (Train->mvControlled->TrainType == dt_EZT ? Train->mvControlled != Train->mvOccupied : Train->iCabn != 0) { // tylko w maszynowym return; @@ -5107,7 +5108,7 @@ void TTrain::OnCommand_motoroverloadrelaythresholdtoggle(TTrain *Train, command_ if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - if ((true == Train->mvControlled->ShuntModeAllow ? (false == Train->mvControlled->ShuntMode) : (false == Train->mvControlled->MotorOverloadRelayHighThreshold))) + if (true == Train->mvControlled->ShuntModeAllow ? false == Train->mvControlled->ShuntMode : false == Train->mvControlled->MotorOverloadRelayHighThreshold) { // turn on OnCommand_motoroverloadrelaythresholdsethigh(Train, Command); @@ -5204,11 +5205,11 @@ void TTrain::OnCommand_lightspresetactivatenext(TTrain *Train, command_data cons return; } - if ((Train->mvOccupied->LightsPos < Train->mvOccupied->LightsPosNo) || (true == Train->mvOccupied->LightsWrap)) + if (Train->mvOccupied->LightsPos < Train->mvOccupied->LightsPosNo || true == Train->mvOccupied->LightsWrap) { // active light preset is stored as value in range 1-LigthPosNo auto const restartcycle{Train->mvOccupied->LightsPos >= Train->mvOccupied->LightsPosNo}; - Train->mvOccupied->LightsPos = (false == restartcycle ? Train->mvOccupied->LightsPos + 1 : 1); // wrap mode + Train->mvOccupied->LightsPos = false == restartcycle ? Train->mvOccupied->LightsPos + 1 : 1; // wrap mode Train->Dynamic()->SetLights(); // visual feedback @@ -5241,11 +5242,11 @@ void TTrain::OnCommand_lightspresetactivateprevious(TTrain *Train, command_data return; } - if ((Train->mvOccupied->LightsPos > 1) || (true == Train->mvOccupied->LightsWrap)) + if (Train->mvOccupied->LightsPos > 1 || true == Train->mvOccupied->LightsWrap) { // active light preset is stored as value in range 1-LigthPosNo auto const restartcycle{Train->mvOccupied->LightsPos <= 1}; - Train->mvOccupied->LightsPos = (false == restartcycle ? Train->mvOccupied->LightsPos - 1 : Train->mvOccupied->LightsPosNo); // wrap mode + Train->mvOccupied->LightsPos = false == restartcycle ? Train->mvOccupied->LightsPos - 1 : Train->mvOccupied->LightsPosNo; // wrap mode Train->Dynamic()->SetLights(); // visual feedback @@ -6076,7 +6077,7 @@ void TTrain::OnCommand_redmarkerdisablerearright(TTrain *Train, command_data con void TTrain::OnCommand_redmarkerstoggle(TTrain *Train, command_data const &Command) { - if ((true == Command.freefly) && (Command.action == GLFW_PRESS)) + if (true == Command.freefly && Command.action == GLFW_PRESS) { auto *vehicle{std::get(simulation::Region->find_vehicle(Command.location, 10, false, true))}; @@ -6093,15 +6094,16 @@ void TTrain::OnCommand_redmarkerstoggle(TTrain *Train, command_data const &Comma auto const lightset{light::redmarker_left | light::redmarker_right}; vehicle->MoverParameters->iLights[CouplNr] = - (false == TestFlag(vehicle->MoverParameters->iLights[CouplNr], lightset) ? vehicle->MoverParameters->iLights[CouplNr] |= lightset : // turn signals on - vehicle->MoverParameters->iLights[CouplNr] ^= lightset); // turn signals off + false == TestFlag(vehicle->MoverParameters->iLights[CouplNr], lightset) ? + vehicle->MoverParameters->iLights[CouplNr] |= lightset : // turn signals on + vehicle->MoverParameters->iLights[CouplNr] ^= lightset; // turn signals off } } void TTrain::OnCommand_endsignalstoggle(TTrain *Train, command_data const &Command) { - if ((true == Command.freefly) && (Command.action == GLFW_PRESS)) + if (true == Command.freefly && Command.action == GLFW_PRESS) { auto *vehicle{std::get(simulation::Region->find_vehicle(Command.location, 10, false, true))}; @@ -6117,8 +6119,9 @@ void TTrain::OnCommand_endsignalstoggle(TTrain *Train, command_data const &Comma auto const lightset{light::rearendsignals}; vehicle->MoverParameters->iLights[CouplNr] = - (false == TestFlag(vehicle->MoverParameters->iLights[CouplNr], lightset) ? vehicle->MoverParameters->iLights[CouplNr] |= lightset : // turn signals on - vehicle->MoverParameters->iLights[CouplNr] ^= lightset); // turn signals off + false == TestFlag(vehicle->MoverParameters->iLights[CouplNr], lightset) ? + vehicle->MoverParameters->iLights[CouplNr] |= lightset : // turn signals on + vehicle->MoverParameters->iLights[CouplNr] ^= lightset; // turn signals off } } @@ -6363,7 +6366,7 @@ void TTrain::OnCommand_compartmentlightstoggle(TTrain *Train, command_data const } // keep the switch from flipping back and forth if key is held down - if ((false == Train->mvOccupied->CompartmentLights.is_active) && (false == Train->mvOccupied->CompartmentLights.is_enabled)) + if (false == Train->mvOccupied->CompartmentLights.is_active && false == Train->mvOccupied->CompartmentLights.is_enabled) { // turn on OnCommand_compartmentlightsenable(Train, Command); @@ -6713,7 +6716,7 @@ void TTrain::OnCommand_heatingdisable(TTrain *Train, command_data const &Command Train->mvOccupied->HeatingSwitch(false); // visual feedback - Train->ggTrainHeatingButton.UpdateValue((Train->ggTrainHeatingButton.type() == TGaugeType::push ? 1.0 : 0.0), Train->dsbSwitch); + Train->ggTrainHeatingButton.UpdateValue(Train->ggTrainHeatingButton.type() == TGaugeType::push ? 1.0 : 0.0, Train->dsbSwitch); } } @@ -6982,7 +6985,7 @@ void TTrain::OnCommand_inverterenable(TTrain *Train, command_data const &Command if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - bool kier = (Train->DynamicObject->DirectionGet() * Train->mvOccupied->CabOccupied > 0); + bool kier = Train->DynamicObject->DirectionGet() * Train->mvOccupied->CabOccupied > 0; int flag = Train->DynamicObject->MoverParameters->InverterControlCouplerFlag; TDynamicObject *p = Train->DynamicObject->GetFirstDynamic(Train->mvOccupied->CabOccupied < 0 ? end::rear : end::front, flag); while (p) @@ -6999,7 +7002,7 @@ void TTrain::OnCommand_inverterenable(TTrain *Train, command_data const &Command itemindex -= p->MoverParameters->InvertersNo; } } - p = (kier ? p->Next(flag) : p->Prev(flag)); + p = kier ? p->Next(flag) : p->Prev(flag); } // visual feedback item.UpdateValue(1.0, Train->dsbSwitch); @@ -7021,7 +7024,7 @@ void TTrain::OnCommand_inverterdisable(TTrain *Train, command_data const &Comman if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - bool kier = (Train->DynamicObject->DirectionGet() * Train->mvOccupied->CabOccupied > 0); + bool kier = Train->DynamicObject->DirectionGet() * Train->mvOccupied->CabOccupied > 0; int flag = Train->DynamicObject->MoverParameters->InverterControlCouplerFlag; TDynamicObject *p = Train->DynamicObject->GetFirstDynamic(Train->mvOccupied->CabOccupied < 0 ? end::rear : end::front, flag); while (p) @@ -7038,7 +7041,7 @@ void TTrain::OnCommand_inverterdisable(TTrain *Train, command_data const &Comman itemindex -= p->MoverParameters->InvertersNo; } } - p = (kier ? p->Next(flag) : p->Prev(flag)); + p = kier ? p->Next(flag) : p->Prev(flag); } // visual feedback item.UpdateValue(1.0, Train->dsbSwitch); @@ -7060,7 +7063,7 @@ void TTrain::OnCommand_invertertoggle(TTrain *Train, command_data const &Command if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - bool kier = (Train->DynamicObject->DirectionGet() * Train->mvOccupied->CabOccupied > 0); + bool kier = Train->DynamicObject->DirectionGet() * Train->mvOccupied->CabOccupied > 0; int flag = Train->DynamicObject->MoverParameters->InverterControlCouplerFlag; TDynamicObject *p = Train->DynamicObject->GetFirstDynamic(Train->mvOccupied->CabOccupied < 0 ? end::rear : end::front, flag); while (p) @@ -7079,7 +7082,7 @@ void TTrain::OnCommand_invertertoggle(TTrain *Train, command_data const &Command itemindex -= p->MoverParameters->InvertersNo; } } - p = (kier ? p->Next(flag) : p->Prev(flag)); + p = kier ? p->Next(flag) : p->Prev(flag); } } }; @@ -7124,7 +7127,7 @@ void TTrain::OnCommand_doortoggleleft(TTrain *Train, command_data const &Command if (Command.action == GLFW_PRESS) { // NOTE: test how the door state check works with consists where the occupied vehicle doesn't have opening doors - if (false == ((Train->ggDoorLeftButton.GetDesiredValue() > 0.5) || (Train->ggDoorLeftOnButton.GetDesiredValue() > 0.5))) + if (false == (Train->ggDoorLeftButton.GetDesiredValue() > 0.5 || Train->ggDoorLeftOnButton.GetDesiredValue() > 0.5)) { // open OnCommand_dooropenleft(Train, Command); @@ -7132,7 +7135,7 @@ void TTrain::OnCommand_doortoggleleft(TTrain *Train, command_data const &Command else { // close - if ((Train->ggDoorAllOffButton.SubModel != nullptr) && (Train->ggDoorLeftOffButton.SubModel == nullptr)) + if (Train->ggDoorAllOffButton.SubModel != nullptr && Train->ggDoorLeftOffButton.SubModel == nullptr) { // OnCommand_doorcloseall( Train, Command ); // if two-button setup lacks dedicated closing button require the user to press appropriate button manually @@ -7147,13 +7150,13 @@ void TTrain::OnCommand_doortoggleleft(TTrain *Train, command_data const &Command else if (Command.action == GLFW_RELEASE) { - if (true == ((Train->ggDoorLeftButton.GetDesiredValue() > 0.5) || (Train->ggDoorLeftOnButton.GetDesiredValue() > 0.5))) + if (true == (Train->ggDoorLeftButton.GetDesiredValue() > 0.5 || Train->ggDoorLeftOnButton.GetDesiredValue() > 0.5)) { // open - if ((Train->mvOccupied->Doors.has_autowarning) && (Train->mvOccupied->DepartureSignal)) + if (Train->mvOccupied->Doors.has_autowarning && Train->mvOccupied->DepartureSignal) { // complete closing the doors - if ((Train->ggDoorAllOffButton.SubModel != nullptr) && (Train->ggDoorLeftOffButton.SubModel == nullptr)) + if (Train->ggDoorAllOffButton.SubModel != nullptr && Train->ggDoorLeftOffButton.SubModel == nullptr) { // OnCommand_doorcloseall( Train, Command ); // if two-button setup lacks dedicated closing button require the user to press appropriate button manually @@ -7172,7 +7175,7 @@ void TTrain::OnCommand_doortoggleleft(TTrain *Train, command_data const &Command else { // close - if ((Train->ggDoorAllOffButton.SubModel != nullptr) && (Train->ggDoorLeftOffButton.SubModel == nullptr)) + if (Train->ggDoorAllOffButton.SubModel != nullptr && Train->ggDoorLeftOffButton.SubModel == nullptr) { // OnCommand_doorcloseall( Train, Command ); // if two-button setup lacks dedicated closing button require the user to press appropriate button manually @@ -7226,7 +7229,7 @@ void TTrain::OnCommand_doorpermitleft(TTrain *Train, command_data const &Command Train->mvOccupied->PermitDoors(side, newstate); // visual feedback - Train->ggDoorLeftPermitButton.UpdateValue((newstate ? 1.0 : 0.0), Train->dsbSwitch); + Train->ggDoorLeftPermitButton.UpdateValue(newstate ? 1.0 : 0.0, Train->dsbSwitch); } } else if (Command.action == GLFW_RELEASE) @@ -7276,7 +7279,7 @@ void TTrain::OnCommand_doorpermitright(TTrain *Train, command_data const &Comman Train->mvOccupied->PermitDoors(side, newstate); // visual feedback - Train->ggDoorRightPermitButton.UpdateValue((newstate ? 1.0 : 0.0), Train->dsbSwitch); + Train->ggDoorRightPermitButton.UpdateValue(newstate ? 1.0 : 0.0, Train->dsbSwitch); } } else if (Command.action == GLFW_RELEASE) @@ -7320,14 +7323,14 @@ void TTrain::OnCommand_doorpermitpresetactivateprevious(TTrain *Train, command_d void TTrain::OnCommand_dooropenleft(TTrain *Train, command_data const &Command) { - auto const remoteopencontrol{(Train->mvOccupied->Doors.open_control == control_t::driver) || (Train->mvOccupied->Doors.open_control == control_t::mixed)}; + auto const remoteopencontrol{Train->mvOccupied->Doors.open_control == control_t::driver || Train->mvOccupied->Doors.open_control == control_t::mixed}; if (false == remoteopencontrol) { return; } - if ((Train->ggDoorLeftOnButton.SubModel == nullptr) && (Train->ggDoorLeftButton.SubModel == nullptr)) + if (Train->ggDoorLeftOnButton.SubModel == nullptr && Train->ggDoorLeftButton.SubModel == nullptr) { return; @@ -7335,7 +7338,7 @@ void TTrain::OnCommand_dooropenleft(TTrain *Train, command_data const &Command) if (Command.action == GLFW_PRESS) { - Train->mvOccupied->OperateDoors((Train->cab_to_end() == end::front ? side::left : side::right), true); + Train->mvOccupied->OperateDoors(Train->cab_to_end() == end::front ? side::left : side::right, true); // visual feedback if (Train->ggDoorLeftOnButton.SubModel != nullptr) { @@ -7362,14 +7365,14 @@ void TTrain::OnCommand_dooropenleft(TTrain *Train, command_data const &Command) void TTrain::OnCommand_doorcloseleft(TTrain *Train, command_data const &Command) { - auto const remoteclosecontrol{(Train->mvOccupied->Doors.close_control == control_t::driver) || (Train->mvOccupied->Doors.close_control == control_t::mixed)}; + auto const remoteclosecontrol{Train->mvOccupied->Doors.close_control == control_t::driver || Train->mvOccupied->Doors.close_control == control_t::mixed}; if (false == remoteclosecontrol) { return; } - if ((Train->ggDoorLeftOffButton.SubModel == nullptr) && (Train->ggDoorLeftButton.SubModel == nullptr)) + if (Train->ggDoorLeftOffButton.SubModel == nullptr && Train->ggDoorLeftButton.SubModel == nullptr) { return; @@ -7386,7 +7389,7 @@ void TTrain::OnCommand_doorcloseleft(TTrain *Train, command_data const &Command) else { // TODO: move door opening/closing to the update, so the switch animation doesn't hinge on door working - Train->mvOccupied->OperateDoors((Train->cab_to_end() == end::front ? side::left : side::right), false); + Train->mvOccupied->OperateDoors(Train->cab_to_end() == end::front ? side::left : side::right, false); } // visual feedback if (Train->ggDoorLeftOffButton.SubModel != nullptr) @@ -7408,7 +7411,7 @@ void TTrain::OnCommand_doorcloseleft(TTrain *Train, command_data const &Command) // automatic departure signal delays actual door closing until the button is released Train->mvOccupied->signal_departure(false); // now we can actually close the door - Train->mvOccupied->OperateDoors((Train->cab_to_end() == end::front ? side::left : side::right), false); + Train->mvOccupied->OperateDoors(Train->cab_to_end() == end::front ? side::left : side::right, false); } // visual feedback // dedicated closing buttons are presumed to be impulse switches and return automatically to neutral position @@ -7423,7 +7426,7 @@ void TTrain::OnCommand_doortoggleright(TTrain *Train, command_data const &Comman if (Command.action == GLFW_PRESS) { // NOTE: test how the door state check works with consists where the occupied vehicle doesn't have opening doors - if (false == ((Train->ggDoorRightButton.GetDesiredValue() > 0.5) || (Train->ggDoorRightOnButton.GetDesiredValue() > 0.5))) + if (false == (Train->ggDoorRightButton.GetDesiredValue() > 0.5 || Train->ggDoorRightOnButton.GetDesiredValue() > 0.5)) { // open OnCommand_dooropenright(Train, Command); @@ -7431,7 +7434,7 @@ void TTrain::OnCommand_doortoggleright(TTrain *Train, command_data const &Comman else { // close - if ((Train->ggDoorAllOffButton.SubModel != nullptr) && (Train->ggDoorRightOffButton.SubModel == nullptr)) + if (Train->ggDoorAllOffButton.SubModel != nullptr && Train->ggDoorRightOffButton.SubModel == nullptr) { // OnCommand_doorcloseall( Train, Command ); // if two-button setup lacks dedicated closing button require the user to press appropriate button manually @@ -7446,13 +7449,13 @@ void TTrain::OnCommand_doortoggleright(TTrain *Train, command_data const &Comman else if (Command.action == GLFW_RELEASE) { - if (true == ((Train->ggDoorRightButton.GetDesiredValue() > 0.5) || (Train->ggDoorRightOnButton.GetDesiredValue() > 0.5))) + if (true == (Train->ggDoorRightButton.GetDesiredValue() > 0.5 || Train->ggDoorRightOnButton.GetDesiredValue() > 0.5)) { // open - if ((Train->mvOccupied->Doors.has_autowarning) && (Train->mvOccupied->DepartureSignal)) + if (Train->mvOccupied->Doors.has_autowarning && Train->mvOccupied->DepartureSignal) { // complete closing the doors - if ((Train->ggDoorAllOffButton.SubModel != nullptr) && (Train->ggDoorRightOffButton.SubModel == nullptr)) + if (Train->ggDoorAllOffButton.SubModel != nullptr && Train->ggDoorRightOffButton.SubModel == nullptr) { // OnCommand_doorcloseall( Train, Command ); // if two-button setup lacks dedicated closing button require the user to press appropriate button manually @@ -7471,7 +7474,7 @@ void TTrain::OnCommand_doortoggleright(TTrain *Train, command_data const &Comman else { // close - if ((Train->ggDoorAllOffButton.SubModel != nullptr) && (Train->ggDoorRightOffButton.SubModel == nullptr)) + if (Train->ggDoorAllOffButton.SubModel != nullptr && Train->ggDoorRightOffButton.SubModel == nullptr) { // OnCommand_doorcloseall( Train, Command ); // if two-button setup lacks dedicated closing button require the user to press appropriate button manually @@ -7495,14 +7498,14 @@ void TTrain::OnCommand_doortoggleright(TTrain *Train, command_data const &Comman void TTrain::OnCommand_dooropenright(TTrain *Train, command_data const &Command) { - auto const remoteopencontrol{(Train->mvOccupied->Doors.open_control == control_t::driver) || (Train->mvOccupied->Doors.open_control == control_t::mixed)}; + auto const remoteopencontrol{Train->mvOccupied->Doors.open_control == control_t::driver || Train->mvOccupied->Doors.open_control == control_t::mixed}; if (false == remoteopencontrol) { return; } - if ((Train->ggDoorRightOnButton.SubModel == nullptr) && (Train->ggDoorRightButton.SubModel == nullptr)) + if (Train->ggDoorRightOnButton.SubModel == nullptr && Train->ggDoorRightButton.SubModel == nullptr) { return; @@ -7511,7 +7514,7 @@ void TTrain::OnCommand_dooropenright(TTrain *Train, command_data const &Command) if (Command.action == GLFW_PRESS) { - Train->mvOccupied->OperateDoors((Train->cab_to_end() == end::front ? side::right : side::left), true); + Train->mvOccupied->OperateDoors(Train->cab_to_end() == end::front ? side::right : side::left, true); // visual feedback if (Train->ggDoorRightOnButton.SubModel != nullptr) { @@ -7538,14 +7541,14 @@ void TTrain::OnCommand_dooropenright(TTrain *Train, command_data const &Command) void TTrain::OnCommand_doorcloseright(TTrain *Train, command_data const &Command) { - auto const remoteclosecontrol{(Train->mvOccupied->Doors.close_control == control_t::driver) || (Train->mvOccupied->Doors.close_control == control_t::mixed)}; + auto const remoteclosecontrol{Train->mvOccupied->Doors.close_control == control_t::driver || Train->mvOccupied->Doors.close_control == control_t::mixed}; if (false == remoteclosecontrol) { return; } - if ((Train->ggDoorRightOffButton.SubModel == nullptr) && (Train->ggDoorRightButton.SubModel == nullptr)) + if (Train->ggDoorRightOffButton.SubModel == nullptr && Train->ggDoorRightButton.SubModel == nullptr) { return; @@ -7561,7 +7564,7 @@ void TTrain::OnCommand_doorcloseright(TTrain *Train, command_data const &Command } else { - Train->mvOccupied->OperateDoors((Train->cab_to_end() == end::front ? side::right : side::left), false); + Train->mvOccupied->OperateDoors(Train->cab_to_end() == end::front ? side::right : side::left, false); } // visual feedback if (Train->ggDoorRightOffButton.SubModel != nullptr) @@ -7583,7 +7586,7 @@ void TTrain::OnCommand_doorcloseright(TTrain *Train, command_data const &Command // automatic departure signal delays actual door closing until the button is released Train->mvOccupied->signal_departure(false); // now we can actually close the door - Train->mvOccupied->OperateDoors((Train->cab_to_end() == end::front ? side::right : side::left), false); + Train->mvOccupied->OperateDoors(Train->cab_to_end() == end::front ? side::right : side::left, false); } // visual feedback // dedicated closing buttons are presumed to be impulse switches and return automatically to neutral position @@ -7595,7 +7598,7 @@ void TTrain::OnCommand_doorcloseright(TTrain *Train, command_data const &Command void TTrain::OnCommand_dooropenall(TTrain *Train, command_data const &Command) { - auto const remoteopencontrol{(Train->mvOccupied->Doors.open_control == control_t::driver) || (Train->mvOccupied->Doors.open_control == control_t::mixed)}; + auto const remoteopencontrol{Train->mvOccupied->Doors.open_control == control_t::driver || Train->mvOccupied->Doors.open_control == control_t::mixed}; if (false == remoteopencontrol) { @@ -7630,7 +7633,7 @@ void TTrain::OnCommand_dooropenall(TTrain *Train, command_data const &Command) void TTrain::OnCommand_doorcloseall(TTrain *Train, command_data const &Command) { - auto const remoteclosecontrol{(Train->mvOccupied->Doors.close_control == control_t::driver) || (Train->mvOccupied->Doors.close_control == control_t::mixed)}; + auto const remoteclosecontrol{Train->mvOccupied->Doors.close_control == control_t::driver || Train->mvOccupied->Doors.close_control == control_t::mixed}; if (false == remoteclosecontrol) { @@ -7747,7 +7750,7 @@ void TTrain::OnCommand_mirrorstoggle(TTrain *Train, command_data const &Command) void TTrain::OnCommand_nearestcarcouplingincrease(TTrain *Train, command_data const &Command) { - if ((true == Command.freefly) && (Command.action == GLFW_PRESS)) + if (true == Command.freefly && Command.action == GLFW_PRESS) { // tryb freefly, press only auto coupler{-1}; @@ -7755,7 +7758,7 @@ void TTrain::OnCommand_nearestcarcouplingincrease(TTrain *Train, command_data co if (vehicle == nullptr) vehicle = Train->DynamicObject->ABuScanNearestObject(Command.location, Train->DynamicObject->GetTrack(), -1, 1500, coupler); - if ((coupler != -1) && (vehicle != nullptr)) + if (coupler != -1 && vehicle != nullptr) { vehicle->couple(coupler); @@ -7771,7 +7774,7 @@ void TTrain::OnCommand_nearestcarcouplingincrease(TTrain *Train, command_data co void TTrain::OnCommand_nearestcarcouplingdisconnect(TTrain *Train, command_data const &Command) { - if ((true == Command.freefly) && (Command.action == GLFW_PRESS)) + if (true == Command.freefly && Command.action == GLFW_PRESS) { // tryb freefly, press only auto coupler{-1}; @@ -7779,7 +7782,7 @@ void TTrain::OnCommand_nearestcarcouplingdisconnect(TTrain *Train, command_data if (vehicle == nullptr) vehicle = Train->DynamicObject->ABuScanNearestObject(Command.location, Train->DynamicObject->GetTrack(), -1, 1500, coupler); - if ((coupler != -1) && (vehicle != nullptr)) + if (coupler != -1 && vehicle != nullptr) { vehicle->uncouple(coupler); @@ -7795,7 +7798,7 @@ void TTrain::OnCommand_nearestcarcouplingdisconnect(TTrain *Train, command_data void TTrain::OnCommand_nearestcarcoupleradapterattach(TTrain *Train, command_data const &Command) { - if ((true == Command.freefly) && (Command.action == GLFW_PRESS)) + if (true == Command.freefly && Command.action == GLFW_PRESS) { // tryb freefly, press only auto *vehicle{std::get(simulation::Region->find_vehicle(Command.location, 50, false, true))}; @@ -7805,8 +7808,7 @@ void TTrain::OnCommand_nearestcarcoupleradapterattach(TTrain *Train, command_dat } auto const coupler = - (glm::length2(glm::vec3{vehicle->CouplerPosition(end::front)} - Command.location) < glm::length2(glm::vec3{vehicle->CouplerPosition(end::rear)} - Command.location) ? end::front : - end::rear); + glm::length2(glm::vec3{vehicle->CouplerPosition(end::front)} - Command.location) < glm::length2(glm::vec3{vehicle->CouplerPosition(end::rear)} - Command.location) ? end::front : end::rear; vehicle->attach_coupler_adapter(coupler); } @@ -7815,7 +7817,7 @@ void TTrain::OnCommand_nearestcarcoupleradapterattach(TTrain *Train, command_dat void TTrain::OnCommand_nearestcarcoupleradapterremove(TTrain *Train, command_data const &Command) { - if ((true == Command.freefly) && (Command.action == GLFW_PRESS)) + if (true == Command.freefly && Command.action == GLFW_PRESS) { // tryb freefly, press only auto *vehicle{std::get(simulation::Region->find_vehicle(Command.location, 50, false, true))}; @@ -7825,8 +7827,7 @@ void TTrain::OnCommand_nearestcarcoupleradapterremove(TTrain *Train, command_dat } auto const coupler = - (glm::length2(glm::vec3{vehicle->CouplerPosition(end::front)} - Command.location) < glm::length2(glm::vec3{vehicle->CouplerPosition(end::rear)} - Command.location) ? end::front : - end::rear); + glm::length2(glm::vec3{vehicle->CouplerPosition(end::front)} - Command.location) < glm::length2(glm::vec3{vehicle->CouplerPosition(end::rear)} - Command.location) ? end::front : end::rear; vehicle->remove_coupler_adapter(coupler); } @@ -7931,7 +7932,7 @@ void TTrain::OnCommand_departureannounce(TTrain *Train, command_data const &Comm void TTrain::OnCommand_hornlowactivate(TTrain *Train, command_data const &Command) { - if ((Train->ggHornButton.SubModel == nullptr) && (Train->ggHornLowButton.SubModel == nullptr)) + if (Train->ggHornButton.SubModel == nullptr && Train->ggHornLowButton.SubModel == nullptr) { if (Command.action == GLFW_PRESS) { @@ -7975,7 +7976,7 @@ void TTrain::OnCommand_hornlowactivate(TTrain *Train, command_data const &Comman void TTrain::OnCommand_hornhighactivate(TTrain *Train, command_data const &Command) { - if ((Train->ggHornButton.SubModel == nullptr) && (Train->ggHornHighButton.SubModel == nullptr)) + if (Train->ggHornButton.SubModel == nullptr && Train->ggHornHighButton.SubModel == nullptr) { if (Command.action == GLFW_PRESS) { @@ -8151,7 +8152,7 @@ void TTrain::OnCommand_radiostopsend(TTrain *Train, command_data const &Command) if (Command.action == GLFW_PRESS) { - if ((true == Train->mvOccupied->Radio) && (Train->mvOccupied->Power24vIsAvailable || Train->mvOccupied->Power110vIsAvailable)) + if (true == Train->mvOccupied->Radio && (Train->mvOccupied->Power24vIsAvailable || Train->mvOccupied->Power110vIsAvailable)) { simulation::Region->RadioStop(Train->Dynamic()->GetPosition()); } @@ -8169,7 +8170,7 @@ void TTrain::OnCommand_radiostopenable(TTrain *Train, command_data const &Comman { if (Command.action == GLFW_PRESS && Train->ggRadioStop.GetValue() == 0) { - if ((true == Train->mvOccupied->Radio) && (Train->mvOccupied->Power24vIsAvailable || Train->mvOccupied->Power110vIsAvailable)) + if (true == Train->mvOccupied->Radio && (Train->mvOccupied->Power24vIsAvailable || Train->mvOccupied->Power110vIsAvailable)) { simulation::Region->RadioStop(Train->Dynamic()->GetPosition()); } @@ -8192,7 +8193,7 @@ void TTrain::OnCommand_radiostoptest(TTrain *Train, command_data const &Command) if (Command.action == GLFW_PRESS) { - if ((Train->RadioChannel() == 10) && (true == Train->mvOccupied->Radio) && (Train->mvOccupied->Power24vIsAvailable || Train->mvOccupied->Power110vIsAvailable)) + if (Train->RadioChannel() == 10 && true == Train->mvOccupied->Radio && (Train->mvOccupied->Power24vIsAvailable || Train->mvOccupied->Power110vIsAvailable)) { Train->Dynamic()->RadioStop(); } @@ -8210,7 +8211,7 @@ void TTrain::OnCommand_radiocall1send(TTrain *Train, command_data const &Command { if (Command.action == GLFW_PRESS) { - if ((Train->RadioChannel() != 10) && (true == Train->mvOccupied->Radio) && (Train->mvOccupied->Power24vIsAvailable || Train->mvOccupied->Power110vIsAvailable)) + if (Train->RadioChannel() != 10 && true == Train->mvOccupied->Radio && (Train->mvOccupied->Power24vIsAvailable || Train->mvOccupied->Power110vIsAvailable)) { simulation::Events.queue_receivers(radio_message::call1, Train->Dynamic()->GetPosition()); } @@ -8229,7 +8230,7 @@ void TTrain::OnCommand_radiocall3send(TTrain *Train, command_data const &Command if (Command.action == GLFW_PRESS) { - if ((Train->RadioChannel() != 10) && (true == Train->mvOccupied->Radio) && (Train->mvOccupied->Power24vIsAvailable || Train->mvOccupied->Power110vIsAvailable)) + if (Train->RadioChannel() != 10 && true == Train->mvOccupied->Radio && (Train->mvOccupied->Power24vIsAvailable || Train->mvOccupied->Power110vIsAvailable)) { simulation::Events.queue_receivers(radio_message::call3, Train->Dynamic()->GetPosition()); } @@ -8301,8 +8302,8 @@ void TTrain::OnCommand_cabchangeforward(TTrain *Train, command_data const &Comma if (TestFlag(Train->mvOccupied->Couplers[exitdirection].CouplingFlag, coupling::gangway)) { // przejscie do nastepnego pojazdu - auto *targetvehicle = (exitdirection == end::front ? Train->DynamicObject->PrevConnected() : Train->DynamicObject->NextConnected()); - targetvehicle->MoverParameters->CabOccupied = (Train->mvOccupied->Neighbours[exitdirection].vehicle_end ? -1 : 1); + auto *targetvehicle = exitdirection == end::front ? Train->DynamicObject->PrevConnected() : Train->DynamicObject->NextConnected(); + targetvehicle->MoverParameters->CabOccupied = Train->mvOccupied->Neighbours[exitdirection].vehicle_end ? -1 : 1; Train->MoveToVehicle(targetvehicle); } } @@ -8333,8 +8334,8 @@ void TTrain::OnCommand_cabchangebackward(TTrain *Train, command_data const &Comm if (TestFlag(Train->mvOccupied->Couplers[exitdirection].CouplingFlag, coupling::gangway)) { // przejscie do nastepnego pojazdu - auto *targetvehicle = (exitdirection == end::front ? Train->DynamicObject->PrevConnected() : Train->DynamicObject->NextConnected()); - targetvehicle->MoverParameters->CabOccupied = (Train->mvOccupied->Neighbours[exitdirection].vehicle_end ? -1 : 1); + auto *targetvehicle = exitdirection == end::front ? Train->DynamicObject->PrevConnected() : Train->DynamicObject->NextConnected(); + targetvehicle->MoverParameters->CabOccupied = Train->mvOccupied->Neighbours[exitdirection].vehicle_end ? -1 : 1; Train->MoveToVehicle(targetvehicle); } } @@ -8398,8 +8399,8 @@ void TTrain::UpdateCab() { // Ra: przesiadka, jeśli AI zmieniło kabinę (a człon?)... - if ((DynamicObject->Mechanik) // może nie być? - && (DynamicObject->Mechanik->AIControllFlag)) + if (DynamicObject->Mechanik // może nie być? + && DynamicObject->Mechanik->AIControllFlag) { if (iCabn != ( // numer kabiny (-1: kabina B) @@ -8409,7 +8410,7 @@ void TTrain::UpdateCab() InitializeCab(mvOccupied->CabOccupied, mvOccupied->TypeName + ".mmd"); } } - iCabn = (mvOccupied->CabOccupied == -1 ? 2 : mvOccupied->CabOccupied); + iCabn = mvOccupied->CabOccupied == -1 ? 2 : mvOccupied->CabOccupied; } bool TTrain::Update(double const Deltatime) @@ -8434,8 +8435,9 @@ bool TTrain::Update(double const Deltatime) } } - if (((ggMainButton.SubModel != nullptr) && (ggMainButton.GetDesiredValue() > 0.95)) || - ((ggMainOnButton.SubModel != nullptr) && (ggMainOnButton.GetDesiredValue() > 0.95) || (ggIgnitionKey.GetDesiredValue() > 0.95))) + if ((ggMainButton.SubModel != nullptr && ggMainButton.GetDesiredValue() > 0.95) || + ggMainOnButton.SubModel != nullptr && ggMainOnButton.GetDesiredValue() > 0.95 || + ggIgnitionKey.GetDesiredValue() > 0.95) { // HACK: fallback // keep track of period the line breaker button is held down, to determine when/if circuit closes if (mvControlled->MainSwitchCheck()) @@ -8466,10 +8468,10 @@ bool TTrain::Update(double const Deltatime) { // for diesels and/or vehicles with toggle switch setup we complete the engine start here // TODO: make it a test for main_on_bt of type push_delayed instead - if ((ggMainOnButton.SubModel == nullptr) || (mvControlled->EngineType != TEngineType::ElectricSeriesMotor)) + if (ggMainOnButton.SubModel == nullptr || mvControlled->EngineType != TEngineType::ElectricSeriesMotor) { // try to finalize state change of the line breaker, set the state based on the outcome - m_linebreakerstate = (mvControlled->MainSwitch(true) ? 1 : 0); + m_linebreakerstate = mvControlled->MainSwitch(true) ? 1 : 0; } } // door permits @@ -8506,20 +8508,20 @@ bool TTrain::Update(double const Deltatime) // helper variables if (DynamicObject->Mechanik != nullptr) { - m_doors = (DynamicObject->Mechanik->IsAnyDoorOpen[side::right] || DynamicObject->Mechanik->IsAnyDoorOpen[side::left]); - m_doorpermits = (DynamicObject->Mechanik->IsAnyDoorPermitActive[side::right] || DynamicObject->Mechanik->IsAnyDoorPermitActive[side::left]); + m_doors = DynamicObject->Mechanik->IsAnyDoorOpen[side::right] || DynamicObject->Mechanik->IsAnyDoorOpen[side::left]; + m_doorpermits = DynamicObject->Mechanik->IsAnyDoorPermitActive[side::right] || DynamicObject->Mechanik->IsAnyDoorPermitActive[side::left]; m_doorspermitleft = mvOccupied->Doors.instances[(cab_to_end() == end::front ? side::left : side::right)].open_permit && - ((simulation::Time.data().wSecond % 2 < 1) || (mvOccupied->DoorsPermitLightBlinking < 1) || - ((mvOccupied->DoorsPermitLightBlinking < 2) && (DynamicObject->Mechanik->IsAnyDoorOpen[(cab_to_end() == end::front ? side::left : side::right)]) || - ((mvOccupied->DoorsPermitLightBlinking < 3) && DynamicObject->Mechanik->IsAnyDoorOnlyOpen[(cab_to_end() == end::front ? side::left : side::right)]))); + (simulation::Time.data().wSecond % 2 < 1 || mvOccupied->DoorsPermitLightBlinking < 1 || + mvOccupied->DoorsPermitLightBlinking < 2 && DynamicObject->Mechanik->IsAnyDoorOpen[(cab_to_end() == end::front ? side::left : side::right)] || + (mvOccupied->DoorsPermitLightBlinking < 3 && DynamicObject->Mechanik->IsAnyDoorOnlyOpen[(cab_to_end() == end::front ? side::left : side::right)])); m_doorspermitright = mvOccupied->Doors.instances[(cab_to_end() == end::front ? side::right : side::left)].open_permit && - ((simulation::Time.data().wSecond % 2 < 1) || (mvOccupied->DoorsPermitLightBlinking < 1) || - ((mvOccupied->DoorsPermitLightBlinking < 2) && (DynamicObject->Mechanik->IsAnyDoorOpen[(cab_to_end() == end::front ? side::right : side::left)]) || - ((mvOccupied->DoorsPermitLightBlinking < 3) && DynamicObject->Mechanik->IsAnyDoorOnlyOpen[(cab_to_end() == end::front ? side::right : side::left)]))); + (simulation::Time.data().wSecond % 2 < 1 || mvOccupied->DoorsPermitLightBlinking < 1 || + mvOccupied->DoorsPermitLightBlinking < 2 && DynamicObject->Mechanik->IsAnyDoorOpen[(cab_to_end() == end::front ? side::right : side::left)] || + (mvOccupied->DoorsPermitLightBlinking < 3 && DynamicObject->Mechanik->IsAnyDoorOnlyOpen[(cab_to_end() == end::front ? side::right : side::left)])); } - m_dirforward = (mvControlled->DirActive > 0); - m_dirneutral = (mvControlled->DirActive == 0); - m_dirbackward = (mvControlled->DirActive < 0); + m_dirforward = mvControlled->DirActive > 0; + m_dirneutral = mvControlled->DirActive == 0; + m_dirbackward = mvControlled->DirActive < 0; // check for received user commands // NOTE: this is a temporary arrangement, for the transition period from old command setup to the new one @@ -8544,10 +8546,10 @@ bool TTrain::Update(double const Deltatime) UpdateCab(); - if ((DynamicObject->Mechanik != nullptr) && (false == DynamicObject->Mechanik->AIControllFlag)) + if (DynamicObject->Mechanik != nullptr && false == DynamicObject->Mechanik->AIControllFlag) { // nie blokujemy AI - if ((mvOccupied->TrainType == dt_ET40) || (mvOccupied->TrainType == dt_EP05) || (mvOccupied->HasCamshaft)) + if (mvOccupied->TrainType == dt_ET40 || mvOccupied->TrainType == dt_EP05 || mvOccupied->HasCamshaft) { // dla ET40 i EU05 automatyczne cofanie nastawnika - i tak nie będzie to działać dobrze... // TODO: use deltatime to stabilize speed @@ -8611,7 +8613,7 @@ bool TTrain::Update(double const Deltatime) } // Ra 2014-09: napięcia i prądy muszą być ustalone najpierw, bo wysyłane są ewentualnie na PoKeys - if ((mvControlled->EngineType != TEngineType::DieselElectric) && (mvControlled->EngineType != TEngineType::ElectricInductionMotor)) + if (mvControlled->EngineType != TEngineType::DieselElectric && mvControlled->EngineType != TEngineType::ElectricInductionMotor) { // Ra 2014-09: czy taki rozdzia? ma sens? fHVoltage = std::max(mvControlled->PantographVoltage, mvControlled->GetTrainsetHighVoltage()); // Winger czy to nie jest zle? @@ -8641,7 +8643,7 @@ bool TTrain::Update(double const Deltatime) fHCurrent[3] = mvControlled->ShowCurrent(3); } - bool kier = (DynamicObject->DirectionGet() * mvOccupied->CabOccupied > 0); + bool kier = DynamicObject->DirectionGet() * mvOccupied->CabOccupied > 0; TDynamicObject *p = DynamicObject->GetFirstDynamic(mvOccupied->CabOccupied < 0 ? end::rear : end::front, 4); int in = 0; fEIMParams[0][6] = 0; @@ -8678,35 +8680,35 @@ bool TTrain::Update(double const Deltatime) fPress[i][6] = p->MoverParameters->SpringBrake.SBP; bBrakes[i][0] = p->MoverParameters->SpringBrake.IsActive; bBrakes[i][1] = p->MoverParameters->SpringBrake.ShuttOff; - bDoors[i][1] = (p->MoverParameters->Doors.instances[side::left].position > 0.f); - bDoors[i][2] = (p->MoverParameters->Doors.instances[side::right].position > 0.f); - bDoors[i][3] = (p->MoverParameters->Doors.instances[side::left].step_position > 0.f); - bDoors[i][4] = (p->MoverParameters->Doors.instances[side::right].step_position > 0.f); - bDoors[i][0] = (bDoors[i][1] || bDoors[i][2]); + bDoors[i][1] = p->MoverParameters->Doors.instances[side::left].position > 0.f; + bDoors[i][2] = p->MoverParameters->Doors.instances[side::right].position > 0.f; + bDoors[i][3] = p->MoverParameters->Doors.instances[side::left].step_position > 0.f; + bDoors[i][4] = p->MoverParameters->Doors.instances[side::right].step_position > 0.f; + bDoors[i][0] = bDoors[i][1] || bDoors[i][2]; iDoorNo[i] = p->iAnimType[ANIM_DOORS]; iUnits[i] = iUnitNo; cCode[i] = p->MoverParameters->TypeName[p->MoverParameters->TypeName.length() - 1]; asCarName[i] = p->name(); if (p->MoverParameters->EnginePowerSource.SourceType == TPowerSource::CurrentCollector) { - bPants[iUnitNo - 1][end::front] = (bPants[iUnitNo - 1][end::front] || p->MoverParameters->Pantographs[end::front].is_active); - bPants[iUnitNo - 1][end::rear] = (bPants[iUnitNo - 1][end::rear] || p->MoverParameters->Pantographs[end::rear].is_active); + bPants[iUnitNo - 1][end::front] = bPants[iUnitNo - 1][end::front] || p->MoverParameters->Pantographs[end::front].is_active; + bPants[iUnitNo - 1][end::rear] = bPants[iUnitNo - 1][end::rear] || p->MoverParameters->Pantographs[end::rear].is_active; } // TBD, TODO: clean up compressor data arrangement? if (iUnitNo <= 8) { - bComp[iUnitNo - 1][0] = (bComp[iUnitNo - 1][0] || p->MoverParameters->CompressorAllow || (p->MoverParameters->CompressorStart == start_t::automatic)); + bComp[iUnitNo - 1][0] = bComp[iUnitNo - 1][0] || p->MoverParameters->CompressorAllow || p->MoverParameters->CompressorStart == start_t::automatic; } if (p->MoverParameters->CompressorSpeed > 0.00001) { if (iUnitNo <= 8) { - bComp[iUnitNo - 1][1] = (bComp[iUnitNo - 1][1] || p->MoverParameters->CompressorFlag); + bComp[iUnitNo - 1][1] = bComp[iUnitNo - 1][1] || p->MoverParameters->CompressorFlag; } - bCompressors.emplace_back(p->MoverParameters->CompressorAllow || (p->MoverParameters->CompressorStart == start_t::automatic), p->MoverParameters->CompressorFlag, i); + bCompressors.emplace_back(p->MoverParameters->CompressorAllow || p->MoverParameters->CompressorStart == start_t::automatic, p->MoverParameters->CompressorFlag, i); } bSlip[i] = p->MoverParameters->SlippingWheels; - if ((in < 8) && (p->MoverParameters->eimc[eimc_p_Pmax] > 1)) + if (in < 8 && p->MoverParameters->eimc[eimc_p_Pmax] > 1) { fEIMParams[1 + in][0] = p->MoverParameters->eimv[eimv_Fmax]; fEIMParams[1 + in][1] = std::max(fEIMParams[1 + in][0], 0.f); @@ -8730,7 +8732,7 @@ bool TTrain::Update(double const Deltatime) in++; iPowerNo = in; } - if ((in < 8) && ((p->MoverParameters->EngineType == TEngineType::DieselEngine) || (p->MoverParameters->EngineType == TEngineType::DieselElectric))) + if (in < 8 && (p->MoverParameters->EngineType == TEngineType::DieselEngine || p->MoverParameters->EngineType == TEngineType::DieselElectric)) { fDieselParams[1 + in][0] = p->MoverParameters->enrot * 60; fDieselParams[1 + in][1] = p->MoverParameters->nrot; @@ -8753,7 +8755,7 @@ bool TTrain::Update(double const Deltatime) } if ((kier ? p->Next(coupling::permanent) : p->Prev(coupling::permanent)) != (kier ? p->Next(coupling::control) : p->Prev(coupling::control))) iUnitNo++; - p = (kier ? p->Next(coupling::control) : p->Prev(coupling::control)); + p = kier ? p->Next(coupling::control) : p->Prev(coupling::control); iCarNo = i + 1; } else @@ -8806,7 +8808,7 @@ bool TTrain::Update(double const Deltatime) // Ra: sterowanie miernikiem: drugi amperomierz Console::ValueSet(4, fHCurrent[2]); // pierwszy amperomierz; dla EZT prąd całkowity - Console::ValueSet(5, fHCurrent[(mvControlled->TrainType & dt_EZT) ? 0 : 1]); + Console::ValueSet(5, fHCurrent[mvControlled->TrainType & dt_EZT ? 0 : 1]); // Ra: prędkość na pin 43 - wyjście analogowe (to nie jest PWM); skakanie zapewnia mechanika napędu Console::ValueSet(6, fTachoVelocity); } @@ -8817,15 +8819,15 @@ bool TTrain::Update(double const Deltatime) if (mvControlled->ConverterFlag == true) { fConverterTimer += Deltatime; - if ((mvControlled->CompressorFlag == true) && (mvControlled->CompressorPower == 1) && ((mvControlled->EngineType == TEngineType::ElectricSeriesMotor) || (mvControlled->TrainType == dt_EZT)) && - (DynamicObject->Controller == Humandriver) // hunter-110212: poprawka dla EZT - && (false == DynamicObject->Mechanik->AIControllFlag)) + if (mvControlled->CompressorFlag == true && mvControlled->CompressorPower == 1 && (mvControlled->EngineType == TEngineType::ElectricSeriesMotor || mvControlled->TrainType == dt_EZT) && + DynamicObject->Controller == Humandriver // hunter-110212: poprawka dla EZT + && false == DynamicObject->Mechanik->AIControllFlag) { // hunter-091012: poprawka (zmiana warunku z CompressorPower /rozne od 0/ na /rowne 1/) if (fConverterTimer < fConverterPrzekaznik) { mvControlled->ConvOvldFlag = true; if (mvControlled->TrainType != dt_EZT) - mvControlled->MainSwitch(false, (mvControlled->TrainType == dt_EZT ? range_t::unit : range_t::local)); + mvControlled->MainSwitch(false, mvControlled->TrainType == dt_EZT ? range_t::unit : range_t::local); } else if (fConverterTimer >= fConverterPrzekaznik) { @@ -8843,10 +8845,10 @@ bool TTrain::Update(double const Deltatime) { TDynamicObject *tmp{nullptr}; if (DynamicObject->NextConnected()) - if ((TestFlag(mvControlled->Couplers[end::rear].CouplingFlag, coupling::control)) && (mvOccupied->CabOccupied == 1)) + if (TestFlag(mvControlled->Couplers[end::rear].CouplingFlag, coupling::control) && mvOccupied->CabOccupied == 1) tmp = DynamicObject->NextConnected(); if (DynamicObject->PrevConnected()) - if ((TestFlag(mvControlled->Couplers[end::front].CouplingFlag, coupling::control)) && (mvOccupied->CabOccupied == -1)) + if (TestFlag(mvControlled->Couplers[end::front].CouplingFlag, coupling::control) && mvOccupied->CabOccupied == -1) tmp = DynamicObject->PrevConnected(); if (tmp) { @@ -8917,14 +8919,14 @@ bool TTrain::Update(double const Deltatime) else { int x; - if ((mvControlled->TrainType == dt_ET42) && (mvControlled->Imax == mvControlled->ImaxHi)) + if (mvControlled->TrainType == dt_ET42 && mvControlled->Imax == mvControlled->ImaxHi) x = 1; else x = 2; - if ((mvControlled->RList[mvControlled->MainCtrlActualPos].Mn > 0) && (std::abs(mvControlled->Im) > 0)) + if (mvControlled->RList[mvControlled->MainCtrlActualPos].Mn > 0 && std::abs(mvControlled->Im) > 0) { - ggEngineVoltage.UpdateValue((x * (std::abs(mvControlled->EngineVoltage) - mvControlled->RList[mvControlled->MainCtrlActualPos].R * std::abs(mvControlled->Im)) / - mvControlled->RList[mvControlled->MainCtrlActualPos].Mn)); + ggEngineVoltage.UpdateValue(x * (std::abs(mvControlled->EngineVoltage) - mvControlled->RList[mvControlled->MainCtrlActualPos].R * std::abs(mvControlled->Im)) / + mvControlled->RList[mvControlled->MainCtrlActualPos].Mn); } else { @@ -8939,7 +8941,7 @@ bool TTrain::Update(double const Deltatime) { // NOTE: since we don't have functional converter object, we're faking it here by simple check whether converter is on // TODO: implement object-based circuits and power systems model so we can have this working more properly - ggLVoltage.UpdateValue(std::max((mvOccupied->Power110vIsAvailable ? mvOccupied->NominalBatteryVoltage : 0.0), (mvOccupied->Power24vIsAvailable ? mvOccupied->BatteryVoltage : 0.0))); + ggLVoltage.UpdateValue(std::max(mvOccupied->Power110vIsAvailable ? mvOccupied->NominalBatteryVoltage : 0.0, mvOccupied->Power24vIsAvailable ? mvOccupied->BatteryVoltage : 0.0)); ggLVoltage.Update(); } @@ -8962,11 +8964,11 @@ bool TTrain::Update(double const Deltatime) ggMainGearStatus.UpdateValue(0.0); ggMainGearStatus.Update(); } - if ((ggIgnitionKey.SubModel) && (ggIgnitionKey.GetDesiredValue() == 0.0)) + if (ggIgnitionKey.SubModel && ggIgnitionKey.GetDesiredValue() == 0.0) { - ggIgnitionKey.UpdateValue((mvControlled->Mains) || (mvControlled->dizel_startup) || (fMainRelayTimer > 0.f) || - ((ggMainButton.SubModel != nullptr) && (ggMainButton.GetDesiredValue() > 0.95)) || - ((ggMainOnButton.SubModel != nullptr) && (ggMainOnButton.GetDesiredValue() > 0.95))); + ggIgnitionKey.UpdateValue(mvControlled->Mains || mvControlled->dizel_startup || fMainRelayTimer > 0.f || + (ggMainButton.SubModel != nullptr && ggMainButton.GetDesiredValue() > 0.95) || + (ggMainOnButton.SubModel != nullptr && ggMainOnButton.GetDesiredValue() > 0.95)); } ggIgnitionKey.Update(); } @@ -9037,11 +9039,11 @@ bool TTrain::Update(double const Deltatime) btLampkaSHP.Turn(mvOccupied->SecuritySystem.is_cabsignal_blinking()); btLampkaCzuwakaSHP.Turn(btLampkaSHP.GetValue() || btLampkaCzuwaka.GetValue()); - btLampkaWylSzybki.Turn((((m_linebreakerstate == 2) || (true == mvControlled->Mains)) ? true : false)); - btLampkaWylSzybkiOff.Turn((((m_linebreakerstate == 2) || (true == mvControlled->Mains)) ? false : true)); - btLampkaMainBreakerReady.Turn((((mvControlled->MainsInitTimeCountdown > 0.0) || (m_linebreakerstate == 2) || (true == mvControlled->Mains)) ? false : true)); + btLampkaWylSzybki.Turn(m_linebreakerstate == 2 || true == mvControlled->Mains ? true : false); + btLampkaWylSzybkiOff.Turn(m_linebreakerstate == 2 || true == mvControlled->Mains ? false : true); + btLampkaMainBreakerReady.Turn(mvControlled->MainsInitTimeCountdown > 0.0 || m_linebreakerstate == 2 || true == mvControlled->Mains ? false : true); btLampkaMainBreakerBlinkingIfReady.Turn( - (((m_linebreakerstate == 2) || (true == mvControlled->Mains) || ((mvControlled->MainsInitTimeCountdown < 0.0) && (simulation::Time.data().wMilliseconds > 500))) ? true : false)); + m_linebreakerstate == 2 || true == mvControlled->Mains || (mvControlled->MainsInitTimeCountdown < 0.0 && simulation::Time.data().wMilliseconds > 500) ? true : false); btLampkaPrzetw.Turn(mvOccupied->Power110vIsAvailable); btLampkaPrzetwOff.Turn(false == mvOccupied->Power110vIsAvailable); @@ -9049,16 +9051,16 @@ bool TTrain::Update(double const Deltatime) btLampkaOpory.Turn(mvControlled->StLinFlag ? mvControlled->ResistorsFlagCheck() : false); - btLampkaBezoporowa.Turn((true == mvControlled->ResistorsFlagCheck()) || (mvControlled->MainCtrlActualPos == 0)); // do EU04 + btLampkaBezoporowa.Turn(true == mvControlled->ResistorsFlagCheck() || mvControlled->MainCtrlActualPos == 0); // do EU04 - btLampkaStyczn.Turn(((mvControlled->StLinFlag) || (mvControlled->ControlPressureSwitch)) ? false : (mvControlled->BrakePress < 1.0)); // mozna prowadzic rozruch + btLampkaStyczn.Turn(mvControlled->StLinFlag || mvControlled->ControlPressureSwitch ? false : mvControlled->BrakePress < 1.0); // mozna prowadzic rozruch - btLampkaPrzekRozn.Turn(((mvControlled->GroundRelay) || (mvControlled->ControlPressureSwitch)) ? false : (mvControlled->BrakePress < 1.0)); // relay is off and needs a reset + btLampkaPrzekRozn.Turn(mvControlled->GroundRelay || mvControlled->ControlPressureSwitch ? false : mvControlled->BrakePress < 1.0); // relay is off and needs a reset - btLampkaNadmSil.Turn(((false == mvControlled->FuseFlagCheck()) || (mvControlled->ControlPressureSwitch)) ? false : (mvControlled->BrakePress < 1.0)); // relay is off and needs a reset + btLampkaNadmSil.Turn(false == mvControlled->FuseFlagCheck() || mvControlled->ControlPressureSwitch ? false : mvControlled->BrakePress < 1.0); // relay is off and needs a reset - if (((mvControlled->CabOccupied == 1) && (TestFlag(mvControlled->Couplers[end::rear].CouplingFlag, coupling::control))) || - ((mvControlled->CabOccupied == -1) && (TestFlag(mvControlled->Couplers[end::front].CouplingFlag, coupling::control)))) + if ((mvControlled->CabOccupied == 1 && TestFlag(mvControlled->Couplers[end::rear].CouplingFlag, coupling::control)) || + (mvControlled->CabOccupied == -1 && TestFlag(mvControlled->Couplers[end::front].CouplingFlag, coupling::control))) { btLampkaUkrotnienie.Turn(true); } @@ -9069,17 +9071,17 @@ bool TTrain::Update(double const Deltatime) // if // ((TestFlag(mvControlled->BrakeStatus,+b_Rused+b_Ractive)))//Lampka drugiego stopnia hamowania - btLampkaHamPosp.Turn((TestFlag(mvOccupied->Hamulec->GetBrakeStatus(), 1))); // lampka drugiego stopnia hamowania + btLampkaHamPosp.Turn(TestFlag(mvOccupied->Hamulec->GetBrakeStatus(), 1)); // lampka drugiego stopnia hamowania // TODO: youBy wyciągnąć flagę wysokiego stopnia // hunter-121211: lampka zanikowo-pradowego wentylatorow: - btLampkaNadmWent.Turn((mvControlled->RventRot < 5.0) && (mvControlled->ResistorsFlagCheck())); + btLampkaNadmWent.Turn(mvControlled->RventRot < 5.0 && mvControlled->ResistorsFlagCheck()); //------- btLampkaWysRozr.Turn(!(mvControlled->Imax < mvControlled->ImaxHi)); - if ((false == mvControlled->DelayCtrlFlag) && - ((mvControlled->ScndCtrlActualPos > 0) || ((mvControlled->RList[mvControlled->MainCtrlActualPos].ScndAct != 0) && (mvControlled->RList[mvControlled->MainCtrlActualPos].ScndAct != 255)))) + if (false == mvControlled->DelayCtrlFlag && + (mvControlled->ScndCtrlActualPos > 0 || (mvControlled->RList[mvControlled->MainCtrlActualPos].ScndAct != 0 && mvControlled->RList[mvControlled->MainCtrlActualPos].ScndAct != 255))) { btLampkaBoczniki.Turn(true); } @@ -9097,8 +9099,8 @@ bool TTrain::Update(double const Deltatime) // Ra: w SU45 boczniki wchodzą na MainCtrlPos, a nie na MainCtrlActualPos // - pokićkał ktoś? scp = mvControlled->RList[mvControlled->MainCtrlPos].ScndAct; - scp = (scp == 255 ? 0 : scp); // Ra: whatta hella is this? - if ((mvControlled->ScndCtrlPos > 0) || (mvControlled->ScndInMain != 0) && (scp > 0)) + scp = scp == 255 ? 0 : scp; // Ra: whatta hella is this? + if (mvControlled->ScndCtrlPos > 0 || mvControlled->ScndInMain != 0 && scp > 0) { // boczniki pojedynczo btLampkaBocznik1.Turn(true); btLampkaBocznik2.Turn(mvControlled->ScndCtrlPos > 1); @@ -9134,7 +9136,7 @@ bool TTrain::Update(double const Deltatime) // zależnie od typu lokomotywy case dt_EZT: { - btLampkaHamienie.Turn((mvControlled->BrakePress >= 0.2) && mvControlled->Signalling); + btLampkaHamienie.Turn(mvControlled->BrakePress >= 0.2 && mvControlled->Signalling); break; } case dt_ET41: @@ -9149,8 +9151,8 @@ bool TTrain::Update(double const Deltatime) } default: { - btLampkaHamienie.Turn((mvOccupied->BrakePress >= 0.1) || mvControlled->DynamicBrakeFlag); - btLampkaBrakingOff.Turn((mvOccupied->BrakePress < 0.1) && (false == mvControlled->DynamicBrakeFlag)); + btLampkaHamienie.Turn(mvOccupied->BrakePress >= 0.1 || mvControlled->DynamicBrakeFlag); + btLampkaBrakingOff.Turn(mvOccupied->BrakePress < 0.1 && false == mvControlled->DynamicBrakeFlag); break; } } @@ -9170,7 +9172,7 @@ bool TTrain::Update(double const Deltatime) btLampkaBlokadaDrzwi.Turn(mvOccupied->Doors.is_locked); btLampkaDoorLockOff.Turn(false == mvOccupied->Doors.lock_enabled); btLampkaDepartureSignal.Turn(mvControlled->DepartureSignal); - btLampkaNapNastHam.Turn((mvControlled->DirActive != 0) && (mvOccupied->EpFuse)); // napiecie na nastawniku hamulcowym + btLampkaNapNastHam.Turn(mvControlled->DirActive != 0 && mvOccupied->EpFuse); // napiecie na nastawniku hamulcowym // Wylaczanie lampek kierunku gdy jedziemy // Feature uruchamiany z fiz z sekcji Ctrl. wpisem HideDirStatusWhenMoving=Yes (domyslnie No) @@ -9213,7 +9215,7 @@ bool TTrain::Update(double const Deltatime) btLampkaWaterOverheat.Turn(mvControlled->dizel_heat.water.is_hot); btLampkaWaterAuxOverheat.Turn(mvControlled->dizel_heat.water_aux.is_hot); btLampkaEngineOverheat.Turn(mvControlled->dizel_heat.engine_is_hot); - btLampkaMotorBlowers.Turn((mvControlled->MotorBlowers[end::front].is_active) && (mvControlled->MotorBlowers[end::rear].is_active)); + btLampkaMotorBlowers.Turn(mvControlled->MotorBlowers[end::front].is_active && mvControlled->MotorBlowers[end::rear].is_active); btLampkaCoolingFans.Turn(mvControlled->RventRot > 1.0); btLampkaTempomat.Turn(mvOccupied->SpeedCtrlUnit.IsActive); btLampkaDistanceCounter.Turn(m_distancecounter >= 0.f); @@ -9303,9 +9305,9 @@ bool TTrain::Update(double const Deltatime) { // yB - wskazniki drugiego czlonu TDynamicObject *tmp{nullptr}; //=mvControlled->mvSecond; //Ra 2014-07: trzeba to jeszcze wyjąć z kabiny... // Ra 2014-07: no nie ma potrzeby szukać tego w każdej klatce - if ((TestFlag(mvControlled->Couplers[1].CouplingFlag, coupling::control)) && (mvOccupied->CabOccupied > 0)) + if (TestFlag(mvControlled->Couplers[1].CouplingFlag, coupling::control) && mvOccupied->CabOccupied > 0) tmp = DynamicObject->NextConnected(); - if ((TestFlag(mvControlled->Couplers[0].CouplingFlag, coupling::control)) && (mvOccupied->CabOccupied < 0)) + if (TestFlag(mvControlled->Couplers[0].CouplingFlag, coupling::control) && mvOccupied->CabOccupied < 0) tmp = DynamicObject->PrevConnected(); if (tmp) @@ -9316,14 +9318,14 @@ bool TTrain::Update(double const Deltatime) auto const *mover{tmp->MoverParameters}; btLampkaWylSzybkiB.Turn(mover->Mains); - btLampkaWylSzybkiBOff.Turn((false == mover->Mains) + btLampkaWylSzybkiBOff.Turn(false == mover->Mains /*&& ( mover->MainsInitTimeCountdown <= 0.0 )*/ /*&& ( fHVoltage != 0.0 )*/); btLampkaOporyB.Turn(mover->ResistorsFlagCheck()); - btLampkaBezoporowaB.Turn((true == mover->ResistorsFlagCheck()) || (mover->MainCtrlActualPos == 0)); // do EU04 + btLampkaBezoporowaB.Turn(true == mover->ResistorsFlagCheck() || mover->MainCtrlActualPos == 0); // do EU04 - if ((mover->StLinFlag) || (mover->ControlPressureSwitch)) + if (mover->StLinFlag || mover->ControlPressureSwitch) { btLampkaStycznB.Turn(false); } @@ -9405,10 +9407,11 @@ bool TTrain::Update(double const Deltatime) // represents the dedicated dynamic-brake lever (DBPN steps), not the pneumatic local brake auto const negativePart{mvControlled->SplitEDPneumaticBrake ? (mvControlled->DynamicBrakeCtrlPos > 0.0 ? mvControlled->DynamicBrakeCtrlPos * mvControlled->DynamicBrakeCtrlPosNo * -1 * brakerangemultiplier : 0.0) : - (mvOccupied->LocalBrakePosA > 0.0 ? mvOccupied->LocalBrakePosA * LocalBrakePosNo * -1 * brakerangemultiplier : 0.0)}; - ggJointCtrl.UpdateValue((negativePart < 0.0 ? negativePart : - mvControlled->CoupledCtrl ? double(mvControlled->MainCtrlPos + mvControlled->ScndCtrlPos) : - double(mvControlled->MainCtrlPos)), + mvOccupied->LocalBrakePosA > 0.0 ? mvOccupied->LocalBrakePosA * LocalBrakePosNo * -1 * brakerangemultiplier : + 0.0}; + ggJointCtrl.UpdateValue(negativePart < 0.0 ? negativePart : + mvControlled->CoupledCtrl ? double(mvControlled->MainCtrlPos + mvControlled->ScndCtrlPos) : + double(mvControlled->MainCtrlPos), dsbNastawnikJazdy); ggJointCtrl.Update(); } @@ -9416,8 +9419,8 @@ bool TTrain::Update(double const Deltatime) { #ifdef _WIN32 - if ((DynamicObject->Mechanik != nullptr) && (false == DynamicObject->Mechanik->AIControllFlag) // nie blokujemy AI - && (Global.iFeedbackMode == 4) && (Global.fCalibrateIn[2][1] != 0.0)) + if (DynamicObject->Mechanik != nullptr && false == DynamicObject->Mechanik->AIControllFlag // nie blokujemy AI + && Global.iFeedbackMode == 4 && Global.fCalibrateIn[2][1] != 0.0) { set_master_controller(Console::AnalogCalibrateGet(2) * mvOccupied->MainCtrlPosNo); @@ -9448,7 +9451,7 @@ bool TTrain::Update(double const Deltatime) // Ra: od byte odejmowane boolean i konwertowane potem na double? if (false == ggScndCtrl.is_push()) { - ggScndCtrl.UpdateValue(double(mvControlled->ScndCtrlPos - ((mvControlled->TrainType == dt_ET42) && mvControlled->DynamicBrakeFlag)), dsbNastawnikBocz); + ggScndCtrl.UpdateValue(double(mvControlled->ScndCtrlPos - (mvControlled->TrainType == dt_ET42 && mvControlled->DynamicBrakeFlag)), dsbNastawnikBocz); } ggScndCtrl.Update(); } @@ -9456,7 +9459,7 @@ bool TTrain::Update(double const Deltatime) { if (ggScndCtrlButton.is_toggle()) { - ggScndCtrlButton.UpdateValue(((mvControlled->ScndCtrlPos > 0) ? 1.f : 0.f), dsbSwitch); + ggScndCtrlButton.UpdateValue(mvControlled->ScndCtrlPos > 0 ? 1.f : 0.f, dsbSwitch); } ggScndCtrlButton.Update(lowvoltagepower); } @@ -9483,7 +9486,7 @@ bool TTrain::Update(double const Deltatime) if (ggBrakeCtrl.SubModel != nullptr) { #ifdef _WIN32 - if (DynamicObject->Mechanik ? (DynamicObject->Mechanik->AIControllFlag ? false : (Global.iFeedbackMode == 4 /*|| (Global.bMWDmasterEnable && Global.bMWDBreakEnable)*/)) : + if (DynamicObject->Mechanik ? (DynamicObject->Mechanik->AIControllFlag ? false : Global.iFeedbackMode == 4 /*|| (Global.bMWDmasterEnable && Global.bMWDBreakEnable)*/) : false && Global.fCalibrateIn[0][1] != 0.0) // nie blokujemy AI { // Ra: nie najlepsze miejsce, ale na początek gdzieś to dać trzeba // Firleju: dlatego kasujemy i zastepujemy funkcją w Console @@ -9525,10 +9528,8 @@ bool TTrain::Update(double const Deltatime) if (ggLocalBrake.SubModel != nullptr) { #ifdef _WIN32 - if ((DynamicObject->Mechanik != nullptr) && (false == DynamicObject->Mechanik->AIControllFlag) // nie blokujemy AI - && (mvOccupied->BrakeLocHandle == TBrakeHandle::FD1) && - ((Global.iFeedbackMode == 4) && Global.fCalibrateIn[0][1] != 0.0 - /* || ( Global.bMWDmasterEnable && Global.bMWDBreakEnable )*/)) + if (DynamicObject->Mechanik != nullptr && false == DynamicObject->Mechanik->AIControllFlag // nie blokujemy AI + && mvOccupied->BrakeLocHandle == TBrakeHandle::FD1 && Global.iFeedbackMode == 4 && Global.fCalibrateIn[0][1] != 0.0) { // Ra: nie najlepsze miejsce, ale na początek gdzieś to dać trzeba // Firleju: dlatego kasujemy i zastepujemy funkcją w Console @@ -9553,7 +9554,7 @@ bool TTrain::Update(double const Deltatime) ggBrakeProfileR.Update(); ggBrakeOperationModeCtrl.Update(); ggWiperSw.Update(); - ggMaxCurrentCtrl.UpdateValue((true == mvControlled->ShuntModeAllow ? (true == mvControlled->ShuntMode ? 1.f : 0.f) : (mvControlled->MotorOverloadRelayHighThreshold ? 1.f : 0.f))); + ggMaxCurrentCtrl.UpdateValue(true == mvControlled->ShuntModeAllow ? (true == mvControlled->ShuntMode ? 1.f : 0.f) : mvControlled->MotorOverloadRelayHighThreshold ? 1.f : 0.f); ggMaxCurrentCtrl.Update(); // NBMX wrzesien 2003 - drzwi ggDoorLeftPermitButton.Update(lowvoltagepower); @@ -9576,7 +9577,7 @@ bool TTrain::Update(double const Deltatime) //--------- // hunter-080812: poprawka na ogrzewanie w elektrykach - usuniete uzaleznienie od przetwornicy - if ((mvControlled->Heating == true) && (mvControlled->ConvOvldFlag == false)) + if (mvControlled->Heating == true && mvControlled->ConvOvldFlag == false) btLampkaOgrzewanieSkladu.Turn(true); else btLampkaOgrzewanieSkladu.Turn(false); @@ -9590,9 +9591,9 @@ bool TTrain::Update(double const Deltatime) InstrumentLightType == 3 ? mvOccupied->Power24vIsAvailable || mvOccupied->Power110vIsAvailable : InstrumentLightType == 4 ? mvOccupied->Power24vIsAvailable || mvOccupied->Power110vIsAvailable : false)}; - InstrumentLightActive = (InstrumentLightType == 3 ? true : // TODO: link the light state with the state of the master key - InstrumentLightType == 4 ? (mvOccupied->iLights[end::front] != 0) || (mvOccupied->iLights[end::rear] != 0) : - InstrumentLightActive); + InstrumentLightActive = InstrumentLightType == 3 ? true : // TODO: link the light state with the state of the master key + InstrumentLightType == 4 ? mvOccupied->iLights[end::front] != 0 || mvOccupied->iLights[end::rear] != 0 : + InstrumentLightActive; btInstrumentLight.Turn(InstrumentLightActive && lightpower); btDashboardLight.Turn(DashboardLightActive && lightpower); btTimetableLight.Turn(TimetableLightActive && lightpower); @@ -9714,7 +9715,7 @@ bool TTrain::Update(double const Deltatime) ggBatteryButton.Update(); ggBatteryOnButton.Update(); ggBatteryOffButton.Update(); - if ((ggCabActivationButton.SubModel != nullptr) && (ggCabActivationButton.type() != TGaugeType::push)) + if (ggCabActivationButton.SubModel != nullptr && ggCabActivationButton.type() != TGaugeType::push) { ggCabActivationButton.UpdateValue(mvOccupied->IsCabMaster() ? 1.0 : 0.0); } @@ -9744,7 +9745,7 @@ bool TTrain::Update(double const Deltatime) for (auto &cab : Cabine) { - auto const cablightlevel = ((cab.bLight == false) ? 0.f : (cab.bLightDim == true) ? 0.4f : 1.f) * (mvOccupied->Power110vIsAvailable ? 1.f : 0.5f); + auto const cablightlevel = (cab.bLight == false ? 0.f : cab.bLightDim == true ? 0.4f : 1.f) * (mvOccupied->Power110vIsAvailable ? 1.f : 0.5f); if (cab.LightLevel != cablightlevel) { @@ -9828,7 +9829,7 @@ void TTrain::update_sounds(double const Deltatime) // local brake, release if (rsSBHiss) { - if ((m_localbrakepressurechange < -0.05f) && (mvOccupied->LocBrakePress > mvOccupied->BrakePress - 0.05)) + if (m_localbrakepressurechange < -0.05f && mvOccupied->LocBrakePress > mvOccupied->BrakePress - 0.05) { rsSBHiss->gain(std::clamp(rsSBHiss->m_amplitudeoffset + rsSBHiss->m_amplitudefactor * -m_localbrakepressurechange * 0.05, 0.0, 1.5)); rsSBHiss->play(sound_flags::exclusive | sound_flags::looping); @@ -9866,13 +9867,13 @@ void TTrain::update_sounds(double const Deltatime) // McZapkie-280302 - syczenie // TODO: softer volume reduction than plain abrupt stop, perhaps as reusable wrapper? - if ((mvOccupied->BrakeHandle == TBrakeHandle::FV4a) || (mvOccupied->BrakeHandle == TBrakeHandle::FVel6)) + if (mvOccupied->BrakeHandle == TBrakeHandle::FV4a || mvOccupied->BrakeHandle == TBrakeHandle::FVel6) { // upuszczanie z PG if (rsHiss) { fPPress = std::lerp(fPPress, static_cast(mvOccupied->Handle->GetSound(s_fv4a_b)), 0.05f); - volume = (fPPress > 0 ? rsHiss->m_amplitudefactor * fPPress * 0.25 + rsHiss->m_amplitudeoffset : 0); + volume = fPPress > 0 ? rsHiss->m_amplitudefactor * fPPress * 0.25 + rsHiss->m_amplitudeoffset : 0; if (volume * brakevolumescale > 0.05) { rsHiss->gain(volume * brakevolumescale); @@ -9887,7 +9888,7 @@ void TTrain::update_sounds(double const Deltatime) if (rsHissU) { fNPress = std::lerp(fNPress, static_cast(mvOccupied->Handle->GetSound(s_fv4a_u)), 0.25f); - volume = (fNPress > 0 ? rsHissU->m_amplitudefactor * fNPress + rsHissU->m_amplitudeoffset : 0); + volume = fNPress > 0 ? rsHissU->m_amplitudefactor * fNPress + rsHissU->m_amplitudeoffset : 0; if (volume * brakevolumescale > 0.05) { rsHissU->gain(volume * brakevolumescale); @@ -9948,7 +9949,7 @@ void TTrain::update_sounds(double const Deltatime) if (rsHiss) { fPPress = (4.0f * fPPress + std::max(0.0, mvOccupied->dpMainValve)) / (4.0f + 1.0f); - volume = (fPPress > 0.0f ? 2.0 * rsHiss->m_amplitudefactor * fPPress + rsHiss->m_amplitudeoffset : 0.0); + volume = fPPress > 0.0f ? 2.0 * rsHiss->m_amplitudefactor * fPPress + rsHiss->m_amplitudeoffset : 0.0; if (volume > 0.05) { rsHiss->gain(volume); @@ -9963,7 +9964,7 @@ void TTrain::update_sounds(double const Deltatime) if (rsHissU) { fNPress = (4.0f * fNPress + std::min(0.0, mvOccupied->dpMainValve)) / (4.0f + 1.0f); - volume = (fNPress < 0.0f ? -1.0 * rsHissU->m_amplitudefactor * fNPress + rsHissU->m_amplitudeoffset : 0.0); + volume = fNPress < 0.0f ? -1.0 * rsHissU->m_amplitudefactor * fNPress + rsHissU->m_amplitudeoffset : 0.0; if (volume > 0.01) { rsHissU->gain(volume); @@ -9979,13 +9980,13 @@ void TTrain::update_sounds(double const Deltatime) // brakes if (rsBrake) { - if ((mvOccupied->UnitBrakeForce > 10.0) && (mvOccupied->Vel > 0.05)) + if (mvOccupied->UnitBrakeForce > 10.0 && mvOccupied->Vel > 0.05) { auto const brakeforceratio{ std::clamp(mvOccupied->UnitBrakeForce / std::max(1.0, mvOccupied->BrakeForceR(1.0, mvOccupied->Vel) / (mvOccupied->NAxles * std::max(1, mvOccupied->NBpA))), 0.0, 1.0)}; // HACK: in external view mute the sound rather than stop it, in case there's an opening bookend it'd (re)play on sound restart after returning inside - volume = (FreeFlyModeFlag ? 0.0 : rsBrake->m_amplitudeoffset + std::sqrt(brakeforceratio * std::lerp(0.4, 1.0, (mvOccupied->Vel / (1 + mvOccupied->Vmax)))) * rsBrake->m_amplitudefactor); + volume = FreeFlyModeFlag ? 0.0 : rsBrake->m_amplitudeoffset + std::sqrt(brakeforceratio * std::lerp(0.4, 1.0, mvOccupied->Vel / (1 + mvOccupied->Vmax))) * rsBrake->m_amplitudefactor; rsBrake->pitch(rsBrake->m_frequencyoffset + mvOccupied->Vel * rsBrake->m_frequencyfactor); rsBrake->gain(volume); rsBrake->play(sound_flags::exclusive | sound_flags::looping); @@ -10006,7 +10007,7 @@ void TTrain::update_sounds(double const Deltatime) if (dsbSlipAlarm) { // alarm przy poslizgu dla 181/182 - BOMBARDIER - if ((mvControlled->SlippingWheels) && (DynamicObject->GetVelocity() > 1.0)) + if (mvControlled->SlippingWheels && DynamicObject->GetVelocity() > 1.0) { dsbSlipAlarm->play(sound_flags::exclusive | sound_flags::looping); } @@ -10040,7 +10041,7 @@ void TTrain::update_sounds(double const Deltatime) // szum w czasie jazdy if (rsRunningNoise) { - if ((false == FreeFlyModeFlag) && (false == Global.CabWindowOpen) && (DynamicObject->GetVelocity() > 0.5)) + if (false == FreeFlyModeFlag && false == Global.CabWindowOpen && DynamicObject->GetVelocity() > 0.5) { update_sounds_runningnoise(*rsRunningNoise); @@ -10054,7 +10055,7 @@ void TTrain::update_sounds(double const Deltatime) // hunting oscillation noise if (rsHuntingNoise) { - if ((false == FreeFlyModeFlag) && (false == Global.CabWindowOpen) && (DynamicObject->GetVelocity() > 0.5) && (DynamicObject->IsHunting)) + if (false == FreeFlyModeFlag && false == Global.CabWindowOpen && DynamicObject->GetVelocity() > 0.5 && DynamicObject->IsHunting) { update_sounds_runningnoise(*rsHuntingNoise); @@ -10073,7 +10074,7 @@ void TTrain::update_sounds(double const Deltatime) // rain sound if (m_rainsound) { - if ((false == FreeFlyModeFlag) && (false == Global.CabWindowOpen) && (Global.Weather == "rain:")) + if (false == FreeFlyModeFlag && false == Global.CabWindowOpen && Global.Weather == "rain:") { if (m_rainsound->is_combined()) { @@ -10255,21 +10256,21 @@ void TTrain::update_sounds_radio() if (false == m_radiomessages.empty()) { // erase completed radio messages from the list - m_radiomessages.erase(std::remove_if(std::begin(m_radiomessages), std::end(m_radiomessages), [](auto const &source) { return (false == source.second->is_playing()); }), + m_radiomessages.erase(std::remove_if(std::begin(m_radiomessages), std::end(m_radiomessages), [](auto const &source) { return false == source.second->is_playing(); }), std::end(m_radiomessages)); } // adjust audibility of remaining messages based on current radio conditions - auto const radioenabled{(true == mvOccupied->Radio) && (mvOccupied->Power24vIsAvailable || mvOccupied->Power110vIsAvailable)}; + auto const radioenabled{true == mvOccupied->Radio && (mvOccupied->Power24vIsAvailable || mvOccupied->Power110vIsAvailable)}; for (auto &message : m_radiomessages) { - auto const volume{(true == radioenabled) && (Dynamic()->Mechanik != nullptr) && (message.first == RadioChannel()) ? m_radiovolume : 0.0}; + auto const volume{true == radioenabled && Dynamic()->Mechanik != nullptr && message.first == RadioChannel() ? m_radiovolume : 0.0}; message.second->gain(volume); - radio_message_played |= (true == radioenabled) && (Dynamic()->Mechanik != nullptr) && (message.first == RadioChannel()); + radio_message_played |= true == radioenabled && Dynamic()->Mechanik != nullptr && message.first == RadioChannel(); } // radiostop if (m_radiostop) { - if ((true == radioenabled) && (true == mvOccupied->RadioStopFlag)) + if (true == radioenabled && true == mvOccupied->RadioStopFlag) { m_radiostop->play(sound_flags::exclusive | sound_flags::looping); radio_message_played |= true; @@ -10309,7 +10310,7 @@ void TTrain::update_screens(double dt) void TTrain::add_distance(double const Distance) { - auto const meterenabled{(m_distancecounter >= 0) && (mvOccupied->Power24vIsAvailable || mvOccupied->Power110vIsAvailable)}; + auto const meterenabled{m_distancecounter >= 0 && (mvOccupied->Power24vIsAvailable || mvOccupied->Power110vIsAvailable)}; if (true == meterenabled) { @@ -10323,7 +10324,7 @@ void TTrain::add_distance(double const Distance) bool TTrain::CabChange(int iDirection) { // McZapkie-090902: zmiana kabiny 1->0->2 i z powrotem - if ((DynamicObject->Mechanik == nullptr) || (true == DynamicObject->Mechanik->AIControllFlag)) + if (DynamicObject->Mechanik == nullptr || true == DynamicObject->Mechanik->AIControllFlag) { // jeśli prowadzi AI albo jest w innym członie // jak AI prowadzi, to nie można mu mieszać @@ -10399,7 +10400,7 @@ bool TTrain::LoadMMediaFile(std::string const &asFileName) token = ""; parser.getTokens(); parser >> token; - } while ((token != "") && (token != "internaldata:")); + } while (token != "" && token != "internaldata:"); if (token == "internaldata:") { @@ -10443,23 +10444,23 @@ bool TTrain::LoadMMediaFile(std::string const &asFileName) } if (rsBrake) { - rsBrake->m_frequencyfactor /= (1 + mvOccupied->Vmax); + rsBrake->m_frequencyfactor /= 1 + mvOccupied->Vmax; } if (rsResonanceNoise) { - rsResonanceNoise->m_frequencyfactor /= (1 + mvOccupied->Vmax); + rsResonanceNoise->m_frequencyfactor /= 1 + mvOccupied->Vmax; } if (rsWindSound) { - rsWindSound->m_frequencyfactor /= (1 + mvOccupied->Vmax); + rsWindSound->m_frequencyfactor /= 1 + mvOccupied->Vmax; } if (rsRunningNoise) { - rsRunningNoise->m_frequencyfactor /= (1 + mvOccupied->Vmax); + rsRunningNoise->m_frequencyfactor /= 1 + mvOccupied->Vmax; } if (rsHuntingNoise) { - rsHuntingNoise->m_frequencyfactor /= (1 + mvOccupied->Vmax); + rsHuntingNoise->m_frequencyfactor /= 1 + mvOccupied->Vmax; } } auto const nullvector{glm::vec3()}; @@ -10499,7 +10500,7 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName) m_radiosound.offset(nullvector); for (auto &sound : CabSoundLocations) { - if ((sound.first.get()) && (sound.first.get()->offset() == nullvector)) + if (sound.first.get() && sound.first.get()->offset() == nullvector) { sound.first.get()->offset(sound.second); } @@ -10538,7 +10539,7 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName) token = ""; parser.getTokens(); parser >> token; - } while ((token != "") && (token != cabstr)); + } while (token != "" && token != cabstr); if (token == cabstr) { @@ -10620,7 +10621,7 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName) { token.erase(0, 1); } - TModel3d *kabina = TModelsManager::GetModel(DynamicObject->asBaseDir + token, true, true, (Global.network_servers.empty() && !Global.network_client) ? 0 : id()); + TModel3d *kabina = TModelsManager::GetModel(DynamicObject->asBaseDir + token, true, true, Global.network_servers.empty() && !Global.network_client ? 0 : id()); // z powrotem defaultowa sciezka do tekstur Global.asCurrentTexturePath = paths::textures; // if (DynamicObject->mdKabina!=k) @@ -10663,7 +10664,7 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName) { screen_entry screen; screen.deserialize(parser); - if ((false == screen.script.empty()) && (substr_path(screen.script).empty())) + if (false == screen.script.empty() && substr_path(screen.script).empty()) { screen.script = DynamicObject->asBaseDir + screen.script; } @@ -10672,9 +10673,9 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName) TSubModel *submodel = nullptr; if (screen.target != "none") { - submodel = (DynamicObject->mdKabina ? DynamicObject->mdKabina->GetFromName(screen.target) : - DynamicObject->mdLowPolyInt ? DynamicObject->mdLowPolyInt->GetFromName(screen.target) : - nullptr); + submodel = DynamicObject->mdKabina ? DynamicObject->mdKabina->GetFromName(screen.target) : + DynamicObject->mdLowPolyInt ? DynamicObject->mdLowPolyInt->GetFromName(screen.target) : + nullptr; if (submodel == nullptr) { WriteLog("Python Screen: submodel " + screen.target + " not found - Ignoring screen"); @@ -10721,11 +10722,11 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName) parser >> ScreenUpdateRate; } // btLampkaUnknown`"unknown",mdKabina,false); - } while ((token != "") + } while (token != "" // TODO: enable full per-cab deserialization when/if .mmd files get proper per-cab switch configuration // && ( token != "cab1definition:" ) // && ( token != "cab2definition:" ) - && (token != "cab0definition:")); + && token != "cab0definition:"); for (auto &screen : m_screens) { if (screen.updatetime > 0) @@ -10792,7 +10793,7 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName) }; for (auto &sound : soundlocations) { - if ((sound.first.get()) && (sound.first.get()->offset() == nullvector)) + if (sound.first.get() && sound.first.get()->offset() == nullvector) { sound.first.get()->offset(sound.second); } @@ -10800,7 +10801,7 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName) // second pass, in case some items received no positioning due to missing submodels etc for (auto &sound : soundlocations) { - if ((sound.first.get()) && (sound.first.get()->offset() == nullvector)) + if (sound.first.get() && sound.first.get()->offset() == nullvector) { sound.first.get()->offset(caboffset); } @@ -10827,7 +10828,7 @@ glm::dvec3 TTrain::MirrorPosition(bool lewe) auto const shiftdirection{(lewe ? -1 : 1) * (iCabn == 2 ? 1 : -1)}; return DynamicObject->mMatrix * - glm::dvec4(mvOccupied->Dim.W * (0.5 * shiftdirection) + (0.2 * shiftdirection), 1.5 + Cabine[iCabn].CabPos1.y, std::lerp(Cabine[iCabn].CabPos1.z, Cabine[iCabn].CabPos2.z, 0.5), 1.0); + glm::dvec4(mvOccupied->Dim.W * (0.5 * shiftdirection) + 0.2 * shiftdirection, 1.5 + Cabine[iCabn].CabPos1.y, std::lerp(Cabine[iCabn].CabPos1.z, Cabine[iCabn].CabPos2.z, 0.5), 1.0); }; void TTrain::DynamicSet(TDynamicObject *d) @@ -10846,7 +10847,7 @@ void TTrain::DynamicSet(TDynamicObject *d) // jeździć dobrze // również hamowanie wykonuje się zaworem w członie, a nie w silnikowym... DynamicObject = d; // jedyne miejsce zmiany - mvOccupied = mvControlled = (d ? DynamicObject->MoverParameters : nullptr); // albo silnikowy w EZT + mvOccupied = mvControlled = d ? DynamicObject->MoverParameters : nullptr; // albo silnikowy w EZT if (DynamicObject == nullptr) { @@ -10872,7 +10873,7 @@ void TTrain::DynamicSet(TDynamicObject *d) { auto *lookup{DynamicObject->FindPantographCarrier()}; // HACK: set pointer to existing vehicle to avoid error checking all over the place - mvPantographUnit = (lookup != nullptr ? lookup->MoverParameters : mvControlled); + mvPantographUnit = lookup != nullptr ? lookup->MoverParameters : mvControlled; } }; @@ -11009,8 +11010,8 @@ void TTrain::MoveToVehicle(TDynamicObject *target) bool TTrain::point_inside(glm::dvec3 const Point) const { - return (Point.x >= Cabine[iCabn].CabPos1.x) && (Point.x <= Cabine[iCabn].CabPos2.x) && (Point.y >= Cabine[iCabn].CabPos1.y + 0.5) && (Point.y <= Cabine[iCabn].CabPos2.y + 1.8) && - (Point.z >= Cabine[iCabn].CabPos1.z) && (Point.z <= Cabine[iCabn].CabPos2.z); + return Point.x >= Cabine[iCabn].CabPos1.x && Point.x <= Cabine[iCabn].CabPos2.x && Point.y >= Cabine[iCabn].CabPos1.y + 0.5 && Point.y <= Cabine[iCabn].CabPos2.y + 1.8 && + Point.z >= Cabine[iCabn].CabPos1.z && Point.z <= Cabine[iCabn].CabPos2.z; } glm::dvec3 TTrain::clamp_inside(glm::dvec3 const &Point) const @@ -11035,7 +11036,7 @@ void TTrain::radio_message(sound_source *Message, int const Channel) { auto const soundrange{Message->range()}; - if ((soundrange > 0) && (glm::length2(Message->location() - glm::dvec3{DynamicObject->GetPosition()}) > sq(soundrange))) + if (soundrange > 0 && glm::length2(Message->location() - glm::dvec3{DynamicObject->GetPosition()}) > sq(soundrange)) { // skip message playback if the receiver is outside of the emitter's range return; @@ -11043,9 +11044,9 @@ void TTrain::radio_message(sound_source *Message, int const Channel) // NOTE: we initiate playback of all sounds in range, in case the user switches on the radio or tunes to the right channel mid-play m_radiomessages.emplace_back(Channel, std::make_shared(m_radiosound)); // assign sound to the template and play it - auto &message = *(m_radiomessages.back().second.get()); - auto const radioenabled{(true == mvOccupied->Radio) && (mvOccupied->Power24vIsAvailable || mvOccupied->Power110vIsAvailable)}; - auto const volume{(true == radioenabled) && (Dynamic()->Mechanik != nullptr) && (Channel == RadioChannel()) ? 1.0 : 0.0}; + auto &message = *m_radiomessages.back().second.get(); + auto const radioenabled{true == mvOccupied->Radio && (mvOccupied->Power24vIsAvailable || mvOccupied->Power110vIsAvailable)}; + auto const volume{true == radioenabled && Dynamic()->Mechanik != nullptr && Channel == RadioChannel() ? 1.0 : 0.0}; message.copy_sounds(*Message).gain(volume).play(); } @@ -11060,11 +11061,11 @@ void TTrain::clear_cab_controls() btLampkaNadmSil.Clear(4); btLampkaStyczn.Clear(5); btLampkaPoslizg.Clear(6); - btLampkaNadmPrzetw.Clear(((mvControlled->TrainType & dt_EZT) != 0) ? -1 : 7); // EN57 nie ma tej lampki - btLampkaPrzetwOff.Clear(((mvControlled->TrainType & dt_EZT) != 0) ? 7 : -1); // za to ma tę + btLampkaNadmPrzetw.Clear((mvControlled->TrainType & dt_EZT) != 0 ? -1 : 7); // EN57 nie ma tej lampki + btLampkaPrzetwOff.Clear((mvControlled->TrainType & dt_EZT) != 0 ? 7 : -1); // za to ma tę btLampkaNadmSpr.Clear(8); btLampkaNadmWent.Clear(9); - btLampkaWysRozr.Clear(((mvControlled->TrainType & dt_ET22) != 0) ? -1 : 10); // ET22 nie ma tej lampki + btLampkaWysRozr.Clear((mvControlled->TrainType & dt_ET22) != 0 ? -1 : 10); // ET22 nie ma tej lampki btLampkaOgrzewanieSkladu.Clear(11); // overheat indicator lamps btLampkaOilOverheat.Clear(-1); @@ -11339,13 +11340,13 @@ void TTrain::set_cab_controls(int const Cab) { // switches // battery - ggBatteryButton.PutValue((ggBatteryButton.type() == TGaugeType::push ? 0.5f : mvOccupied->Power24vIsAvailable ? 1.f : 0.f)); + ggBatteryButton.PutValue(ggBatteryButton.type() == TGaugeType::push ? 0.5f : mvOccupied->Power24vIsAvailable ? 1.f : 0.f); // activation - ggCabActivationButton.PutValue((ggCabActivationButton.type() == TGaugeType::push ? 0.5f : mvOccupied->IsCabMaster() ? 1.f : 0.f)); + ggCabActivationButton.PutValue(ggCabActivationButton.type() == TGaugeType::push ? 0.5f : mvOccupied->IsCabMaster() ? 1.f : 0.f); // line breaker if (ggMainButton.SubModel != nullptr) { // instead of single main button there can be on/off pair - ggMainButton.PutValue((ggMainButton.type() == TGaugeType::push ? 0.5f : m_linebreakerstate > 0 ? 1.f : 0.f)); + ggMainButton.PutValue(ggMainButton.type() == TGaugeType::push ? 0.5f : m_linebreakerstate > 0 ? 1.f : 0.f); } if (ggModernLightDimSw.SubModel != nullptr) @@ -11365,7 +11366,7 @@ void TTrain::set_cab_controls(int const Cab) } // motor connectors - ggStLinOffButton.PutValue((mvControlled->StLinSwitchOff ? 1.f : 0.f)); + ggStLinOffButton.PutValue(mvControlled->StLinSwitchOff ? 1.f : 0.f); // radio ggRadioChannelSelector.PutValue((Dynamic()->Mechanik ? Dynamic()->Mechanik->iRadioChannel : 1) - 1); // pantographs @@ -11402,7 +11403,7 @@ void TTrain::set_cab_controls(int const Cab) // front/end pantograph selection is relative to occupied cab if (ggPantSelectedButton.type() == TGaugeType::toggle) { - ggPantSelectedButton.PutValue((mvPantographUnit->PantsValve.is_enabled ? 1.f : 0.f)); + ggPantSelectedButton.PutValue(mvPantographUnit->PantsValve.is_enabled ? 1.f : 0.f); } else { @@ -11414,7 +11415,7 @@ void TTrain::set_cab_controls(int const Cab) } if (ggPantSelectedDownButton.type() == TGaugeType::toggle) { - ggPantSelectedDownButton.PutValue((mvPantographUnit->PantsValve.is_disabled ? 1.f : 0.f)); + ggPantSelectedDownButton.PutValue(mvPantographUnit->PantsValve.is_disabled ? 1.f : 0.f); } ggPantValvesButton.PutValue(0.5f); @@ -11434,7 +11435,7 @@ void TTrain::set_cab_controls(int const Cab) ggCompressorLocalButton.PutValue(mvControlled->CompressorAllowLocal ? 1.f : 0.f); ggCompressorListButton.PutValue(mvOccupied->CompressorListPos - 1); // motor overload relay threshold / shunt mode - ggMaxCurrentCtrl.PutValue((true == mvControlled->ShuntModeAllow ? (true == mvControlled->ShuntMode ? 1.f : 0.f) : (mvControlled->MotorOverloadRelayHighThreshold ? 1.f : 0.f))); + ggMaxCurrentCtrl.PutValue(true == mvControlled->ShuntModeAllow ? (true == mvControlled->ShuntMode ? 1.f : 0.f) : mvControlled->MotorOverloadRelayHighThreshold ? 1.f : 0.f); // lights ggLightsButton.PutValue(mvOccupied->LightsPos - 1); @@ -11484,11 +11485,11 @@ void TTrain::set_cab_controls(int const Cab) ggCabLightDimButton.PutValue(1.f); } // compartment lights - ggCompartmentLightsButton.PutValue((ggCompartmentLightsButton.type() == TGaugeType::push ? 0.5f : mvOccupied->CompartmentLights.is_enabled ? 1.f : 0.f)); + ggCompartmentLightsButton.PutValue(ggCompartmentLightsButton.type() == TGaugeType::push ? 0.5f : mvOccupied->CompartmentLights.is_enabled ? 1.f : 0.f); // instrument lights - ggInstrumentLightButton.PutValue((InstrumentLightActive ? 1.f : 0.f)); - ggDashboardLightButton.PutValue((DashboardLightActive ? 1.f : 0.f)); - ggTimetableLightButton.PutValue((TimetableLightActive ? 1.f : 0.f)); + ggInstrumentLightButton.PutValue(InstrumentLightActive ? 1.f : 0.f); + ggDashboardLightButton.PutValue(DashboardLightActive ? 1.f : 0.f); + ggTimetableLightButton.PutValue(TimetableLightActive ? 1.f : 0.f); // doors permits if (false == ggDoorLeftPermitButton.is_push()) { @@ -11517,7 +11518,7 @@ void TTrain::set_cab_controls(int const Cab) // brake acting time if (ggBrakeProfileCtrl.SubModel != nullptr) { - ggBrakeProfileCtrl.PutValue(((mvOccupied->BrakeDelayFlag & bdelay_R) != 0 ? 2.f : mvOccupied->BrakeDelayFlag - 1)); + ggBrakeProfileCtrl.PutValue((mvOccupied->BrakeDelayFlag & bdelay_R) != 0 ? 2.f : mvOccupied->BrakeDelayFlag - 1); } if (ggBrakeProfileG.SubModel != nullptr) { @@ -11535,7 +11536,7 @@ void TTrain::set_cab_controls(int const Cab) if (ggBrakeOperationModeCtrl.SubModel != nullptr) { - ggBrakeOperationModeCtrl.PutValue((mvOccupied->BrakeOpModeFlag > 0 ? std::log2(mvOccupied->BrakeOpModeFlag) : 0)); + ggBrakeOperationModeCtrl.PutValue(mvOccupied->BrakeOpModeFlag > 0 ? std::log2(mvOccupied->BrakeOpModeFlag) : 0); } // alarm chain ggAlarmChain.PutValue(mvControlled->AlarmChainFlag ? 1.f : 0.f); @@ -11574,7 +11575,7 @@ void TTrain::set_cab_controls(int const Cab) } if (ggMotorBlowersAllOffButton.type() != TGaugeType::push) { - ggMotorBlowersAllOffButton.PutValue((mvControlled->MotorBlowers[end::front].is_disabled || mvControlled->MotorBlowers[end::rear].is_disabled) ? 1.f : 0.f); + ggMotorBlowersAllOffButton.PutValue(mvControlled->MotorBlowers[end::front].is_disabled || mvControlled->MotorBlowers[end::rear].is_disabled ? 1.f : 0.f); } // second controller if (ggScndCtrl.is_push()) @@ -11585,7 +11586,7 @@ void TTrain::set_cab_controls(int const Cab) // tempomat if (false == ggScndCtrlButton.is_push()) { - ggScndCtrlButton.PutValue((mvControlled->ScndCtrlPos > 0) ? 1.f : 0.f); + ggScndCtrlButton.PutValue(mvControlled->ScndCtrlPos > 0 ? 1.f : 0.f); } // sandbox if (ggAutoSandButton.type() != TGaugeType::push) @@ -11596,7 +11597,7 @@ void TTrain::set_cab_controls(int const Cab) ggRadioVolumeSelector.PutValue(m_radiovolume); // finding each inverter - not so optimal, but action ins performed only during changing cabin - bool kier = (DynamicObject->DirectionGet() * mvOccupied->CabOccupied > 0); + bool kier = DynamicObject->DirectionGet() * mvOccupied->CabOccupied > 0; int flag = DynamicObject->MoverParameters->InverterControlCouplerFlag; int itemstart = 0; for (auto &item : ggInverterToggleButtons) // for each button @@ -11619,7 +11620,7 @@ void TTrain::set_cab_controls(int const Cab) itemindex -= p->MoverParameters->InvertersNo; } } - p = (kier ? p->Next(flag) : p->Prev(flag)); + p = kier ? p->Next(flag) : p->Prev(flag); } } @@ -12098,7 +12099,7 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con ggMainCtrlAct.Load(Parser, DynamicObject); } // SEKCJA WSKAZNIKOW - else if ((Label == "tachometer:") || (Label == "tachometerb:")) + else if (Label == "tachometer:" || Label == "tachometerb:") { // predkosciomierz wskaźnikowy z szarpaniem auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka @@ -12134,28 +12135,28 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con dsbHasler->offset(gauge.model_offset()); } } - else if ((Label == "hvcurrent1:") || (Label == "hvcurrent1b:")) + else if (Label == "hvcurrent1:" || Label == "hvcurrent1b:") { // 1szy amperomierz auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka gauge.Load(Parser, DynamicObject); gauge.AssignFloat(fHCurrent + 1); } - else if ((Label == "hvcurrent2:") || (Label == "hvcurrent2b:")) + else if (Label == "hvcurrent2:" || Label == "hvcurrent2b:") { // 2gi amperomierz auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka gauge.Load(Parser, DynamicObject); gauge.AssignFloat(fHCurrent + 2); } - else if ((Label == "hvcurrent3:") || (Label == "hvcurrent3b:")) + else if (Label == "hvcurrent3:" || Label == "hvcurrent3b:") { // 3ci amperomierz auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałska gauge.Load(Parser, DynamicObject); gauge.AssignFloat(fHCurrent + 3); } - else if ((Label == "hvcurrent:") || (Label == "hvcurrentb:")) + else if (Label == "hvcurrent:" || Label == "hvcurrentb:") { // amperomierz calkowitego pradu auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka @@ -12182,7 +12183,7 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con gauge.Load(Parser, DynamicObject, 0.1); gauge.AssignFloat(&fPress[std::clamp(i, 1, 20) - 1][std::clamp(j, 0, 3)]); } - else if ((Label == "brakepress:") || (Label == "brakepressb:")) + else if (Label == "brakepress:" || Label == "brakepressb:") { // manometr cylindrow hamulcowych // Ra 2014-08: przeniesione do TCab @@ -12190,7 +12191,7 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con gauge.Load(Parser, DynamicObject, 0.1); gauge.AssignDouble(&mvOccupied->BrakePress); } - else if ((Label == "pipepress:") || (Label == "pipepressb:")) + else if (Label == "pipepress:" || Label == "pipepressb:") { // manometr przewodu hamulcowego auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka @@ -12232,7 +12233,7 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con gauge.Load(Parser, DynamicObject, 0.1); gauge.AssignDouble(&mvOccupied->EpForce); } - else if ((Label == "compressor:") || (Label == "compressorb:")) + else if (Label == "compressor:" || Label == "compressorb:") { // manometr sprezarki/zbiornika glownego auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka @@ -12388,14 +12389,14 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con { auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka gauge.Load(Parser, DynamicObject); - gauge.AssignDouble(&(mvControlled->HeatingPowerSource.EngineGenerator.voltage)); + gauge.AssignDouble(&mvControlled->HeatingPowerSource.EngineGenerator.voltage); } } else if (Label == "heatingcurrent:") { auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka gauge.Load(Parser, DynamicObject); - gauge.AssignDouble(&(mvControlled->TotalCurrent)); + gauge.AssignDouble(&mvControlled->TotalCurrent); } else { diff --git a/vehicle/Train.h b/vehicle/Train.h index 69a6c662..39c32403 100644 --- a/vehicle/Train.h +++ b/vehicle/Train.h @@ -218,10 +218,7 @@ class TTrain { void update_sounds_radio(); inline end cab_to_end( int const End ) const { - return ( - End == 2 ? - end::rear : - end::front ); } + return End == 2 ? end::rear : end::front; } inline end cab_to_end() const { return cab_to_end( iCabn ); } @@ -926,7 +923,7 @@ private: // plays provided sound from position of the radio bool radio_message_played; void radio_message( sound_source *Message, int const Channel ); - inline auto const RadioChannel() const { return ( Dynamic()->Mechanik ? Dynamic()->Mechanik->iRadioChannel : 1 ); } + inline auto const RadioChannel() const { return Dynamic()->Mechanik ? Dynamic()->Mechanik->iRadioChannel : 1; } inline auto &RadioChannel() { return Dynamic()->Mechanik->iRadioChannel; } inline TDynamicObject *Dynamic() { return DynamicObject; }; inline TDynamicObject const *Dynamic() const { return DynamicObject; }; diff --git a/world/EvLaunch.cpp b/world/EvLaunch.cpp index eebc4255..29c3104f 100644 --- a/world/EvLaunch.cpp +++ b/world/EvLaunch.cpp @@ -46,7 +46,7 @@ int vk_to_glfw_key( int const Keycode ) { ErrorLog("unknown key: " + std::to_string(Keycode)); } - return ((int)modifier << 8) | key; + return (int)modifier << 8 | key; } bool TEventLauncher::Load(cParser *parser) @@ -71,11 +71,9 @@ bool TEventLauncher::Load(cParser *parser) { "radio_call3", radio_message::call3 } }; auto lookup = messages.find( token ); - iKey = ( - lookup != messages.end() ? - lookup->second : - // a jak więcej, to jakby numer klawisza jest - vk_to_glfw_key( stol_def( token, 0 ) ) ); + iKey = lookup != messages.end() ? lookup->second : + // a jak więcej, to jakby numer klawisza jest + vk_to_glfw_key(stol_def(token, 0)); } } parser->getTokens(); @@ -86,7 +84,7 @@ bool TEventLauncher::Load(cParser *parser) parser->getTokens(); *parser >> token; asEvent2Name = token; // drugi event - if ((asEvent2Name == "end") || (asEvent2Name == "condition") || (asEvent2Name == "traintriggered")) + if (asEvent2Name == "end" || asEvent2Name == "condition" || asEvent2Name == "traintriggered") { // drugiego eventu może nie być, bo są z tym problemy, ale ciii... token = asEvent2Name; // rozpoznane słowo idzie do dalszego przetwarzania asEvent2Name = "none"; // a drugiego eventu nie ma @@ -143,7 +141,7 @@ bool TEventLauncher::Load(cParser *parser) auto const timeoffset{ static_cast( Global.ScenarioTimeOffset * 60 ) }; if( timeoffset != 0 ) { auto const adjustedtime{ clamp_circular( iHour * 60 + iMinute + timeoffset, 24 * 60 ) }; - iHour = ( adjustedtime / 60 ) % 24; + iHour = adjustedtime / 60 % 24; iMinute = adjustedtime % 60; } @@ -217,8 +215,8 @@ bool TEventLauncher::check_conditions() { auto bCond { true }; - if( ( iCheckMask != 0 ) - && ( MemCell != nullptr ) ) { + if( iCheckMask != 0 + && MemCell != nullptr ) { // sprawdzanie warunku na komórce pamięci bCond = MemCell->Compare( szText, fVal1, fVal2, iCheckMask ); } @@ -229,15 +227,12 @@ bool TEventLauncher::check_conditions() { // sprawdzenie, czy jest globalnym wyzwalaczem czasu bool TEventLauncher::IsGlobal() const { - return ( ( DeltaTime == 0 ) - && ( iHour >= 0 ) - && ( iMinute >= 0 ) - && ( dRadius < 0.0 ) ); // bez ograniczenia zasięgu + return DeltaTime == 0 && iHour >= 0 && iMinute >= 0 && dRadius < 0.0; // bez ograniczenia zasięgu } bool TEventLauncher::IsRadioActivated() const { - return ( iKey < 0 ); + return iKey < 0; } // radius() subclass details, calculates node's bounding radius @@ -293,8 +288,8 @@ TEventLauncher::export_as_text_( std::ostream &Output ) const { } else { // single activation at specified time - if( ( iHour < 0 ) - && ( iMinute < 0 ) ) { + if( iHour < 0 + && iMinute < 0 ) { Output << DeltaTime << ' '; } else { @@ -302,7 +297,7 @@ TEventLauncher::export_as_text_( std::ostream &Output ) const { auto const timeoffset{ static_cast( Global.ScenarioTimeOffset * 60 ) }; auto const adjustedtime{ clamp_circular( iHour * 60 + iMinute - timeoffset, 24 * 60 ) }; Output - << ( adjustedtime / 60 ) % 24 + << adjustedtime / 60 % 24 << ( adjustedtime % 60 ) << ' '; } diff --git a/world/Event.cpp b/world/Event.cpp index 3cbb53ab..eb679e72 100644 --- a/world/Event.cpp +++ b/world/Event.cpp @@ -164,7 +164,7 @@ basic_event::event_conditions::test() const { "[*]" ) + " - "; - comparisonlog += ( comparisonresult ? "Pass" : "Fail" ); + comparisonlog += comparisonresult ? "Pass" : "Fail"; WriteLog( comparisonlog ); @@ -182,9 +182,9 @@ basic_event::event_conditions::deserialize( cParser &Input ) { // przetwarzanie warunków, wspólne dla Multiple i UpdateValues std::string token; - while( ( true == Input.getTokens() ) - && ( false == ( token = Input.peek() ).empty() ) - && ( false == basic_event::is_keyword( token ) ) ) { + while( true == Input.getTokens() + && false == (token = Input.peek()).empty() + && false == basic_event::is_keyword(token) ) { if( token == "trackoccupied" ) { flags |= flags::track_busy; @@ -192,7 +192,7 @@ basic_event::event_conditions::deserialize( cParser &Input ) { else if( token == "trackfree" ) { flags |= flags::track_free; } - else if( ( token == "propability" ) || ( token == "probability" )) { //remove propability in few years after changing old scenery scripts 01.2021 + else if( token == "propability" || token == "probability") { //remove propability in few years after changing old scenery scripts 01.2021 flags |= flags::probability; Input.getTokens(); Input >> probability; @@ -304,8 +304,8 @@ basic_event::deserialize( cParser &Input, scene::scratch_data &Scratchpad ) { deserialize_( Input, Scratchpad ); // subclass method is expected to leave next token past its own data preloaded on its exit - while( ( false == ( token = Input.peek() ).empty() ) - && ( token != "endevent" ) ) { + while( false == (token = Input.peek()).empty() + && token != "endevent" ) { if( token == "randomdelay" ) { // losowe opóźnienie Input.getTokens(); @@ -335,7 +335,7 @@ basic_event::deserialize_targets( std::string const &Input ) { void basic_event::run() { - WriteLog( "EVENT LAUNCHED" + ( m_activator ? ( " by " + m_activator->asName ) : "" ) + ": " + m_name ); + WriteLog( "EVENT LAUNCHED" + ( m_activator ? " by " + m_activator->asName : "" ) + ": " + m_name ); run_(); } @@ -442,9 +442,9 @@ basic_event::input_location() const { bool basic_event::is_keyword( std::string const &Token ) { // TODO: convert to array lookup if keyword list gets longer - return ( Token == "endevent" ) - || ( Token == "randomdelay" ) - || ( Token == "departuredelay" ); + return Token == "endevent" + || Token == "randomdelay" + || Token == "departuredelay"; } @@ -476,10 +476,7 @@ updatevalues_event::init() { std::string updatevalues_event::type() const { - return ( - ( m_input.flags & flags::mode_add ) == 0 ? - "updatevalues" : - "addvalues" ); + return (m_input.flags & flags::mode_add) == 0 ? "updatevalues" : "addvalues"; } // deserialize() subclass details @@ -504,8 +501,8 @@ updatevalues_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpa Input.getTokens(); // optional blocks std::string token; - while( ( false == ( token = Input.peek() ).empty() ) - && ( false == is_keyword( token ) ) ) { + while( false == (token = Input.peek()).empty() + && false == is_keyword(token) ) { if( token == "condition" ) { m_conditions.deserialize( Input ); @@ -521,10 +518,10 @@ updatevalues_event::run_() { if( false == m_conditions.test() ) { return; } - WriteLog( "Type: " + std::string( ( m_input.flags & flags::mode_add ) ? "AddValues" : "UpdateValues" ) + " & Track command - [" - + ( ( m_input.flags & flags::text ) ? m_input.data_text : "X" ) + "] [" - + ( ( m_input.flags & flags::value1 ) ? to_string( m_input.data_value_1, 2 ) : "X" ) + "] [" - + ( ( m_input.flags & flags::value2 ) ? to_string( m_input.data_value_2, 2 ) : "X" ) + "]" ); + WriteLog( "Type: " + std::string( m_input.flags & flags::mode_add ? "AddValues" : "UpdateValues" ) + " & Track command - [" + + ( m_input.flags & flags::text ? m_input.data_text : "X" ) + "] [" + + ( m_input.flags & flags::value1 ? to_string( m_input.data_value_1, 2 ) : "X" ) + "] [" + + ( m_input.flags & flags::value2 ? to_string( m_input.data_value_2, 2 ) : "X" ) + "]" ); for( auto &target : m_targets ) { auto *targetcell { static_cast( std::get( target ) ) }; if( targetcell == nullptr ) { continue; } @@ -566,7 +563,7 @@ updatevalues_event::export_as_text_( std::ostream &Output ) const { bool updatevalues_event::is_instant() const { - return ( ( ( m_input.flags & flags::mode_add ) != 0 ) && ( m_delay == 0.0 ) ); + return (m_input.flags & flags::mode_add) != 0 && m_delay == 0.0; } @@ -625,7 +622,7 @@ getvalues_event::run_() { cell->PutCommand( m_activator->Mechanik, - &( cell->location() ) ); + &cell->location() ); // potwierdzenie wykonania dla serwera (odczyt semafora już tak nie działa) if( Global.iMultiplayer ) { @@ -670,7 +667,7 @@ double getvalues_event::input_value( int Index ) const { Index &= 1; // tylko 1 albo 2 jest prawidłowy - return ( Index == 1 ? m_input.data_cell()->Value1() : m_input.data_cell()->Value2() ); + return Index == 1 ? m_input.data_cell()->Value1() : m_input.data_cell()->Value2(); } glm::dvec3 @@ -792,8 +789,8 @@ putvalues_event::run_() { m_input.data_value_2, loc ); } - else if( ( m_activator->ctOwner ) - && ( is_command_for_owner( m_input ) ) ) { + else if( m_activator->ctOwner + && is_command_for_owner(m_input) ) { // send the command to consist owner, // we're acting on presumption there's hardly ever need to issue command to unmanned vehicle // and the intended recipient moved between vehicles after the event was queued @@ -859,7 +856,7 @@ double putvalues_event::input_value( int Index ) const { Index &= 1; // tylko 1 albo 2 jest prawidłowy - return ( Index == 1 ? m_input.data_value_1 : m_input.data_value_2 ); + return Index == 1 ? m_input.data_value_1 : m_input.data_value_2; } glm::dvec3 @@ -894,14 +891,14 @@ copyvalues_event::type() const { void copyvalues_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) { - m_input.flags = ( flags::text | flags::value1 | flags::value2 ); // normalnie trzy + m_input.flags = flags::text | flags::value1 | flags::value2; // normalnie trzy std::string token; int paramidx { 0 }; - while( ( true == Input.getTokens() ) - && ( false == ( token = Input.peek() ).empty() ) - && ( false == is_keyword( token ) ) ) { + while( true == Input.getTokens() + && false == (token = Input.peek()).empty() + && false == is_keyword(token) ) { Input >> token; switch( ++paramidx ) { @@ -910,7 +907,7 @@ copyvalues_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad break; } case 2: { // maska wartości - m_input.flags = stol_def( token, ( flags::text | flags::value1 | flags::value2 ) ); + m_input.flags = stol_def( token, flags::text | flags::value1 | flags::value2 ); break; } default: { @@ -931,9 +928,9 @@ copyvalues_event::run_() { m_input.data_value_2 = datasource->Value2(); WriteLog( "Type: CopyValues - [" - + ( ( m_input.flags & flags::text ) ? m_input.data_text : "X" ) + "] [" - + ( ( m_input.flags & flags::value1 ) ? to_string( m_input.data_value_1, 2 ) : "X" ) + "] [" - + ( ( m_input.flags & flags::value2 ) ? to_string( m_input.data_value_2, 2 ) : "X" ) + "]" ); + + ( m_input.flags & flags::text ? m_input.data_text : "X" ) + "] [" + + ( m_input.flags & flags::value1 ? to_string( m_input.data_value_1, 2 ) : "X" ) + "] [" + + ( m_input.flags & flags::value2 ? to_string( m_input.data_value_2, 2 ) : "X" ) + "]" ); // TODO: dump status of target cells after the operation for( auto &target : m_targets ) { auto *targetcell { static_cast( std::get( target ) ) }; @@ -991,19 +988,19 @@ whois_event::type() const { void whois_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) { - m_input.flags = ( flags::text | flags::value1 | flags::value2 ); // normalnie trzy + m_input.flags = flags::text | flags::value1 | flags::value2; // normalnie trzy std::string token; int paramidx { 0 }; - while( ( true == Input.getTokens() ) - && ( false == ( token = Input.peek() ).empty() ) - && ( false == is_keyword( token ) ) ) { + while( true == Input.getTokens() + && false == (token = Input.peek()).empty() + && false == is_keyword(token) ) { Input >> token; switch( ++paramidx ) { case 1: { // maska wartości - m_input.flags = stol_def( token, ( flags::text | flags::value1 | flags::value2 ) ); + m_input.flags = stol_def( token, flags::text | flags::value1 | flags::value2 ); break; } default: { @@ -1014,7 +1011,7 @@ whois_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) { } // run() subclass details -void +void whois_event::run_() { for( auto &target : m_targets ) { @@ -1032,7 +1029,7 @@ whois_event::run_() { // next station name if( m_input.flags & flags::mode_alt ) { auto const *owner { ( - ( ( m_activator->Mechanik != nullptr ) && ( m_activator->Mechanik->primary() ) ) ? + m_activator->Mechanik != nullptr && m_activator->Mechanik->primary() ? m_activator->Mechanik : m_activator->ctOwner ) }; auto const nextstop { ( @@ -1040,7 +1037,7 @@ whois_event::run_() { owner->TrainTimetable().NextStop() : "none" ) }; auto const isstop { ( - ( ( owner != nullptr ) && ( owner->IsStop() ) ) ? + owner != nullptr && owner->IsStop() ? 1 : 0 ) }; // 1, gdy ma tu zatrzymanie @@ -1078,7 +1075,7 @@ whois_event::run_() { // jeśli typ pojazdu // TODO: define and recognize individual request types auto const owner { ( - ( ( m_activator->Mechanik != nullptr ) && ( m_activator->Mechanik->primary() ) ) ? + m_activator->Mechanik != nullptr && m_activator->Mechanik->primary() ? m_activator->Mechanik : m_activator->ctOwner ) }; auto const consistbrakelevel { ( @@ -1253,9 +1250,9 @@ multi_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) { m_conditions.has_else = false; std::string token; - while( ( true == Input.getTokens() ) - && ( false == ( token = Input.peek() ).empty() ) - && ( false == is_keyword( token ) ) ) { + while( true == Input.getTokens() + && false == (token = Input.peek()).empty() + && false == is_keyword(token) ) { if( token == "condition" ) { m_conditions.deserialize( Input ); @@ -1273,7 +1270,7 @@ multi_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) { WriteLog( "Multi-event \"" + m_name + "\" ignored link to event \"" + token + "\"" ); } else { - m_children.emplace_back( token, nullptr, ( m_conditions.has_else == false ) ); + m_children.emplace_back( token, nullptr, m_conditions.has_else == false ); } } } @@ -1762,9 +1759,9 @@ lights_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) { int lightidx { 0 }; std::string token; - while( ( true == Input.getTokens() ) - && ( false == ( token = Input.peek() ).empty() ) - && ( false == is_keyword( token ) ) ) { + while( true == Input.getTokens() + && false == (token = Input.peek()).empty() + && false == is_keyword(token) ) { if( lightidx < lightcountlimit ) { Input >> m_lights[ lightidx++ ]; @@ -1807,8 +1804,8 @@ void lights_event::export_as_text_( std::ostream &Output ) const { auto lightidx{ 0 }; - while( ( lightidx < iMaxNumLights ) - && ( false == std::isnan( m_lights[ lightidx ] ) ) ) { + while( lightidx < iMaxNumLights + && false == std::isnan(m_lights[lightidx]) ) { Output << m_lights[ lightidx ] << ' '; ++lightidx; } @@ -1830,8 +1827,8 @@ switch_event::init() { // jeśli nie jest zwrotnicą ani obrotnicą to będzie się zmieniał stan uszkodzenia targettrack->iAction |= 0x100; } - if( ( m_switchstate == 0 ) - && ( m_switchmovedelay >= 0.0 ) ) { + if( m_switchstate == 0 + && m_switchmovedelay >= 0.0 ) { // jeśli przełącza do stanu 0 & jeśli jest zdefiniowany dodatkowy ruch iglic // przesłanie parametrów targettrack->Switch( @@ -1896,8 +1893,8 @@ void switch_event::export_as_text_( std::ostream &Output ) const { Output << m_switchstate << ' '; - if( ( m_switchmoverate < 0.f ) - || ( m_switchmovedelay < 0.f ) ) { + if( m_switchmoverate < 0.f + || m_switchmovedelay < 0.f ) { Output << m_switchmoverate << ' '; } if( m_switchmovedelay < 0.f ) { @@ -2099,7 +2096,7 @@ void friction_event::run_() { // zmiana tarcia na scenerii WriteLog( "Type: Friction" ); - Global.fFriction = ( m_friction ); + Global.fFriction = m_friction; } // export_as_text() subclass details @@ -2173,9 +2170,9 @@ void message_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) { // wyświetlenie komunikatu std::string token; - while( ( true == Input.getTokens() ) - && ( false == ( token = Input.peek() ).empty() ) - && ( false == is_keyword( token ) ) ) { + while( true == Input.getTokens() + && false == (token = Input.peek()).empty() + && false == is_keyword(token) ) { m_message += ( m_message.empty() ? "" : " " ) + token; } } @@ -2255,10 +2252,10 @@ void event_manager::queue_receivers( radio_message const Message, glm::dvec3 const &Location ) { for( auto *launcher : m_radiodrivenlaunchers.sequence() ) { - if( ( launcher->key() == Message ) - && ( ( launcher->dRadius < 0 ) - || ( glm::length2( launcher->location() - Location ) < launcher->dRadius ) ) - && ( true == launcher->check_conditions() ) ) { + if( launcher->key() == Message + && ( launcher->dRadius < 0 + || glm::length2(launcher->location() - Location) < launcher->dRadius ) + && true == launcher->check_conditions() ) { // NOTE: only execution of event1 is supported for radio messages // TBD, TODO: consider ability/way to execute event2 simulation::Events.AddToQuery( launcher->Event1, nullptr ); @@ -2337,8 +2334,8 @@ event_manager::insert( basic_event *Event ) { if( lookup == m_eventmap.end() ) { // if it's first event with such name, it's potential candidate for the execution queue m_eventmap.emplace( Event->m_name, m_events.size() - 1 ); - if( ( Event->m_ignored != true ) - && ( contains( Event->m_name, "onstart" ) ) ) { + if( Event->m_ignored != true + && contains(Event->m_name, "onstart") ) { // event uruchamiany automatycznie po starcie AddToQuery( Event, nullptr ); } @@ -2381,7 +2378,7 @@ event_manager::AddToQuery( basic_event *Event, TDynamicObject const *Owner, doub if( Event->m_passive ) { return false; } // jeśli może być dodany do kolejki (nie używany w skanowaniu) if( Event->m_inqueue > 0 ) { return false; } // jeśli nie dodany jeszcze do kolejki - + // kolejka eventów jest posortowana względem (fStartTime) Event->m_activator = Owner; if( Event->is_instant() ) { @@ -2394,24 +2391,24 @@ event_manager::AddToQuery( basic_event *Event, TDynamicObject const *Owner, doub Event = Event->m_sibling; // NOTE: we could've received a new event from joint event above, so we need to check conditions just in case and discard the bad events // TODO: refactor this arrangement, it's hardly optimal - } while( ( Event != nullptr ) - && ( ( Event->m_passive ) - || ( Event->m_inqueue > 0 ) ) ); + } while( Event != nullptr + && ( Event->m_passive + || Event->m_inqueue > 0 ) ); } - if( ( Event != nullptr ) - && ( false == Event->m_ignored ) ) { + if( Event != nullptr + && false == Event->m_ignored ) { // standardowe dodanie do kolejki - ++(Event->m_inqueue); // zabezpieczenie przed podwójnym dodaniem do kolejki - WriteLog( "EVENT ADDED TO QUEUE" + ( Owner ? ( " by " + Owner->asName ) : "" ) + ": " + Event->m_name ); + ++Event->m_inqueue; // zabezpieczenie przed podwójnym dodaniem do kolejki + WriteLog( "EVENT ADDED TO QUEUE" + ( Owner ? " by " + Owner->asName : "" ) + ": " + Event->m_name ); Event->m_launchtime = delay + std::abs( Event->m_delay ) + Timer::GetTime(); // czas od uruchomienia scenerii if( Event->m_delayrandom > 0.0 ) { // doliczenie losowego czasu opóźnienia Event->m_launchtime += Event->m_delayrandom * Random(); } - if( ( Owner != nullptr ) - && ( false == std::isnan( Event->m_delaydeparture ) ) ) { + if( Owner != nullptr + && false == std::isnan(Event->m_delaydeparture) ) { auto const *timetableowner { ( - ( ( Owner->Mechanik != nullptr ) && ( Owner->Mechanik->primary() ) ) ? + Owner->Mechanik != nullptr && Owner->Mechanik->primary() ? Owner->Mechanik : Owner->ctOwner ) }; if( timetableowner != nullptr ) { @@ -2427,8 +2424,8 @@ event_manager::AddToQuery( basic_event *Event, TDynamicObject const *Owner, doub if( QueryRootEvent != nullptr ) { basic_event *target { QueryRootEvent }; basic_event *previous { nullptr }; - while( ( Event->m_launchtime >= target->m_launchtime ) - && ( target->m_next != nullptr ) ) { + while( Event->m_launchtime >= target->m_launchtime + && target->m_next != nullptr ) { previous = target; target = target->m_next; } @@ -2464,8 +2461,8 @@ event_manager::AddToQuery( basic_event *Event, TDynamicObject const *Owner, doub bool event_manager::CheckQuery() { - while( ( QueryRootEvent != nullptr ) - && ( QueryRootEvent->m_launchtime < Timer::GetTime() ) ) + while( QueryRootEvent != nullptr + && QueryRootEvent->m_launchtime < Timer::GetTime() ) { // eventy są posortowana wg czasu wykonania m_workevent = QueryRootEvent; // wyjęcie eventu z kolejki if (QueryRootEvent->m_sibling) // jeśli jest kolejny o takiej samej nazwie @@ -2479,9 +2476,9 @@ event_manager::CheckQuery() { } else // a jak nazwa jest unikalna, to kolejka idzie dalej QueryRootEvent = QueryRootEvent->m_next; // NULL w skrajnym przypadku - if( ( false == m_workevent->m_ignored ) && ( false == m_workevent->m_passive ) ) { + if( false == m_workevent->m_ignored && false == m_workevent->m_passive ) { // w zasadzie te wyłączone są skanowane i nie powinny się nigdy w kolejce znaleźć - --(m_workevent->m_inqueue); // teraz moze być ponownie dodany do kolejki + --m_workevent->m_inqueue; // teraz moze być ponownie dodany do kolejki m_workevent->run(); } // if (tmpEvent->bEnabled) } // while diff --git a/world/Event.h b/world/Event.h index d04b4c87..52ee3468 100644 --- a/world/Event.h +++ b/world/Event.h @@ -659,10 +659,7 @@ public: inline bool insert( TEventLauncher *Launcher ) { - return ( - Launcher->IsRadioActivated() ? - m_radiodrivenlaunchers.insert( Launcher ) : - m_inputdrivenlaunchers.insert( Launcher ) ); } + return Launcher->IsRadioActivated() ? m_radiodrivenlaunchers.insert(Launcher) : m_inputdrivenlaunchers.insert(Launcher); } inline void purge (TEventLauncher *Launcher) { m_radiodrivenlaunchers.purge(Launcher); m_inputdrivenlaunchers.purge(Launcher); } diff --git a/world/MemCell.cpp b/world/MemCell.cpp index 71c48c97..76e9e4f1 100644 --- a/world/MemCell.cpp +++ b/world/MemCell.cpp @@ -163,23 +163,23 @@ bool TMemCell::Compare( std::string const &szTestText, double const fTestValue1, compare( szText, szTestText, TextOperator ) : compare( szText.substr( 0, range ), szTestText.substr( 0, range ), TextOperator ) ) }; checkpassed |= result; - checkfailed |= ( !result ); + checkfailed |= !result; } if( TestFlag( CheckMask, basic_event::flags::value1 ) ) { auto const result { compare( fValue1, fTestValue1, Value1Operator ) }; checkpassed |= result; - checkfailed |= ( !result ); + checkfailed |= !result; } if( TestFlag( CheckMask, basic_event::flags::value2 ) ) { auto const result { compare( fValue2, fTestValue2, Value2Operator ) }; checkpassed |= result; - checkfailed |= ( !result ); + checkfailed |= !result; } switch( Pass ) { - case comparison_pass::all: { return ( checkfailed == false ); } - case comparison_pass::any: { return ( checkpassed == true ); } - case comparison_pass::none: { return ( checkpassed == false ); } + case comparison_pass::all: { return checkfailed == false; } + case comparison_pass::any: { return checkpassed == true; } + case comparison_pass::none: { return checkpassed == false; } default: { return false; } } }; @@ -190,7 +190,7 @@ bool TMemCell::IsVelocity() const return true; if (eCommand == TCommandType::cm_ShuntVelocity) return true; - return (eCommand == TCommandType::cm_SetProximityVelocity); + return eCommand == TCommandType::cm_SetProximityVelocity; }; void TMemCell::StopCommandSent() diff --git a/world/Segment.cpp b/world/Segment.cpp index 4610c5bd..53f1f904 100644 --- a/world/Segment.cpp +++ b/world/Segment.cpp @@ -115,20 +115,17 @@ bool TSegment::Init(glm::dvec3 &NewPoint1, glm::dvec3 NewCPointOut, glm::dvec3 N fLength = 0.01; // crude workaround TODO: fix this properly } - fStoop = std::atan2((Point2.y - Point1.y), fLength); // pochylenie toru prostego, żeby nie liczyć wielokrotnie + fStoop = std::atan2(Point2.y - Point1.y, fLength); // pochylenie toru prostego, żeby nie liczyć wielokrotnie fStep = fNewStep; // NOTE: optionally replace this part with the commented version, after solving geometry issues with double switches - if( ( pOwner->eType == tt_Switch ) - && ( fStep * ( 3.0 * Global.SplineFidelity ) > fLength ) ) { + if( pOwner->eType == tt_Switch + && fStep * (3.0 * Global.SplineFidelity) > fLength ) { // NOTE: a workaround for too short switches (less than 3 segments) messing up animation/generation of blades fStep = fLength / ( 3.0 * Global.SplineFidelity ); } // iSegCount = static_cast( std::ceil( fLength / fStep ) ); // potrzebne do VBO - iSegCount = ( - pOwner->eType == tt_Switch ? - 6 * Global.SplineFidelity : - static_cast( std::ceil( fLength / fStep ) ) ); // potrzebne do VBO + iSegCount = pOwner->eType == tt_Switch ? 6 * Global.SplineFidelity : static_cast(std::ceil(fLength / fStep)); // potrzebne do VBO fStep = fLength / iSegCount; // update step to equalize size of individual pieces @@ -170,7 +167,7 @@ double TSegment::RombergIntegral(double const fA, double const fB) const double ms_apfRom[2][ms_iOrder]; ms_apfRom[0][0] = - 0.5 * fH * ((glm::length(GetFirstDerivative(fA))) + glm::length(GetFirstDerivative(fB))); + 0.5 * fH * (glm::length(GetFirstDerivative(fA)) + glm::length(GetFirstDerivative(fB))); for (int i0 = 2, iP0 = 1; i0 <= ms_iOrder; i0++, iP0 *= 2, fH *= 0.5) { // approximations via the trapezoid rule @@ -249,14 +246,14 @@ double TSegment::ComputeLength() const // McZapkie-150503: dlugosc miedzy punkta l += t; // zwiększenie wyliczanej długości last = tmp; } - return (l); + return l; } // finds point on segment closest to specified point in 3d space. returns: point on segment as value in range 0-1 double TSegment::find_nearest_point( glm::dvec3 const &Point ) const { - if( ( false == bCurve ) || ( iSegCount == 1 ) ) { + if( false == bCurve || iSegCount == 1 ) { // for straight track just treat it as a single segment return nearest_segment_point( @@ -300,22 +297,22 @@ glm::dvec3 TSegment::GetDirection(double const fDistance) const { // takie toporne liczenie pochodnej dla podanego dystansu od Point1 double t1 = GetTFromS(fDistance - fDirectionOffset); if (t1 <= 0.0) - return (CPointOut - Point1); // na zewnątrz jako prosta + return CPointOut - Point1; // na zewnątrz jako prosta double t2 = GetTFromS(fDistance + fDirectionOffset); if (t2 >= 1.0) - return (Point1 - CPointIn); // na zewnątrz jako prosta - return (FastGetPoint(t2) - FastGetPoint(t1)); + return Point1 - CPointIn; // na zewnątrz jako prosta + return FastGetPoint(t2) - FastGetPoint(t1); } glm::dvec3 TSegment::FastGetDirection(double fDistance, double fOffset) { // takie toporne liczenie pochodnej dla parametru 0.0÷1.0 double t1 = fDistance - fOffset; if (t1 <= 0.0) - return (CPointOut - Point1); // wektor na początku jest stały + return CPointOut - Point1; // wektor na początku jest stały double t2 = fDistance + fOffset; if (t2 >= 1.0) - return (Point2 - CPointIn); // wektor na końcu jest stały - return (FastGetPoint(t2) - FastGetPoint(t1)); + return Point2 - CPointIn; // wektor na końcu jest stały + return FastGetPoint(t2) - FastGetPoint(t1); } /* Math3D::vector3 TSegment::GetPoint(double const fDistance) const @@ -366,9 +363,7 @@ void TSegment::RaPositionGet(double const fDistance, glm::dvec3 &position, glm:: glm::dvec3 TSegment::FastGetPoint(double const t) const { // return (bCurve?std::lerp(t,Point1,CPointOut,CPointIn,Point2):((1.0-t)*Point1+(t)*Point2)); - return ( - ( ( true == bCurve ) || ( iSegCount != 1 ) ) ? - RaInterpolate( t ) : glm::mix(Point1, Point2, t)); + return true == bCurve || iSegCount != 1 ? RaInterpolate(t) : glm::mix(Point1, Point2, t); } bool TSegment::RenderLoft( gfx::vertex_array &Output, glm::dvec3 const &Origin, const gfx::vertex_array &ShapePoints, bool const Transition, double fTextureLength, double Texturescale, int iSkip, int iEnd, std::pair fOffsetX, glm::vec3 **p, bool bRender) @@ -424,7 +419,7 @@ bool TSegment::RenderLoft( gfx::vertex_array &Output, glm::dvec3 const &Origin, jmm2 = 1.f - m2; // nowa pozycja if( i == iEnd ) { // gdy przekroczyliśmy koniec - stąd dziury w torach... - step -= ( s - fEnd ); // jeszcze do wyliczenia mapowania potrzebny + step -= s - fEnd; // jeszcze do wyliczenia mapowania potrzebny s = fEnd; m2 = 1.f; jmm2 = 0.f; @@ -465,7 +460,7 @@ bool TSegment::RenderLoft( gfx::vertex_array &Output, glm::dvec3 const &Origin, if( *p ) if( !j ) // to dla pierwszego punktu { - *( *p ) = pt; + **p = pt; ( *p )++; } // zapamiętanie brzegu jezdni // dla trapezu drugi koniec ma inne współrzędne @@ -484,7 +479,7 @@ bool TSegment::RenderLoft( gfx::vertex_array &Output, glm::dvec3 const &Origin, if( *p ) if( !j ) // to dla pierwszego punktu if( i == iSegCount ) { - *( *p ) = pt; + **p = pt; ( *p )++; } // zapamiętanie brzegu jezdni } diff --git a/world/Segment.h b/world/Segment.h index ba3fc32d..fccaf3af 100644 --- a/world/Segment.h +++ b/world/Segment.h @@ -132,7 +132,7 @@ public: inline int RaSegCount() const { - return ( fTsBuffer.empty() ? 1 : iSegCount ); }; + return fTsBuffer.empty() ? 1 : iSegCount; }; void render_lines(std::vector &out, float quality = 1.0f) const; diff --git a/world/Spring.cpp b/world/Spring.cpp index 49992411..b58d8859 100644 --- a/world/Spring.cpp +++ b/world/Spring.cpp @@ -34,12 +34,12 @@ glm::dvec3 TSpring::ComputateForces(glm::dvec3 const &pPosition1, glm::dvec3 con auto deltaV = pPosition1 - pPosition2; // Dterm = (DotProduct(&deltaV,&deltaP) * spring->Kd) / dist; // Damping Term - auto Dterm = (glm::dot(deltaV,deltaP) * Kd) / dist; + auto Dterm = glm::dot(deltaV, deltaP) * Kd / dist; //Dterm = 0; // ScaleVector(&deltaP,1.0f / dist, &springForce); // Normalize Distance Vector // ScaleVector(&springForce,-(Hterm + Dterm),&springForce); // Calc Force - springForce = deltaP / dist * ( -( Hterm + Dterm )); + springForce = deltaP / dist * -(Hterm + Dterm); // VectorSum(&p1->f,&springForce,&p1->f); // Apply to Particle 1 // VectorDifference(&p2->f,&springForce,&p2->f); // - Force on Particle 2 } diff --git a/world/Track.cpp b/world/Track.cpp index aa7dc63c..6155116c 100644 --- a/world/Track.cpp +++ b/world/Track.cpp @@ -58,16 +58,16 @@ TSwitchExtension::TSwitchExtension(TTrack *owner, int const what) fOffset2 = 0.f; // w zasadniczym wewnętrzna iglica dolega Segments[0] = std::make_shared(owner); // z punktu 1 do 2 Segments[1] = std::make_shared(owner); // z punktu 3 do 4 (1=3 dla zwrotnic; odwrócony dla skrzyżowań, ewentualnie 1=4) - Segments[2] = (what >= 3) ? + Segments[2] = what >= 3 ? std::make_shared(owner) : nullptr; // z punktu 2 do 4 skrzyżowanie od góry: wersja "-1": - Segments[3] = (what >= 4) ? + Segments[3] = what >= 4 ? std::make_shared(owner) : nullptr; // z punktu 4 do 1 1 1=4 0 0=3 - Segments[4] = (what >= 5) ? + Segments[4] = what >= 5 ? std::make_shared(owner) : nullptr; // z punktu 1 do 3 4 x 3 3 3 x 2 2 - Segments[5] = (what >= 6) ? + Segments[5] = what >= 6 ? std::make_shared(owner) : nullptr; // z punktu 3 do 2 2 2 1 1 } @@ -142,10 +142,7 @@ void TIsolated::Modify(int i, TDynamicObject *o) simulation::Events.AddToQuery(evBusy, o); // dodanie zajętości do kolejki if (Global.iMultiplayer) // jeśli multiplayer { - auto const *owner = ( - ((o->Mechanik != nullptr) && (o->Mechanik->primary())) ? - o->Mechanik : - o->ctOwner); + auto const *owner = o->Mechanik != nullptr && o->Mechanik->primary() ? o->Mechanik : o->ctOwner; auto textline = owner != nullptr ? Bezogonkow(owner->TrainName(), true) : "none"; if ("none" != textline && Global.bIsolatedTrainName) { textline = ":" + Bezogonkow(owner->TrainName(), true); @@ -234,7 +231,7 @@ TTrack * TTrack::NullCreate(int dir) nodedata.name = "auto_null"; // track isn't visible so only name is needed trk = new TTrack( nodedata ); trk->m_visible = false; // nie potrzeba pokazywać, zresztą i tak nie ma tekstur - trk->iCategoryFlag = (iCategoryFlag & 15) | 0x80; // taki sam typ plus informacja, że dodatkowy + trk->iCategoryFlag = iCategoryFlag & 15 | 0x80; // taki sam typ plus informacja, że dodatkowy float r1, r2; Segment->GetRolls(r1, r2); // pobranie przechyłek na początku toru glm::dvec3 p1, cv1, cv2, p2; // będziem tworzyć trajektorię lotu @@ -277,7 +274,7 @@ TTrack * TTrack::NullCreate(int dir) trk->Init(); // utworzenie segmentu trk2 = new TTrack( nodedata ); trk2->iCategoryFlag = - (iCategoryFlag & 15) | 0x80; // taki sam typ plus informacja, że dodatkowy + iCategoryFlag & 15 | 0x80; // taki sam typ plus informacja, że dodatkowy trk2->m_visible = false; trk2->fVelocity = 20.0; // zawracanie powoli trk2->fRadius = 20.0; // promień, aby się dodawało do tabelki prędkości i liczyło narastająco @@ -329,7 +326,7 @@ void TTrack::ConnectPrevPrev(TTrack *pTrack, int typ) if (pTrack) { //(pTrack) może być zwrotnicą, a (this) tylko zwykłym odcinkiem trPrev = pTrack; - iPrevDirection = ((pTrack->eType == tt_Switch) ? 0 : (typ & 2)); + iPrevDirection = pTrack->eType == tt_Switch ? 0 : typ & 2; pTrack->trPrev = this; pTrack->iPrevDirection = 0; } @@ -346,11 +343,10 @@ void TTrack::ConnectPrevNext(TTrack *pTrack, int typ) if (pTrack->m_visible) if (eType == tt_Normal) // jeśli łączone są dwa normalne if (pTrack->eType == tt_Normal) - if ((fTrackWidth != - pTrack->fTrackWidth) // Ra: jeśli kolejny ma inne wymiary + if (fTrackWidth != pTrack->fTrackWidth // Ra: jeśli kolejny ma inne wymiary || - (fTexHeight1 != pTrack->fTexHeight1) || - (fTexWidth != pTrack->fTexWidth) || (fTexSlope != pTrack->fTexSlope)) + fTexHeight1 != pTrack->fTexHeight1 || + fTexWidth != pTrack->fTexWidth || fTexSlope != pTrack->fTexSlope) pTrack->iTrapezoid |= 2; // to rysujemy potworka } } @@ -359,18 +355,17 @@ void TTrack::ConnectNextPrev(TTrack *pTrack, int typ) if (pTrack) { trNext = pTrack; - iNextDirection = ((pTrack->eType == tt_Switch) ? 0 : (typ & 2)); + iNextDirection = pTrack->eType == tt_Switch ? 0 : typ & 2; pTrack->trPrev = this; pTrack->iPrevDirection = 1; if (m_visible) if (pTrack->m_visible) if (eType == tt_Normal) // jeśli łączone są dwa normalne if (pTrack->eType == tt_Normal) - if ((fTrackWidth != - pTrack->fTrackWidth) // Ra: jeśli kolejny ma inne wymiary + if (fTrackWidth != pTrack->fTrackWidth // Ra: jeśli kolejny ma inne wymiary || - (fTexHeight1 != pTrack->fTexHeight1) || - (fTexWidth != pTrack->fTexWidth) || (fTexSlope != pTrack->fTexSlope)) + fTexHeight1 != pTrack->fTexHeight1 || + fTexWidth != pTrack->fTexWidth || fTexSlope != pTrack->fTexSlope) iTrapezoid |= 2; // to rysujemy potworka } } @@ -479,16 +474,13 @@ void TTrack::Load(cParser *parser, glm::dvec3 const &pOrigin) } parser->getTokens(); *parser >> token; - m_visible = (token.compare("vis") == 0); // visible + m_visible = token.compare("vis") == 0; // visible if (m_visible) { parser->getTokens(); *parser >> str; // railtex replace_slashes(str); - m_material1 = ( - str == "none" ? - null_handle : - GfxRenderer->Fetch_Material( str ) ); + m_material1 = str == "none" ? null_handle : GfxRenderer->Fetch_Material(str); parser->getTokens(); *parser >> fTexLength; // tex tile length if (fTexLength < 0.01) @@ -496,10 +488,7 @@ void TTrack::Load(cParser *parser, glm::dvec3 const &pOrigin) parser->getTokens(); *parser >> str; // sub || railtex replace_slashes(str); - m_material2 = ( - str == "none" ? - null_handle : - GfxRenderer->Fetch_Material( str ) ); + m_material2 = str == "none" ? null_handle : GfxRenderer->Fetch_Material(str); parser->getTokens(3); *parser >> fTexHeight1 @@ -561,8 +550,8 @@ void TTrack::Load(cParser *parser, glm::dvec3 const &pOrigin) } // length2 is better than length for comparing because it does not require sqrt function - if( (glm::length2(( p1 + p1 + p2 ) / 3.0 - p1 - cp1) < sq(0.02)) - || (glm::length2(( p1 + p2 + p2 ) / 3.0 - p2 + cp1) < sq(0.02)) ) { + if( glm::length2((p1 + p1 + p2) / 3.0 - p1 - cp1) < sq(0.02) + || glm::length2((p1 + p2 + p2) / 3.0 - p2 + cp1) < sq(0.02) ) { // "prostowanie" prostych z kontrolnymi, dokładność 2cm cp1 = cp2 = glm::dvec3(0, 0, 0); } @@ -577,7 +566,7 @@ void TTrack::Load(cParser *parser, glm::dvec3 const &pOrigin) } else { // HACK: crude check whether claimed straight is an actual straight piece - if ((cp1 == glm::dvec3()) && (cp2 == glm::dvec3())) + if (cp1 == glm::dvec3() && cp2 == glm::dvec3()) { segsize = 10.0; // for straights, 10m per segment works good enough } @@ -591,7 +580,7 @@ void TTrack::Load(cParser *parser, glm::dvec3 const &pOrigin) } } - if ((cp1 == glm::dvec3()) && (cp2 == glm::dvec3())) + if (cp1 == glm::dvec3() && cp2 == glm::dvec3()) { // Ra: hm, czasem dla prostego są podane... // gdy prosty, kontrolne wyliczane przy zmiennej przechyłce @@ -602,7 +591,7 @@ void TTrack::Load(cParser *parser, glm::dvec3 const &pOrigin) Segment->Init( p1, cp1 + p1, cp2 + p2, p2, segsize, r1, r2 ); } - if ((r1 != 0) || (r2 != 0)) + if (r1 != 0 || r2 != 0) iTrapezoid = 1; // są przechyłki do uwzględniania w rysowaniu if (eType == tt_Table) // obrotnica ma doklejkę @@ -675,7 +664,7 @@ void TTrack::Load(cParser *parser, glm::dvec3 const &pOrigin) } else { // HACK: crude check whether claimed straight is an actual straight piece - if ((cp1 == glm::dvec3()) && (cp2 == glm::dvec3())) + if (cp1 == glm::dvec3() && cp2 == glm::dvec3()) { segsize = 10.0; // for straights, 10m per segment works good enough } @@ -689,7 +678,7 @@ void TTrack::Load(cParser *parser, glm::dvec3 const &pOrigin) } } - if ((cp1 == glm::dvec3()) && (cp2 == glm::dvec3())) + if (cp1 == glm::dvec3() && cp2 == glm::dvec3()) { // Ra: hm, czasem dla prostego są podane... // gdy prosty, kontrolne wyliczane przy zmiennej przechyłce @@ -723,8 +712,8 @@ void TTrack::Load(cParser *parser, glm::dvec3 const &pOrigin) if( eType != tt_Cross ) { // dla skrzyżowań muszą być podane kontrolne // length2 is better than length for comparing because it does not require sqrt function - if( (glm::length2(( p3 + p3 + p4 ) / 3.0 - p3 - cp3) < sq(0.02)) - || (glm::length2(( p3 + p4 + p4 ) / 3.0 - p4 + cp3) < sq(0.02)) ) { + if( glm::length2((p3 + p3 + p4) / 3.0 - p3 - cp3) < sq(0.02) + || glm::length2((p3 + p4 + p4) / 3.0 - p4 + cp3) < sq(0.02) ) { // "prostowanie" prostych z kontrolnymi, dokładność 2cm cp3 = cp4 = glm::dvec3(0, 0, 0); } @@ -740,7 +729,7 @@ void TTrack::Load(cParser *parser, glm::dvec3 const &pOrigin) } else { // HACK: crude check whether claimed straight is an actual straight piece - if ((cp3 == glm::dvec3()) && (cp4 == glm::dvec3())) + if (cp3 == glm::dvec3() && cp4 == glm::dvec3()) { segsize = 10.0; // for straights, 10m per segment works good enough } @@ -754,7 +743,7 @@ void TTrack::Load(cParser *parser, glm::dvec3 const &pOrigin) } } - if ((cp3 == glm::dvec3()) && (cp4 == glm::dvec3())) + if (cp3 == glm::dvec3() && cp4 == glm::dvec3()) { // Ra: hm, czasem dla prostego są podane... // gdy prosty, kontrolne wyliczane przy zmiennej przechyłce @@ -990,7 +979,7 @@ bool TTrack::AssignEvents() { { "event2", &m_events2 }, { "eventall2", &m_events2all } }; for( auto &eventsequence : eventsequences ) { - for( auto &event : *( eventsequence.second ) ) { + for( auto &event : *eventsequence.second ) { event.second = simulation::Events.FindEvent( event.first ); if( event.second != nullptr ) { m_events = true; @@ -1004,8 +993,8 @@ bool TTrack::AssignEvents() { auto const trackname { name() }; - if( ( Global.iHiddenEvents & 1 ) - && ( false == trackname.empty() ) ) { + if (Global.iHiddenEvents & 1 + && false == trackname.empty() ) { // jeśli podana jest nazwa torów, można szukać eventów skojarzonych przez nazwę for( auto &eventsequence : eventsequences ) { auto *event = simulation::Events.FindEvent( trackname + ':' + eventsequence.first ); @@ -1017,7 +1006,7 @@ bool TTrack::AssignEvents() { } } - return ( lookupfail == false ); + return lookupfail == false; } bool TTrack::AssignForcedEvents(basic_event *NewEventPlus, basic_event *NewEventMinus) @@ -1045,8 +1034,8 @@ void TTrack::QueueEvents( event_sequence const &Events, TDynamicObject const *Ow void TTrack::QueueEvents( event_sequence const &Events, TDynamicObject const *Owner, double const Delaylimit ) { for( auto const &event : Events ) { - if( ( event.second != nullptr ) - && ( event.second->m_delay <= Delaylimit) ) { + if( event.second != nullptr + && event.second->m_delay <= Delaylimit ) { simulation::Events.AddToQuery( event.second, Owner ); } } @@ -1109,7 +1098,7 @@ bool TTrack::RemoveDynamicObject(TDynamicObject *Dynamic) Dynamics.pop_front(); result = true; } - else if( *( --Dynamics.end() ) == Dynamic ) { + else if( *--Dynamics.end() == Dynamic ) { // ...or the back of the queue... Dynamics.pop_back(); result = true; @@ -1153,12 +1142,9 @@ bool TTrack::InMovement() if (!SwitchExtension->CurrentIndex) return false; // 0=zablokowana się nie animuje // trzeba każdorazowo porównywać z kątem modelu - auto ac = ( - SwitchExtension->pModel ? - SwitchExtension->pModel->GetContainer() : - nullptr ); + auto ac = SwitchExtension->pModel ? SwitchExtension->pModel->GetContainer() : nullptr; return ac ? - (ac->AngleGet() != SwitchExtension->fOffset) || + ac->AngleGet() != SwitchExtension->fOffset || !(ac->TransGet() == SwitchExtension->vTrans) : false; // return true; //jeśli jest taki obiekt @@ -1174,7 +1160,7 @@ void TTrack::RaAssign( TAnimModel *am, basic_event *done, basic_event *joined ) SwitchExtension->pModel = am; SwitchExtension->evMinus = done; // event zakończenia animacji (zadanie nowej przedłuża) SwitchExtension->evPlus = joined; // event potwierdzenia połączenia (gdy nie znajdzie, to się nie połączy) - if( ( am != nullptr ) && ( am->GetContainer() ) ) {// może nie być? + if( am != nullptr && am->GetContainer() ) {// może nie być? am->GetContainer()->EventAssign( done ); // zdarzenie zakończenia animacji } } @@ -1372,7 +1358,7 @@ void TTrack::create_geometry( gfx::geometrybank_handle const &Bank ) { // optional vertical shift of the auto-generated ballast (sleepermodel ballastZ). // positive value raises the trackbed, negative pushes it down so a custom // sleeper model placed on top can sit flush with the ballast surface. - if( m_sleeper_enabled && ( m_sleeper_ballast_z != 0.f ) ) { + if( m_sleeper_enabled && m_sleeper_ballast_z != 0.f ) { for( auto &v : bpts1 ) { v.position.y += m_sleeper_ballast_z; } @@ -1380,10 +1366,10 @@ void TTrack::create_geometry( gfx::geometrybank_handle const &Bank ) { auto const texturelength { texture_length( m_material2 ) }; gfx::vertex_array vertices; Segment->RenderLoft(vertices, m_origin, bpts1, iTrapezoid > 0, texturelength); - if( ( Bank != 0 ) && ( true == Geometry2.empty() ) ) { + if( Bank != 0 && true == Geometry2.empty() ) { Geometry2.emplace_back(GfxRenderer->Insert(vertices, empty_userdata, Bank, GL_TRIANGLE_STRIP)); } - if( ( Bank == 0 ) && ( false == Geometry2.empty() ) ) { + if( Bank == 0 && false == Geometry2.empty() ) { // special variant, replace existing data for a turntable track GfxRenderer->Replace(vertices, empty_userdata, Geometry2[0], GL_TRIANGLE_STRIP); } @@ -1393,14 +1379,14 @@ void TTrack::create_geometry( gfx::geometrybank_handle const &Bank ) { auto const nnumPts { track_rail_profile( m_profile1.second ).size() / 2 }; auto const texturelength { texture_length( m_material1 ) }; gfx::vertex_array vertices; - if( ( Bank != 0 ) && ( true == Geometry1.empty() ) ) { + if( Bank != 0 && true == Geometry1.empty() ) { Segment->RenderLoft( vertices, m_origin, rpts1, iTrapezoid > 0, texturelength ); Geometry1.emplace_back(GfxRenderer->Insert(vertices, empty_userdata, Bank, GL_TRIANGLE_STRIP)); vertices.clear(); // reuse the scratchpad Segment->RenderLoft( vertices, m_origin, rpts2, iTrapezoid > 0, texturelength ); Geometry1.emplace_back(GfxRenderer->Insert(vertices, empty_userdata, Bank, GL_TRIANGLE_STRIP)); } - if( ( Bank == 0 ) && ( false == Geometry1.empty() ) ) { + if( Bank == 0 && false == Geometry1.empty() ) { // special variant, replace existing data for a turntable track Segment->RenderLoft( vertices, m_origin, rpts1, iTrapezoid > 0, texturelength ); GfxRenderer->Replace(vertices, empty_userdata, Geometry1[0], GL_TRIANGLE_STRIP); @@ -1550,13 +1536,13 @@ void TTrack::create_geometry( gfx::geometrybank_handle const &Bank ) { gfx::vertex_array rpts1, rpts2; // współrzędne przekroju i mapowania dla prawej i lewej strony create_road_side_profile( rpts1, rpts2, bpts1 ); gfx::vertex_array vertices; - if( ( fTexHeight1 >= 0.0 ) || ( slop != 0.0 ) ) { + if( fTexHeight1 >= 0.0 || slop != 0.0 ) { // tylko jeśli jest z prawej Segment->RenderLoft( vertices, m_origin, rpts1, iTrapezoid > 0, texturelength ); Geometry2.emplace_back(GfxRenderer->Insert(vertices, empty_userdata, Bank, GL_TRIANGLE_STRIP)); vertices.clear(); } - if( ( fTexHeight1 >= 0.0 ) || ( side != 0.0 ) ) { + if( fTexHeight1 >= 0.0 || side != 0.0 ) { // tylko jeśli jest z lewej Segment->RenderLoft( vertices, m_origin, rpts2, iTrapezoid > 0, texturelength ); Geometry2.emplace_back(GfxRenderer->Insert(vertices, empty_userdata, Bank, GL_TRIANGLE_STRIP)); @@ -1627,13 +1613,13 @@ void TTrack::create_geometry( gfx::geometrybank_handle const &Bank ) { gfx::vertex_array rpts1, rpts2; // współrzędne przekroju i mapowania dla prawej i lewej strony create_road_side_profile( rpts1, rpts2, bpts1, true ); // Ra 2014-07: trzeba to przerobić na pętlę i pobierać profile (przynajmniej 2..4) z sąsiednich dróg - bool render = ( m_material2 != 0 ); // renderować nie trzeba, ale trzeba wyznaczyć punkty brzegowe nawierzchni + bool render = m_material2 != 0; // renderować nie trzeba, ale trzeba wyznaczyć punkty brzegowe nawierzchni auto const side{ std::abs( fTexWidth ) }; // szerokść podsypki na zewnątrz szyny albo pobocza auto const texturelength{ texture_length( m_material2 ) }; gfx::vertex_array vertices; if (SwitchExtension->iRoads == 4) { // pobocza do trapezowatej nawierzchni - dodatkowe punkty z drugiej strony odcinka - if( ( fTexHeight1 >= 0.0 ) || ( side != 0.0 ) ) { + if( fTexHeight1 >= 0.0 || side != 0.0 ) { SwitchExtension->Segments[ 2 ]->RenderLoft( vertices, m_origin, rpts2, true, texturelength, 1.0, 0, 0, {}, &b, render ); if( true == render ) { Geometry2.emplace_back(GfxRenderer->Insert(vertices, empty_userdata, Bank, GL_TRIANGLE_STRIP)); @@ -1658,7 +1644,7 @@ void TTrack::create_geometry( gfx::geometrybank_handle const &Bank ) { } else { // punkt 3 pokrywa się z punktem 1, jak w zwrotnicy; połączenie 1->2 nie musi być prostoliniowe - if( ( fTexHeight1 >= 0.0 ) || ( side != 0.0 ) ) { + if( fTexHeight1 >= 0.0 || side != 0.0 ) { SwitchExtension->Segments[ 2 ]->RenderLoft( vertices, m_origin, rpts2, true, texturelength, 1.0, 0, 0, {}, &b, render ); // z P2 do P4 if( true == render ) { Geometry2.emplace_back(GfxRenderer->Insert(vertices, empty_userdata, Bank, GL_TRIANGLE_STRIP)); @@ -1680,8 +1666,8 @@ void TTrack::create_geometry( gfx::geometrybank_handle const &Bank ) { // renderowanie nawierzchni na końcu double sina0 = sin(a[0]), cosa0 = cos(a[0]); double u, v; - if( ( false == SwitchExtension->bPoints ) // jeśli tablica nie wypełniona - && ( b != nullptr ) ) { + if( false == SwitchExtension->bPoints // jeśli tablica nie wypełniona + && b != nullptr ) { SwitchExtension->bPoints = true; // tablica punktów została wypełniona } @@ -1862,13 +1848,13 @@ bool TTrack::Switch(int i, float const t, float const d) if (trNext || trPrev) { fVelocity = 6.0; // jazda dozwolona - if( ( trPrev ) - && ( trPrev->fVelocity == 0.0 ) ) { + if( trPrev + && trPrev->fVelocity == 0.0 ) { // ustawienie 0 da możliwość zatrzymania AI na obrotnicy trPrev->VelocitySet( 6.0 ); // odblokowanie dołączonego toru do jazdy } - if( ( trNext ) - && ( trNext->fVelocity == 0.0 ) ) { + if( trNext + && trNext->fVelocity == 0.0 ) { trNext->VelocitySet( 6.0 ); } if( SwitchExtension->evPlus ) { // w starych sceneriach może nie być @@ -1937,15 +1923,15 @@ int TTrack::CrossSegment(int from, int into) break; case 1: // left // WriteLog( "Turning left from P" + to_string( from + 1 ) + " on " + name() ); - i = (SwitchExtension->iRoads == 4) ? iLewo4[from] : iLewo3[from]; + i = SwitchExtension->iRoads == 4 ? iLewo4[from] : iLewo3[from]; break; case 2: // right // WriteLog( "Turning right from P" + to_string( from + 1 ) + " on " + name() ); - i = (SwitchExtension->iRoads == 4) ? iPrawo4[from] : iPrawo3[from]; + i = SwitchExtension->iRoads == 4 ? iPrawo4[from] : iPrawo3[from]; break; case 3: // stright // WriteLog( "Going straight from P" + to_string( from + 1 ) + " on " + name() ); - i = (SwitchExtension->iRoads == 4) ? iProsto4[from] : iProsto3[from]; + i = SwitchExtension->iRoads == 4 ? iProsto4[from] : iProsto3[from]; break; } if (i) @@ -1958,7 +1944,7 @@ int TTrack::CrossSegment(int from, int into) void TTrack::RaAnimListAdd(TTrack *t) { // dodanie toru do listy animacyjnej - if ((t != nullptr) && (SwitchExtension != nullptr)) + if (t != nullptr && SwitchExtension != nullptr) { if (t == this) return; // siebie nie dodajemy drugi raz do listy @@ -2014,10 +2000,10 @@ TTrack * TTrack::RaAnimate() } } // skip the geometry update if no geometry for this track was generated yet - if( ( ( m_material1 != 0 ) - || ( m_material2 != 0 ) ) - && ( ( false == Geometry1.empty() ) - || ( false == Geometry2.empty() ) ) ) { + if( ( m_material1 != 0 + || m_material2 != 0 ) + && ( false == Geometry1.empty() + || false == Geometry2.empty() ) ) { // iglice liczone tylko dla zwrotnic gfx::vertex_array rpts1, rpts2; create_track_rail_profile( rpts1, rpts2 ); @@ -2075,12 +2061,10 @@ TTrack * TTrack::RaAnimate() SwitchExtension->CurrentIndex) // 0=zablokowana się nie animuje { // trzeba każdorazowo porównywać z kątem modelu // //pobranie kąta z modelu - auto ac = ( - SwitchExtension->pModel ? - SwitchExtension->pModel->GetContainer() : // pobranie głównego submodelu - nullptr ); + auto ac = SwitchExtension->pModel ? SwitchExtension->pModel->GetContainer() : // pobranie głównego submodelu + nullptr; if( ac ) { - if( ( ac->AngleGet() != SwitchExtension->fOffset ) + if( ac->AngleGet() != SwitchExtension->fOffset || !( ac->TransGet() == SwitchExtension->vTrans ) ) { // czy przemieściło się od ostatniego sprawdzania double hlen = 0.5 * SwitchExtension->Segments[ 0 ]->GetLength(); // połowa długości @@ -2127,9 +2111,9 @@ double TTrack::WidthTotal() bool TTrack::IsGroupable() { // czy wyświetlanie toru może być zgrupwane z innymi - if ((eType == tt_Switch) || (eType == tt_Table)) + if (eType == tt_Switch || eType == tt_Table) return false; // tory ruchome nie są grupowane - if ((eEnvironment == e_canyon) || (eEnvironment == e_tunnel)) + if (eEnvironment == e_canyon || eEnvironment == e_tunnel) return false; // tory ze zmianą światła return true; }; @@ -2322,10 +2306,7 @@ TTrack::export_as_text_( std::ostream &Output ) const { << texturefile << ' ' << fTexLength << ' '; - texturefile = ( - m_material2 != null_handle ? - GfxRenderer->Material( m_material2 )->GetName() : - "none" ); + texturefile = m_material2 != null_handle ? GfxRenderer->Material(m_material2)->GetName() : "none"; if( texturefile.find( paths::textures ) == 0 ) { // don't include 'textures/' in the path texturefile.erase( 0, std::string{ paths::textures }.size() ); @@ -2333,7 +2314,7 @@ TTrack::export_as_text_( std::ostream &Output ) const { Output << texturefile << ' '; Output - << (fTexHeight1 - fTexHeightOffset ) * ( ( iCategoryFlag & 4 ) ? -1 : 1 ) << ' ' + << (fTexHeight1 - fTexHeightOffset ) * ( iCategoryFlag & 4 ? -1 : 1 ) << ' ' << fTexWidth << ' ' << fTexSlope << ' '; } @@ -2367,7 +2348,7 @@ TTrack::export_as_text_( std::ostream &Output ) const { { "event2", &m_events2 }, { "eventall2", &m_events2all } }; for( auto &eventsequence : eventsequences ) { - for( auto &event : *( eventsequence.second ) ) { + for( auto &event : *eventsequence.second ) { // NOTE: actual event name can be potentially different from its cached name, if it was renamed in the editor // therefore on export we pull the name from the event itself, if the binding isn't broken Output @@ -2378,8 +2359,8 @@ TTrack::export_as_text_( std::ostream &Output ) const { << ' '; } } - if( ( SwitchExtension ) - && ( SwitchExtension->fVelocity != -1.0 ) ) { + if( SwitchExtension + && SwitchExtension->fVelocity != -1.0 ) { Output << "velocity " << SwitchExtension->fVelocity << ' '; } else { @@ -2396,8 +2377,8 @@ TTrack::export_as_text_( std::ostream &Output ) const { if( fVerticalRadius != 0.f ) { Output << "vradius " << fVerticalRadius << ' '; } - if( ( eType == tt_Switch ) - && ( SwitchExtension->m_material3 != null_handle ) ) { + if( eType == tt_Switch + && SwitchExtension->m_material3 != null_handle) { auto texturefile { GfxRenderer->Material( m_material2 )->GetName() }; if( texturefile.find( paths::textures ) == 0 ) { // don't include 'textures/' in the path @@ -2408,7 +2389,7 @@ TTrack::export_as_text_( std::ostream &Output ) const { if( false == m_friction.first.empty() ) { Output << "friction " << m_friction.first << ' '; } - if( m_sleeper_enabled && ( false == m_sleeper_model_name.empty() ) ) { + if( m_sleeper_enabled && false == m_sleeper_model_name.empty() ) { Output << "sleepermodel " << m_sleeper_frequency << ' ' @@ -2546,10 +2527,7 @@ TTrack::texture_length( material_handle const Material ) { return fTexLength; } auto const texturelength { GfxRenderer->Material( Material )->GetSize().y }; - return ( - texturelength < 0.f ? - fTexLength : - texturelength ); + return texturelength < 0.f ? fTexLength : texturelength; } void TTrack::MovedUp1(float const dh) @@ -2561,17 +2539,17 @@ void TTrack::MovedUp1(float const dh) // ustawienie prędkości z ograniczeniem do pierwotnej wartości (zapisanej w scenerii) void TTrack::VelocitySet(float v) { // TBD, TODO: add a variable to preserve potential speed limit set by the track configuration on basic track pieces - if( ( SwitchExtension ) - && ( SwitchExtension->fVelocity != -1 ) ) { + if( SwitchExtension + && SwitchExtension->fVelocity != -1 ) { // zwrotnica może mieć odgórne ograniczenie, nieprzeskakiwalne eventem fVelocity = min_speed( v, - ( SwitchExtension->fVelocity > 0 ? + SwitchExtension->fVelocity > 0 ? SwitchExtension->fVelocity : // positive limit applies to both switch tracks - ( SwitchExtension->CurrentIndex == 0 ? + SwitchExtension->CurrentIndex == 0 ? -1 : // negative limit applies only to the diverging track - -SwitchExtension->fVelocity ) ) ); + -SwitchExtension->fVelocity ); } else { fVelocity = v; // nie ma ograniczenia @@ -2580,7 +2558,7 @@ void TTrack::VelocitySet(float v) { double TTrack::VelocityGet() { // pobranie dozwolonej prędkości podczas skanowania - return ((iDamageFlag & 128) ? 0.0 : fVelocity); // tor uszkodzony = prędkość zerowa + return iDamageFlag & 128 ? 0.0 : fVelocity; // tor uszkodzony = prędkość zerowa }; float TTrack::Friction() const { @@ -2616,14 +2594,8 @@ TTrack::DoubleSlip() const { // crude way to discern part of double slip switch: // a switch with name ending in _a or _b or _c or _d - return ( - ( iCategoryFlag == 1 ) - && ( eType == tt_Switch ) - && ( m_name.size() > 2 ) - && ( m_name.back() >= 'a' ) - && ( m_name.back() <= 'd' ) - && ( ( m_name[ m_name.size() - 2 ] == '_' ) - || ( m_name.rfind( '_' ) != std::string::npos ) ) ); + return iCategoryFlag == 1 && eType == tt_Switch && m_name.size() > 2 && m_name.back() >= 'a' && m_name.back() <= 'd' && + (m_name[m_name.size() - 2] == '_' || m_name.rfind('_') != std::string::npos); } @@ -2633,7 +2605,7 @@ TTrack * TTrack::Connected(int s, double &d) const TTrack *t; // nie zmieniamy kierunku (d), jeśli nie ma toru dalej if (eType != tt_Cross) { // jeszcze trzeba sprawdzić zgodność - t = (s > 0) ? trNext : trPrev; + t = s > 0 ? trNext : trPrev; if (t) // o ile jest na co przejść, zmieniamy znak kierunku na nowym torze if (t->eType == tt_Cross) { // jeśli wjazd na skrzyżowanie, trzeba ustalić segment, bo od tego zależy zmiana @@ -2644,33 +2616,33 @@ TTrack * TTrack::Connected(int s, double &d) const } else { - if ((s > 0) ? iNextDirection : !iPrevDirection) + if (s > 0 ? iNextDirection : !iPrevDirection) d = -d; // następuje zmiana kierunku wózka albo kierunku skanowania // s=((s>0)?iNextDirection:iPrevDirection)?-1:1; //kierunek toru po zmianie } - return (t); // zwrotnica ma odpowiednio ustawione (trNext) + return t; // zwrotnica ma odpowiednio ustawione (trNext) } - switch ((SwitchExtension->iRoads == 4) ? iEnds4[s + 6] : + switch (SwitchExtension->iRoads == 4 ? iEnds4[s + 6] : iEnds3[s + 6]) // numer końca 0..3, -1 to błąd { // zjazd ze skrzyżowania case 0: if (SwitchExtension->pPrevs[0]) - if ((s > 0) == SwitchExtension->iPrevDirection[0]) + if (s > 0 == SwitchExtension->iPrevDirection[0]) d = -d; return SwitchExtension->pPrevs[0]; case 1: if (SwitchExtension->pNexts[0]) - if ((s > 0) == SwitchExtension->iNextDirection[0]) + if (s > 0 == SwitchExtension->iNextDirection[0]) d = -d; return SwitchExtension->pNexts[0]; case 2: if (SwitchExtension->pPrevs[1]) - if ((s > 0) == SwitchExtension->iPrevDirection[1]) + if (s > 0 == SwitchExtension->iPrevDirection[1]) d = -d; return SwitchExtension->pPrevs[1]; case 3: if (SwitchExtension->pNexts[1]) - if ((s > 0) == SwitchExtension->iNextDirection[1]) + if (s > 0 == SwitchExtension->iNextDirection[1]) d = -d; return SwitchExtension->pNexts[1]; } @@ -2834,11 +2806,7 @@ TTrack::create_track_blade_profile( gfx::vertex_array &Right, gfx::vertex_array void TTrack::create_track_bed_profile( gfx::vertex_array &Output, TTrack const *Previous, TTrack const *Next ) { // geometry parameters - auto * profilesource = ( - eType != tt_Switch ? this : - Previous && Previous->eType != tt_Switch ? Previous : - Next && Next->eType != tt_Switch ? Next : - this ); + auto * profilesource = eType != tt_Switch ? this : Previous && Previous->eType != tt_Switch ? Previous : Next && Next->eType != tt_Switch ? Next : this; auto const texheight1 { profilesource->fTexHeight1 }; auto const texwidth { profilesource->fTexWidth }; @@ -2861,10 +2829,10 @@ TTrack::create_track_bed_profile( gfx::vertex_array &Output, TTrack const *Previ glm::vec3 normal2; float fHTW2, side2, slop2, rozp2, fTexHeight2, hypot2; - if( ( Next != nullptr ) - && ( Next->eType != tt_Switch ) - && ( ( iTrapezoid & 2 ) // ten bit oznacza, że istnieje odpowiednie pNext - || ( eType == tt_Switch ) ) ) { + if( Next != nullptr + && Next->eType != tt_Switch + && ( iTrapezoid & 2 // ten bit oznacza, że istnieje odpowiednie pNext + || eType == tt_Switch ) ) { fHTW2 = 0.5f * std::abs(Next->fTrackWidth); // połowa rozstawu/nawierzchni side2 = std::abs(Next->fTexWidth); slop2 = std::abs(Next->fTexSlope); // nie jest używane później @@ -2905,7 +2873,7 @@ TTrack::create_track_bed_profile( gfx::vertex_array &Output, TTrack const *Previ cos2 { std::cos( roll2 ) }; // profile - auto const transition { ( iTrapezoid != 0 ) || ( eType == tt_Switch ) }; + auto const transition { iTrapezoid != 0 || eType == tt_Switch }; auto const pointcount { transition ? 10 : 5 }; Output.resize( pointcount ); // potentially retrieve texture length override from the assigned material @@ -3081,7 +3049,7 @@ TTrack::create_road_profile( gfx::vertex_array &Output, bool const Forcetransiti auto const map1 = max > 0.f ? fHTW / max : 0.5f; // obcięcie tekstury od strony 1 auto const map2 = max > 0.f ? fHTW2 / max : 0.5f; // obcięcie tekstury od strony 2 - auto const transition { ( true == Forcetransition ) || ( iTrapezoid != 0 ) }; + auto const transition { true == Forcetransition || iTrapezoid != 0 }; auto const pointcount{ transition ? 4 : 2 }; Output.resize( pointcount ); @@ -3156,7 +3124,7 @@ TTrack::create_road_side_profile( gfx::vertex_array &Right, gfx::vertex_array &L auto const texturelength{ texture_length( m_material2 ) }; - auto const transition { ( true == Forcetransition ) || ( iTrapezoid != 0 ) }; + auto const transition { true == Forcetransition || iTrapezoid != 0 }; auto const pointcount{ transition ? 6 : 3 }; Right.resize( pointcount ); @@ -3221,22 +3189,10 @@ TTrack::create_road_side_profile( gfx::vertex_array &Right, gfx::vertex_array &L // krawężnik jest mapowany od 31/64 do 32/64 lewy i od 32/64 do 33/64 prawy auto const d = -fTexHeight1 / 3.75f; // krawężnik o wysokości 150mm jest pochylony 40mm auto const max = fTexRatio2 * texturelength; // test: szerokość proporcjonalna do długości - auto const map1l = ( - max > 0.f ? - side / max : - 0.484375f ); // obcięcie tekstury od lewej strony punktu 1 - auto const map1r = ( - max > 0.f ? - slop / max : - 0.484375f ); // obcięcie tekstury od prawej strony punktu 1 - auto const h1r = ( - slop > d ? - -fTexHeight1 : - 0.f ); - auto const h1l = ( - side > d ? - -fTexHeight1 : - 0.f ); + auto const map1l = max > 0.f ? side / max : 0.484375f; // obcięcie tekstury od lewej strony punktu 1 + auto const map1r = max > 0.f ? slop / max : 0.484375f; // obcięcie tekstury od prawej strony punktu 1 + auto const h1r = slop > d ? -fTexHeight1 : 0.f; + auto const h1l = side > d ? -fTexHeight1 : 0.f; Right[ 0 ] = { {Road[ 0 ].position.x + slop, Road[ 0 ].position.y + h1r, 0.f}, @@ -3265,26 +3221,11 @@ TTrack::create_road_side_profile( gfx::vertex_array &Right, gfx::vertex_array &L if( transition ) { // pobocza do trapezowatej nawierzchni - dodatkowe punkty z drugiej strony odcinka - slop2 = ( - std::fabs( ( iTrapezoid & 2 ) ? - slop2 : - slop ) ); // szerokość chodnika po prawej - auto const map2l = ( - max > 0.f ? - side2 / max : - 0.484375f ); // obcięcie tekstury od lewej strony punktu 2 - auto const map2r = ( - max > 0.f ? - slop2 / max : - 0.484375f ); // obcięcie tekstury od prawej strony punktu 2 - auto const h2r = ( - slop2 > d ? - -fTexHeight2 : - 0.f ); - auto const h2l = ( - side2 > d ? - -fTexHeight2 : - 0.f ); + slop2 = std::fabs(iTrapezoid & 2 ? slop2 : slop); // szerokość chodnika po prawej + auto const map2l = max > 0.f ? side2 / max : 0.484375f; // obcięcie tekstury od lewej strony punktu 2 + auto const map2r = max > 0.f ? slop2 / max : 0.484375f; // obcięcie tekstury od prawej strony punktu 2 + auto const h2r = slop2 > d ? -fTexHeight2 : 0.f; + auto const h2l = side2 > d ? -fTexHeight2 : 0.f; Right[ 3 ] = { {Road[ 2 ].position.x + slop2, Road[ 2 ].position.y + h2r, 0.f}, @@ -3317,14 +3258,12 @@ TTrack::create_road_side_profile( gfx::vertex_array &Right, gfx::vertex_array &L void TTrack::create_switch_trackbed( gfx::vertex_array &Output ) { // try to get trackbed material from a regular track connected to the primary path - if( ( SwitchExtension->m_material3 == null_handle ) - && ( trPrev != nullptr ) - && ( trPrev->eType == tt_Normal ) ) { + if( SwitchExtension->m_material3 == null_handle && trPrev != nullptr + && trPrev->eType == tt_Normal ) { SwitchExtension->m_material3 = trPrev->m_material2; } - if( ( SwitchExtension->m_material3 == null_handle ) - && ( trNext != nullptr ) - && ( trNext->eType == tt_Normal ) ) { + if( SwitchExtension->m_material3 == null_handle && trNext != nullptr + && trNext->eType == tt_Normal ) { SwitchExtension->m_material3 = trNext->m_material2; } // without material don't bother @@ -3429,7 +3368,7 @@ TTrack::copy_adjacent_trackbed_material( TTrack const *Exclude ) { } for( auto *adjacent : adjacents ) { - if( ( adjacent != nullptr ) && ( adjacent != Exclude ) ) { + if( adjacent != nullptr && adjacent != Exclude ) { material = adjacent->copy_adjacent_trackbed_material( this ); if( material != null_handle ) { break; } // got what we wanted } @@ -3574,8 +3513,8 @@ path_table::InitTracks() { } } // switch - if( ( trackname[ 0 ] == '*' ) - && ( !track->CurrentPrev() && track->CurrentNext() ) ) { + if( trackname[0] == '*' + && !track->CurrentPrev() && track->CurrentNext() ) { // możliwy portal, jeśli nie podłączony od strony 1 // ustawienie flagi portalu track->iCategoryFlag |= 0x100; @@ -3642,8 +3581,8 @@ void path_table::TrackBusyList() const { // wysłanie informacji o wszystkich zajętych odcinkach for( auto const *path : m_items ) { - if( ( false == path->name().empty() ) // musi być nazwa - && ( false == path->Dynamics.empty() ) ) { + if( false == path->name().empty() // musi być nazwa + && false == path->Dynamics.empty() ) { // zajęty multiplayer::WyslijString( path->name(), 8 ); } @@ -3753,7 +3692,7 @@ void TTrack::build_sleeper_transforms() return; } // resolve replacable skin (optional) - if( ( false == m_sleeper_skin_name.empty() ) && ( m_sleeper_skin_name != "none" ) ) { + if( false == m_sleeper_skin_name.empty() && m_sleeper_skin_name != "none" ) { auto skinpath { m_sleeper_skin_name }; replace_slashes( skinpath ); m_sleeper_skin = GfxRenderer->Fetch_Material( skinpath ); diff --git a/world/Track.h b/world/Track.h index 6c544203..9bf38e0a 100644 --- a/world/Track.h +++ b/world/Track.h @@ -115,15 +115,15 @@ public: inline bool Busy() { - return (iAxles > 0); }; + return iAxles > 0; }; inline static TIsolated * Root() { - return (pRoot); }; + return pRoot; }; inline TIsolated * Next() { - return (pNext); }; + return pNext; }; inline void parent( TIsolated *Parent ) { @@ -270,19 +270,13 @@ public: bool SwitchForced(int i, TDynamicObject *o); int CrossSegment(int from, int into); inline int GetSwitchState() { - return ( - SwitchExtension ? - SwitchExtension->CurrentIndex : - -1); }; + return SwitchExtension ? SwitchExtension->CurrentIndex : -1; }; // returns number of different routes possible to take from given point // TODO: specify entry point, number of routes for switches can vary inline int RouteCount() const { - return ( - SwitchExtension != nullptr ? - SwitchExtension->iRoads - 1 : - 1 ); } + return SwitchExtension != nullptr ? SwitchExtension->iRoads - 1 : 1; } void Load(cParser *parser, glm::dvec3 const &pOrigin); bool AssignEvents(); bool AssignForcedEvents(basic_event *NewEventPlus, basic_event *NewEventMinus); diff --git a/world/Traction.cpp b/world/Traction.cpp index d660ac02..ef0c85bd 100644 --- a/world/Traction.cpp +++ b/world/Traction.cpp @@ -131,15 +131,12 @@ TTraction::Load( cParser *parser, glm::dvec3 const &pOrigin ) { auto const minheight { parser->getToken() }; fHeightDifference = ( pPoint3.y - pPoint1.y + pPoint4.y - pPoint2.y ) * 0.5 - minheight; auto const segmentlength { parser->getToken() }; - iNumSections = ( - segmentlength ? - glm::length( ( pPoint1 - pPoint2 ) ) / segmentlength : - 0 ); + iNumSections = segmentlength ? glm::length(pPoint1 - pPoint2) / segmentlength : 0; parser->getTokens( 2 ); *parser >> Wires >> WireOffset; - m_visible = ( parser->getToken() == "vis" ); + m_visible = parser->getToken() == "vis"; std::string token { parser->getToken() }; if( token == "parallel" ) { @@ -147,8 +144,8 @@ TTraction::Load( cParser *parser, glm::dvec3 const &pOrigin ) { parser->getTokens(); *parser >> asParallel; } - while( ( false == token.empty() ) - && ( token != "endtraction" ) ) { + while( false == token.empty() + && token != "endtraction" ) { token = parser->getToken(); } @@ -210,10 +207,10 @@ TTraction::create_geometry( gfx::geometrybank_handle const &Bank ) { pPoint3.z - m_origin.z ); for( int i = 0; i < iNumSections - 1; ++i ) { pt3 = pPoint3 + v1 * f; - t = ( 1 - std::fabs( f - mid ) * 2 ); - if( ( Wires < 4 ) - || ( ( i != 0 ) - && ( i != iNumSections - 2 ) ) ) { + t = 1 - std::fabs(f - mid) * 2; + if( Wires < 4 + || ( i != 0 + && i != iNumSections - 2 ) ) { endvertex.position = glm::vec3( pt3.x - m_origin.x, @@ -259,13 +256,12 @@ TTraction::create_geometry( gfx::geometrybank_handle const &Bank ) { pPoint3.z - m_origin.z ); for( int i = 0; i < iNumSections - 1; ++i ) { pt3 = pPoint3 + v1 * f; - t = ( 1 - std::fabs( f - mid ) * 2 ); + t = 1 - std::fabs(f - mid) * 2; endvertex.position = glm::vec3( pt3.x - m_origin.x, pt3.y - std::sqrt( t ) * fHeightDifference - ( - ( ( i == 0 ) - || ( i == iNumSections - 2 ) ) ? + i == 0 || i == iNumSections - 2 ? 0.25f * fHeightDifference : 0.05 ) - m_origin.y, @@ -292,12 +288,12 @@ TTraction::create_geometry( gfx::geometrybank_handle const &Bank ) { for( int i = 0; i < iNumSections - 1; ++i ) { pt3 = pPoint3 + v1 * f; pt4 = pPoint1 + v2 * f; - t = ( 1 - std::fabs( f - mid ) * 2 ); - if( ( i % 2 ) == 0 ) { + t = 1 - std::fabs(f - mid) * 2; + if( i % 2 == 0 ) { startvertex.position = glm::vec3( pt3.x - m_origin.x, - pt3.y - std::sqrt( t ) * fHeightDifference - ( ( i == 0 ) || ( i == iNumSections - 2 ) ? flo : flo1 ) - m_origin.y, + pt3.y - std::sqrt( t ) * fHeightDifference - ( i == 0 || i == iNumSections - 2 ? flo : flo1 ) - m_origin.y, pt3.z - m_origin.z ); endvertex.position = glm::vec3( @@ -311,7 +307,7 @@ TTraction::create_geometry( gfx::geometrybank_handle const &Bank ) { startvertex.position = glm::vec3( pt3.x - m_origin.x, - pt3.y - std::sqrt( t ) * fHeightDifference - ( ( i == 0 ) || ( i == iNumSections - 2 ) ? flo : flo1 ) - m_origin.y, + pt3.y - std::sqrt( t ) * fHeightDifference - ( i == 0 || i == iNumSections - 2 ? flo : flo1 ) - m_origin.y, pt3.z - m_origin.z ); endvertex.position = glm::vec3( @@ -321,9 +317,7 @@ TTraction::create_geometry( gfx::geometrybank_handle const &Bank ) { vertices.emplace_back( startvertex ); vertices.emplace_back( endvertex ); } - if( ( ( Wires == 4 ) - && ( ( i == 1 ) - || ( i == iNumSections - 3 ) ) ) ) { + if( Wires == 4 && (i == 1 || i == iNumSections - 3) ) { startvertex.position = glm::vec3( pt3.x - m_origin.x, @@ -351,12 +345,12 @@ TTraction::create_geometry( gfx::geometrybank_handle const &Bank ) { int TTraction::TestPoint(glm::dvec3 const &Point) { // sprawdzanie, czy przęsła można połączyć - if( ( hvNext[ 0 ] == nullptr ) - && ( glm::all( glm::epsilonEqual( Point, pPoint1, 0.025 ) ) ) ) { + if( hvNext[0] == nullptr + && glm::all(glm::epsilonEqual(Point, pPoint1, 0.025)) ) { return 0; } - if( ( hvNext[ 1 ] == nullptr ) - && ( glm::all( glm::epsilonEqual( Point, pPoint2, 0.025 ) ) ) ) { + if( hvNext[1] == nullptr + && glm::all(glm::epsilonEqual(Point, pPoint2, 0.025)) ) { return 1; } return -1; @@ -369,8 +363,8 @@ TTraction::Connect(int my, TTraction *with, int to) { hvNext[ my ] = with; iNext[ my ] = to; - if( ( hvNext[ 0 ] != nullptr ) - && ( hvNext[ 1 ] != nullptr ) ) { + if( hvNext[0] != nullptr + && hvNext[1] != nullptr ) { // jeśli z obu stron podłączony to nie jest ostatnim iLast = 0; } @@ -380,8 +374,8 @@ TTraction::Connect(int my, TTraction *with, int to) { with->hvNext[ to ] = this; with->iNext[ to ] = my; - if( ( with->hvNext[ 0 ] != nullptr ) - && ( with->hvNext[ 1 ] != nullptr ) ) { + if( with->hvNext[0] != nullptr + && with->hvNext[1] != nullptr ) { // temu też, bo drugi raz łączenie się nie nie wykona with->iLast = 0; } @@ -392,7 +386,7 @@ bool TTraction::WhereIs() { if( iLast ) { // ma już ustaloną informację o położeniu - return ( iLast & 1 ); + return iLast & 1; } for( int endindex = 0; endindex < 2; ++endindex ) { if( hvNext[ endindex ] == nullptr ) { @@ -404,7 +398,7 @@ bool TTraction::WhereIs() { iLast |= 2; } } - return (iLast & 1); // ostatnie będą dostawać zasilanie + return iLast & 1; // ostatnie będą dostawać zasilanie } void TTraction::Init() @@ -423,8 +417,8 @@ void TTraction::ResistanceCalc(int d, double r, TTractionPowerSource *ps) ps = psPower[d ^ 1]; // zasilacz od przeciwnej strony niż idzie analiza d = iNext[d]; // kierunek PowerState = 4; - while( ( t != nullptr ) - && ( t->psPower[d] == nullptr ) ) // jeśli jest jakiś kolejny i nie ma ustalonego zasilacza + while( t != nullptr + && t->psPower[d] == nullptr ) // jeśli jest jakiś kolejny i nie ma ustalonego zasilacza { // ustawienie zasilacza i policzenie rezystancji zastępczej if( t->PowerState != 4 ) { // przęsła zasilającego nie modyfikować @@ -480,16 +474,10 @@ double TTraction::VoltageGet(double u, double i) // 1. zasilacz psPower[0] z rezystancją fResistance[0] oraz jego wewnętrzną // 2. zasilacz psPower[1] z rezystancją fResistance[1] oraz jego wewnętrzną // 3. zasilacz psPowered z jego wewnętrzną rezystancją dla przęseł zasilanych bezpośrednio - double res = ( - (i != 0.0) ? - (u / i) : - 10000.0 ); + double res = i != 0.0 ? u / i : 10000.0; if( psPowered != nullptr ) { // yB: dla zasilanego nie baw się w gwiazdy, tylko bierz bezpośrednio - return ( - ( res != 0.0 ) ? - psPowered->CurrentGet( res ) * res : - 0.0 ); + return res != 0.0 ? psPowered->CurrentGet(res) * res : 0.0; } if( ( psPower[0] && psPower[0]->Fuse() ) || ( psPower[1] && psPower[1]->Fuse() ) ) { @@ -506,10 +494,10 @@ double TTraction::VoltageGet(double u, double i) // yB: Gdy wywali podstacja, to zaczyna się robić nieciekawie - napięcie w sekcji na jednym końcu jest równe zasilaniu, // yB: a na drugim końcu jest równe 0. Kolejna sprawa to rozróżnienie uszynienia sieci na podstacji/odłączniku (czyli // yB: potencjał masy na sieci) od braku zasilania (czyli odłączenie źródła od sieci i brak jego wpływu na napięcie). - if ((r0t > 0.0) && (r1t > 0.0)) + if (r0t > 0.0 && r1t > 0.0) { // rezystancje w mianowniku nie mogą być zerowe - r0g = res + r0t + (res * r0t) / r1t; // przeliczenie z trójkąta na gwiazdę - r1g = res + r1t + (res * r1t) / r0t; + r0g = res + r0t + res * r0t / r1t; // przeliczenie z trójkąta na gwiazdę + r1g = res + r1t + res * r1t / r0t; // pobierane są prądy dla każdej rezystancji, a suma jest mnożona przez rezystancję // pojazdu w celu uzyskania napięcia i0 = psPower[0]->CurrentGet(r0g); // oddzielnie dla sprawdzenia @@ -523,11 +511,11 @@ double TTraction::VoltageGet(double u, double i) else return 0.0; // co z tym zrobić? } - else if (psPower[0] && (r0t >= 0.0)) + else if (psPower[0] && r0t >= 0.0) { // jeśli odcinek podłączony jest tylko z jednej strony return psPower[0]->CurrentGet(res + r0t) * res; } - else if (psPower[1] && (r1t >= 0.0)) + else if (psPower[1] && r1t >= 0.0) return psPower[1]->CurrentGet(res + r1t) * res; return 0.0; // gdy nie podłączony wcale? }; @@ -596,10 +584,7 @@ TTraction::wire_color() const { } case 4: { // white for powered, red for ends - color = ( - psPowered != nullptr ? - glm::vec3{ 239.f / 255.f, 239.f / 255.f, 239.f / 255.f } : - glm::vec3{ 239.f / 255.f, 128.f / 255.f, 128.f / 255.f } ); + color = psPowered != nullptr ? glm::vec3{239.f / 255.f, 239.f / 255.f, 239.f / 255.f} : glm::vec3{239.f / 255.f, 128.f / 255.f, 128.f / 255.f}; break; } default: { break; } @@ -709,8 +694,8 @@ traction_table::InitTraction() { traction->PowerSet( powersource ); } else { - if( ( traction->asPowerSupplyName != "*" ) // gwiazdka dla przęsła z izolatorem - && ( traction->asPowerSupplyName != "none" ) ) { // dopuszczamy na razie brak podłączenia? + if( traction->asPowerSupplyName != "*" // gwiazdka dla przęsła z izolatorem + && traction->asPowerSupplyName != "none" ) { // dopuszczamy na razie brak podłączenia? // logowanie błędu i utworzenie zasilacza o domyślnej zawartości ErrorLog( "Bad scenario: traction piece connected to nonexistent power source \"" + traction->asPowerSupplyName + "\"" ); scene::node_data nodedata; @@ -746,19 +731,19 @@ traction_table::InitTraction() { } if( traction->hvNext[ 0 ] ) { // jeśli został podłączony - if( ( traction->psSection != nullptr ) - && ( matchingtraction->psSection != nullptr ) ) { + if( traction->psSection != nullptr + && matchingtraction->psSection != nullptr ) { // tylko przęsło z izolatorem może nie mieć zasilania, bo ma 2, trzeba sprawdzać sąsiednie if( traction->psSection != matchingtraction->psSection ) { // połączone odcinki mają różne zasilacze // to może być albo podłączenie podstacji lub kabiny sekcyjnej do sekcji, albo błąd - if( ( true == traction->psSection->bSection ) - && ( false == matchingtraction->psSection->bSection ) ) { + if( true == traction->psSection->bSection + && false == matchingtraction->psSection->bSection ) { //(tmp->psSection) jest podstacją, a (Traction->psSection) nazwą sekcji matchingtraction->PowerSet( traction->psSection ); // zastąpienie wskazaniem sekcji } - else if( ( false == traction->psSection->bSection ) - && ( true == matchingtraction->psSection->bSection ) ) { + else if( false == traction->psSection->bSection + && true == matchingtraction->psSection->bSection ) { //(Traction->psSection) jest podstacją, a (tmp->psSection) nazwą sekcji traction->PowerSet( matchingtraction->psSection ); // zastąpienie wskazaniem sekcji } @@ -785,18 +770,18 @@ traction_table::InitTraction() { } if( traction->hvNext[ 1 ] ) { // jeśli został podłączony - if( ( traction->psSection != nullptr ) - && ( matchingtraction->psSection != nullptr ) ) { + if( traction->psSection != nullptr + && matchingtraction->psSection != nullptr ) { // tylko przęsło z izolatorem może nie mieć zasilania, bo ma 2, trzeba sprawdzać sąsiednie if( traction->psSection != matchingtraction->psSection ) { // to może być albo podłączenie podstacji lub kabiny sekcyjnej do sekcji, albo błąd - if( ( true == traction->psSection->bSection ) - && ( false == matchingtraction->psSection->bSection ) ) { + if( true == traction->psSection->bSection + && false == matchingtraction->psSection->bSection ) { //(tmp->psSection) jest podstacją, a (Traction->psSection) nazwą sekcji matchingtraction->PowerSet( traction->psSection ); // zastąpienie wskazaniem sekcji } - else if( ( false == traction->psSection->bSection ) - && ( true == matchingtraction->psSection->bSection ) ) { + else if( false == traction->psSection->bSection + && true == matchingtraction->psSection->bSection ) { //(Traction->psSection) jest podstacją, a (tmp->psSection) nazwą sekcji traction->PowerSet( matchingtraction->psSection ); // zastąpienie wskazaniem sekcji } @@ -830,8 +815,8 @@ traction_table::InitTraction() { //łączenie bieżni wspólnych, w tym oznaczanie niepodanych jawnie if( false == traction->asParallel.empty() ) { // będzie wskaźnik na inne przęsło - if( ( traction->asParallel == "none" ) - || ( traction->asParallel == "*" ) ) { + if( traction->asParallel == "none" + || traction->asParallel == "*" ) { // jeśli nieokreślone traction->iLast |= 2; // jakby przedostatni - niech po prostu szuka (iLast już przeliczone) } diff --git a/world/TractionPower.cpp b/world/TractionPower.cpp index bb7862c0..7d816e21 100644 --- a/world/TractionPower.cpp +++ b/world/TractionPower.cpp @@ -56,8 +56,8 @@ bool TTractionPowerSource::Load(cParser *parser) { bSection = true; } // skip rest of the section - while( ( false == token.empty() ) - && ( token != "end" ) ) { + while( false == token.empty() + && token != "end" ) { token = parser->getToken(); } @@ -123,10 +123,10 @@ double TTractionPowerSource::CurrentGet(double res) FuseTimer = 0; return 0; } - if ((res > 0) || ((res < 0) && (Recuperation || true))) + if (res > 0 || (res < 0 && (Recuperation || true))) TotalAdmitance += 1.0 / res; // połączenie równoległe rezystancji jest równoważne sumie admitancji - float NomVolt = (TotalPreviousAdmitance < 0 ? NominalVoltage * 1.083 : NominalVoltage); - TotalCurrent = (TotalPreviousAdmitance != 0.0) ? + float NomVolt = TotalPreviousAdmitance < 0 ? NominalVoltage * 1.083 : NominalVoltage; + TotalCurrent = TotalPreviousAdmitance != 0.0 ? NomVolt / (InternalRes + 1.0 / TotalPreviousAdmitance) : 0.0; // napięcie dzielone przez sumę rezystancji wewnętrznej i obciążenia OutputVoltage = NomVolt - InternalRes * TotalCurrent; // napięcie na obciążeniu diff --git a/world/TractionPower.h b/world/TractionPower.h index d84b6b81..d1faa037 100644 --- a/world/TractionPower.h +++ b/world/TractionPower.h @@ -29,7 +29,7 @@ public: NominalVoltage = v; }; void PowerSet(TTractionPowerSource *ps); bool Fuse() const { - return ( FastFuse || SlowFuse ); } + return FastFuse || SlowFuse; } // members TTractionPowerSource *psNode[ 2 ] = { nullptr, nullptr }; // zasilanie na końcach dla sekcji bool bSection = false; // czy jest sekcją diff --git a/world/TrkFoll.cpp b/world/TrkFoll.cpp index 5d8a8757..b1884896 100644 --- a/world/TrkFoll.cpp +++ b/world/TrkFoll.cpp @@ -33,7 +33,7 @@ bool TTrackFollower::Init(TTrack *pTrack, TDynamicObject *NewOwner, double fDir) SetCurrentTrack(pTrack, 0); iEventFlag = 3; // na torze startowym również wykonać eventy 1/2 iEventallFlag = 3; - if ((pCurrentSegment)) // && (pCurrentSegment->GetLength()GetLength()iNextDirection : pCurrentTrack->iPrevDirection); + int i = end ? pCurrentTrack->iNextDirection : pCurrentTrack->iPrevDirection; if (i > 0) // jeżeli wjazd z ostrza pTrack->SwitchForced(i >> 1, Owner); // to przełożenie zwrotnicy - rozprucie! } @@ -91,7 +91,7 @@ TTrack * TTrackFollower::SetCurrentTrack(TTrack *pTrack, int end) pCurrentTrack->AxleCounter(-1, Owner); // opuszczenie tamtego toru } pCurrentTrack = pTrack; - pCurrentSegment = ( pCurrentTrack != nullptr ? pCurrentTrack->CurrentSegment() : nullptr ); + pCurrentSegment = pCurrentTrack != nullptr ? pCurrentTrack->CurrentSegment() : nullptr; if (!pCurrentTrack) Error(Owner->MoverParameters->Name + " at NULL track"); return pCurrentTrack; @@ -121,19 +121,19 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary) if( false == ismoving ) { //McZapkie-140602: wyzwalanie zdarzenia gdy pojazd stoi - if( ( Owner->Mechanik != nullptr ) - && ( Owner->Mechanik->primary() ) ) { + if( Owner->Mechanik != nullptr + && Owner->Mechanik->primary() ) { // tylko dla jednego członu pCurrentTrack->QueueEvents( pCurrentTrack->m_events0, Owner ); } pCurrentTrack->QueueEvents( pCurrentTrack->m_events0all, Owner ); } - else if( (fDistance < 0) && ( eventfilter < 0 ) ) { + else if( fDistance < 0 && eventfilter < 0 ) { // event1, eventall1 if( SetFlag( iEventFlag, -1 ) ) { // zawsze zeruje flagę sprawdzenia, jak mechanik dosiądzie, to się nie wykona - if( ( Owner->Mechanik != nullptr ) - && ( Owner->Mechanik->primary() ) ) { + if( Owner->Mechanik != nullptr + && Owner->Mechanik->primary() ) { // tylko dla jednego członu // McZapkie-280503: wyzwalanie event tylko dla pojazdow z obsada pCurrentTrack->QueueEvents( pCurrentTrack->m_events1, Owner ); @@ -144,12 +144,12 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary) pCurrentTrack->QueueEvents( pCurrentTrack->m_events1all, Owner ); } } - else if( ( fDistance > 0 ) && ( eventfilter > 0 ) ) { + else if( fDistance > 0 && eventfilter > 0 ) { // event2, eventall2 if( SetFlag( iEventFlag, -2 ) ) { // zawsze ustawia flagę sprawdzenia, jak mechanik dosiądzie, to się nie wykona - if( ( Owner->Mechanik != nullptr ) - && ( Owner->Mechanik->primary() ) ) { + if( Owner->Mechanik != nullptr + && Owner->Mechanik->primary() ) { // tylko dla jednego członu pCurrentTrack->QueueEvents( pCurrentTrack->m_events2, Owner ); } @@ -181,7 +181,7 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary) */ if (s < 0) { // jeśli przekroczenie toru od strony Point1 - bCanSkip = ( bPrimary && pCurrentTrack->CheckDynamicObject( Owner ) ); + bCanSkip = bPrimary && pCurrentTrack->CheckDynamicObject(Owner); if( bCanSkip ) { // tylko główna oś przenosi pojazd do innego toru // zdejmujemy pojazd z dotychczasowego toru @@ -217,7 +217,7 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary) } else if (s > pCurrentSegment->GetLength()) { // jeśli przekroczenie toru od strony Point2 - bCanSkip = ( bPrimary && pCurrentTrack->CheckDynamicObject( Owner ) ); + bCanSkip = bPrimary && pCurrentTrack->CheckDynamicObject(Owner); if (bCanSkip) // tylko główna oś przenosi pojazd do innego toru Owner->MyTrack->RemoveDynamicObject(Owner); // zdejmujemy pojazd z dotychczasowego toru fDistance = s - pCurrentSegment->GetLength(); @@ -274,7 +274,7 @@ bool TTrackFollower::ComputatePosition() vAngles.x = -vAngles.x; // przechyłka jest w przecinwą stronę vAngles.y = -vAngles.y; // pochylenie jest w przecinwą stronę vAngles.z += - (vAngles.z >= M_PI) ? -M_PI : M_PI; // ale kierunek w planie jest obrócony o 180° + vAngles.z >= M_PI ? -M_PI : M_PI; // ale kierunek w planie jest obrócony o 180° } if (fOffsetH != 0.0) { // jeśli przesunięcie względem osi toru, to je doliczyć diff --git a/world/mtable.cpp b/world/mtable.cpp index 24a19336..cec54f87 100644 --- a/world/mtable.cpp +++ b/world/mtable.cpp @@ -16,7 +16,7 @@ http://mozilla.org/MPL/2.0/. double TTrainParameters::CheckTrainLatency() { - if ((LastStationLatency > 1.0) || (LastStationLatency < 0)) + if (LastStationLatency > 1.0 || LastStationLatency < 0) return LastStationLatency; /*spoznienie + lub do przodu - z tolerancja 1 min*/ else return 0; @@ -66,7 +66,7 @@ TTrainParameters::last_stop_sound() const { bool TTrainParameters::IsStop() const { // zapytanie, czy zatrzymywać na następnym punkcie rozkładu - if ((StationIndex <= StationCount)) + if (StationIndex <= StationCount) return TimeTable[StationIndex].Ah >= 0; //-1 to brak postoju else return true; // na ostatnim się zatrzymać zawsze @@ -74,19 +74,19 @@ bool TTrainParameters::IsStop() const bool TTrainParameters::IsLastStop() const { - return ( StationIndex >= StationCount ); + return StationIndex >= StationCount; } bool TTrainParameters::IsMaintenance() const { - if( ( StationIndex <= StationCount ) ) + if( StationIndex <= StationCount ) return TimeTable[ StationIndex ].is_maintenance; else return false; } int TTrainParameters::radio_channel() const { - if( ( StationIndex <= StationCount ) ) + if( StationIndex <= StationCount ) return TimeTable[ StationIndex ].radio_channel; else return -1; @@ -94,7 +94,7 @@ int TTrainParameters::radio_channel() const { // returns: sound file associated with current station, or -1 sound_source TTrainParameters::current_stop_sound() const { - if( ( StationIndex <= StationCount ) ) + if( StationIndex <= StationCount ) return TimeTable[ StationIndex ].name_sound; else return { sound_placement::engine }; @@ -167,11 +167,11 @@ bool TTrainParameters::IsTimeToGo(double hh, double mm) // sprawdzenie, czy można już odjechać z aktualnego zatrzymania // StationIndex to numer następnego po dodarciu do aktualnego { - if ((StationIndex < 1)) + if (StationIndex < 1) return true; // przed pierwszą jechać - else if ((StationIndex < StationCount)) + else if (StationIndex < StationCount) { // oprócz ostatniego przystanku - if ((TimeTable[StationIndex].Ah < 0)) // odjazd z poprzedniego + if (TimeTable[StationIndex].Ah < 0) // odjazd z poprzedniego return true; // czas przyjazdu nie był podany - przelot else return CompareTime(hh, mm, TimeTable[StationIndex].Dh, TimeTable[StationIndex].Dm) <= 0; @@ -183,17 +183,17 @@ bool TTrainParameters::IsTimeToGo(double hh, double mm) // returns: difference between specified time and scheduled departure from current stop, in seconds double TTrainParameters::seconds_until_departure( double const Hour, double const Minute ) const { - if( ( TimeTable[ StationStart ].Ah < 0 ) ) { // passthrough + if( TimeTable[StationStart].Ah < 0 ) { // passthrough return 0; } - return ( 60.0 * CompareTime( Hour, Minute, TimeTable[ StationStart ].Dh, TimeTable[ StationStart ].Dm ) ); + return 60.0 * CompareTime(Hour, Minute, TimeTable[StationStart].Dh, TimeTable[StationStart].Dm); } std::string TTrainParameters::ShowRelation() const /*zwraca informację o relacji*/ { // if (Relation1=TimeTable[1].StationName) and (Relation2=TimeTable[StationCount].StationName) - if ((Relation1 != "") && (Relation2 != "")) + if (Relation1 != "" && Relation2 != "") return Relation1 + " - " + Relation2; else return ""; @@ -233,7 +233,7 @@ void TTrainParameters::UpdateVelocity(int StationCount, double vActual) { int i = StationCount; // TTVmax:=vActual; {PROWIZORKA!!!} - while ((i >= 0) && (TimeTable[i].vmax == -1)) + while (i >= 0 && TimeTable[i].vmax == -1) { TimeTable[i].vmax = vActual; // prędkość dojazdu do przystanku i --i; // ewentualnie do poprzedniego też @@ -256,7 +256,7 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax) int ConversionError = 0; EndTable = false; - if ((TrainName == "")) + if (TrainName == "") { // jeśli pusty rozkład // UpdateVelocity(StationCount,vMax); //ograniczenie do prędkości startowej } @@ -274,7 +274,7 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax) if (!fin.is_open()) { // jeśli nie ma pliku vmax = atoi(TrainName.c_str()); // nie ma pliku ale jest liczba - if ((vmax > 10) && (vmax < 200)) + if (vmax > 10 && vmax < 200) { TTVmax = vmax; // Ra 2014-07: zamiast rozkładu można podać Vmax UpdateVelocity(StationCount, vmax); // ograniczenie do prędkości startowej @@ -286,7 +286,7 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax) else { /*analiza rozkładu jazdy*/ ConversionError = 0; - while (fin.good() && !((ConversionError != 0) || EndTable)) + while (fin.good() && !(ConversionError != 0 || EndTable)) { std::getline(fin, lines); /*wczytanie linii*/ if (contains( lines, "___________________") ) /*linia pozioma górna*/ @@ -299,7 +299,7 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax) do { fin >> s; - } while (!(s == "|") || (fin.eof())); /*środkowy pion*/ + } while (!(s == "|") || fin.eof()); /*środkowy pion*/ } } else if (lines == "") @@ -323,7 +323,7 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax) do { fin >> s; - } while (!((s == "|") || (fin.bad()))); + } while (!(s == "|" || fin.bad())); fin >> TrainCategory; continue; } @@ -332,7 +332,7 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax) do { fin >> s; - } while (!((s == "|") || (fin.bad()))); + } while (!(s == "|" || fin.bad())); fin >> TrainLabel; continue; } @@ -375,7 +375,7 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax) } // while (!(); while (fin >> s || !fin.bad()) { - if ((s == "|") || (s == "\n")) + if (s == "|" || s == "\n") break; } // while (!()); fin >> s; @@ -389,7 +389,7 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax) do { fin >> s; - } while (!((s == "|") || (fin.bad()))); + } while (!(s == "|" || fin.bad())); fin >> LocSeries; fin >> LocLoad; // = s2rE(ReadWord(fin)); do @@ -403,7 +403,7 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax) do { fin >> s; - } while (!((s == "[") || (fin.bad()))); + } while (!(s == "[" || fin.bad())); TMTableLine *record = &TimeTable[StationCount]; { if (s == "[") @@ -431,7 +431,7 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax) do { fin >> s; - } while (!((s == "1") || (s == "2") || fin.bad())); + } while (!(s == "1" || s == "2" || fin.bad())); record->TrackNo = atoi(s.c_str()); fin >> s; if (s != "|") @@ -450,13 +450,13 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax) do { fin >> s; - } while (!((s != "|") || (fin.bad()))); + } while (!(s != "|" || fin.bad())); if (s != "]") record->tm = atof(s.c_str()); do { fin >> s; - } while (!((s == "[") || fin.bad())); + } while (!(s == "[" || fin.bad())); fin >> s; if (false == contains(s,"|")) { @@ -476,14 +476,14 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax) fin >> s; // stationware. added fix for empty entry fin >> s; - while( false == ( ( s == "1" ) - || ( s == "2" ) + while( false == ( s == "1" + || s == "2" || fin.bad() ) ) { record->StationWare += s; fin >> s; } // cache relevant station data - record->is_maintenance = ( contains( s, "pt" ) ); + record->is_maintenance = contains(s, "pt"); { auto const stationware { Split( record->StationWare, ',' ) }; for( auto const &entry : stationware ) { @@ -491,11 +491,11 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax) continue; } auto const entrysplit { split_string_and_number( entry ) }; - if( ( entrysplit.first == "R" ) - && ( entrysplit.second <= 10 ) ) { + if( entrysplit.first == "R" + && entrysplit.second <= 10 ) { auto const radiochannel { entrysplit.second }; - if( ( record->radio_channel == -1 ) - || ( radiochannel != activeradiochannel ) ) { + if( record->radio_channel == -1 + || radiochannel != activeradiochannel ) { // if the station has more than one radiochannel listed, // it generally means we should switch to the one we weren't using so far // TODO: reverse this behaviour (keep the channel used so far) once W28 signs are included in the system @@ -530,7 +530,7 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax) do { fin >> s; - } while (!((s != "|") || (fin.bad()))); + } while (!(s != "|" || fin.bad())); if (s != "]") record->tm = atof(s.c_str()); do @@ -554,7 +554,7 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax) } while (false == contains( s, "|" ) ) fin >> s; - while ((false == contains( s,"]") )) + while (false == contains(s, "]")) fin >> s; if (contains( s,"_|_") ) EndTable = true; @@ -567,8 +567,8 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax) } if (ConversionError == 0) { - if ((TimeTable[1].StationName == Relation1)) // jeśli nazwa pierwszego zgodna z relacją - if ((TimeTable[1].Ah < 0)) // a nie podany czas przyjazdu + if (TimeTable[1].StationName == Relation1) // jeśli nazwa pierwszego zgodna z relacją + if (TimeTable[1].Ah < 0) // a nie podany czas przyjazdu { // to mamy zatrzymanie na pierwszym, a nie przelot TimeTable[1].Ah = TimeTable[1].Dh; TimeTable[1].Am = TimeTable[1].Dm; @@ -584,17 +584,17 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax) float adjustedtime; // do zwiększania czasu for (auto i = 1; i < i_end; ++i) // bez with, bo ciężko się przenosi na C++ { - if ((TimeTable[i].Ah >= 0)) + if (TimeTable[i].Ah >= 0) { adjustedtime = clamp_circular( TimeTable[i].Ah * 60 + TimeTable[i].Am + timeoffset, 24 * 60 ); // nowe minuty - TimeTable[i].Am = (int(60 * adjustedtime) % 3600) / 60.f; - TimeTable[i].Ah = int((adjustedtime) / 60) % 24; + TimeTable[i].Am = int(60 * adjustedtime) % 3600 / 60.f; + TimeTable[i].Ah = int(adjustedtime / 60) % 24; } - if ((TimeTable[i].Dh >= 0)) + if (TimeTable[i].Dh >= 0) { adjustedtime = clamp_circular( TimeTable[i].Dh * 60 + TimeTable[i].Dm + timeoffset, 24 * 60 ); // nowe minuty - TimeTable[i].Dm = (int(60 * adjustedtime) % 3600) / 60.f; - TimeTable[i].Dh = int((adjustedtime) / 60) % 24; + TimeTable[i].Dm = int(60 * adjustedtime) % 3600 / 60.f; + TimeTable[i].Dh = int(adjustedtime / 60) % 24; } } } @@ -632,7 +632,7 @@ TTrainParameters::load_sounds() { bool TTrainParameters::DirectionChange() // sprawdzenie, czy po zatrzymaniu wykonać kolejne komendy { - if ((StationIndex > 0) && (StationIndex < StationCount)) // dla ostatniej stacji nie + if (StationIndex > 0 && StationIndex < StationCount) // dla ostatniej stacji nie if (contains( TimeTable[StationIndex].StationWare, '@') ) return true; return false; @@ -657,15 +657,15 @@ void TTrainParameters::serialize( dictionary_source *Output ) const { for( auto stationidx = 1; stationidx <= StationCount; ++stationidx ) { auto const stationlabel { "train_station" + std::to_string( stationidx ) + "_" }; auto const &timetableline { TimeTable[ stationidx ] }; - Output->insert( ( stationlabel + "name" ), Bezogonkow( timetableline.StationName ) ); - Output->insert( ( stationlabel + "fclt" ), Bezogonkow( timetableline.StationWare ) ); - Output->insert( ( stationlabel + "lctn" ), timetableline.km ); - Output->insert( ( stationlabel + "vmax" ), timetableline.vmax ); - Output->insert( ( stationlabel + "ah" ), timetableline.Ah ); - Output->insert( ( stationlabel + "am" ), timetableline.Am ); - Output->insert( ( stationlabel + "dh" ), timetableline.Dh ); - Output->insert( ( stationlabel + "dm" ), timetableline.Dm ); - Output->insert( ( stationlabel + "tracks" ), timetableline.TrackNo ); + Output->insert( stationlabel + "name", Bezogonkow( timetableline.StationName ) ); + Output->insert( stationlabel + "fclt", Bezogonkow( timetableline.StationWare ) ); + Output->insert( stationlabel + "lctn", timetableline.km ); + Output->insert( stationlabel + "vmax", timetableline.vmax ); + Output->insert( stationlabel + "ah", timetableline.Ah ); + Output->insert( stationlabel + "am", timetableline.Am ); + Output->insert( stationlabel + "dh", timetableline.Dh ); + Output->insert( stationlabel + "dm", timetableline.Dm ); + Output->insert( stationlabel + "tracks", timetableline.TrackNo ); } } } diff --git a/world/station.cpp b/world/station.cpp index fd8d7067..eae81d9e 100644 --- a/world/station.cpp +++ b/world/station.cpp @@ -74,7 +74,7 @@ basic_station::update_load( TDynamicObject *First, Mtable::TTrainParameters &Sch loadcount *= 2; } - if( ( unloadcount > 0 ) || ( loadcount > 0 ) ) { + if( unloadcount > 0 || loadcount > 0 ) { vehicle->LoadExchange( unloadcount, loadcount, Platform ); exchangetime = std::max( exchangetime, vehicle->LoadExchangeTime() );