From 8c23c1fe2bf23de8bf08710b2625b3c3b47106a2 Mon Sep 17 00:00:00 2001 From: jerrrrycho Date: Sat, 10 Oct 2026 15:16:28 +0200 Subject: [PATCH] refactor(sonar): make narrowing conversions explicit (cpp:S5276) Co-Authored-By: Claude Opus 5.5 --- McZapkie/Mover.cpp | 90 ++++----- McZapkie/hamulce.cpp | 8 +- application/driverhints.cpp | 16 +- application/driveruipanels.cpp | 26 +-- application/uitranscripts.cpp | 8 +- audio/sound.cpp | 24 +-- environment/moon.cpp | 14 +- environment/skydome.cpp | 14 +- environment/sun.cpp | 10 +- gl/shader.cpp | 2 +- gl/ubo.h | 2 +- gl/vao.cpp | 4 +- input/gamepadinput.cpp | 8 +- input/keyboardinput.cpp | 2 +- input/messaging.cpp | 12 +- launcher/deferred_image.h | 2 +- network/backend/asio.cpp | 6 +- network/message.cpp | 4 +- network/network.cpp | 6 +- network/network.h | 4 +- rendering/lightarray.cpp | 8 +- rendering/nullrenderer.h | 2 +- rendering/opengl33particles.cpp | 4 +- rendering/openglcamera.cpp | 2 +- rendering/openglgeometrybank.cpp | 12 +- rendering/openglparticles.cpp | 4 +- rendering/particles.cpp | 32 +-- scene/sn_utils.cpp | 64 +++--- scripting/ladderlogic.cpp | 2 +- scripting/ladderlogic.h | 2 +- scripting/pythonscreenviewer.cpp | 6 +- simulation/simulationenvironment.cpp | 8 +- simulation/simulationtime.cpp | 34 ++-- utilities/Float3d.h | 6 +- utilities/Logs.cpp | 16 +- utilities/Timer.h | 2 +- utilities/color.h | 8 +- utilities/headtrack.cpp | 6 +- utilities/motiontelemetry.cpp | 18 +- utilities/uart.cpp | 6 +- utilities/utilities.h | 4 +- vehicle/Camera.cpp | 18 +- vehicle/Gauge.cpp | 20 +- vehicle/Train.cpp | 288 +++++++++++++-------------- widgets/perfgraphs.cpp | 4 +- widgets/trainingcard.cpp | 2 +- world/EvLaunch.cpp | 12 +- world/Segment.cpp | 46 ++--- world/Spring.cpp | 4 +- world/Traction.cpp | 10 +- world/TractionPower.cpp | 2 +- world/mtable.cpp | 20 +- world/station.cpp | 2 +- 53 files changed, 468 insertions(+), 468 deletions(-) diff --git a/McZapkie/Mover.cpp b/McZapkie/Mover.cpp index 9c6e6821..f2de7e7e 100644 --- a/McZapkie/Mover.cpp +++ b/McZapkie/Mover.cpp @@ -1930,17 +1930,17 @@ void TMoverParameters::PowerCouplersCheck(double const Deltatime, coupling const { case coupling::highvoltage: { - couplervoltage = Couplers[end::front].power_high.voltage + Couplers[end::rear].power_high.voltage; + couplervoltage = static_cast(Couplers[end::front].power_high.voltage + Couplers[end::rear].power_high.voltage); break; } case coupling::power110v: { - couplervoltage = Couplers[end::front].power_110v.voltage + Couplers[end::rear].power_110v.voltage; + couplervoltage = static_cast(Couplers[end::front].power_110v.voltage + Couplers[end::rear].power_110v.voltage); break; } case coupling::power24v: { - couplervoltage = Couplers[end::front].power_24v.voltage + Couplers[end::rear].power_24v.voltage; + couplervoltage = static_cast(Couplers[end::front].power_24v.voltage + Couplers[end::rear].power_24v.voltage); break; } default: @@ -2224,11 +2224,11 @@ void TMoverParameters::OilPumpCheck(double const Timestep) if (OilPump.pressure < OilPump.pressure_target) { // TODO: scale change rate from 0.01-0.05 with oil/engine temperature/idle time - OilPump.pressure = std::min(OilPump.pressure_target, OilPump.pressure + (enrot > 5.0 ? 0.05 : 0.035) * Timestep); + OilPump.pressure = std::min(OilPump.pressure_target, static_cast(OilPump.pressure + (enrot > 5.0 ? 0.05 : 0.035) * Timestep)); } if (OilPump.pressure > OilPump.pressure_target) { - OilPump.pressure = std::max(OilPump.pressure_target, OilPump.pressure - (enrot > 5.0 ? 0.05 : 0.035) * 0.5 * Timestep); + OilPump.pressure = std::max(OilPump.pressure_target, static_cast(OilPump.pressure - (enrot > 5.0 ? 0.05 : 0.035) * 0.5 * Timestep)); } OilPump.pressure = std::clamp(OilPump.pressure, 0.f, 1.5f); } @@ -2245,7 +2245,7 @@ void TMoverParameters::MotorBlowersCheck(double const Timestep) { if (stop) { - blower.stop_timer += Timestep; + blower.stop_timer += static_cast(Timestep); if (blower.stop_timer > blower.sustain_time) { disable = true; @@ -2285,11 +2285,11 @@ void TMoverParameters::MotorBlowersCheck(double const Timestep) if (revolutionstarget > 0.f) { auto const speedincreasecap{std::max(50.f, fan.speed * 0.05f * -1)}; // 5% of fixed revolution speed, or 50 - fan.revolutions += std::clamp(revolutionstarget - fan.revolutions, speedincreasecap * -2, speedincreasecap) * Timestep; + fan.revolutions += static_cast(std::clamp(revolutionstarget - fan.revolutions, speedincreasecap * -2, speedincreasecap) * Timestep); } else { - fan.revolutions *= std::max(0.0, 1.0 - Timestep); + fan.revolutions *= static_cast(std::max(0.0, 1.0 - Timestep)); } } } @@ -2798,7 +2798,7 @@ bool TMoverParameters::IncScndCtrl(int CtrlSpeed) 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); + SpeedCtrlValue = static_cast(Round(Vel)); SpeedCtrlUnit.IsActive = true; } @@ -4350,7 +4350,7 @@ void TMoverParameters::CompressorCheck(double dt) EmergencyValveOpen = Compressor > (EmergencyValveOpen ? EmergencyValveOff : EmergencyValveOn); if (EmergencyValveOpen) { - float dV = PF(0, Compressor, EmergencyValveArea) * dt; + float dV = static_cast(PF(0, Compressor, EmergencyValveArea) * dt); CompressedVolume -= dV; } @@ -4737,7 +4737,7 @@ void TMoverParameters::UpdatePipePressure(double dt) if (DCEMUED_EP_min_Im > 0.001 && abs(Im) > DCEMUED_EP_min_Im && DynamicBrakeEMUStatus) temp1 = 0; Hamulec->SetEPS(temp1); - TUHEX_StageActual = EpForce; + TUHEX_StageActual = static_cast(EpForce); TUHEX_Active = TUHEX_StageActual > 0; // Ra 2014-11: na tym się wysypuje, ale nie wiem, w jakich warunkach SendCtrlToNext("Brake", EpForce, CabActive); @@ -5425,7 +5425,7 @@ double TMoverParameters::CouplerForce(int const End, double dt) if (std::abs(CF) > coupler.FmaxC) { // coupler is stretched with excessive force, may break - coupler.stretch_duration += dt; + coupler.stretch_duration += static_cast(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) @@ -5643,14 +5643,14 @@ double TMoverParameters::TractionForce(double dt) { // TBD, TODO: currently ignores RVentType, fix this? RventRot += std::clamp(enrot - RventRot, -100.0, 50.0) * dt; - dizel_heat.rpmw += std::clamp(dizel_heat.rpmwz - dizel_heat.rpmw, -100.f, 50.f) * dt; - dizel_heat.rpmw2 += std::clamp(dizel_heat.rpmwz2 - dizel_heat.rpmw2, -100.f, 50.f) * dt; + dizel_heat.rpmw += static_cast(std::clamp(dizel_heat.rpmwz - dizel_heat.rpmw, -100.f, 50.f) * dt); + dizel_heat.rpmw2 += static_cast(std::clamp(dizel_heat.rpmwz2 - dizel_heat.rpmw2, -100.f, 50.f) * dt); } else { RventRot *= std::max(0.0, 1.0 - RVentSpeed * dt); - dizel_heat.rpmw *= std::max(0.0, 1.0 - dizel_heat.rpmw * dt); - dizel_heat.rpmw2 *= std::max(0.0, 1.0 - dizel_heat.rpmw2 * dt); + dizel_heat.rpmw *= static_cast(std::max(0.0, 1.0 - dizel_heat.rpmw * dt)); + dizel_heat.rpmw2 *= static_cast(std::max(0.0, 1.0 - dizel_heat.rpmw2 * dt)); } break; } @@ -5660,13 +5660,13 @@ double TMoverParameters::TractionForce(double dt) // NOTE: we update only radiator fans, as vehicles with diesel engine don't have other ventilators if (true == Mains) { - dizel_heat.rpmw += std::clamp(dizel_heat.rpmwz - dizel_heat.rpmw, -100.f, 50.f) * dt; - dizel_heat.rpmw2 += std::clamp(dizel_heat.rpmwz2 - dizel_heat.rpmw2, -100.f, 50.f) * dt; + dizel_heat.rpmw += static_cast(std::clamp(dizel_heat.rpmwz - dizel_heat.rpmw, -100.f, 50.f) * dt); + dizel_heat.rpmw2 += static_cast(std::clamp(dizel_heat.rpmwz2 - dizel_heat.rpmw2, -100.f, 50.f) * dt); } else { - dizel_heat.rpmw *= std::max(0.0, 1.0 - dizel_heat.rpmw * dt); - dizel_heat.rpmw2 *= std::max(0.0, 1.0 - dizel_heat.rpmw2 * dt); + dizel_heat.rpmw *= static_cast(std::max(0.0, 1.0 - dizel_heat.rpmw * dt)); + dizel_heat.rpmw2 *= static_cast(std::max(0.0, 1.0 - dizel_heat.rpmw2 * dt)); } break; } @@ -6326,7 +6326,7 @@ double TMoverParameters::TractionForce(double dt) SpeedCtrlTimer += dt; if (SpeedCtrlTimer > SpeedCtrlDelay) { - int NewSCAP = (float)ScndCtrlPos / (float)ScndCtrlPosNo * Vmax; + int NewSCAP = static_cast((float)ScndCtrlPos / (float)ScndCtrlPosNo * Vmax); if (NewSCAP != SpeedCtrlValue) { SpeedCtrlValue = NewSCAP; @@ -6365,7 +6365,7 @@ double TMoverParameters::TractionForce(double dt) { PosRatio = 0; } - PosRatio = Round(20.0 * PosRatio) / 20.0; // stopniowanie PN/ED + PosRatio = static_cast(Round(20.0 * PosRatio)) / 20.0; // stopniowanie PN/ED if (PosRatio < 19.5 / 20.0) PosRatio *= 0.9; Hamulec->SetED(std::max(0.0, std::min(PosRatio, 1.0))); // ustalenie stopnia zmniejszenia ciśnienia @@ -8339,13 +8339,13 @@ void TMoverParameters::dizel_Heat(double const dt) // 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 dTss{Qs / Cs}; - dizel_heat.Ts += dTss * dt; + dizel_heat.Ts += static_cast(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; + dizel_heat.To += static_cast(dTo * dt); // heater /* @@ -8364,7 +8364,7 @@ void TMoverParameters::dizel_Heat(double const dt) (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.rpmwz2 = static_cast(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 @@ -8376,8 +8376,8 @@ void TMoverParameters::dizel_Heat(double const dt) // 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; - dizel_heat.Tsr2 = 0.5 * (dizel_heat.Twy2 + Twe2); + dizel_heat.Twy2 = static_cast(Twe2 + dTs2 * dt); + dizel_heat.Tsr2 = static_cast(0.5 * (dizel_heat.Twy2 + Twe2)); dizel_heat.temperatura2 = dizel_heat.Twy2; } // primary water circuit setup @@ -8387,7 +8387,7 @@ void TMoverParameters::dizel_Heat(double const dt) 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.rpmwz = static_cast(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 @@ -8398,8 +8398,8 @@ void TMoverParameters::dizel_Heat(double const dt) 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; - dizel_heat.Tsr = 0.5 * (dizel_heat.Twy + Twe); + dizel_heat.Twy = static_cast(Twe + dTs * dt); + dizel_heat.Tsr = static_cast(0.5 * (dizel_heat.Twy + Twe)); dizel_heat.temperatura1 = dizel_heat.Twy; /* fuelConsumed = fuelConsumed + ( Ge * 0.5 ); @@ -8580,7 +8580,7 @@ bool TMoverParameters::LoadingDone(double const LSpeed, std::string const &Loadn if (LoadAmount >= MaxLoad * (1.0 + OverLoadFactor) || CommandIn.Value1 <= 0) { LoadStatus = 4; // skończony załadunek - LoadAmount = std::min(MaxLoad * (1.0 + OverLoadFactor), LoadAmount); + LoadAmount = std::min(static_cast(MaxLoad * (1.0 + OverLoadFactor)), LoadAmount); } ComputeMass(); } @@ -8819,10 +8819,10 @@ void TMoverParameters::update_doors(double const Deltatime) if (false == door.step_unfolding // no wait if no doorstep || Doors.step_type == 2) { // no wait for rotating doorstep - door.open_delay += Deltatime; + door.open_delay += static_cast(Deltatime); if (door.open_delay > Doors.open_delay) { - door.position = std::min(Doors.range, door.position + Doors.open_rate * Deltatime); + door.position = std::min(Doors.range, static_cast(door.position + Doors.open_rate * Deltatime)); } } door.close_delay = 0.f; @@ -8830,10 +8830,10 @@ void TMoverParameters::update_doors(double const Deltatime) if (true == door.is_closing) { // close door - door.close_delay += Deltatime; + door.close_delay += static_cast(Deltatime); if (door.close_delay > Doors.close_delay) { - door.position = std::max(0.f, door.position - Doors.close_rate * Deltatime); + door.position = std::max(0.f, static_cast(door.position - Doors.close_rate * Deltatime)); } door.open_delay = 0.f; } @@ -8841,7 +8841,7 @@ void TMoverParameters::update_doors(double const Deltatime) if (door.step_unfolding) { // unfold left doorstep - door.step_position = std::min(1.f, door.step_position + Doors.step_rate * Deltatime); + door.step_position = std::min(1.f, static_cast(door.step_position + Doors.step_rate * Deltatime)); } if (door.step_folding) { @@ -8851,12 +8851,12 @@ void TMoverParameters::update_doors(double const Deltatime) // multi-unit vehicles typically fold the doorstep only after closing the door if (door.position <= 0.f) { - door.step_position = std::max(0.f, door.step_position - Doors.step_rate * Deltatime); + door.step_position = std::max(0.f, static_cast(door.step_position - Doors.step_rate * Deltatime)); } } else { - door.step_position = std::max(0.f, door.step_position - Doors.step_rate * Deltatime); + door.step_position = std::max(0.f, static_cast(door.step_position - Doors.step_rate * Deltatime)); } } } @@ -8879,7 +8879,7 @@ void TMoverParameters::update_doors(double const Deltatime) if (door.auto_timer > 0.f) { - door.auto_timer -= Deltatime; + door.auto_timer -= static_cast(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) @@ -10418,7 +10418,7 @@ void TMoverParameters::LoadFIZ_Dimensions(std::string const &line) if (Dim.H <= 2.0) { // gdyby nie było parametru, lepsze to niż zero - Floor = Dim.H; + Floor = static_cast(Dim.H); } else { @@ -10635,7 +10635,7 @@ void TMoverParameters::LoadFIZ_Doors(std::string const &line) { // HACK: legacy position indices start from 1, so we deduct 1 to arrive at proper index into the array extract_value(Doors.permit_preset, "DoorPermitListDefault", line, "1"); - Doors.permit_preset = std::min(Doors.permit_presets.size(), Doors.permit_preset) - 1; + Doors.permit_preset = std::min(static_cast(Doors.permit_presets.size()), Doors.permit_preset) - 1; } } @@ -11113,7 +11113,7 @@ void TMoverParameters::LoadFIZ_Light(std::string const &line) extract_value(NominalVoltage, "Volt", line, ""); extract_value(BatteryVoltage, "LMaxVoltage", line, ""); - NominalBatteryVoltage = BatteryVoltage; + NominalBatteryVoltage = static_cast(BatteryVoltage); } void TMoverParameters::LoadFIZ_Clima(std::string const &line) @@ -12314,7 +12314,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV if (DCEMUED_EP_min_Im > 0.001 && abs(Im) > DCEMUED_EP_min_Im && DynamicBrakeEMUStatus) temp1 = 0; Hamulec->SetEPS(temp1); - TUHEX_StageActual = CValue1; + TUHEX_StageActual = static_cast(CValue1); TUHEX_Active = TUHEX_StageActual > 0; if (CValue1 < 0.001) DynamicBrakeEMUStatus = true; @@ -12324,7 +12324,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV } // youby - odluzniacz hamulcow, przyda sie else if (Command == "BrakeReleaser") { - OK = BrakeReleaser(Round(CValue1)); // samo się przesyła dalej + OK = BrakeReleaser(static_cast(Round(CValue1))); // samo się przesyła dalej // OK:=SendCtrlToNext(command,CValue1,CValue2); //to robiło kaskadę 2^n } else if (Command == "WaterPumpBreakerSwitch") @@ -12535,7 +12535,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV } else if (Command == "RelayReset") { - RelayReset(CValue1, range_t::local); + RelayReset(static_cast(CValue1), range_t::local); OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype); } else if (Command == "ConverterSwitch") /*NBMX*/ diff --git a/McZapkie/hamulce.cpp b/McZapkie/hamulce.cpp index 3cd39f4a..c0059a90 100644 --- a/McZapkie/hamulce.cpp +++ b/McZapkie/hamulce.cpp @@ -3241,7 +3241,7 @@ double TFV4aM::GetRP() /// Interpolated target pressure [bar]. double TFV4aM::LPP_RP(double pos) // cisnienie z zaokraglonej pozycji; { - int const i_pos = 2 + std::floor(pos); // zaokraglone w dol + int const i_pos = static_cast(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 } @@ -3844,7 +3844,7 @@ double TM394::GetPF(double i_bcp, double PP, double HP, double dt, double ep) double ActFlowSpeed; int BCP; - BCP = lround(i_bcp); + BCP = static_cast(lround(i_bcp)); if (BCP < -1) BCP = 1; @@ -3937,7 +3937,7 @@ double TH14K1::GetPF(double i_bcp, double PP, double HP, double dt, double ep) //{ (10, 0), (4, 1), (0, 1), (4, 0), (4, -1), (15, -1) }; double const NomPress = 5.0; - int BCP = std::lround(i_bcp); + int BCP = static_cast(std::lround(i_bcp)); if (i_bcp < -1) { BCP = 1; @@ -4034,7 +4034,7 @@ double TSt113::GetPF(double i_bcp, double PP, double HP, double dt, double ep) CP = PP; - BCP = lround(i_bcp); + BCP = static_cast(lround(i_bcp)); EPS = BEP_K[BCP + 1]; diff --git a/application/driverhints.cpp b/application/driverhints.cpp index 373b130e..4ed1f5ba 100644 --- a/application/driverhints.cpp +++ b/application/driverhints.cpp @@ -543,7 +543,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) Action, [this](float const Parameter) { return mvControlling->EIMDirectionChangeAllow(); }, - mvControlling->MainCtrlMaxDirChangePos ); + static_cast(mvControlling->MainCtrlMaxDirChangePos) ); break; } case driver_hint::tractiveforcedecrease: { @@ -555,11 +555,11 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) Action, [this](float const Parameter) { return std::abs(mvControlling->Ft) <= Parameter; }, - std::min( + static_cast(std::min( 0.0, std::max( std::abs( mvControlling->Ft ) * 0.95, - std::abs( mvControlling->Ft ) - 5.0 ) ) ); + std::abs( mvControlling->Ft ) - 5.0 ) )) ); break; } case driver_hint::tractiveforceincrease: { @@ -831,7 +831,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) Action, [this](float const Parameter) { return std::abs(mvControlling->Fb) <= Parameter; }, - std::min( 0.0, 0.95 * std::abs( mvControlling->Fb ) ) ); // keep hint until 5% decrease + static_cast(std::min( 0.0, 0.95 * std::abs( mvControlling->Fb ) )) ); // keep hint until 5% decrease break; } case driver_hint::brakingforceincrease: { @@ -847,11 +847,11 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) Action, [this](float const Parameter) { return std::abs(mvControlling->Fb) > Parameter || is_equal(mvOccupied->fBrakeCtrlPos, mvOccupied->Handle->GetPos(bh_EB), 0.2); }, - std::max( + static_cast(std::max( 0.0, std::max( std::abs( mvControlling->Fb ) * 1.05, - std::abs( mvControlling->Fb ) + 5.0 ) ) ); + std::abs( mvControlling->Fb ) + 5.0 ) )) ); break; } case driver_hint::brakingforcesetzero: { // releases both train and independent brake @@ -1216,7 +1216,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) case driver_hint::couplingadapterattach: { // TODO: run also for potential settings-based virtual assistant if( AIControllFlag ) { - pVehicles[ end::front ]->attach_coupler_adapter( Actionparameter ); + pVehicles[ end::front ]->attach_coupler_adapter( static_cast(Actionparameter) ); } hint( Action, @@ -1227,7 +1227,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) } case driver_hint::couplingadapterremove: { if( AIControllFlag || Global.AITrainman ) { - pVehicles[ end::front ]->remove_coupler_adapter( Actionparameter ); + pVehicles[ end::front ]->remove_coupler_adapter( static_cast(Actionparameter) ); } hint( Action, diff --git a/application/driveruipanels.cpp b/application/driveruipanels.cpp index 8b71c4bf..d39296f4 100644 --- a/application/driveruipanels.cpp +++ b/application/driveruipanels.cpp @@ -428,13 +428,13 @@ timetable_panel::update() { && 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 ) ) }; + || time.wHour * 60 + time.wMinute + time.wSecond * 0.0167 >= static_cast(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 ) ) }; + tableline->Ah >= 0 ? to_minutes_str( static_cast(CompareTime( table.TimeTable[ i - 1 ].Dh, table.TimeTable[ i - 1 ].Dm, tableline->Ah, tableline->Am )), false, 3 ) : + to_minutes_str( static_cast(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 : loadchangeinprogress ? colors::uitextred : @@ -611,13 +611,13 @@ debug_panel::render() { render_section_developer(); // Developer tools #ifdef WITH_UART if(true == render_section( "UART", m_uartlines)) { - int ports_num = UartStatus.available_ports.size(); + int ports_num = static_cast(UartStatus.available_ports.size()); char **avlports = new char*[ports_num]; for (int i=0; i < ports_num; i++) { avlports[i] = (char *) UartStatus.available_ports[i].c_str(); } ImGui::Combo("Port", &UartStatus.selected_port_index, avlports, ports_num); - ImGui::Combo("Baud", &UartStatus.selected_baud_index, uart_baudrates_list, uart_baudrates_list_num); + ImGui::Combo("Baud", &UartStatus.selected_baud_index, uart_baudrates_list, static_cast(uart_baudrates_list_num)); ImGui::Checkbox("Enabled", &UartStatus.enabled); } #endif @@ -903,7 +903,7 @@ debug_panel::update_section_vehicle( std::vector &Output ) { mover.LoadFlag, mover.LocalBrakePosA, mover.LocalBrakePosAEIM, - mover.ManualBrakePos / static_cast(ManualBrakePosNo), + static_cast(mover.ManualBrakePos) / static_cast(ManualBrakePosNo), mover.SpringBrake.Activate ? 1.f : 0.f, // cylinders mover.BrakePress, @@ -981,11 +981,11 @@ debug_panel::update_section_vehicle( std::vector &Output ) { if (!std::isnan(last_time)) { double dt = Timer::GetTime() - last_time; - AccN_jerk_graph.update((mover.AccN - last_AccN) / dt); - AccN_acc_graph.update(mover.AccN); + AccN_jerk_graph.update(static_cast((mover.AccN - last_AccN) / dt)); + AccN_acc_graph.update(static_cast(mover.AccN)); } - last_AccN = mover.AccN; + last_AccN = static_cast(mover.AccN); last_time = Timer::GetTime(); } @@ -1002,7 +1002,7 @@ void debug_panel::graph_data::update(float val) { void debug_panel::graph_data::render() { ImGui::PushID(this); ImGui::SliderFloat(STR_C("##Range"), &range, 0.5f, 60.0f, "%.1f"); - ImGui::PlotLines("##plot", data.data(), data.size(), pos, nullptr, 0.0f, range, ImVec2(0, 100)); + ImGui::PlotLines("##plot", data.data(), static_cast(data.size()), static_cast(pos), nullptr, 0.0f, range, ImVec2(0, 100)); ImGui::PopID(); } @@ -1326,7 +1326,7 @@ debug_panel::update_section_scenario( std::vector &Output ) { + to_string( simulation::Environment.wind_azimuth(), 0 ) // ma być azymut, czyli 0 na północy i rośnie na wschód + " " + std::string( "N NEE SES SWW NW" ) - .substr( 0 + 2 * std::floor( std::fmod( 8 + ( glm::radians( simulation::Environment.wind_azimuth() ) + 0.5 * M_PI_4 ) / M_PI_4, 8 ) ), 2 ) + .substr( static_cast( 2 * std::floor( std::fmod( 8 + ( glm::radians( simulation::Environment.wind_azimuth() ) + 0.5 * M_PI_4 ) / M_PI_4, 8 ) ) ), 2 ) + ", " + to_string( glm::length( simulation::Environment.wind() ), 1 ) + " m/s"; textline += "\nAir temperature: " + to_string( Global.AirTemperature, 1 ) + " deg C"; @@ -1440,7 +1440,7 @@ debug_panel::update_section_camera( std::vector &Output ) { + to_string( 180.0 - glm::degrees( camera.Angle.y ), 0 ) // ma być azymut, czyli 0 na północy i rośnie na wschód + " " + std::string( "S SEE NEN NWW SW" ) - .substr( 0 + 2 * floor( fmod( 8 + ( camera.Angle.y + 0.5 * M_PI_4 ) / M_PI_4, 8 ) ), 2 ); + .substr( static_cast( 2 * floor( fmod( 8 + ( camera.Angle.y + 0.5 * M_PI_4 ) / M_PI_4, 8 ) ) ), 2 ); Output.emplace_back( textline, Global.UITextColor ); } @@ -1563,7 +1563,7 @@ debug_panel::render_section_settings() { // reflection fidelity ImGui::SliderInt( ( std::to_string( Global.reflectiontune.fidelity ) + "###reflectionfidelity" ).c_str(), &Global.reflectiontune.fidelity, 0, 2, "Reflection fidelity" ); ImGui::SliderInt( ( std::to_string( Global.gfx_shadow_rank_cutoff ) + "###shadowrankcutoff" ).c_str(), &Global.gfx_shadow_rank_cutoff, 1, 3, "Shadow ranks" ); - if( ImGui::SliderFloat( ( to_string( std::abs( Global.gfx_shadow_angle_min ), 2 ) + "###shadowanglecutoff" ).c_str(), &Global.gfx_shadow_angle_min, -1.0, -0.2, "Shadow angle cutoff" ) ) { + if( ImGui::SliderFloat( ( to_string( std::abs( Global.gfx_shadow_angle_min ), 2 ) + "###shadowanglecutoff" ).c_str(), &Global.gfx_shadow_angle_min, -1.0, -0.2f, "Shadow angle cutoff" ) ) { Global.gfx_shadow_angle_min = quantize( Global.gfx_shadow_angle_min, 0.05f ); } if( DebugModeFlag ) { diff --git a/application/uitranscripts.cpp b/application/uitranscripts.cpp index bfe3f233..0655f9fe 100644 --- a/application/uitranscripts.cpp +++ b/application/uitranscripts.cpp @@ -16,8 +16,8 @@ TTranscripts::AddLine( std::string const &txt, float show, float hide, bool it ) if( show == hide ) { return; } // komentarz jest ignorowany // TODO: replace the timeangledeg mess with regular time points math - show = Global.fTimeAngleDeg + show / 240.0; // jeśli doba to 360, to 1s będzie równe 1/240 - hide = Global.fTimeAngleDeg + hide / 240.0; + show = static_cast(Global.fTimeAngleDeg + show / 240.0); // jeśli doba to 360, to 1s będzie równe 1/240 + hide = static_cast(Global.fTimeAngleDeg + hide / 240.0); TTranscript transcript; transcript.asText = txt; @@ -49,14 +49,14 @@ TTranscripts::Add( std::string const &txt, bool backgorund ) { >> begin >> end >> transcript; - AddLine( transcript, 0.10 * begin, 0.12 * end, false ); + AddLine( transcript, static_cast(0.10 * begin), static_cast(0.12 * end), false ); } // try to handle malformed(?) cases with no show/hide times std::string transcript; parser >> transcript; while( false == transcript.empty() ) { // WriteLog( "Transcript text with no display/hide times: \"" + transcript + "\"" ); - AddLine( transcript, 0.0, 0.12 * transcript.size(), false ); + AddLine( transcript, 0.0, static_cast(0.12 * static_cast(transcript.size())), false ); transcript = ""; parser >> transcript; } } diff --git a/audio/sound.cpp b/audio/sound.cpp index 49f17270..f27fcfe5 100644 --- a/audio/sound.cpp +++ b/audio/sound.cpp @@ -59,7 +59,7 @@ sound_source::deserialize( cParser &Input, sound_type const Legacytype, int cons // 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 ) { - m_soundchunks[ idx ].second.fadeout = m_soundchunks[ idx + 1 ].second.threshold; + m_soundchunks[ idx ].second.fadeout = static_cast(m_soundchunks[ idx + 1 ].second.threshold); /* m_soundchunks[ idx ].second.fadeout = interpolate( @@ -69,11 +69,11 @@ sound_source::deserialize( cParser &Input, sound_type const Legacytype, int cons */ } // ...and on the other end from the threshold point back into the range of previous chunk - m_soundchunks.front().second.fadein = std::max( 0, m_soundchunks.front().second.threshold ); + m_soundchunks.front().second.fadein = static_cast(std::max( 0, m_soundchunks.front().second.threshold )); // m_soundchunks.front().second.fadein = m_soundchunks.front().second.threshold; for( std::size_t idx = 1; idx < m_soundchunks.size(); ++idx ) { auto const previouschunkwidth { m_soundchunks[ idx ].second.threshold - m_soundchunks[ idx - 1 ].second.threshold }; - m_soundchunks[ idx ].second.fadein = m_soundchunks[ idx ].second.threshold - 0.01f * m_crossfaderange * previouschunkwidth; + m_soundchunks[ idx ].second.fadein = static_cast(m_soundchunks[ idx ].second.threshold) - 0.01f * static_cast(m_crossfaderange) * static_cast(previouschunkwidth); /* m_soundchunks[ idx ].second.fadein = interpolate( @@ -82,7 +82,7 @@ sound_source::deserialize( cParser &Input, sound_type const Legacytype, int cons m_crossfaderange * 0.01f ); */ } - m_soundchunks.back().second.fadeout = std::max( Chunkrange, m_soundchunks.back().second.threshold ); + m_soundchunks.back().second.fadeout = static_cast(std::max( Chunkrange, m_soundchunks.back().second.threshold )); // m_soundchunks.back().second.fadeout = m_soundchunks.back().second.threshold; // test if the chunk table contains any actual samples while at it for( auto &soundchunk : m_soundchunks ) { @@ -761,7 +761,7 @@ sound_source::update_crossfade( sound_handle const Chunk ) { // relative pitch adjustment // pitch of each chunk is modified based on ratio of the chunk's pitch to that of its neighbour - if( soundpoint < chunkdata.threshold ) { + if( soundpoint < static_cast(chunkdata.threshold) ) { if( chunkindex > 0 ) { // interpolate between the pitch of previous chunk and this chunk's base pitch, @@ -772,7 +772,7 @@ sound_source::update_crossfade( sound_handle const Chunk ) { previouschunkdata.pitch / chunkdata.pitch, 1.f, std::clamp( - ( soundpoint - previouschunkdata.threshold ) / ( chunkdata.threshold - previouschunkdata.threshold ), + ( soundpoint - static_cast(previouschunkdata.threshold) ) / ( static_cast(chunkdata.threshold - previouschunkdata.threshold) ), 0.f, 1.f ) ); } } @@ -787,7 +787,7 @@ sound_source::update_crossfade( sound_handle const Chunk ) { 1.f, nextchunkdata.pitch / chunkdata.pitch, std::clamp( - ( soundpoint - chunkdata.threshold ) / ( nextchunkdata.threshold - chunkdata.threshold ), + ( soundpoint - static_cast(chunkdata.threshold) ) / ( static_cast(nextchunkdata.threshold - chunkdata.threshold) ), 0.f, 1.f ) ); } else { @@ -801,7 +801,7 @@ sound_source::update_crossfade( sound_handle const Chunk ) { if( chunkindex > 0 ) { // chunks other than the first can have fadein auto const fadeinwidth { chunkdata.threshold - chunkdata.fadein }; - if( soundpoint < chunkdata.threshold ) { + if( soundpoint < static_cast(chunkdata.threshold) ) { float lineargain = std::lerp( 0.f, 1.f, @@ -809,8 +809,8 @@ sound_source::update_crossfade( sound_handle const Chunk ) { ( soundpoint - chunkdata.fadein ) / fadeinwidth, 0.f, 1.f ) ); m_properties.gain *= - lineargain / - (1 + (1 - lineargain) * -0.57); // approximation of logarytmic fade in + static_cast(lineargain / + (1 + (1 - lineargain) * -0.57)); // approximation of logarytmic fade in return; } } @@ -828,8 +828,8 @@ sound_source::update_crossfade( sound_handle const Chunk ) { std::clamp( ( soundpoint - fadeoutstart ) / fadeoutwidth, 0.f, 1.f ) ); - m_properties.gain *= (-lineargain + 1) / - (1 + lineargain * -0.57); // approximation of logarytmic fade out + m_properties.gain *= static_cast((-lineargain + 1) / + (1 + lineargain * -0.57)); // approximation of logarytmic fade out return; } } diff --git a/environment/moon.cpp b/environment/moon.cpp index 8cc86683..b4c8abcf 100644 --- a/environment/moon.cpp +++ b/environment/moon.cpp @@ -72,8 +72,8 @@ float cMoon::getIntensity() { 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 - static_cast((int)Longitude)) * 100.0 / 60.0; + m_observer.latitude = (int)Latitude + (Latitude - static_cast((int)Latitude)) * 100.0 / 60.0 ; } // sets current time, overriding one acquired from the system clock @@ -101,9 +101,9 @@ void cMoon::move() { SYSTEMTIME localtime = simulation::Time.data(); // time for the calculation - if( m_observer.hour >= 0 ) { localtime.wHour = m_observer.hour; } - if( m_observer.minute >= 0 ) { localtime.wMinute = m_observer.minute; } - if( m_observer.second >= 0 ) { localtime.wSecond = m_observer.second; } + if( m_observer.hour >= 0 ) { localtime.wHour = static_cast(m_observer.hour); } + if( m_observer.minute >= 0 ) { localtime.wMinute = static_cast(m_observer.minute); } + if( m_observer.second >= 0 ) { localtime.wSecond = static_cast(m_observer.second); } double localut = localtime.wHour @@ -297,7 +297,7 @@ cMoon::phase() { m_phase = 50; else { // calculate moon's age in days from new moon - float ip = normalize( ( simulation::Time.julian_day() - 2451550.1f ) / 29.530588853f ); + float ip = normalize( ( static_cast(simulation::Time.julian_day()) - 2451550.1f ) / 29.530588853f ); m_phase = ip * 29.53f; } } @@ -306,7 +306,7 @@ cMoon::phase() { float cMoon::normalize( const float Value ) const { - float value = Value - floor( Value ); + float value = static_cast(Value - floor( Value )); if( value < 0.f ) { ++value; } return value; diff --git a/environment/skydome.cpp b/environment/skydome.cpp index 9e79619d..c1b1729b 100644 --- a/environment/skydome.cpp +++ b/environment/skydome.cpp @@ -70,13 +70,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 = static_cast(M_PI * ( -0.5f + (float)i / static_cast(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 = static_cast(2.0 * M_PI * (float)j / longitudes); float const x = std::cos( longitude ); float const y = std::sin( longitude ); /* @@ -168,8 +168,8 @@ float CSkyDome::GetZenith( float Zenithmatrix[ 3 ][ 4 ], const float Theta, cons float CSkyDome::PerezFunctionO1( float Perezcoeffs[ 5 ], const float Thetasun, const float Zenithval ) { - const float val = ( 1.0f + Perezcoeffs[ 0 ] * std::exp( Perezcoeffs[ 1 ] ) ) * - ( 1.0f + Perezcoeffs[ 2 ] * std::exp( Perezcoeffs[ 3 ] * Thetasun ) + Perezcoeffs[ 4 ] * std::pow( std::cos( Thetasun ), 2 ) ); + const float val = static_cast(( 1.0f + Perezcoeffs[ 0 ] * std::exp( Perezcoeffs[ 1 ] ) ) * + ( 1.0f + Perezcoeffs[ 2 ] * std::exp( Perezcoeffs[ 3 ] * Thetasun ) + Perezcoeffs[ 4 ] * std::pow( std::cos( Thetasun ), 2 ) )); return Zenithval / val; } @@ -187,7 +187,7 @@ 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 const chi = static_cast(( 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 @@ -238,7 +238,7 @@ void CSkyDome::RebuildColors() { // = 1.0f / cosf( arccos( vertex.y ) ); // = 1.0f / vertex.y; float const icostheta = 1.0f / vertex.y; - float const cosgamma2 = std::pow( std::cos( gamma ), 2 ); + float const cosgamma2 = static_cast(std::pow( std::cos( gamma ), 2 )); // Compute x,y values float const x = PerezFunctionO2( perezx, icostheta, gamma, cosgamma2, zenithx ); @@ -274,7 +274,7 @@ void CSkyDome::RebuildColors() { // 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 ); + float const degreesabovehorizon = static_cast(90.0f - m_thetasun * ( 180.0f / M_PI )); 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 ); diff --git a/environment/sun.cpp b/environment/sun.cpp index 998d31dd..c85fcacb 100644 --- a/environment/sun.cpp +++ b/environment/sun.cpp @@ -76,8 +76,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 - static_cast((int)Longitude)) * 100.0 / 60.0; + m_observer.latitude = (int)Latitude + (Latitude - static_cast((int)Latitude)) * 100.0 / 60.0 ; } // sets current time, overriding one acquired from the system clock @@ -105,9 +105,9 @@ void cSun::move() { SYSTEMTIME localtime = simulation::Time.data(); // time for the calculation - if( m_observer.hour >= 0 ) { localtime.wHour = m_observer.hour; } - if( m_observer.minute >= 0 ) { localtime.wMinute = m_observer.minute; } - if( m_observer.second >= 0 ) { localtime.wSecond = m_observer.second; } + if( m_observer.hour >= 0 ) { localtime.wHour = static_cast(m_observer.hour); } + if( m_observer.minute >= 0 ) { localtime.wMinute = static_cast(m_observer.minute); } + if( m_observer.second >= 0 ) { localtime.wSecond = static_cast(m_observer.second); } double localut = localtime.wHour diff --git a/gl/shader.cpp b/gl/shader.cpp index 7815a470..79948a3e 100644 --- a/gl/shader.cpp +++ b/gl/shader.cpp @@ -343,7 +343,7 @@ void gl::program::init() { shader::texture_entry &e = it.second; GLuint loc = glGetUniformLocation(*this, it.first.c_str()); - glUniform1i(loc, e.id); + glUniform1i(loc, static_cast(e.id)); } glUniform1i(glGetUniformLocation(*this, "shadowmap"), gl::SHADOW_TEX); diff --git a/gl/ubo.h b/gl/ubo.h index e4cb7c00..d5335b21 100644 --- a/gl/ubo.h +++ b/gl/ubo.h @@ -29,7 +29,7 @@ namespace gl void update(const uint8_t *data, int offset, GLsizeiptr size); template void update(const T &data, size_t offset = 0) { - update(reinterpret_cast(&data), offset, sizeof(data)); + update(reinterpret_cast(&data), static_cast(offset), sizeof(data)); } }; diff --git a/gl/vao.cpp b/gl/vao.cpp index 6c36a1ef..093b8beb 100644 --- a/gl/vao.cpp +++ b/gl/vao.cpp @@ -67,7 +67,7 @@ void gl::vao::bind() } for (size_t i = params.size(); i < 5; i++) - glDisableVertexAttribArray(i); + glDisableVertexAttribArray(static_cast(i)); if (ebo) ebo->bind(gl::buffer::ELEMENT_ARRAY_BUFFER); @@ -84,6 +84,6 @@ void gl::vao::unbind() } else { for (size_t i = 0; i < 4; i++) - glDisableVertexAttribArray(i); + glDisableVertexAttribArray(static_cast(i)); } } diff --git a/input/gamepadinput.cpp b/input/gamepadinput.cpp index b0f26267..b0024181 100644 --- a/input/gamepadinput.cpp +++ b/input/gamepadinput.cpp @@ -94,7 +94,7 @@ gamepad_input::poll() { if( button.state != buttons[ idx ] ) { // button pressed or released, both are important on_button( - idx, + static_cast(idx), buttons[idx] == 1 ? GLFW_PRESS : GLFW_RELEASE); } else { @@ -102,7 +102,7 @@ gamepad_input::poll() { if( button.state == GLFW_PRESS ) { on_button( - idx, + static_cast(idx), GLFW_REPEAT ); } } @@ -383,7 +383,7 @@ gamepad_input::process_axes() { } if( boundcommand1 != user_command::none ) { if( axis.state > m_deadzone ) { - axis.accumulator += ( axis.state - m_deadzone ) / ( 1.0 - m_deadzone ) * deltatime; + axis.accumulator += static_cast(( axis.state - m_deadzone ) / ( 1.0 - m_deadzone ) * deltatime); // we're making sure there's always a positive charge left in the accumulator, // to more reliably decect when the stick goes from active to dead zone, below while( axis.accumulator > 1.0f ) { @@ -423,7 +423,7 @@ gamepad_input::process_axes() { } if( boundcommand1 != user_command::none ) { if( axis.state < -m_deadzone ) { - axis.accumulator += ( axis.state + m_deadzone ) / ( 1.0 - m_deadzone ) * deltatime; + axis.accumulator += static_cast(( axis.state + m_deadzone ) / ( 1.0 - m_deadzone ) * deltatime); // we're making sure there's always a positive charge left in the accumulator, // to more reliably decect when the stick goes from active to dead zone, below while( axis.accumulator < -1.0f ) { diff --git a/input/keyboardinput.cpp b/input/keyboardinput.cpp index 0279f055..8e089213 100644 --- a/input/keyboardinput.cpp +++ b/input/keyboardinput.cpp @@ -284,7 +284,7 @@ keyboard_input::key( int const Key, int const Action ) { if( Key == -1 ) { return false; } // store key state - input::keys[ Key ] = Action; + input::keys[ Key ] = static_cast( Action ); if( true == is_movement_key( Key ) ) { // if the received key was one of movement keys, it's been handled and we don't need to bother further diff --git a/input/messaging.cpp b/input/messaging.cpp index 754defb4..d73a6d32 100644 --- a/input/messaging.cpp +++ b/input/messaging.cpp @@ -115,16 +115,16 @@ OnCommandGet(multiplayer::DaneRozkaz *pRozkaz) if (*pRozkaz->iPar & 1) // ustawienie czasu { auto t = pRozkaz->fPar[1]; - simulation::Time.data().wDay = std::floor(t); // niby nie powinno być dnia, ale... + simulation::Time.data().wDay = static_cast(std::floor(t)); // niby nie powinno być dnia, ale... if (Global.fMoveLight >= 0) Global.fMoveLight = t; // trzeba by deklinację Słońca przeliczyć - simulation::Time.data().wHour = std::floor(24 * t) - 24.0 * simulation::Time.data().wDay; - simulation::Time.data().wMinute = std::floor(60 * 24 * t) - 60.0 * (24.0 * simulation::Time.data().wDay + simulation::Time.data().wHour); - simulation::Time.data().wSecond = std::floor( 60 * 60 * 24 * t ) - 60.0 * ( 60.0 * ( 24.0 * simulation::Time.data().wDay + simulation::Time.data().wHour ) + simulation::Time.data().wMinute ); + simulation::Time.data().wHour = static_cast(std::floor(24 * t) - 24.0 * simulation::Time.data().wDay); + simulation::Time.data().wMinute = static_cast(std::floor(60 * 24 * t) - 60.0 * (24.0 * simulation::Time.data().wDay + simulation::Time.data().wHour)); + simulation::Time.data().wSecond = static_cast(std::floor( 60 * 60 * 24 * t ) - 60.0 * ( 60.0 * ( 24.0 * simulation::Time.data().wDay + simulation::Time.data().wHour ) + simulation::Time.data().wMinute )); } if (*pRozkaz->iPar & 2) { // ustawienie flag zapauzowania - Global.iPause = pRozkaz->fPar[2]; // zakładamy, że wysyłający wie, co robi + Global.iPause = static_cast(pRozkaz->fPar[2]); // zakładamy, że wysyłający wie, co robi } } break; @@ -189,7 +189,7 @@ OnCommandGet(multiplayer::DaneRozkaz *pRozkaz) d->Damage( pRozkaz->cString[ 0 ] ); d = d->Prev(); // w drugą stronę też } - WyslijUszkodzenia( lookup->asName, lookup->MoverParameters->EngDmgFlag ); // zwrot informacji o pojeździe + WyslijUszkodzenia( lookup->asName, static_cast(lookup->MoverParameters->EngDmgFlag) ); // zwrot informacji o pojeździe } break; default: diff --git a/launcher/deferred_image.h b/launcher/deferred_image.h index 85582264..6217fdc9 100644 --- a/launcher/deferred_image.h +++ b/launcher/deferred_image.h @@ -33,7 +33,7 @@ public: tex.create(); if (tex.get_is_ready()) - return tex.get_id(); + return static_cast(tex.get_id()); } return invalid_id; diff --git a/network/backend/asio.cpp b/network/backend/asio.cpp index c2d1364d..11e0ac6d 100644 --- a/network/backend/asio.cpp +++ b/network/backend/asio.cpp @@ -106,7 +106,7 @@ void network::tcp::connection::write_message(const message &msg, std::ostream &s return; } stream.seekp(beg + 4, std::ios_base::beg); - sn_utils::ls_uint32(stream, size); + sn_utils::ls_uint32(stream, static_cast(size)); stream.seekp(0, std::ios_base::end); } @@ -138,7 +138,7 @@ void network::tcp::connection::send_message(const message &msg) network::tcp::server::server(std::shared_ptr buf, asio::io_context &io_ctx, const std::string &host, uint32_t port) : network::server(buf), m_acceptor(io_ctx), m_io_ctx(io_ctx) { - auto endpoint = asio::ip::tcp::endpoint(asio::ip::make_address(host), port); + auto endpoint = asio::ip::tcp::endpoint(asio::ip::make_address(host), static_cast(port)); m_acceptor.open(endpoint.protocol()); m_acceptor.set_option(asio::socket_base::reuse_address(true)); m_acceptor.set_option(asio::ip::tcp::no_delay(true)); @@ -188,7 +188,7 @@ void network::tcp::client::connect() conn->set_handler(std::bind(&client::handle_message, this, conn, std::placeholders::_1)); asio::ip::tcp::endpoint endpoint( - asio::ip::make_address(host), port); + asio::ip::make_address(host), static_cast(port)); conn->m_socket.open(endpoint.protocol()); conn->m_socket.set_option(asio::ip::tcp::no_delay(true)); conn->m_socket.async_connect(endpoint, diff --git a/network/message.cpp b/network/message.cpp index 12609905..c121838b 100644 --- a/network/message.cpp +++ b/network/message.cpp @@ -32,11 +32,11 @@ void network::server_hello::deserialize(std::istream &stream) void ::network::request_command::serialize(std::ostream &stream) const { - sn_utils::ls_uint32(stream, commands.size()); + sn_utils::ls_uint32(stream, static_cast(commands.size())); for (auto const &kv : commands) { sn_utils::ls_uint32(stream, kv.first); - sn_utils::ls_uint32(stream, kv.second.size()); + sn_utils::ls_uint32(stream, static_cast(kv.second.size())); for (command_data const &data : kv.second) { sn_utils::ls_uint32(stream, (uint32_t)data.command); diff --git a/network/network.cpp b/network/network.cpp index ae83bf78..cc3e3a9d 100644 --- a/network/network.cpp +++ b/network/network.cpp @@ -43,7 +43,7 @@ void network::connection::connected() if (is_client) { client_hello msg; msg.version = EU07_NETWORK_VERSION; - msg.start_packet = packet_counter; + msg.start_packet = static_cast(packet_counter); send_message(msg); } } @@ -188,9 +188,9 @@ std::tuple network::client::get_nex } - float size = delta_queue.size() - consume_counter; + float size = static_cast(delta_queue.size()) - consume_counter; const auto& entry = delta_queue.front(); - float mult = entry.render_dt / std::chrono::duration_cast>(frame_time).count(); + float mult = static_cast(entry.render_dt / std::chrono::duration_cast>(frame_time).count()); if (counter == 1 && size < MAX_BUFFER_SIZE * 2.0f) { last_target = last_target * TARGET_MIX + diff --git a/network/network.h b/network/network.h index 1ce802be..5f3d5cca 100644 --- a/network/network.h +++ b/network/network.h @@ -99,10 +99,10 @@ namespace network std::tuple get_next_delta(int counter); void send_commands(command_queue::commands_map commands); int get_frame_counter() { - return resume_frame_counter; + return static_cast(resume_frame_counter); } int get_awaiting_frames() { - return delta_queue.size(); + return static_cast(delta_queue.size()); } }; diff --git a/rendering/lightarray.cpp b/rendering/lightarray.cpp index 41bff159..aa931f51 100644 --- a/rendering/lightarray.cpp +++ b/rendering/lightarray.cpp @@ -75,13 +75,13 @@ light_array::update() { light.intensity = std::max(0.0f, std::log((float)light.count + 1.0f)); if (light.owner->DimHeadlights && !light.owner->HighBeamLights && isEnabled) // tylko przyciemnione - light.intensity *= light.owner->MoverParameters->dimMultiplier; + light.intensity *= static_cast(light.owner->MoverParameters->dimMultiplier); else if (!light.owner->DimHeadlights && !light.owner->HighBeamLights && isEnabled) // normalne - light.intensity *= light.owner->MoverParameters->normMultiplier; + light.intensity *= static_cast(light.owner->MoverParameters->normMultiplier); else if (light.owner->DimHeadlights && light.owner->HighBeamLights && isEnabled) // przyciemnione dlugie - light.intensity *= light.owner->MoverParameters->highDimMultiplier; + light.intensity *= static_cast(light.owner->MoverParameters->highDimMultiplier); else if (!light.owner->DimHeadlights && light.owner->HighBeamLights && isEnabled) // dlugie zwykle - light.intensity *= light.owner->MoverParameters->highMultiplier; + light.intensity *= static_cast(light.owner->MoverParameters->highMultiplier); else if (!isEnabled) { light.intensity = 0.0f; diff --git a/rendering/nullrenderer.h b/rendering/nullrenderer.h index d72ba105..ccd1c272 100644 --- a/rendering/nullrenderer.h +++ b/rendering/nullrenderer.h @@ -100,7 +100,7 @@ public: Fetch_Material( std::string const &Filename, bool const Loadnow = true ) override { m_materials.push_back(std::make_shared()); m_materials.back()->name = Filename; - return m_materials.size(); + return static_cast(m_materials.size()); } void Bind_Material( material_handle const Material, TSubModel const *sm = nullptr, lighting_data const *lighting = nullptr ) override {} diff --git a/rendering/opengl33particles.cpp b/rendering/opengl33particles.cpp index b869012b..4ba5e6d5 100644 --- a/rendering/opengl33particles.cpp +++ b/rendering/opengl33particles.cpp @@ -61,7 +61,7 @@ opengl33_particles::update( opengl_camera const &Camera ) { // TODO: put sanity cap on the overall amount of particles that can be drawn auto const sizestep { 256.0 * billboard_vertices.size() }; m_particlevertices.reserve( - sizestep * std::ceil( m_particlevertices.size() + ( particles.size() * billboard_vertices.size() ) / sizestep ) ); + static_cast( sizestep * std::ceil( static_cast(m_particlevertices.size()) + ( static_cast(particles.size() * billboard_vertices.size()) ) / sizestep ) ) ); for( auto const &particle : particles ) { // TODO: particle color support vertex.color[ 0 ] = particlecolor.r; @@ -128,7 +128,7 @@ opengl33_particles::render() { m_shader->bind(); m_vao->bind(); - glDrawArrays(GL_TRIANGLES, 0, m_particlevertices.size()); + glDrawArrays(GL_TRIANGLES, 0, static_cast(m_particlevertices.size())); m_shader->unbind(); m_vao->unbind(); diff --git a/rendering/openglcamera.cpp b/rendering/openglcamera.cpp index 97891e63..418a120d 100644 --- a/rendering/openglcamera.cpp +++ b/rendering/openglcamera.cpp @@ -38,7 +38,7 @@ opengl_camera::visible( TDynamicObject const *Dynamic ) const { // sphere test is faster than AABB, so we'll use it here // we're giving vehicles some extra padding, to allow for things like shared bogeys extending past the main body - return ( m_frustum.sphere_inside( Dynamic->GetPosition(), Dynamic->radius() * 1.25 ) > 0.0f ); + return ( m_frustum.sphere_inside( Dynamic->GetPosition(), static_cast(Dynamic->radius() * 1.25) ) > 0.0f ); } // debug helper, draws shape of frustum in world space diff --git a/rendering/openglgeometrybank.cpp b/rendering/openglgeometrybank.cpp index 69ebaac0..725d76d2 100644 --- a/rendering/openglgeometrybank.cpp +++ b/rendering/openglgeometrybank.cpp @@ -90,23 +90,23 @@ opengl_vbogeometrybank::draw_( gfx::geometry_handle const &Geometry, gfx::stream } ::glDrawRangeElementsBaseVertex( chunk.type, - 0, chunkrecord.vertex_count, - chunkrecord.index_count, GL_UNSIGNED_INT, reinterpret_cast( chunkrecord.index_offset * sizeof( gfx::basic_index ) ), - chunkrecord.vertex_offset ); + 0, static_cast(chunkrecord.vertex_count), + static_cast(chunkrecord.index_count), GL_UNSIGNED_INT, reinterpret_cast( chunkrecord.index_offset * sizeof( gfx::basic_index ) ), + static_cast(chunkrecord.vertex_offset) ); } else { bind_streams( Units, Streams, chunkrecord.vertex_offset ); ::glDrawRangeElements( chunk.type, - 0, chunkrecord.vertex_count, - chunkrecord.index_count, GL_UNSIGNED_INT, reinterpret_cast( chunkrecord.index_offset * sizeof( gfx::basic_index ) ) ); + 0, static_cast(chunkrecord.vertex_count), + static_cast(chunkrecord.index_count), GL_UNSIGNED_INT, reinterpret_cast( chunkrecord.index_offset * sizeof( gfx::basic_index ) ) ); } } else { if( m_activestreams != Streams ) { bind_streams( Units, Streams ); } - ::glDrawArrays( chunk.type, chunkrecord.vertex_offset, chunkrecord.vertex_count ); + ::glDrawArrays( chunk.type, static_cast(chunkrecord.vertex_offset), static_cast(chunkrecord.vertex_count) ); } // ...post-render cleanup /* diff --git a/rendering/openglparticles.cpp b/rendering/openglparticles.cpp index 54db2ddf..2bee2f64 100644 --- a/rendering/openglparticles.cpp +++ b/rendering/openglparticles.cpp @@ -59,7 +59,7 @@ opengl_particles::update( opengl_camera const &Camera ) { // TODO: put sanity cap on the overall amount of particles that can be drawn auto const sizestep { 256.0 * billboard_vertices.size() }; m_particlevertices.reserve( - sizestep * std::ceil( m_particlevertices.size() + ( particles.size() * billboard_vertices.size() ) / sizestep ) ); + static_cast( sizestep * std::ceil( static_cast(m_particlevertices.size()) + ( static_cast(particles.size() * billboard_vertices.size()) ) / sizestep ) ) ); for( auto const &particle : particles ) { // TODO: particle color support vertex.color[ 0 ] = static_cast( particlecolor.r ); @@ -147,7 +147,7 @@ opengl_particles::render( GLint const Textureunit ) { ::glTexCoordPointer( 2, GL_FLOAT, sizeof( particle_vertex ), reinterpret_cast( sizeof( float ) * 3 + sizeof( std::uint8_t ) * 4 ) ); ::glEnableClientState( GL_TEXTURE_COORD_ARRAY ); // ...draw... - ::glDrawArrays( GL_QUADS, 0, m_particlevertices.size() ); + ::glDrawArrays( GL_QUADS, 0, static_cast(m_particlevertices.size()) ); // ...and cleanup ::glPopClientAttrib(); ::glBindBuffer( GL_ARRAY_BUFFER, 0 ); diff --git a/rendering/particles.cpp b/rendering/particles.cpp index d31b8d6c..d96e5bae 100644 --- a/rendering/particles.cpp +++ b/rendering/particles.cpp @@ -69,9 +69,9 @@ smoke_source::particle_emitter::initialize( smoke_particle &Particle ) { Particle.velocity = launchvector * launchvelocity; - Particle.rotation = glm::radians( LocalRandom( 0, 360 ) ); - Particle.size = LocalRandom( size[ value_limit::min ], size[ value_limit::max ] ); - Particle.opacity = LocalRandom( opacity[ value_limit::min ], opacity[ value_limit::max ] ) / Global.SmokeFidelity; + Particle.rotation = static_cast(glm::radians( LocalRandom( 0, 360 ) )); + Particle.size = static_cast(LocalRandom( size[ value_limit::min ], size[ value_limit::max ] )); + Particle.opacity = static_cast(LocalRandom( opacity[ value_limit::min ], opacity[ value_limit::max ] ) / Global.SmokeFidelity); Particle.age = 0; } @@ -166,8 +166,8 @@ smoke_source::update( double const Timedelta, bool const Onlydespawn ) { ( ( false == Global.Smoke ) || ( true == Onlydespawn ) ) ? 0.f : std::min( - m_spawncount + ( m_spawnrate * Timedelta * Global.SmokeFidelity ), - m_max_particles ) ); + static_cast(m_spawncount + ( m_spawnrate * Timedelta * Global.SmokeFidelity )), + static_cast(m_max_particles) ) ); // consider special spawn rate cases if( m_ownertype == owner_type::vehicle ) { @@ -183,7 +183,7 @@ smoke_source::update( double const Timedelta, bool const Onlydespawn ) { 0.f : std::min( // m_spawncount + ( m_spawnrate * Timedelta * Global.SmokeFidelity ), - m_spawncount +(m_spawnrate * Timedelta * Global.SmokeFidelity * (((m_owner.vehicle->MoverParameters->enrot) / 4 ) * 0.01)), m_max_particles); + static_cast(m_spawncount +(m_spawnrate * Timedelta * Global.SmokeFidelity * (((m_owner.vehicle->MoverParameters->enrot) / 4 ) * 0.01))), static_cast(m_max_particles)); } else { @@ -195,7 +195,7 @@ smoke_source::update( double const Timedelta, bool const Onlydespawn ) { 0.f : std::min( // m_spawncount + ( m_spawnrate * Timedelta * Global.SmokeFidelity ), - m_spawncount + (m_spawnrate * Timedelta * Global.SmokeFidelity * ((((m_owner.vehicle->MoverParameters->DElist[m_owner.vehicle->MoverParameters->MainCtrlPosNo].RPM -m_owner.vehicle->MoverParameters->enrot) /60) *0.02) *(m_owner.vehicle->MoverParameters->EnginePower * 0.005))), m_max_particles); + static_cast(m_spawncount + (m_spawnrate * Timedelta * Global.SmokeFidelity * ((((m_owner.vehicle->MoverParameters->DElist[m_owner.vehicle->MoverParameters->MainCtrlPosNo].RPM -m_owner.vehicle->MoverParameters->enrot) /60) *0.02) *(m_owner.vehicle->MoverParameters->EnginePower * 0.005)))), static_cast(m_max_particles)); } else { @@ -205,7 +205,7 @@ smoke_source::update( double const Timedelta, bool const Onlydespawn ) { 0.f : std::min( // m_spawncount + ( m_spawnrate * Timedelta * Global.SmokeFidelity ), - m_spawncount + (m_spawnrate * Timedelta * Global.SmokeFidelity * ((((m_owner.vehicle->MoverParameters->DElist[m_owner.vehicle->MoverParameters->MainCtrlPosNo].RPM -m_owner.vehicle->MoverParameters->enrot) /60) * (sqrt(m_owner.vehicle->MoverParameters->Im) * 0.01) * 0.02) *(m_owner.vehicle->MoverParameters->EnginePower * 0.005))), m_max_particles); + static_cast(m_spawncount + (m_spawnrate * Timedelta * Global.SmokeFidelity * ((((m_owner.vehicle->MoverParameters->DElist[m_owner.vehicle->MoverParameters->MainCtrlPosNo].RPM -m_owner.vehicle->MoverParameters->enrot) /60) * (sqrt(m_owner.vehicle->MoverParameters->Im) * 0.01) * 0.02) *(m_owner.vehicle->MoverParameters->EnginePower * 0.005)))), static_cast(m_max_particles)); } } } @@ -283,7 +283,7 @@ smoke_source::update( double const Timedelta, bool const Onlydespawn ) { // determine bounding area from calculated bounding box if( false == m_particles.empty() ) { m_area.center = glm::mix(boundingbox[value_limit::min], boundingbox[value_limit::max], 0.5); - m_area.radius = 0.5 * ( glm::length( boundingbox[ value_limit::max ] - boundingbox[ value_limit::min ] ) ); + m_area.radius = static_cast(0.5 * ( glm::length( boundingbox[ value_limit::max ] - boundingbox[ value_limit::min ] ) )); } else { m_area.center = location(); @@ -331,7 +331,7 @@ smoke_source::initialize( smoke_particle &Particle ) { Particle.position = location(); if( m_ownertype == owner_type::vehicle ) { - Particle.opacity *= m_owner.vehicle->MoverParameters->dizel_fill; + Particle.opacity *= static_cast(m_owner.vehicle->MoverParameters->dizel_fill); auto const enginerevolutionsfactor { 1.5f }; // high engine revolutions increase initial particle velocity switch( m_owner.vehicle->MoverParameters->EngineType ) { case TEngineType::DieselElectric: { @@ -372,15 +372,15 @@ smoke_source::update( smoke_particle &Particle, bounding_box &Boundingbox, doubl { case owner_type::vehicle: { - Particle.velocity.y += ( 0.025 * Particle.velocity.y ) * std::min( 0.f, Global.AirTemperature - 90 ) * Timedelta; // decelerate faster in cold weather - Particle.velocity.y -= ( (0.05 * (pow(m_owner.vehicle->GetVelocity()*1,0.4))) * Particle.velocity.y ) * Global.Overcast * Timedelta; // decelerate faster with high air humidity and/or precipitation + Particle.velocity.y += static_cast(( 0.025 * Particle.velocity.y ) * std::min( 0.f, Global.AirTemperature - 90 ) * Timedelta); // decelerate faster in cold weather + Particle.velocity.y -= static_cast(( (0.05 * (pow(m_owner.vehicle->GetVelocity()*1,0.4))) * Particle.velocity.y ) * Global.Overcast * Timedelta); // decelerate faster with high air humidity and/or precipitation break; } default: { - Particle.velocity.y += ( 0.005 * Particle.velocity.y ) * std::min( 0.f, Global.AirTemperature - 10 ) * Timedelta; // decelerate faster in cold weather - Particle.velocity.y -= ( 0.050 * Particle.velocity.y ) * Global.Overcast * Timedelta; // decelerate faster with high air humidity and/or precipitation - Particle.velocity.y = std::max( 0.25 * ( 2.f - Global.Overcast ), Particle.velocity.y ); // put a cap on deceleration + Particle.velocity.y += static_cast(( 0.005 * Particle.velocity.y ) * std::min( 0.f, Global.AirTemperature - 10 ) * Timedelta); // decelerate faster in cold weather + Particle.velocity.y -= static_cast(( 0.050 * Particle.velocity.y ) * Global.Overcast * Timedelta); // decelerate faster with high air humidity and/or precipitation + Particle.velocity.y = std::max( static_cast(0.25 * ( 2.f - Global.Overcast )), Particle.velocity.y ); // put a cap on deceleration break; } } @@ -389,7 +389,7 @@ smoke_source::update( smoke_particle &Particle, bounding_box &Boundingbox, doubl Particle.position += 0.1f * Particle.age * simulation::Environment.wind() * static_cast( Timedelta ); // m_velocitymodifier.update( Particle.velocity, Timedelta ); - Particle.age += Timedelta; + Particle.age += static_cast(Timedelta); // update bounding box Boundingbox[ value_limit::min ] = glm::min( Boundingbox[ value_limit::min ], Particle.position - glm::dvec3{ Particle.size } ); diff --git a/scene/sn_utils.cpp b/scene/sn_utils.cpp index 08825d91..0df3f8cb 100644 --- a/scene/sn_utils.cpp +++ b/scene/sn_utils.cpp @@ -18,7 +18,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 = static_cast(buf[1] << 8 | buf[0]); return v; } @@ -142,7 +142,7 @@ uint8_t sn_utils::d_uint8( std::istream& s ) { void sn_utils::ls_uint16(std::ostream &s, uint16_t v) { uint8_t buf[2]; - buf[0] = v; + buf[0] = static_cast(v); buf[1] = v >> 8; s.write((char*)buf, 2); } @@ -150,9 +150,9 @@ void sn_utils::ls_uint16(std::ostream &s, uint16_t v) void sn_utils::ls_uint32(std::ostream &s, uint32_t v) { uint8_t buf[4]; - buf[0] = v; - buf[1] = v >> 8; - buf[2] = v >> 16; + buf[0] = static_cast(v); + buf[1] = static_cast(v >> 8); + buf[2] = static_cast(v >> 16); buf[3] = v >> 24; s.write((char*)buf, 4); } @@ -160,9 +160,9 @@ void sn_utils::ls_uint32(std::ostream &s, uint32_t v) void sn_utils::ls_int32(std::ostream &s, int32_t v) { uint8_t buf[4]; - buf[0] = v; - buf[1] = v >> 8; - buf[2] = v >> 16; + buf[0] = static_cast(v); + buf[1] = static_cast(v >> 8); + buf[2] = static_cast(v >> 16); buf[3] = v >> 24; s.write((char*)buf, 4); } @@ -170,13 +170,13 @@ void sn_utils::ls_int32(std::ostream &s, int32_t v) void sn_utils::ls_uint64(std::ostream &s, uint64_t v) { uint8_t buf[8]; - buf[0] = v; - buf[1] = v >> 8; - buf[2] = v >> 16; - buf[3] = v >> 24; - buf[4] = v >> 32; - buf[5] = v >> 40; - buf[6] = v >> 48; + buf[0] = static_cast(v); + buf[1] = static_cast(v >> 8); + buf[2] = static_cast(v >> 16); + buf[3] = static_cast(v >> 24); + buf[4] = static_cast(v >> 32); + buf[5] = static_cast(v >> 40); + buf[6] = static_cast(v >> 48); buf[7] = v >> 56; s.write((char*)buf, 8); } @@ -184,13 +184,13 @@ void sn_utils::ls_uint64(std::ostream &s, uint64_t v) void sn_utils::ls_int64(std::ostream &s, int64_t v) { uint8_t buf[8]; - buf[0] = v; - buf[1] = v >> 8; - buf[2] = v >> 16; - buf[3] = v >> 24; - buf[4] = v >> 32; - buf[5] = v >> 40; - buf[6] = v >> 48; + buf[0] = static_cast(v); + buf[1] = static_cast(v >> 8); + buf[2] = static_cast(v >> 16); + buf[3] = static_cast(v >> 24); + buf[4] = static_cast(v >> 32); + buf[5] = static_cast(v >> 40); + buf[6] = static_cast(v >> 48); buf[7] = v >> 56; s.write((char*)buf, 8); } @@ -199,9 +199,9 @@ void sn_utils::ls_float32(std::ostream &s, float t) { uint32_t v = std::bit_cast(t); uint8_t buf[4]; - buf[0] = v; - buf[1] = v >> 8; - buf[2] = v >> 16; + buf[0] = static_cast(v); + buf[1] = static_cast(v >> 8); + buf[2] = static_cast(v >> 16); buf[3] = v >> 24; s.write((char*)buf, 4); } @@ -210,13 +210,13 @@ void sn_utils::ls_float64(std::ostream &s, double t) { uint64_t v = std::bit_cast(t); uint8_t buf[8]; - buf[0] = v; - buf[1] = v >> 8; - buf[2] = v >> 16; - buf[3] = v >> 24; - buf[4] = v >> 32; - buf[5] = v >> 40; - buf[6] = v >> 48; + buf[0] = static_cast(v); + buf[1] = static_cast(v >> 8); + buf[2] = static_cast(v >> 16); + buf[3] = static_cast(v >> 24); + buf[4] = static_cast(v >> 32); + buf[5] = static_cast(v >> 40); + buf[6] = static_cast(v >> 48); buf[7] = v >> 56; s.write((char*)buf, 8); } diff --git a/scripting/ladderlogic.cpp b/scripting/ladderlogic.cpp index 5dcb1947..388fa12e 100644 --- a/scripting/ladderlogic.cpp +++ b/scripting/ladderlogic.cpp @@ -141,7 +141,7 @@ basic_controller::deserialize_operation( cParser &Input ) -> bool { auto const lookup { m_operationcodemap.find( operationname ) }; 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 ); + log_error( "contains unknown command \"" + operationname + "\"", static_cast(Input.Line() - 1) ); } if( operation.code == opcode_e::op_nop ) { return true; } diff --git a/scripting/ladderlogic.h b/scripting/ladderlogic.h index 075e4b0d..3d430f62 100644 --- a/scripting/ladderlogic.h +++ b/scripting/ladderlogic.h @@ -158,7 +158,7 @@ auto basic_controller::find_or_insert( std::string const &Name, basic_element::t auto index { 1 }; for( auto const &name : m_elementnames ) { if( name == Name ) { - return index; + return static_cast(index); } ++index; } diff --git a/scripting/pythonscreenviewer.cpp b/scripting/pythonscreenviewer.cpp index 3d63b9b4..78380293 100644 --- a/scripting/pythonscreenviewer.cpp +++ b/scripting/pythonscreenviewer.cpp @@ -91,7 +91,7 @@ void python_screen_viewer::threadfunc() glActiveTexture(GL_TEXTURE0); if (Global.python_sharectx) { - glBindTexture(GL_TEXTURE_2D, m_rt->shared_tex->get_id()); + glBindTexture(GL_TEXTURE_2D, static_cast(m_rt->shared_tex->get_id())); } else { GLuint tex; @@ -215,8 +215,8 @@ void python_screen_viewer::notify_cursor_pos(GLFWwindow *window, double x, doubl { for (auto &conf : m_windows) { if (conf->window == window) { - conf->cursor_pos.x = x; - conf->cursor_pos.y = y; + conf->cursor_pos.x = static_cast(x); + conf->cursor_pos.y = static_cast(y); return; } } diff --git a/simulation/simulationenvironment.cpp b/simulation/simulationenvironment.cpp index 6c4061c4..3c11c14d 100644 --- a/simulation/simulationenvironment.cpp +++ b/simulation/simulationenvironment.cpp @@ -196,7 +196,7 @@ world_environment::update() { if( true == (FreeFlyModeFlag || Global.CabWindowOpen) && Global.Weather == "rain:" ) { if( m_rainsound.is_combined() ) { - m_rainsound.pitch( Global.Overcast - 1.0 ); + m_rainsound.pitch( static_cast(Global.Overcast - 1.0) ); } m_rainsound .gain( m_rainsound.m_amplitudeoffset + m_rainsound.m_amplitudefactor * 1.f ) @@ -228,12 +228,12 @@ world_environment::update_wind() { m_wind.change_time -= timedelta; if( m_wind.change_time < 0 ) { - m_wind.change_time = Random( 5, 15 ); - m_wind.velocity_change = Random( -0.2, 0.2 ); + m_wind.change_time = static_cast(Random( 5, 15 )); + m_wind.velocity_change = static_cast(Random( -0.2, 0.2 )); if( Random() < 0.05 ) { // changes in wind direction should be less frequent than changes in wind speed // TBD, TODO: configuration-driven direction change frequency - m_wind.azimuth_change = Random( -5, 5 ); + m_wind.azimuth_change = static_cast(Random( -5, 5 )); } else { // keep direction change periods short, to avoid too drastic changes in direction diff --git a/simulation/simulationtime.cpp b/simulation/simulationtime.cpp index f1683c53..f04b4b47 100644 --- a/simulation/simulationtime.cpp +++ b/simulation/simulationtime.cpp @@ -27,20 +27,20 @@ scenario_time::init(std::time_t timestamp) { ::memcpy( m_monthdaycounts, monthdaycounts, sizeof( monthdaycounts ) ); // potentially adjust scenario clock - auto const requestedtime { clamp_circular( m_time.wHour * 60 + m_time.wMinute + Global.ScenarioTimeOffset * 60, 24 * 60 ) }; + auto const requestedtime { clamp_circular( static_cast(m_time.wHour * 60 + m_time.wMinute + Global.ScenarioTimeOffset * 60), 24 * 60 ) }; auto const requestedhour { requestedtime / 60 % 24 }; auto const requestedminute { requestedtime % 60 }; // cache requested elements, if any std::tm const tm = utc_tm(timestamp); std::tm const *tms = &tm; - m_time.wYear = tms->tm_year + 1900; - m_time.wMonth = tms->tm_mon + 1; - m_time.wDayOfWeek = tms->tm_wday; - m_time.wDay = tms->tm_mday; - m_time.wHour = tms->tm_hour; - m_time.wMinute = tms->tm_min; - m_time.wSecond = tms->tm_sec; + m_time.wYear = static_cast(tms->tm_year + 1900); + m_time.wMonth = static_cast(tms->tm_mon + 1); + m_time.wDayOfWeek = static_cast(tms->tm_wday); + m_time.wDay = static_cast(tms->tm_mday); + m_time.wHour = static_cast(tms->tm_hour); + m_time.wMinute = static_cast(tms->tm_min); + m_time.wSecond = static_cast(tms->tm_sec); m_time.wMilliseconds = 0; if( Global.fMoveLight > 0.0 ) { @@ -83,7 +83,7 @@ scenario_time::init(std::time_t timestamp) { zonebias += timezoneinfo.StandardBias; } - m_timezonebias = zonebias / 60.0; + m_timezonebias = static_cast(zonebias) / 60.0; } void @@ -95,7 +95,7 @@ scenario_time::update( double const Deltatime ) { ++m_time.wSecond; m_milliseconds -= 1000.0; } - m_time.wMilliseconds = std::floor( m_milliseconds ); + m_time.wMilliseconds = static_cast(std::floor( m_milliseconds )); while( m_time.wSecond >= 60 ) { ++m_time.wMinute; @@ -166,12 +166,12 @@ scenario_time::daymonth( WORD &Day, WORD &Month, WORD const Year, WORD const Yea int scenario_time::julian_day() const { - int yy = ( m_time.wYear < 0 ? m_time.wYear + 1 : m_time.wYear ) - std::floor( ( 12 - m_time.wMonth ) / 10.f ); + int yy = static_cast(( m_time.wYear < 0 ? m_time.wYear + 1 : m_time.wYear ) - std::floor( ( 12 - m_time.wMonth ) / 10.f )); int mm = m_time.wMonth + 9; if( mm >= 12 ) { mm -= 12; } - int K1 = std::floor( 365.25 * ( yy + 4712 ) ); - int K2 = std::floor( 30.6 * mm + 0.5 ); + int K1 = static_cast(std::floor( 365.25 * ( yy + 4712 ) )); + int K2 = static_cast(std::floor( 30.6 * mm + 0.5 )); // for dates in Julian calendar int JD = K1 + K2 + m_time.wDay + 59; @@ -179,7 +179,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 = static_cast(std::floor( std::floor( yy * 0.01 + 49 ) * 0.75 ) - 38); JD -= K3; } @@ -188,8 +188,8 @@ scenario_time::julian_day() const { void scenario_time::set_time(int yearday, int minute) { m_yearday = yearday; - daymonth(m_time.wDay, m_time.wMonth, m_time.wYear, m_yearday); - m_time.wHour = minute / 60; + daymonth(m_time.wDay, m_time.wMonth, m_time.wYear, static_cast(m_yearday)); + m_time.wHour = static_cast(minute / 60); m_time.wMinute = minute % 60; } @@ -246,7 +246,7 @@ void scenario_time::convert_transition_time( SYSTEMTIME &Time ) const { // NOTE: windows uses 0-6 range for days of week numbering, our methods use 1-7 - Time.wDay = day_of_month( Time.wDay, Time.wDayOfWeek + 1, Time.wMonth, m_time.wYear ); + Time.wDay = static_cast(day_of_month( Time.wDay, Time.wDayOfWeek + 1, Time.wMonth, m_time.wYear )); } bool diff --git a/utilities/Float3d.h b/utilities/Float3d.h index 4ff67a3c..93d07519 100644 --- a/utilities/Float3d.h +++ b/utilities/Float3d.h @@ -120,7 +120,7 @@ class float4 }; float inline Length() const { - return sqrt(x * x + y * y + z * z + w * w); + return static_cast(sqrt(x * x + y * y + z * z + w * w)); }; }; inline float4 operator*(const float4 &q1, const float4 &q2) @@ -194,8 +194,8 @@ inline float4 Slerp(const float4 &q0, const float4 &q1, float t) auto const sinOmega = std::sqrt(1.0f - cosOmega * cosOmega); // sinus z jedynki tryg. auto const omega = std::atan2(sinOmega, cosOmega); // wyznaczenie kąta auto const oneOverSinOmega = 1.0f / sinOmega; // odwrotność sinusa, bo sinus w mianowniku - k0 = sin((1.0f - t) * omega) * oneOverSinOmega; - k1 = sin(t * omega) * oneOverSinOmega; + k0 = static_cast(sin((1.0f - t) * omega) * oneOverSinOmega); + k1 = static_cast(sin(t * omega) * oneOverSinOmega); } return float4(q0.x * k0 + new_q1.x * k1, q0.y * k0 + new_q1.y * k1, q0.z * k0 + new_q1.z * k1, q0.w * k0 + new_q1.w * k1); diff --git a/utilities/Logs.cpp b/utilities/Logs.cpp index c26896e9..65fae196 100644 --- a/utilities/Logs.cpp +++ b/utilities/Logs.cpp @@ -33,14 +33,14 @@ std::string filename_date() { clock_gettime(CLOCK_REALTIME, &ts); std::tm const tm = local_tm(ts.tv_sec); std::tm const *tms = &tm; - st.wYear = tms->tm_year; - st.wMonth = tms->tm_mon; - st.wDayOfWeek = tms->tm_wday; - st.wDay = tms->tm_mday; - st.wHour = tms->tm_hour; - st.wMinute = tms->tm_min; - st.wSecond = tms->tm_sec; - st.wMilliseconds = ts.tv_nsec / 1000000; + st.wYear = static_cast(tms->tm_year); + st.wMonth = static_cast(tms->tm_mon); + st.wDayOfWeek = static_cast(tms->tm_wday); + st.wDay = static_cast(tms->tm_mday); + st.wHour = static_cast(tms->tm_hour); + st.wMinute = static_cast(tms->tm_min); + st.wSecond = static_cast(tms->tm_sec); + st.wMilliseconds = static_cast(ts.tv_nsec / 1000000); #elif _WIN32 ::GetLocalTime( &st ); #endif diff --git a/utilities/Timer.h b/utilities/Timer.h index 0e47e14c..32e170a4 100644 --- a/utilities/Timer.h +++ b/utilities/Timer.h @@ -35,7 +35,7 @@ public: std::chrono::duration stop() { m_last = std::chrono::duration_cast( std::chrono::steady_clock::now() - m_start ); - m_accumulator = 0.95f * m_accumulator + m_last.count() / 1000.f; + m_accumulator = 0.95f * m_accumulator + static_cast(m_last.count()) / 1000.f; return m_last; } float average() const { diff --git a/utilities/color.h b/utilities/color.h index 76aecf16..dd9ade6b 100644 --- a/utilities/color.h +++ b/utilities/color.h @@ -59,10 +59,10 @@ RGBtoHSV( glm::vec3 const &RGB ) { else hsv.x = 4.f + ( RGB.r - RGB.g ) / delta; // between magenta & cyan - hsv.x *= 60.0; // degrees + hsv.x *= 60.0f; // degrees if( hsv.x < 0.0 ) - hsv.x += 360.0; + hsv.x += 360.0f; return hsv; } @@ -81,9 +81,9 @@ HSVtoRGB( glm::vec3 const &HSV ) { } float hh = HSV.x; if( hh >= 360.0 ) hh = 0.0; - hh /= 60.0; + hh /= 60.0f; int const i = (int)hh; - float const ff = hh - i; + float const ff = hh - static_cast(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) ); diff --git a/utilities/headtrack.cpp b/utilities/headtrack.cpp index 2094a217..75cb301f 100644 --- a/utilities/headtrack.cpp +++ b/utilities/headtrack.cpp @@ -6,12 +6,12 @@ headtrack::headtrack() = default; void headtrack::find_joy() { for (size_t i = GLFW_JOYSTICK_1; i <= GLFW_JOYSTICK_LAST; i++) { - if (!glfwJoystickPresent(i)) + if (!glfwJoystickPresent(static_cast(i))) continue; - std::string name(glfwGetJoystickName(i)); + std::string name(glfwGetJoystickName(static_cast(i))); if (name == Global.headtrack_conf.joy) { - joy_id = i; + joy_id = static_cast(i); return; } } diff --git a/utilities/motiontelemetry.cpp b/utilities/motiontelemetry.cpp index 1bfe1f36..21fa6961 100644 --- a/utilities/motiontelemetry.cpp +++ b/utilities/motiontelemetry.cpp @@ -146,15 +146,15 @@ void motiontelemetry::update() } float buffer[12] = { 0 }; - buffer[0] = Timer::GetTime(); - buffer[1] = velocity; - buffer[2] = local_acc.y; - buffer[3] = local_acc.z; - buffer[4] = local_acc.x; - buffer[5] = glm::degrees(rot.x); - buffer[6] = glm::degrees(rot.z); - buffer[7] = glm::degrees(rot.y); - buffer[8] = yaw_vel; + buffer[0] = static_cast(Timer::GetTime()); + buffer[1] = static_cast(velocity); + buffer[2] = static_cast(local_acc.y); + buffer[3] = static_cast(local_acc.z); + buffer[4] = static_cast(local_acc.x); + buffer[5] = static_cast(glm::degrees(rot.x)); + buffer[6] = static_cast(glm::degrees(rot.z)); + buffer[7] = static_cast(glm::degrees(rot.y)); + buffer[8] = static_cast(yaw_vel); buffer[9] = 1.0f; if (send(sock, (char*)buffer, sizeof(buffer), 0) == -1) diff --git a/utilities/uart.cpp b/utilities/uart.cpp index 4a07bd2c..1ef1f372 100644 --- a/utilities/uart.cpp +++ b/utilities/uart.cpp @@ -275,7 +275,7 @@ void uart_input::poll() /* handle baud change */ if(status->active_baud_index != status->selected_baud_index) { - status->baud = std::stoul(uart_baudrates_list[status->selected_baud_index]); + status->baud = static_cast(std::stoul(uart_baudrates_list[status->selected_baud_index])); status->active_baud_index = status->selected_baud_index; status->reset_stats(); status->is_connected = false; @@ -534,7 +534,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 : static_cast(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); @@ -543,7 +543,7 @@ void uart_input::poll() uint16_t current1 = (uint16_t)std::min(conf.currentuart, trainstate.hv_current[0] / conf.currentmax * conf.currentuart); uint16_t current2 = (uint16_t)std::min(conf.currentuart, trainstate.hv_current[1] / conf.currentmax * conf.currentuart); uint16_t current3 = (uint16_t)std::min(conf.currentuart, trainstate.hv_current[2] / conf.currentmax * conf.currentuart); - uint32_t odometer = trainstate.distance * 10000.0; + uint32_t odometer = static_cast(trainstate.distance * 10000.0); uint16_t lv_voltage = (uint16_t)std::min( conf.lvuart, trainstate.lv_voltage / conf.lvmax * conf.lvuart ); if( trainstate.cab > 0 ) { // NOTE: moving from a cab to engine room doesn't change cab indicator diff --git a/utilities/utilities.h b/utilities/utilities.h index 79339de4..0e365c94 100644 --- a/utilities/utilities.h +++ b/utilities/utilities.h @@ -100,7 +100,7 @@ inline double LocalRandom(double b) inline double BorlandTime() { auto timesinceepoch = std::time(nullptr); - return timesinceepoch / (24.0 * 60 * 60); + return static_cast(timesinceepoch) / (24.0 * 60 * 60); /* // std alternative auto timesinceepoch = std::chrono::system_clock::now().time_since_epoch(); @@ -315,7 +315,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 static_cast(Step * std::round(Value / Step)); } template T min_speed(T const Left, T const Right) diff --git a/vehicle/Camera.cpp b/vehicle/Camera.cpp index 3186030e..e24bd3f3 100644 --- a/vehicle/Camera.cpp +++ b/vehicle/Camera.cpp @@ -40,8 +40,8 @@ void TCamera::Reset() { void TCamera::OnCursorMove(double x, double y) { - m_rotationoffsets.x += y; - m_rotationoffsets.y += x; + m_rotationoffsets.x += static_cast(y); + m_rotationoffsets.y += static_cast(x); } static double ComputeAxisSpeed(double param, double walkspeed, double maxspeed, double threshold) { @@ -142,13 +142,13 @@ void TCamera::Update() // update rotation auto const rotationfactor { std::min( 1.0, 20 * deltatime ) }; - Angle.y -= m_rotationoffsets.y * rotationfactor; - m_rotationoffsets.y *= 1.0 - rotationfactor; - Angle.y = std::remainder(Angle.y, 2.0 * M_PI); + Angle.y -= static_cast(m_rotationoffsets.y * rotationfactor); + m_rotationoffsets.y *= static_cast(1.0 - rotationfactor); + Angle.y = static_cast(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 = static_cast(std::clamp(Angle.x - m_rotationoffsets.x * rotationfactor, -M_PI_2, M_PI_2)); + m_rotationoffsets.x *= static_cast(1.0 - rotationfactor); // update position if( m_owner == nullptr @@ -215,12 +215,12 @@ 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 ) { - Angle.y = atan2( -where.x, -where.z ); // kąt horyzontalny + Angle.y = static_cast(atan2( -where.x, -where.z )); // kąt horyzontalny m_rotationoffsets.y = 0.0; } double l = glm::length(where); if( l > 0.0 ) { - Angle.x = asin( where.y / l ); // kąt w pionie + Angle.x = static_cast(asin( where.y / l )); // kąt w pionie m_rotationoffsets.x = 0.0; } }; diff --git a/vehicle/Gauge.cpp b/vehicle/Gauge.cpp index c91045e4..182d5878 100644 --- a/vehicle/Gauge.cpp +++ b/vehicle/Gauge.cpp @@ -184,9 +184,9 @@ void TGauge::Load( cParser &Parser, TDynamicObject const *Owner, double const mu soundfxrecord.second.owner( Owner ); } - scale *= mul; + scale *= static_cast(mul); if( interpolatescale ) { - endscale *= mul; + endscale *= static_cast(mul); } TSubModel *submodel { nullptr }; std::array sources { Owner->mdKabina, Owner->mdLowPolyInt }; @@ -362,7 +362,7 @@ void TGauge::Update( bool const Power ) { // update value // TODO: remove passing manually power state when LD is in place if( m_value != m_targetvalue ) { - float dt = Timer::GetDeltaTime(); + float dt = static_cast(Timer::GetDeltaTime()); 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; @@ -429,11 +429,11 @@ void TGauge::UpdateValue() break; } case 'd': { - UpdateValue( *dData ); + UpdateValue( static_cast(*dData) ); break; } case 'i': { - UpdateValue( *iData ); + UpdateValue( static_cast(*iData) ); break; } case 'b': { @@ -463,7 +463,7 @@ TGauge::UpdateAnimation( TSubModel *Submodel ) { switch (m_animation) { case TGaugeAnimation::gt_Rotate: { - Submodel->SetRotate( float3( 0, 1, 0 ), GetScaledValue() * 360.0 ); + Submodel->SetRotate( float3( 0, 1, 0 ), static_cast(GetScaledValue() * 360.0) ); break; } case TGaugeAnimation::gt_Move: { @@ -472,13 +472,13 @@ TGauge::UpdateAnimation( TSubModel *Submodel ) { } case TGaugeAnimation::gt_Wiper: { auto const scaledvalue { GetScaledValue() }; - Submodel->SetRotate( float3( 0, 1, 0 ), scaledvalue * 360.0 ); + Submodel->SetRotate( float3( 0, 1, 0 ), static_cast(scaledvalue * 360.0) ); auto *sm = Submodel->ChildGet(); if( sm ) { - sm->SetRotate( float3( 0, 1, 0 ), scaledvalue * 360.0 ); + sm->SetRotate( float3( 0, 1, 0 ), static_cast(scaledvalue * 360.0) ); sm = sm->ChildGet(); if( sm ) - sm->SetRotate( float3( 0, 1, 0 ), scaledvalue * 360.0 ); + sm->SetRotate( float3( 0, 1, 0 ), static_cast(scaledvalue * 360.0) ); } break; } @@ -493,7 +493,7 @@ TGauge::UpdateAnimation( TSubModel *Submodel ) { && std::isdigit(sm->pName[0]) ) { sm->SetRotate( float3( 0, 1, 0 ), - -36.0 * ( n[ '0' + 9 - sm->pName[ 0 ] ] - '0' ) ); + static_cast(-36.0 * ( n[ '0' + 9 - sm->pName[ 0 ] ] - '0' )) ); } sm = sm->NextGet(); } while( sm ); diff --git a/vehicle/Train.cpp b/vehicle/Train.cpp index ec9ac51a..1de804c0 100644 --- a/vehicle/Train.cpp +++ b/vehicle/Train.cpp @@ -155,7 +155,7 @@ void TCab::Load(cParser &Parser) Parser.getTokens(); Parser >> token; } - CabPos1.x = std::stod(token); + CabPos1.x = static_cast(std::stod(token)); Parser.getTokens(5, false); Parser >> CabPos1.y >> CabPos1.z >> CabPos2.x >> CabPos2.y >> CabPos2.z; @@ -983,7 +983,7 @@ bool TTrain::is_eztoer() const 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(static_cast(Position), mvControlled->CoupledCtrl ? mvControlled->MainCtrlPosNo + mvControlled->ScndCtrlPosNo : mvControlled->MainCtrlPosNo) - (mvControlled->CoupledCtrl ? mvControlled->MainCtrlPos + mvControlled->ScndCtrlPos : mvControlled->MainCtrlPos)}; while (positionchange < 0 && true == mvControlled->DecMainCtrl(1)) { @@ -1039,7 +1039,7 @@ 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 : static_cast(mvOccupied->BrakeDelayFlag - 1), dsbSwitch); } if (ggBrakeProfileG.SubModel != nullptr) { @@ -1683,7 +1683,7 @@ void TTrain::OnCommand_secondcontrollerdecreasefast(TTrain *Train, command_data void TTrain::OnCommand_secondcontrollerset(TTrain *Train, command_data const &Command) { - auto const targetposition{std::min(Command.param1, Train->mvControlled->ScndCtrlPosNo)}; + auto const targetposition{std::min(static_cast(Command.param1), Train->mvControlled->ScndCtrlPosNo)}; // HACK: potentially animate push or pushtoggle control if (Train->ggScndCtrl.is_push()) { @@ -1729,7 +1729,7 @@ void TTrain::OnCommand_independentbrakeincrease(TTrain *Train, command_data cons } else { - Train->mvOccupied->IncLocalBrakeLevel(useStepped ? 1 : Global.brake_speed * Command.time_delta * LocalBrakePosNo); + Train->mvOccupied->IncLocalBrakeLevel(useStepped ? 1 : static_cast(Global.brake_speed * Command.time_delta * LocalBrakePosNo)); if (useStepped) { Train->m_mastercontrollerinuse = true; @@ -1784,7 +1784,7 @@ void TTrain::OnCommand_independentbrakedecrease(TTrain *Train, command_data cons } else { - Train->mvOccupied->DecLocalBrakeLevel(useStepped ? 1 : Global.brake_speed * Command.time_delta * LocalBrakePosNo); + Train->mvOccupied->DecLocalBrakeLevel(useStepped ? 1 : static_cast(Global.brake_speed * Command.time_delta * LocalBrakePosNo)); if (useStepped) { Train->m_mastercontrollerinuse = true; @@ -2455,7 +2455,7 @@ void TTrain::OnCommand_trainbrakeoperationmodeincrease(TTrain *Train, command_da // next mode Train->mvOccupied->BrakeOpModeFlag <<= 1; // visual feedback - Train->ggBrakeOperationModeCtrl.UpdateValue(Train->mvOccupied->BrakeOpModeFlag > 0 ? std::log2(Train->mvOccupied->BrakeOpModeFlag) : 0); // audio fallback + Train->ggBrakeOperationModeCtrl.UpdateValue(Train->mvOccupied->BrakeOpModeFlag > 0 ? static_cast(std::log2(Train->mvOccupied->BrakeOpModeFlag)) : 0); // audio fallback } } } @@ -2471,7 +2471,7 @@ void TTrain::OnCommand_trainbrakeoperationmodedecrease(TTrain *Train, command_da // previous mode Train->mvOccupied->BrakeOpModeFlag >>= 1; // visual feedback - Train->ggBrakeOperationModeCtrl.UpdateValue(Train->mvOccupied->BrakeOpModeFlag > 0 ? std::log2(Train->mvOccupied->BrakeOpModeFlag) : 0); + Train->ggBrakeOperationModeCtrl.UpdateValue(Train->mvOccupied->BrakeOpModeFlag > 0 ? static_cast(std::log2(Train->mvOccupied->BrakeOpModeFlag)) : 0); } } } @@ -2642,7 +2642,7 @@ void TTrain::OnCommand_wiperswitchincrease(TTrain *Train, command_data const &Co Train->mvOccupied->wiperSwitchPos = Train->mvOccupied->WiperListSize - 1; // Visual feedback - Train->ggWiperSw.UpdateValue(Train->mvOccupied->wiperSwitchPos, Train->dsbSwitch); + Train->ggWiperSw.UpdateValue(static_cast(Train->mvOccupied->wiperSwitchPos), Train->dsbSwitch); } } void TTrain::OnCommand_wiperswitchdecrease(TTrain *Train, command_data const &Command) @@ -2654,7 +2654,7 @@ void TTrain::OnCommand_wiperswitchdecrease(TTrain *Train, command_data const &Co Train->mvOccupied->wiperSwitchPos = 0; // visual feedback - Train->ggWiperSw.UpdateValue(Train->mvOccupied->wiperSwitchPos, Train->dsbSwitch); + Train->ggWiperSw.UpdateValue(static_cast(Train->mvOccupied->wiperSwitchPos), Train->dsbSwitch); } } @@ -3531,7 +3531,7 @@ void TTrain::change_pantograph_selection(int const Change) auto const &presets{mvOccupied->PantsPreset.first}; auto &selection{mvOccupied->PantsPreset.second[cab_to_end()]}; auto const initialstate{selection}; - selection = std::clamp(selection + Change, 0, std::max(presets.size() - 1, 0)); + selection = std::clamp(selection + Change, 0, std::max(static_cast(presets.size() - 1), 0)); if (selection == initialstate) { @@ -4674,7 +4674,7 @@ void TTrain::OnCommand_compressorpresetactivatenext(TTrain *Train, command_data 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); + Train->ggCompressorListButton.UpdateValue(static_cast(Train->mvOccupied->CompressorListPos - 1), Train->dsbSwitch); } else { @@ -4689,7 +4689,7 @@ void TTrain::OnCommand_compressorpresetactivatenext(TTrain *Train, command_data // 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 // visual feedback - Train->ggCompressorListButton.UpdateValue(Train->mvOccupied->CompressorListPos - 1, Train->dsbSwitch); + Train->ggCompressorListButton.UpdateValue(static_cast(Train->mvOccupied->CompressorListPos - 1), Train->dsbSwitch); } } } @@ -4720,7 +4720,7 @@ void TTrain::OnCommand_compressorpresetactivateprevious(TTrain *Train, command_d // visual feedback if (Train->ggCompressorListButton.SubModel != nullptr) { - Train->ggCompressorListButton.UpdateValue(Train->mvOccupied->CompressorListPos - 1, Train->dsbSwitch); + Train->ggCompressorListButton.UpdateValue(static_cast(Train->mvOccupied->CompressorListPos - 1), Train->dsbSwitch); } } } @@ -4742,7 +4742,7 @@ void TTrain::OnCommand_compressorpresetactivatedefault(TTrain *Train, command_da // visual feedback if (Train->ggCompressorListButton.SubModel != nullptr) { - Train->ggCompressorListButton.UpdateValue(Train->mvOccupied->CompressorListPos - 1, Train->dsbSwitch); + Train->ggCompressorListButton.UpdateValue(static_cast(Train->mvOccupied->CompressorListPos - 1), Train->dsbSwitch); } } @@ -5216,11 +5216,11 @@ void TTrain::OnCommand_lightspresetactivatenext(TTrain *Train, command_data cons // HACK: skip submodel animation when restarting cycle, since it plays in the 'wrong' direction if (false == restartcycle) { - Train->ggLightsButton.UpdateValue(Train->mvOccupied->LightsPos - 1, Train->dsbSwitch); + Train->ggLightsButton.UpdateValue(static_cast(Train->mvOccupied->LightsPos - 1), Train->dsbSwitch); } else { - Train->ggLightsButton.PutValue(Train->mvOccupied->LightsPos - 1); + Train->ggLightsButton.PutValue(static_cast(Train->mvOccupied->LightsPos - 1)); } } } @@ -5253,11 +5253,11 @@ void TTrain::OnCommand_lightspresetactivateprevious(TTrain *Train, command_data // HACK: skip submodel animation when restarting cycle, since it plays in the 'wrong' direction if (false == restartcycle) { - Train->ggLightsButton.UpdateValue(Train->mvOccupied->LightsPos - 1, Train->dsbSwitch); + Train->ggLightsButton.UpdateValue(static_cast(Train->mvOccupied->LightsPos - 1), Train->dsbSwitch); } else { - Train->ggLightsButton.PutValue(Train->mvOccupied->LightsPos - 1); + Train->ggLightsButton.PutValue(static_cast(Train->mvOccupied->LightsPos - 1)); } } } @@ -5287,8 +5287,8 @@ void TTrain::OnCommand_headlighttoggleleft(TTrain *Train, command_data const &Co void TTrain::OnCommand_lightsset(TTrain *Train, command_data const &Command) { // set custom item in Lights inventory - Train->mvOccupied->Lights[end::front][17] = Command.param1; - Train->mvOccupied->Lights[end::rear][17] = Command.param2; + Train->mvOccupied->Lights[end::front][17] = static_cast(Command.param1); + Train->mvOccupied->Lights[end::rear][17] = static_cast(Command.param2); Train->mvOccupied->LightsPos = 18; // nasza custom pozycja Train->Dynamic()->SetLights(); } @@ -5904,7 +5904,7 @@ void TTrain::OnCommand_modernlightdimmerincrease(TTrain *Train, command_data con // visual feedback if (Train->ggModernLightDimSw.SubModel != nullptr) - Train->ggModernLightDimSw.UpdateValue(dimPos, Train->dsbSwitch); + Train->ggModernLightDimSw.UpdateValue(static_cast(dimPos), Train->dsbSwitch); } } void TTrain::OnCommand_modernlightdimmerdecrease(TTrain *Train, command_data const &Command) @@ -5931,7 +5931,7 @@ void TTrain::OnCommand_modernlightdimmerdecrease(TTrain *Train, command_data con Train->Dynamic()->SetLightDimmings(); if (Train->ggModernLightDimSw.SubModel != nullptr) - Train->ggModernLightDimSw.UpdateValue(dimPos, Train->dsbSwitch); + Train->ggModernLightDimSw.UpdateValue(static_cast(dimPos), Train->dsbSwitch); } } @@ -7302,7 +7302,7 @@ void TTrain::OnCommand_doorpermitpresetactivatenext(TTrain *Train, command_data Train->mvOccupied->ChangeDoorPermitPreset(1); // visual feedback - Train->ggDoorPermitPresetButton.UpdateValue(Train->mvOccupied->Doors.permit_preset, Train->dsbSwitch); + Train->ggDoorPermitPresetButton.UpdateValue(static_cast(Train->mvOccupied->Doors.permit_preset), Train->dsbSwitch); } } @@ -7314,7 +7314,7 @@ void TTrain::OnCommand_doorpermitpresetactivateprevious(TTrain *Train, command_d Train->mvOccupied->ChangeDoorPermitPreset(-1); // visual feedback - Train->ggDoorPermitPresetButton.UpdateValue(Train->mvOccupied->Doors.permit_preset, Train->dsbSwitch); + Train->ggDoorPermitPresetButton.UpdateValue(static_cast(Train->mvOccupied->Doors.permit_preset), Train->dsbSwitch); } } @@ -8141,7 +8141,7 @@ void TTrain::OnCommand_radiochannelset(TTrain *Train, command_data const &Comman { // on press or hold Train->RadioChannel() = std::clamp((int)Command.param1, 1, 10); - Train->ggRadioChannelSelector.UpdateValue(Train->RadioChannel() - 1); + Train->ggRadioChannelSelector.UpdateValue(static_cast(Train->RadioChannel() - 1)); } } @@ -8281,7 +8281,7 @@ void TTrain::OnCommand_radiovolumeset(TTrain *Train, command_data const &Command if (Command.action != GLFW_RELEASE) { // on press or hold - Train->m_radiovolume = std::clamp(Command.param1, 0.0, 1.0); + Train->m_radiovolume = static_cast(std::clamp(Command.param1, 0.0, 1.0)); Train->ggRadioVolumeSelector.UpdateValue(Train->m_radiovolume); audio::event_volume_change = true; } @@ -8440,7 +8440,7 @@ bool TTrain::Update(double const Deltatime) // keep track of period the line breaker button is held down, to determine when/if circuit closes if (mvControlled->MainSwitchCheck()) { - fMainRelayTimer += Deltatime; + fMainRelayTimer += static_cast(Deltatime); } } else @@ -8480,7 +8480,7 @@ bool TTrain::Update(double const Deltatime) { continue; } - doorpermittimer -= Deltatime; + doorpermittimer -= static_cast(Deltatime); if (doorpermittimer < 0.f) { mvOccupied->OperateDoors(static_cast(idx), true); @@ -8490,7 +8490,7 @@ bool TTrain::Update(double const Deltatime) // train measurement timer if (trainLenghtMeasureTimer >= 0.f) { - trainLenghtMeasureTimer -= Deltatime; + trainLenghtMeasureTimer -= static_cast(Deltatime); if (trainLenghtMeasureTimer < 0.f) trainLenghtMeasureTimer = -1.f; } @@ -8498,7 +8498,7 @@ bool TTrain::Update(double const Deltatime) // battery timer if (fBatteryTimer >= 0.f) { - fBatteryTimer -= Deltatime; + fBatteryTimer -= static_cast(Deltatime); if (fBatteryTimer < 0.f) fBatteryTimer = -1.f; } @@ -8559,7 +8559,7 @@ bool TTrain::Update(double const Deltatime) */ if (false == (m_mastercontrollerinuse || Global.ctrlState)) { - m_mastercontrollerreturndelay -= Deltatime; + m_mastercontrollerreturndelay -= static_cast(Deltatime); if (m_mastercontrollerreturndelay < 0.f) { m_mastercontrollerreturndelay = EU07_CONTROLLER_BASERETURNDELAY; @@ -8592,9 +8592,9 @@ bool TTrain::Update(double const Deltatime) if (ff != fTachoTimer) // jesli w tej sekundzie nie zmienial { if (fTachoVelocity >= 5) // jedzie - fTachoVelocityJump = fTachoVelocity + (2.0 - LocalRandom(3) + LocalRandom(3)) * 0.5; + fTachoVelocityJump = static_cast(fTachoVelocity + (2.0 - LocalRandom(3) + LocalRandom(3)) * 0.5); else if (fTachoVelocity < 5 && fTachoVelocity > 1) - fTachoVelocityJump = Random(0, 4); // tu ma sie bujac jak wariat i zatrzymac na jakiejs predkosci + fTachoVelocityJump = static_cast(Random(0, 4)); // tu ma sie bujac jak wariat i zatrzymac na jakiejs predkosci // fTachoVelocityJump = 0; // stoi fTachoTimer = ff; // juz zmienil } @@ -8602,43 +8602,43 @@ bool TTrain::Update(double const Deltatime) if (fTachoVelocity > 1) // McZapkie-270503: podkrecanie tachometru { // szybciej zacznij stukac - fTachoCount = std::min(maxtacho, fTachoCount + Deltatime * 3); + fTachoCount = static_cast(std::min(maxtacho, fTachoCount + Deltatime * 3)); } else if (fTachoCount > 0) { // schodz powoli - niektore haslery to ze 4 sekundy potrafia stukac - fTachoCount = std::max(0.0, fTachoCount - Deltatime * 0.66); + fTachoCount = static_cast(std::max(0.0, fTachoCount - Deltatime * 0.66)); } // 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) { // Ra 2014-09: czy taki rozdzia? ma sens? - fHVoltage = std::max(mvControlled->PantographVoltage, - mvControlled->GetTrainsetHighVoltage()); // Winger czy to nie jest zle? + fHVoltage = static_cast(std::max(mvControlled->PantographVoltage, + mvControlled->GetTrainsetHighVoltage())); // Winger czy to nie jest zle? } // *mvControlled->Mains); else { - fHVoltage = mvControlled->EngineVoltage; + fHVoltage = static_cast(mvControlled->EngineVoltage); } if (ShowNextCurrent) { // jeśli pokazywać drugi człon if (mvSecond) { // o ile jest ten drugi - fHCurrent[0] = mvSecond->ShowCurrent(0) * 1.05; - fHCurrent[1] = mvSecond->ShowCurrent(1) * 1.05; - fHCurrent[2] = mvSecond->ShowCurrent(2) * 1.05; - fHCurrent[3] = mvSecond->ShowCurrent(3) * 1.05; + fHCurrent[0] = static_cast(mvSecond->ShowCurrent(0) * 1.05); + fHCurrent[1] = static_cast(mvSecond->ShowCurrent(1) * 1.05); + fHCurrent[2] = static_cast(mvSecond->ShowCurrent(2) * 1.05); + fHCurrent[3] = static_cast(mvSecond->ShowCurrent(3) * 1.05); } else fHCurrent[0] = fHCurrent[1] = fHCurrent[2] = fHCurrent[3] = 0.0; // gdy nie ma człona } else { // normalne pokazywanie - fHCurrent[0] = mvControlled->ShowCurrent(0); - fHCurrent[1] = mvControlled->ShowCurrent(1); - fHCurrent[2] = mvControlled->ShowCurrent(2); - fHCurrent[3] = mvControlled->ShowCurrent(3); + fHCurrent[0] = static_cast(mvControlled->ShowCurrent(0)); + fHCurrent[1] = static_cast(mvControlled->ShowCurrent(1)); + fHCurrent[2] = static_cast(mvControlled->ShowCurrent(2)); + fHCurrent[3] = static_cast(mvControlled->ShowCurrent(3)); } bool kier = DynamicObject->DirectionGet() * mvOccupied->CabOccupied > 0; @@ -8669,13 +8669,13 @@ bool TTrain::Update(double const Deltatime) { if (p) { - fPress[i][0] = p->MoverParameters->BrakePress; - fPress[i][1] = p->MoverParameters->PipePress; - fPress[i][2] = p->MoverParameters->ScndPipePress; - fPress[i][3] = p->MoverParameters->CntrlPipePress; - fPress[i][4] = p->MoverParameters->Hamulec->GetBRP(); - fPress[i][5] = (p->MoverParameters->TotalMass - p->MoverParameters->Mred) * 0.001; - fPress[i][6] = p->MoverParameters->SpringBrake.SBP; + fPress[i][0] = static_cast(p->MoverParameters->BrakePress); + fPress[i][1] = static_cast(p->MoverParameters->PipePress); + fPress[i][2] = static_cast(p->MoverParameters->ScndPipePress); + fPress[i][3] = static_cast(p->MoverParameters->CntrlPipePress); + fPress[i][4] = static_cast(p->MoverParameters->Hamulec->GetBRP()); + fPress[i][5] = static_cast((p->MoverParameters->TotalMass - p->MoverParameters->Mred) * 0.001); + fPress[i][6] = static_cast(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; @@ -8708,19 +8708,19 @@ bool TTrain::Update(double const Deltatime) bSlip[i] = p->MoverParameters->SlippingWheels; if (in < 8 && p->MoverParameters->eimc[eimc_p_Pmax] > 1) { - fEIMParams[1 + in][0] = p->MoverParameters->eimv[eimv_Fmax]; + fEIMParams[1 + in][0] = static_cast(p->MoverParameters->eimv[eimv_Fmax]); fEIMParams[1 + in][1] = std::max(fEIMParams[1 + in][0], 0.f); fEIMParams[1 + in][2] = -std::min(fEIMParams[1 + in][0], 0.f); - fEIMParams[1 + in][3] = p->MoverParameters->eimv[eimv_Fmax] / std::max(p->MoverParameters->eimv[eimv_Fful], 1.); + fEIMParams[1 + in][3] = static_cast(p->MoverParameters->eimv[eimv_Fmax] / std::max(p->MoverParameters->eimv[eimv_Fful], 1.)); fEIMParams[1 + in][4] = std::max(fEIMParams[1 + in][3], 0.f); fEIMParams[1 + in][5] = -std::min(fEIMParams[1 + in][3], 0.f); - fEIMParams[1 + in][6] = p->MoverParameters->eimv[eimv_If]; - fEIMParams[1 + in][7] = p->MoverParameters->eimv[eimv_U]; - fEIMParams[1 + in][8] = p->MoverParameters->Itot; // p->MoverParameters->eimv[eimv_Ipoj]; - fEIMParams[1 + in][9] = p->MoverParameters->EngineVoltage; + fEIMParams[1 + in][6] = static_cast(p->MoverParameters->eimv[eimv_If]); + fEIMParams[1 + in][7] = static_cast(p->MoverParameters->eimv[eimv_U]); + fEIMParams[1 + in][8] = static_cast(p->MoverParameters->Itot); // p->MoverParameters->eimv[eimv_Ipoj]; + fEIMParams[1 + in][9] = static_cast(p->MoverParameters->EngineVoltage); fEIMParams[0][6] += fEIMParams[1 + in][8]; bMains[in] = p->MoverParameters->Mains; - fCntVol[in] = p->MoverParameters->BatteryVoltage; + fCntVol[in] = static_cast(p->MoverParameters->BatteryVoltage); bFuse[in] = p->MoverParameters->FuseFlag; bBatt[in] = p->MoverParameters->Battery; bConv[in] = p->MoverParameters->ConverterFlag; @@ -8732,18 +8732,18 @@ bool TTrain::Update(double const Deltatime) } 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; - fDieselParams[1 + in][2] = p->MoverParameters->RList[p->MoverParameters->MainCtrlPos].R; - fDieselParams[1 + in][3] = p->MoverParameters->dizel_fill; - fDieselParams[1 + in][4] = p->MoverParameters->RList[p->MoverParameters->MainCtrlPos].Mn; - fDieselParams[1 + in][5] = p->MoverParameters->dizel_engage; + fDieselParams[1 + in][0] = static_cast(p->MoverParameters->enrot * 60); + fDieselParams[1 + in][1] = static_cast(p->MoverParameters->nrot); + fDieselParams[1 + in][2] = static_cast(p->MoverParameters->RList[p->MoverParameters->MainCtrlPos].R); + fDieselParams[1 + in][3] = static_cast(p->MoverParameters->dizel_fill); + fDieselParams[1 + in][4] = static_cast(p->MoverParameters->RList[p->MoverParameters->MainCtrlPos].Mn); + fDieselParams[1 + in][5] = static_cast(p->MoverParameters->dizel_engage); fDieselParams[1 + in][6] = p->MoverParameters->dizel_heat.Twy; fDieselParams[1 + in][7] = p->MoverParameters->OilPump.pressure; fDieselParams[1 + in][8] = p->MoverParameters->dizel_heat.Ts; - fDieselParams[1 + in][9] = p->MoverParameters->hydro_R_Fill; + fDieselParams[1 + in][9] = static_cast(p->MoverParameters->hydro_R_Fill); bMains[in] = p->MoverParameters->Mains; - fCntVol[in] = p->MoverParameters->BatteryVoltage; + fCntVol[in] = static_cast(p->MoverParameters->BatteryVoltage); bFuse[in] = p->MoverParameters->FuseFlag; bBatt[in] = p->MoverParameters->Battery; bConv[in] = p->MoverParameters->ConverterFlag; @@ -8773,11 +8773,11 @@ bool TTrain::Update(double const Deltatime) // else // fEIMParams[0][3] = // mvControlled->eimv[eimv_Fzad] - mvOccupied->LocalBrakeRatio(); // procent zadany - fEIMParams[0][3] = mvOccupied->eimic_real; + fEIMParams[0][3] = static_cast(mvOccupied->eimic_real); fEIMParams[0][4] = std::max(fEIMParams[0][3], 0.f); fEIMParams[0][5] = -std::min(fEIMParams[0][3], 0.f); - fEIMParams[0][1] = fEIMParams[0][4] * mvControlled->eimv[eimv_Fful]; - fEIMParams[0][2] = fEIMParams[0][5] * mvControlled->eimv[eimv_Fful]; + fEIMParams[0][1] = static_cast(fEIMParams[0][4] * mvControlled->eimv[eimv_Fful]); + fEIMParams[0][2] = static_cast(fEIMParams[0][5] * mvControlled->eimv[eimv_Fful]); fEIMParams[0][0] = fEIMParams[0][1] - fEIMParams[0][2]; fEIMParams[0][7] = 0; fEIMParams[0][8] = 0; @@ -8816,7 +8816,7 @@ bool TTrain::Update(double const Deltatime) // Ra 15-01: to musi stąd wylecieć - zależności nie mogą być w kabinie if (mvControlled->ConverterFlag == true) { - fConverterTimer += Deltatime; + fConverterTimer += static_cast(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) @@ -8854,22 +8854,22 @@ bool TTrain::Update(double const Deltatime) { if (ggI1B.SubModel) { - ggI1B.UpdateValue(tmp->MoverParameters->ShowCurrent(1)); + ggI1B.UpdateValue(static_cast(tmp->MoverParameters->ShowCurrent(1))); ggI1B.Update(); } if (ggI2B.SubModel) { - ggI2B.UpdateValue(tmp->MoverParameters->ShowCurrent(2)); + ggI2B.UpdateValue(static_cast(tmp->MoverParameters->ShowCurrent(2))); ggI2B.Update(); } if (ggI3B.SubModel) { - ggI3B.UpdateValue(tmp->MoverParameters->ShowCurrent(3)); + ggI3B.UpdateValue(static_cast(tmp->MoverParameters->ShowCurrent(3))); ggI3B.Update(); } if (ggItotalB.SubModel) { - ggItotalB.UpdateValue(tmp->MoverParameters->ShowCurrent(0)); + ggItotalB.UpdateValue(static_cast(tmp->MoverParameters->ShowCurrent(0))); ggItotalB.Update(); } if (ggWater1TempB.SubModel) @@ -8892,7 +8892,7 @@ bool TTrain::Update(double const Deltatime) ggClockSInd.Update(); ggClockMInd.UpdateValue(simulation::Time.data().wMinute); ggClockMInd.Update(); - ggClockHInd.UpdateValue(simulation::Time.data().wHour + simulation::Time.data().wMinute / 60.0); + ggClockHInd.UpdateValue(static_cast(simulation::Time.data().wHour + simulation::Time.data().wMinute / 60.0)); ggClockHInd.Update(); } @@ -8912,7 +8912,7 @@ bool TTrain::Update(double const Deltatime) { if (mvControlled->DynamicBrakeFlag) { - ggEngineVoltage.UpdateValue(std::abs(mvControlled->Im * 5)); + ggEngineVoltage.UpdateValue(static_cast(std::abs(mvControlled->Im * 5))); } else { @@ -8923,8 +8923,8 @@ bool TTrain::Update(double const Deltatime) x = 2; 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(static_cast(x * (std::abs(mvControlled->EngineVoltage) - mvControlled->RList[mvControlled->MainCtrlActualPos].R * std::abs(mvControlled->Im)) / + mvControlled->RList[mvControlled->MainCtrlActualPos].Mn)); } else { @@ -8939,25 +8939,25 @@ 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(static_cast(std::max(mvOccupied->Power110vIsAvailable ? mvOccupied->NominalBatteryVoltage : 0.0, mvOccupied->Power24vIsAvailable ? mvOccupied->BatteryVoltage : 0.0))); ggLVoltage.Update(); } if (mvControlled->EngineType == TEngineType::DieselElectric) { // ustawienie zmiennych dla silnika spalinowego - fEngine[1] = mvControlled->ShowEngineRotation(1); - fEngine[2] = mvControlled->ShowEngineRotation(2); + fEngine[1] = static_cast(mvControlled->ShowEngineRotation(1)); + fEngine[2] = static_cast(mvControlled->ShowEngineRotation(2)); } else if (mvControlled->EngineType == TEngineType::DieselEngine) { // albo dla innego spalinowego - fEngine[1] = mvControlled->ShowEngineRotation(1); - fEngine[2] = mvControlled->ShowEngineRotation(2); - fEngine[3] = mvControlled->ShowEngineRotation(3); + fEngine[1] = static_cast(mvControlled->ShowEngineRotation(1)); + fEngine[2] = static_cast(mvControlled->ShowEngineRotation(2)); + fEngine[3] = static_cast(mvControlled->ShowEngineRotation(3)); if (ggMainGearStatus.SubModel) { if (mvControlled->Mains) - ggMainGearStatus.UpdateValue(1.1 - std::abs(mvControlled->dizel_automaticgearstatus)); + ggMainGearStatus.UpdateValue(static_cast(1.1 - std::abs(mvControlled->dizel_automaticgearstatus))); else ggMainGearStatus.UpdateValue(0.0); ggMainGearStatus.Update(); @@ -9381,9 +9381,9 @@ bool TTrain::Update(double const Deltatime) (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), + ggJointCtrl.UpdateValue(negativePart < 0.0 ? static_cast(negativePart) : + mvControlled->CoupledCtrl ? static_cast(double(mvControlled->MainCtrlPos + mvControlled->ScndCtrlPos)) : + static_cast(double(mvControlled->MainCtrlPos)), dsbNastawnikJazdy); ggJointCtrl.Update(); } @@ -9402,20 +9402,20 @@ bool TTrain::Update(double const Deltatime) if (mvControlled->CoupledCtrl) { - ggMainCtrl.UpdateValue(double(mvControlled->MainCtrlPos + mvControlled->ScndCtrlPos), dsbNastawnikJazdy); + ggMainCtrl.UpdateValue(static_cast(double(mvControlled->MainCtrlPos + mvControlled->ScndCtrlPos)), dsbNastawnikJazdy); } else { - ggMainCtrl.UpdateValue(double(mvControlled->MainCtrlPos), dsbNastawnikJazdy); + ggMainCtrl.UpdateValue(static_cast(double(mvControlled->MainCtrlPos)), dsbNastawnikJazdy); } ggMainCtrl.Update(); } if (ggMainCtrlAct.SubModel != nullptr) { if (mvControlled->CoupledCtrl) - ggMainCtrlAct.UpdateValue(double(mvControlled->MainCtrlActualPos + mvControlled->ScndCtrlActualPos)); + ggMainCtrlAct.UpdateValue(static_cast(double(mvControlled->MainCtrlActualPos + mvControlled->ScndCtrlActualPos))); else - ggMainCtrlAct.UpdateValue(double(mvControlled->MainCtrlActualPos)); + ggMainCtrlAct.UpdateValue(static_cast(double(mvControlled->MainCtrlActualPos))); ggMainCtrlAct.Update(); } if (ggScndCtrl.SubModel != nullptr) @@ -9423,7 +9423,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(static_cast(double(mvControlled->ScndCtrlPos - (mvControlled->TrainType == dt_ET42 && mvControlled->DynamicBrakeFlag))), dsbNastawnikBocz); } ggScndCtrl.Update(); } @@ -9447,11 +9447,11 @@ bool TTrain::Update(double const Deltatime) { if (mvControlled->TrainType != dt_EZT) { - ggDirKey.UpdateValue(double(mvControlled->DirActive), dsbReverserKey); + ggDirKey.UpdateValue(static_cast(double(mvControlled->DirActive)), dsbReverserKey); } else { - ggDirKey.UpdateValue(double(mvControlled->DirActive) + double(mvControlled->Imin == mvControlled->IminHi), dsbReverserKey); + ggDirKey.UpdateValue(static_cast(double(mvControlled->DirActive) + double(mvControlled->Imin == mvControlled->IminHi)), dsbReverserKey); } ggDirKey.Update(); } @@ -9492,7 +9492,7 @@ bool TTrain::Update(double const Deltatime) { // else //standardowa prodedura z kranem powiązanym z klawiaturą // ggBrakeCtrl.UpdateValue(double(mvOccupied->BrakeCtrlPos)); - ggBrakeCtrl.UpdateValue(mvOccupied->fBrakeCtrlPos); + ggBrakeCtrl.UpdateValue(static_cast(mvOccupied->fBrakeCtrlPos)); ggBrakeCtrl.Update(); } } @@ -9513,7 +9513,7 @@ bool TTrain::Update(double const Deltatime) #endif { // standardowa prodedura z kranem powiązanym z klawiaturą - ggLocalBrake.UpdateValue(mvOccupied->LocalBrakePosA * LocalBrakePosNo); + ggLocalBrake.UpdateValue(static_cast(mvOccupied->LocalBrakePosA * LocalBrakePosNo)); } ggLocalBrake.Update(); } @@ -9644,7 +9644,7 @@ bool TTrain::Update(double const Deltatime) ggWhistleButton.Update(); if (DynamicObject->Mechanik != nullptr) { - ggHelperButton.UpdateValue(DynamicObject->Mechanik->HelperState); + ggHelperButton.UpdateValue(static_cast(DynamicObject->Mechanik->HelperState)); } ggHelperButton.Update(); @@ -9795,22 +9795,22 @@ void TTrain::update_sounds(double const Deltatime) { // calculate rate of pressure drop in local brake cylinder, once it's been initialized auto const brakepressuredifference{mvOccupied->LocBrakePress - m_lastlocalbrakepressure}; - m_localbrakepressurechange = std::lerp(m_localbrakepressurechange, 10 * (brakepressuredifference / Deltatime), 0.1f); + m_localbrakepressurechange = static_cast(std::lerp(m_localbrakepressurechange, 10 * (brakepressuredifference / Deltatime), 0.1f)); } - m_lastlocalbrakepressure = mvOccupied->LocBrakePress; + m_lastlocalbrakepressure = static_cast(mvOccupied->LocBrakePress); // local brake, release if (rsSBHiss) { 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->gain(static_cast(std::clamp(rsSBHiss->m_amplitudeoffset + rsSBHiss->m_amplitudefactor * -m_localbrakepressurechange * 0.05, 0.0, 1.5))); rsSBHiss->play(sound_flags::exclusive | sound_flags::looping); } else { // don't stop the sound too abruptly volume = std::max(0.0, rsSBHiss->gain() - 0.1 * Deltatime); - rsSBHiss->gain(volume); + rsSBHiss->gain(static_cast(volume)); if (volume < 0.05) { rsSBHiss->stop(); @@ -9822,14 +9822,14 @@ void TTrain::update_sounds(double const Deltatime) { if (m_localbrakepressurechange > 0.05f) { - rsSBHissU->gain(std::clamp(rsSBHissU->m_amplitudeoffset + rsSBHissU->m_amplitudefactor * m_localbrakepressurechange * 0.05, 0.0, 1.5)); + rsSBHissU->gain(static_cast(std::clamp(rsSBHissU->m_amplitudeoffset + rsSBHissU->m_amplitudefactor * m_localbrakepressurechange * 0.05, 0.0, 1.5))); rsSBHissU->play(sound_flags::exclusive | sound_flags::looping); } else { // don't stop the sound too abruptly volume = std::max(0.0, rsSBHissU->gain() - 0.1 * Deltatime); - rsSBHissU->gain(volume); + rsSBHissU->gain(static_cast(volume)); if (volume < 0.05) { rsSBHissU->stop(); @@ -9848,7 +9848,7 @@ void TTrain::update_sounds(double const Deltatime) volume = fPPress > 0 ? rsHiss->m_amplitudefactor * fPPress * 0.25 + rsHiss->m_amplitudeoffset : 0; if (volume * brakevolumescale > 0.05) { - rsHiss->gain(volume * brakevolumescale); + rsHiss->gain(static_cast(volume * brakevolumescale)); rsHiss->play(sound_flags::exclusive | sound_flags::looping); } else @@ -9863,7 +9863,7 @@ void TTrain::update_sounds(double const Deltatime) volume = fNPress > 0 ? rsHissU->m_amplitudefactor * fNPress + rsHissU->m_amplitudeoffset : 0; if (volume * brakevolumescale > 0.05) { - rsHissU->gain(volume * brakevolumescale); + rsHissU->gain(static_cast(volume * brakevolumescale)); rsHissU->play(sound_flags::exclusive | sound_flags::looping); } else @@ -9877,7 +9877,7 @@ void TTrain::update_sounds(double const Deltatime) volume = mvOccupied->Handle->GetSound(s_fv4a_e) * rsHissE->m_amplitudefactor + rsHissE->m_amplitudeoffset; if (volume * brakevolumescale > 0.05) { - rsHissE->gain(volume * brakevolumescale); + rsHissE->gain(static_cast(volume * brakevolumescale)); rsHissE->play(sound_flags::exclusive | sound_flags::looping); } else @@ -9891,7 +9891,7 @@ void TTrain::update_sounds(double const Deltatime) volume = mvOccupied->Handle->GetSound(s_fv4a_x) * rsHissX->m_amplitudefactor + rsHissX->m_amplitudeoffset; if (volume * brakevolumescale > 0.05) { - rsHissX->gain(volume * brakevolumescale); + rsHissX->gain(static_cast(volume * brakevolumescale)); rsHissX->play(sound_flags::exclusive | sound_flags::looping); } else @@ -9905,7 +9905,7 @@ void TTrain::update_sounds(double const Deltatime) volume = mvOccupied->Handle->GetSound(s_fv4a_t) * rsHissT->m_amplitudefactor + +rsHissT->m_amplitudeoffset; if (volume * brakevolumescale > 0.05) { - rsHissT->gain(volume * brakevolumescale); + rsHissT->gain(static_cast(volume * brakevolumescale)); rsHissT->play(sound_flags::exclusive | sound_flags::looping); } else @@ -9920,11 +9920,11 @@ void TTrain::update_sounds(double const Deltatime) // upuszczanie z PG if (rsHiss) { - fPPress = (4.0f * fPPress + std::max(0.0, mvOccupied->dpMainValve)) / (4.0f + 1.0f); + fPPress = static_cast((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; if (volume > 0.05) { - rsHiss->gain(volume); + rsHiss->gain(static_cast(volume)); rsHiss->play(sound_flags::exclusive | sound_flags::looping); } else @@ -9935,11 +9935,11 @@ void TTrain::update_sounds(double const Deltatime) // napelnianie PG if (rsHissU) { - fNPress = (4.0f * fNPress + std::min(0.0, mvOccupied->dpMainValve)) / (4.0f + 1.0f); + fNPress = static_cast((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; if (volume > 0.01) { - rsHissU->gain(volume); + rsHissU->gain(static_cast(volume)); rsHissU->play(sound_flags::exclusive | sound_flags::looping); } else @@ -9959,8 +9959,8 @@ void TTrain::update_sounds(double const Deltatime) 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; - rsBrake->pitch(rsBrake->m_frequencyoffset + mvOccupied->Vel * rsBrake->m_frequencyfactor); - rsBrake->gain(volume); + rsBrake->pitch(static_cast(rsBrake->m_frequencyoffset + mvOccupied->Vel * rsBrake->m_frequencyfactor)); + rsBrake->gain(static_cast(volume)); rsBrake->play(sound_flags::exclusive | sound_flags::looping); } else @@ -10035,7 +10035,7 @@ void TTrain::update_sounds(double const Deltatime) auto const huntingamount = std::lerp( 0.0, 1.0, std::clamp((mvOccupied->Vel - DynamicObject->HuntingShake.fadein_begin) / (DynamicObject->HuntingShake.fadein_end - DynamicObject->HuntingShake.fadein_begin), 0.0, 1.0)); - rsHuntingNoise->gain(rsHuntingNoise->gain() * huntingamount); + rsHuntingNoise->gain(static_cast(rsHuntingNoise->gain() * huntingamount)); } else { @@ -10050,7 +10050,7 @@ void TTrain::update_sounds(double const Deltatime) { if (m_rainsound->is_combined()) { - m_rainsound->pitch(Global.Overcast - 1.0); + m_rainsound->pitch(static_cast(Global.Overcast - 1.0)); } m_rainsound->gain(m_rainsound->m_amplitudeoffset + m_rainsound->m_amplitudefactor * 1.f); m_rainsound->play(sound_flags::exclusive | sound_flags::looping); @@ -10066,7 +10066,7 @@ void TTrain::update_sounds(double const Deltatime) if (fTachoCount >= 3.f) { auto const frequency{(true == dsbHasler->is_combined() ? fTachoVelocity * 0.01 : dsbHasler->m_frequencyoffset + dsbHasler->m_frequencyfactor)}; - dsbHasler->pitch(frequency); + dsbHasler->pitch(static_cast(frequency)); dsbHasler->gain(dsbHasler->m_amplitudeoffset + dsbHasler->m_amplitudefactor); dsbHasler->play(sound_flags::exclusive | sound_flags::looping); } @@ -10178,7 +10178,7 @@ void TTrain::update_sounds_resonancenoise(sound_source &Sound) if (volume > 0.05) { - Sound.pitch(frequency).gain(volume).play(sound_flags::exclusive | sound_flags::looping); + Sound.pitch(static_cast(frequency)).gain(static_cast(volume)).play(sound_flags::exclusive | sound_flags::looping); } else { @@ -10213,7 +10213,7 @@ void TTrain::update_sounds_runningnoise(sound_source &Sound) if (volume > 0.05) { - Sound.pitch(frequency).gain(volume).play(sound_flags::exclusive | sound_flags::looping); + Sound.pitch(static_cast(frequency)).gain(static_cast(volume)).play(sound_flags::exclusive | sound_flags::looping); } else { @@ -10236,7 +10236,7 @@ void TTrain::update_sounds_radio() for (auto &message : m_radiomessages) { auto const volume{true == radioenabled && Dynamic()->Mechanik != nullptr && message.first == RadioChannel() ? m_radiovolume : 0.0}; - message.second->gain(volume); + message.second->gain(static_cast(volume)); radio_message_played |= true == radioenabled && Dynamic()->Mechanik != nullptr && message.first == RadioChannel(); } // radiostop @@ -10286,7 +10286,7 @@ void TTrain::add_distance(double const Distance) if (true == meterenabled) { - m_distancecounter += Distance * Occupied()->CabOccupied; + m_distancecounter += static_cast(Distance * Occupied()->CabOccupied); } else { @@ -10391,7 +10391,7 @@ bool TTrain::LoadMMediaFile(std::string const &asFileName) auto const soundconfig{lookup->second}; sound_source sound{std::get(soundconfig), std::get(soundconfig)}; - sound.deserialize(parser, std::get(soundconfig), std::get(soundconfig), std::get(soundconfig)); + sound.deserialize(parser, std::get(soundconfig), std::get(soundconfig), static_cast(std::get(soundconfig))); sound.owner(DynamicObject); std::get &>(soundconfig) = sound; } while (token != ""); @@ -10416,23 +10416,23 @@ bool TTrain::LoadMMediaFile(std::string const &asFileName) } if (rsBrake) { - rsBrake->m_frequencyfactor /= 1 + mvOccupied->Vmax; + rsBrake->m_frequencyfactor /= static_cast(1 + mvOccupied->Vmax); } if (rsResonanceNoise) { - rsResonanceNoise->m_frequencyfactor /= 1 + mvOccupied->Vmax; + rsResonanceNoise->m_frequencyfactor /= static_cast(1 + mvOccupied->Vmax); } if (rsWindSound) { - rsWindSound->m_frequencyfactor /= 1 + mvOccupied->Vmax; + rsWindSound->m_frequencyfactor /= static_cast(1 + mvOccupied->Vmax); } if (rsRunningNoise) { - rsRunningNoise->m_frequencyfactor /= 1 + mvOccupied->Vmax; + rsRunningNoise->m_frequencyfactor /= static_cast(1 + mvOccupied->Vmax); } if (rsHuntingNoise) { - rsHuntingNoise->m_frequencyfactor /= 1 + mvOccupied->Vmax; + rsHuntingNoise->m_frequencyfactor /= static_cast(1 + mvOccupied->Vmax); } } auto const nullvector{glm::vec3()}; @@ -11019,7 +11019,7 @@ void TTrain::radio_message(sound_source *Message, int const Channel) 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(); + message.copy_sounds(*Message).gain(static_cast(volume)).play(); } // clears state of all cabin controls @@ -11327,7 +11327,7 @@ void TTrain::set_cab_controls(int const Cab) if (ggModernLightDimSw.SubModel != nullptr) { mvOccupied->modernDimmerPosition = mvOccupied->modernDimmerDefaultPosition; - ggModernLightDimSw.PutValue(mvOccupied->modernDimmerDefaultPosition); + ggModernLightDimSw.PutValue(static_cast(mvOccupied->modernDimmerDefaultPosition)); } // Init separate buttons @@ -11343,7 +11343,7 @@ void TTrain::set_cab_controls(int const Cab) // motor connectors ggStLinOffButton.PutValue(mvControlled->StLinSwitchOff ? 1.f : 0.f); // radio - ggRadioChannelSelector.PutValue((Dynamic()->Mechanik ? Dynamic()->Mechanik->iRadioChannel : 1) - 1); + ggRadioChannelSelector.PutValue(static_cast((Dynamic()->Mechanik ? Dynamic()->Mechanik->iRadioChannel : 1) - 1)); // pantographs /* if( mvOccupied->PantSwitchType != "impulse" ) { @@ -11408,11 +11408,11 @@ void TTrain::set_cab_controls(int const Cab) // compressor ggCompressorButton.PutValue(mvControlled->CompressorAllow ? 1.f : 0.f); ggCompressorLocalButton.PutValue(mvControlled->CompressorAllowLocal ? 1.f : 0.f); - ggCompressorListButton.PutValue(mvOccupied->CompressorListPos - 1); + ggCompressorListButton.PutValue(static_cast(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); // lights - ggLightsButton.PutValue(mvOccupied->LightsPos - 1); + ggLightsButton.PutValue(static_cast(mvOccupied->LightsPos - 1)); auto const vehicleend{cab_to_end(Cab)}; @@ -11452,7 +11452,7 @@ void TTrain::set_cab_controls(int const Cab) } if (1 == DynamicObject->MoverParameters->modernDimmerPosition) { - ggDimHeadlightsButton.PutValue(DynamicObject->MoverParameters->modernDimmerPosition); + ggDimHeadlightsButton.PutValue(static_cast(DynamicObject->MoverParameters->modernDimmerPosition)); } // cab lights if (true == Cabine[Cab].bLightDim) @@ -11474,7 +11474,7 @@ void TTrain::set_cab_controls(int const Cab) { ggDoorRightPermitButton.PutValue(mvOccupied->Doors.instances[(cab_to_end() == end::front ? side::right : side::left)].open_permit ? 1.f : 0.f); } - ggDoorPermitPresetButton.PutValue(mvOccupied->Doors.permit_preset); + ggDoorPermitPresetButton.PutValue(static_cast(mvOccupied->Doors.permit_preset)); // door controls ggDoorLeftButton.PutValue(mvOccupied->Doors.instances[(cab_to_end() == end::front ? side::left : side::right)].is_closed ? 0.f : 1.f); ggDoorRightButton.PutValue(mvOccupied->Doors.instances[(cab_to_end() == end::front ? side::right : side::left)].is_closed ? 0.f : 1.f); @@ -11493,7 +11493,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 : static_cast(mvOccupied->BrakeDelayFlag - 1)); } if (ggBrakeProfileG.SubModel != nullptr) { @@ -11506,12 +11506,12 @@ void TTrain::set_cab_controls(int const Cab) if (ggWiperSw.SubModel != nullptr) { - ggWiperSw.PutValue(mvOccupied->wiperSwitchPos); + ggWiperSw.PutValue(static_cast(mvOccupied->wiperSwitchPos)); } if (ggBrakeOperationModeCtrl.SubModel != nullptr) { - ggBrakeOperationModeCtrl.PutValue(mvOccupied->BrakeOpModeFlag > 0 ? std::log2(mvOccupied->BrakeOpModeFlag) : 0); + ggBrakeOperationModeCtrl.PutValue(mvOccupied->BrakeOpModeFlag > 0 ? static_cast(std::log2(mvOccupied->BrakeOpModeFlag)) : 0); } // alarm chain ggAlarmChain.PutValue(mvControlled->AlarmChainFlag ? 1.f : 0.f); @@ -12285,9 +12285,9 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con if (DynamicObject->mdKabina) { // McZapkie-300302: zegarek - ggClockSInd.Init(DynamicObject->mdKabina->GetFromName("ClockShand"), nullptr, TGaugeAnimation::gt_Rotate, 1.0 / 60.0); - ggClockMInd.Init(DynamicObject->mdKabina->GetFromName("ClockMhand"), nullptr, TGaugeAnimation::gt_Rotate, 1.0 / 60.0); - ggClockHInd.Init(DynamicObject->mdKabina->GetFromName("ClockHhand"), nullptr, TGaugeAnimation::gt_Rotate, 1.0 / 12.0); + ggClockSInd.Init(DynamicObject->mdKabina->GetFromName("ClockShand"), nullptr, TGaugeAnimation::gt_Rotate, static_cast(1.0 / 60.0)); + ggClockMInd.Init(DynamicObject->mdKabina->GetFromName("ClockMhand"), nullptr, TGaugeAnimation::gt_Rotate, static_cast(1.0 / 60.0)); + ggClockHInd.Init(DynamicObject->mdKabina->GetFromName("ClockHhand"), nullptr, TGaugeAnimation::gt_Rotate, static_cast(1.0 / 12.0)); } } } diff --git a/widgets/perfgraphs.cpp b/widgets/perfgraphs.cpp index 574cc7ef..e717f647 100644 --- a/widgets/perfgraphs.cpp +++ b/widgets/perfgraphs.cpp @@ -49,7 +49,7 @@ void perfgraph_panel::render_contents() { if (!stopwatch) return; - history[pos] = stopwatch->last().count() / 1000.0; + history[pos] = static_cast(static_cast(stopwatch->last().count()) / 1000.0); const std::string label = std::to_string(history[pos]) + "ms"; pos++; @@ -57,5 +57,5 @@ void perfgraph_panel::render_contents() { pos = 0; ImGui::SliderFloat(STR_C("Range"), &max, 0.1f, 250.0f); - ImGui::PlotLines("##timer", &history[0], history.size(), pos, label.c_str(), 0.0f, max, ImVec2(500, 200)); + ImGui::PlotLines("##timer", &history[0], static_cast(history.size()), static_cast(pos), label.c_str(), 0.0f, max, ImVec2(500, 200)); } diff --git a/widgets/trainingcard.cpp b/widgets/trainingcard.cpp index 27fb0965..180653bf 100644 --- a/widgets/trainingcard.cpp +++ b/widgets/trainingcard.cpp @@ -177,7 +177,7 @@ void trainingcard_panel::render_contents() { state.store(2); if (simulation::Trains.sequence().size() > 0) - distance = simulation::Trains.sequence()[0]->Dynamic()->MoverParameters->DistCounter; + distance = static_cast(simulation::Trains.sequence()[0]->Dynamic()->MoverParameters->DistCounter); if (save_thread.joinable()) save_thread.join(); diff --git a/world/EvLaunch.cpp b/world/EvLaunch.cpp index 29c3104f..a838b909 100644 --- a/world/EvLaunch.cpp +++ b/world/EvLaunch.cpp @@ -34,14 +34,14 @@ int vk_to_glfw_key( int const Keycode ) { char key = 0; if (Keycode < 'A') { - key = Keycode; + key = static_cast(Keycode); } else if (Keycode <= 'Z') { - key = Keycode; + key = static_cast(Keycode); modifier = GLFW_MOD_SHIFT; } else if (Keycode < 'a') { - key = Keycode; + key = static_cast(Keycode); } else if (Keycode <= 'z') { - key = Keycode - 32; + key = static_cast(Keycode - 32); } else { ErrorLog("unknown key: " + std::to_string(Keycode)); } @@ -164,7 +164,7 @@ bool TEventLauncher::check_activation_key() { bool result = Console::Pressed(key); - char modifier = iKey >> 8; + char modifier = static_cast(iKey >> 8); if (modifier & GLFW_MOD_SHIFT) result &= Global.shiftState; if (modifier & GLFW_MOD_CONTROL) @@ -239,7 +239,7 @@ bool TEventLauncher::IsRadioActivated() const { float TEventLauncher::radius_() { - return std::sqrt( dRadius ); + return static_cast(std::sqrt( dRadius )); } // serialize() subclass details, sends content of the subclass to provided stream diff --git a/world/Segment.cpp b/world/Segment.cpp index a53f3fbe..d05e83f3 100644 --- a/world/Segment.cpp +++ b/world/Segment.cpp @@ -67,8 +67,8 @@ bool TSegment::Init(glm::dvec3 &NewPoint1, glm::dvec3 NewCPointOut, glm::dvec3 N CPointIn = NewCPointIn; Point2 = NewPoint2; // poprawienie przechyłki - fRoll1 = glm::radians(fNewRoll1); // Ra: przeliczone jest bardziej przydatne do obliczeń - fRoll2 = glm::radians(fNewRoll2); + fRoll1 = static_cast(glm::radians(fNewRoll1)); // Ra: przeliczone jest bardziej przydatne do obliczeń + fRoll2 = static_cast(glm::radians(fNewRoll2)); bCurve = bIsCurve; if (Global.bRollFix) { // Ra: poprawianie przechyłki @@ -85,7 +85,7 @@ bool TSegment::Init(glm::dvec3 &NewPoint1, glm::dvec3 NewCPointOut, glm::dvec3 N Point1.y += w1; // modyfikacja musi być przed policzeniem dalszych parametrów if (bCurve) CPointOut.y += w1; // prosty ma wektory jednostkowe - pOwner->MovedUp1(w1); // zwrócić trzeba informację o podwyższeniu podsypki + pOwner->MovedUp1(static_cast(w1)); // zwrócić trzeba informację o podwyższeniu podsypki } if (fRoll2 != 0.f) { @@ -125,7 +125,7 @@ bool TSegment::Init(glm::dvec3 &NewPoint1, glm::dvec3 NewCPointOut, glm::dvec3 N 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 ? static_cast(6 * Global.SplineFidelity) : static_cast(std::ceil(fLength / fStep)); // potrzebne do VBO fStep = fLength / iSegCount; // update step to equalize size of individual pieces @@ -267,7 +267,7 @@ double TSegment::ComputeLength() const // McZapkie-150503: dlugosc miedzy punkta double l = 0; glm::dvec3 last{0, 0, 0}; // długość liczona po przesunięciu odcinka do początku układu glm::dvec3 tmp = Point2 - Point1; - int m = 20.0 * glm::length(tmp); // było zawsze do 10000, teraz jest liczone odcinkami po około 5cm + int m = static_cast(20.0 * glm::length(tmp)); // było zawsze do 10000, teraz jest liczone odcinkami po około 5cm for (int i = 1; i <= m; i++) { t = double(i) / double(m); // wyznaczenie parametru na krzywej z przedziału (0,1> @@ -372,22 +372,22 @@ void TSegment::RaPositionGet(double const fDistance, glm::dvec3 &position, glm:: auto const t = FastGetTFromS(fDistance); // aproksymacja dystansu na krzywej Beziera na parametr (t) position = FastGetPoint( t ); // przechyłka w danym miejscu (zmienia się liniowo) - rotation.x = std::lerp( fRoll1, fRoll2, t ); + rotation.x = static_cast(std::lerp( fRoll1, fRoll2, t )); // pochodna auto const tangent = GetFirstDerivative( t ); // pochylenie krzywej (w pionie) - rotation.y = std::atan( tangent.y ); + rotation.y = static_cast(std::atan( tangent.y )); // kierunek krzywej w planie - rotation.z = -std::atan2( tangent.x, tangent.z ); + rotation.z = static_cast(-std::atan2( tangent.x, tangent.z )); } else { // wyliczenie dla odcinka prostego jest prostsze auto const t = fDistance / fLength; // zerowych torów nie ma position = FastGetPoint( t ); // przechyłka w danym miejscu (zmienia się liniowo) - rotation.x = std::lerp( fRoll1, fRoll2, t ); - rotation.y = fStoop; // pochylenie toru prostego - rotation.z = fDirection; // kierunek toru w planie + rotation.x = static_cast(std::lerp( fRoll1, fRoll2, t )); + rotation.y = static_cast(fStoop); // pochylenie toru prostego + rotation.z = static_cast(fDirection); // kierunek toru w planie } }; @@ -420,20 +420,20 @@ bool TSegment::RenderLoft( gfx::vertex_array &Output, glm::dvec3 const &Origin, float t; float fEnd; auto const iNumShapePoints = Transition ? ShapePoints.size() / 2 : ShapePoints.size(); - float const texturelength = fTextureLength * Texturescale; - float const texturescale = Texturescale; + float const texturelength = static_cast(fTextureLength * Texturescale); + float const texturescale = static_cast(Texturescale); float m1; float jmm1; float m2; float jmm2; // pozycje względne na odcinku 0...1 (ale nie parametr Beziera) - step = fStep; + step = static_cast(fStep); tv1 = 1.0; // Ra: to by można było wyliczać dla odcinka, wyglądało by lepiej - s = fStep * iSkip; // iSkip - ile odcinków z początku pominąć + s = static_cast(fStep * iSkip); // iSkip - ile odcinków z początku pominąć int i = iSkip; // domyślnie 0 - t = fTsBuffer[ i ]; // tabela wattości t dla segmentów + t = static_cast(fTsBuffer[ i ]); // tabela wattości t dla segmentów // BUG: length of spline can be 0, we should skip geometry generation for such cases - fOffset = 0.1 / fLength; // pierwsze 10cm + fOffset = static_cast(0.1 / fLength); // pierwsze 10cm pos1 = glm::dvec3{ FastGetPoint( t ) - Origin }; // wektor początku segmentu dir = glm::dvec3{ FastGetDirection( t, fOffset ) }; // wektor kierunku parallel1 = glm::vec3{ -dir.z, 0.f, dir.x }; // wektor poprzeczny @@ -444,11 +444,11 @@ bool TSegment::RenderLoft( gfx::vertex_array &Output, glm::dvec3 const &Origin, parallel1 = glm::normalize( parallel1 ); if( iEnd == 0 ) iEnd = iSegCount; - fEnd = fLength * double( iEnd ) / double( iSegCount ); + fEnd = static_cast(fLength * double( iEnd ) / double( iSegCount )); /* m2 = s / fEnd; */ - m2 = static_cast( i - iSkip ) / ( iEnd - iSkip ); + m2 = static_cast( i - iSkip ) / ( static_cast(iEnd - iSkip) ); jmm2 = 1.f - m2; @@ -461,7 +461,7 @@ bool TSegment::RenderLoft( gfx::vertex_array &Output, glm::dvec3 const &Origin, /* m2 = s / fEnd; */ - m2 = static_cast( i - iSkip ) / ( iEnd - iSkip ); + m2 = static_cast( i - iSkip ) / ( static_cast(iEnd - iSkip) ); jmm2 = 1.f - m2; // nowa pozycja if( i == iEnd ) { // gdy przekroczyliśmy koniec - stąd dziury w torach... @@ -478,7 +478,7 @@ bool TSegment::RenderLoft( gfx::vertex_array &Output, glm::dvec3 const &Origin, tv1 = clamp_circular( tv1, 1.0f ); tv2 = tv1 - step / texturelength; // mapowanie na końcu segmentu - t = fTsBuffer[ i ]; // szybsze od GetTFromS(s); + t = static_cast(fTsBuffer[ i ]); // szybsze od GetTFromS(s); pos2 = glm::dvec3{ FastGetPoint( t ) - Origin }; dir = glm::dvec3{ FastGetDirection( t, fOffset ) }; // nowy wektor kierunku parallel2 = glm::vec3{ -dir.z, 0.f, dir.x }; // wektor poprzeczny @@ -565,7 +565,7 @@ bool TSegment::RenderLoft( gfx::vertex_array &Output, glm::dvec3 const &Origin, void TSegment::render_lines(std::vector &out, float quality) const { - float step = 1.0f / iSegCount / quality; + float step = 1.0f / static_cast(iSegCount) / quality; float x; @@ -586,7 +586,7 @@ void TSegment::render_lines(std::vector &out, float quality) glm::vec3 TSegment::get_nearest_point(const glm::dvec3 &point, float quality) const { - float step = 1.0f / iSegCount / quality; + float step = 1.0f / static_cast(iSegCount) / quality; float x; diff --git a/world/Spring.cpp b/world/Spring.cpp index b58d8859..e53de505 100644 --- a/world/Spring.cpp +++ b/world/Spring.cpp @@ -13,8 +13,8 @@ http://mozilla.org/MPL/2.0/. void TSpring::Init(double nKs, double nKd) { Ks = nKs; Kd = nKd; - ks = Ks; - kd = Kd; + ks = static_cast(Ks); + kd = static_cast(Kd); } glm::dvec3 TSpring::ComputateForces(glm::dvec3 const &pPosition1, glm::dvec3 const &pPosition2) { diff --git a/world/Traction.cpp b/world/Traction.cpp index ca676229..a3f15195 100644 --- a/world/Traction.cpp +++ b/world/Traction.cpp @@ -131,7 +131,7 @@ 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 != 0.0 ? static_cast(glm::length(pPoint1 - pPoint2) / segmentlength) : 0; parser->getTokens( 2 ); *parser >> Wires @@ -213,7 +213,7 @@ 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 = static_cast(1 - std::fabs(f - mid) * 2); if( Wires < 4 || ( i != 0 && i != iNumSections - 2 ) ) { @@ -262,7 +262,7 @@ 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 = static_cast(1 - std::fabs(f - mid) * 2); endvertex.position = glm::vec3( pt3.x - m_origin.x, @@ -294,7 +294,7 @@ 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; + t = static_cast(1 - std::fabs(f - mid) * 2); if( i % 2 == 0 ) { startvertex.position = glm::vec3( @@ -439,7 +439,7 @@ void TTraction::ResistanceCalc(int d, double r, TTractionPowerSource *ps) } } t->psPower[d] = ps; // skopiowanie wskaźnika zasilacza od danej strony - t->fResistance[d] = r; // wpisanie rezystancji w kierunku tego zasilacza + t->fResistance[d] = static_cast(r); // wpisanie rezystancji w kierunku tego zasilacza r += t->fResistivity * glm::length(t->vParametric); // doliczenie oporu kolejnego odcinka p = t; // zapamiętanie dotychczasowego t = p->hvNext[d ^ 1]; // podążanie w tę samą stronę diff --git a/world/TractionPower.cpp b/world/TractionPower.cpp index 7d816e21..540c32fc 100644 --- a/world/TractionPower.cpp +++ b/world/TractionPower.cpp @@ -125,7 +125,7 @@ double TTractionPowerSource::CurrentGet(double res) } 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; + float NomVolt = TotalPreviousAdmitance < 0 ? static_cast(NominalVoltage * 1.083) : static_cast(NominalVoltage); TotalCurrent = TotalPreviousAdmitance != 0.0 ? NomVolt / (InternalRes + 1.0 / TotalPreviousAdmitance) : 0.0; // napięcie dzielone przez sumę rezystancji wewnętrznej i obciążenia diff --git a/world/mtable.cpp b/world/mtable.cpp index cec54f87..2b89eeac 100644 --- a/world/mtable.cpp +++ b/world/mtable.cpp @@ -235,7 +235,7 @@ void TTrainParameters::UpdateVelocity(int StationCount, double vActual) // TTVmax:=vActual; {PROWIZORKA!!!} while (i >= 0 && TimeTable[i].vmax == -1) { - TimeTable[i].vmax = vActual; // prędkość dojazdu do przystanku i + TimeTable[i].vmax = static_cast(vActual); // prędkość dojazdu do przystanku i --i; // ewentualnie do poprzedniego też } } @@ -412,7 +412,7 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax) ConversionError = -4; if (false == contains( s,"|") ) { - record->km = atof(s.c_str()); + record->km = static_cast(atof(s.c_str())); fin >> s; } if (contains( s,"|_____|")) /*zmiana predkosci szlakowej*/ @@ -439,12 +439,12 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax) if (contains( s, hrsd) ) { record->Ah = atoi( s.substr(0, s.find(hrsd)).c_str()); // godzina przyjazdu - record->Am = atof(s.substr(s.find(hrsd) + 1, s.length()).c_str()); // minuta przyjazdu + record->Am = static_cast(atof(s.substr(s.find(hrsd) + 1, s.length()).c_str())); // minuta przyjazdu } else { record->Ah = TimeTable[StationCount - 1].Ah; // godzina z poprzedniej pozycji - record->Am = atof(s.c_str()); // bo tylko minuty podane + record->Am = static_cast(atof(s.c_str())); // bo tylko minuty podane } } do @@ -452,7 +452,7 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax) fin >> s; } while (!(s != "|" || fin.bad())); if (s != "]") - record->tm = atof(s.c_str()); + record->tm = static_cast(atof(s.c_str())); do { fin >> s; @@ -514,12 +514,12 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax) if (contains( s, hrsd) ) { record->Dh = atoi(s.substr(0, s.find(hrsd)).c_str()); // godzina odjazdu - record->Dm = atof(s.substr(s.find(hrsd) + 1, s.length()).c_str()); // minuta odjazdu + record->Dm = static_cast(atof(s.substr(s.find(hrsd) + 1, s.length()).c_str())); // minuta odjazdu } else { record->Dh = TimeTable[StationCount - 1].Dh; // godzina z poprzedniej pozycji - record->Dm = atof(s.c_str()); // bo tylko minuty podane + record->Dm = static_cast(atof(s.c_str())); // bo tylko minuty podane } } else @@ -532,7 +532,7 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax) fin >> s; } while (!(s != "|" || fin.bad())); if (s != "]") - record->tm = atof(s.c_str()); + record->tm = static_cast(atof(s.c_str())); do { fin >> s; @@ -586,13 +586,13 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax) { if (TimeTable[i].Ah >= 0) { - adjustedtime = clamp_circular( TimeTable[i].Ah * 60 + TimeTable[i].Am + timeoffset, 24 * 60 ); // nowe minuty + adjustedtime = clamp_circular( static_cast(TimeTable[i].Ah * 60) + TimeTable[i].Am + static_cast(timeoffset), 24 * 60 ); // nowe minuty TimeTable[i].Am = int(60 * adjustedtime) % 3600 / 60.f; TimeTable[i].Ah = int(adjustedtime / 60) % 24; } if (TimeTable[i].Dh >= 0) { - adjustedtime = clamp_circular( TimeTable[i].Dh * 60 + TimeTable[i].Dm + timeoffset, 24 * 60 ); // nowe minuty + adjustedtime = clamp_circular( static_cast(TimeTable[i].Dh * 60) + TimeTable[i].Dm + static_cast(timeoffset), 24 * 60 ); // nowe minuty TimeTable[i].Dm = int(60 * adjustedtime) % 3600 / 60.f; TimeTable[i].Dh = int(adjustedtime / 60) % 24; } diff --git a/world/station.cpp b/world/station.cpp index eae81d9e..684a7d8f 100644 --- a/world/station.cpp +++ b/world/station.cpp @@ -63,7 +63,7 @@ basic_station::update_load( TDynamicObject *First, Mtable::TTrainParameters &Sch maintenancestop ? 0 : std::min( parameters.LoadAmount, - Random( parameters.MaxLoad * 0.15f * stationsizemodifier ) ) ); + static_cast(Random( parameters.MaxLoad * 0.15f * stationsizemodifier )) ) ); auto loadcount = static_cast( TestFlag( parameters.DamageFlag, dtrain_out ) ? 0 : laststop ? 0 :