diff --git a/EU07.cpp b/EU07.cpp
index cf0a4dec..bf545595 100644
--- a/EU07.cpp
+++ b/EU07.cpp
@@ -65,7 +65,7 @@ LONG WINAPI CrashHandler(EXCEPTION_POINTERS *ExceptionInfo)
dumpInfo.ClientPointers = FALSE;
// Wybrana kombinacja flag
- const auto dumpType = MINIDUMP_TYPE(MiniDumpWithFullMemory | MiniDumpWithHandleData | MiniDumpWithThreadInfo | MiniDumpWithUnloadedModules | MiniDumpWithIndirectlyReferencedMemory |
+ constexpr auto dumpType = MINIDUMP_TYPE(MiniDumpWithFullMemory | MiniDumpWithHandleData | MiniDumpWithThreadInfo | MiniDumpWithUnloadedModules | MiniDumpWithIndirectlyReferencedMemory |
MiniDumpWithFullMemoryInfo | MiniDumpWithTokenInformation);
MessageBoxA(nullptr, "Simulator crash occured :(\n", "Simulator crashed :(", MB_ICONERROR);
diff --git a/McZapkie/MOVER.h b/McZapkie/MOVER.h
index 3c6a0c30..45ce9641 100644
--- a/McZapkie/MOVER.h
+++ b/McZapkie/MOVER.h
@@ -82,75 +82,75 @@ zwiekszenie nacisku przy duzych predkosciach w hamulcach Oerlikona
extern int ConversionError;
/// Static friction coefficient for steel-on-steel contact (used for adhesion at standstill).
-const double Steel2Steel_friction = 0.15; // tarcie statyczne
+constexpr double Steel2Steel_friction = 0.15; // tarcie statyczne
/// Earth gravitational acceleration [m/s^2].
-const double g = 9.81; // przyspieszenie ziemskie
+constexpr double g = 9.81; // przyspieszenie ziemskie
/// Sand consumption rate when sanding is active [kg/s].
-const double SandSpeed = 0.1; // ile kg/s}
+constexpr double SandSpeed = 0.1; // ile kg/s}
/// 2*pi shortcut.
-const double Pirazy2 = 6.2831853071794f;
+constexpr double Pirazy2 = 6.2831853071794f;
//-- var, const, procedure ---------------------------------------------------
/// Truthy alias used by CheckLocomotiveParameters() to ignore a check failure.
-static bool const Go = true;
+static constexpr bool Go = true;
/// Falsy alias used by CheckLocomotiveParameters() to abort on a check failure.
-static bool const Hold = false; /*dla CheckLocomotiveParameters*/
+static constexpr bool Hold = false; /*dla CheckLocomotiveParameters*/
/// Maximum number of resistor / scheme entries for electric motor traction.
-static int const ResArraySize = 64; /*dla silnikow elektrycznych*/
+static constexpr int ResArraySize = 64; /*dla silnikow elektrycznych*/
/// Maximum number of motor-parameter table entries (gear stages).
-static int const MotorParametersArraySize = 10;
+static constexpr int MotorParametersArraySize = 10;
/// Maximum number of pantograph current collectors per vehicle.
-static int const maxcc = 4; /*max. ilosc odbierakow pradu*/
+static constexpr int maxcc = 4; /*max. ilosc odbierakow pradu*/
// static int const LocalBrakePosNo = 10; /*ilosc nastaw hamulca pomocniczego*/
// static int const MainBrakeMaxPos = 10; /*max. ilosc nastaw hamulca zasadniczego*/
/// Number of positions on the manual (parking) brake handle.
-static int const ManualBrakePosNo = 20; /*ilosc nastaw hamulca recznego*/
+static constexpr int ManualBrakePosNo = 20; /*ilosc nastaw hamulca recznego*/
/// Number of positions on the lights selector switch.
-static int const LightsSwitchPosNo = 16;
+static constexpr int LightsSwitchPosNo = 16;
/// Maximum number of positions of the universal (auxiliary) controller.
-static int const UniversalCtrlArraySize = 32; /*max liczba pozycji uniwersalnego nastawnika*/
+static constexpr int UniversalCtrlArraySize = 32; /*max liczba pozycji uniwersalnego nastawnika*/
/*uszkodzenia toru*/
/// Track damage flag: rail wear.
-static int const dtrack_railwear = 2;
+static constexpr int dtrack_railwear = 2;
/// Track damage flag: free / loose rail.
-static int const dtrack_freerail = 4;
+static constexpr int dtrack_freerail = 4;
/// Track damage flag: thin (worn-out) rail.
-static int const dtrack_thinrail = 8;
+static constexpr int dtrack_thinrail = 8;
/// Track damage flag: bent rail.
-static int const dtrack_railbend = 16;
+static constexpr int dtrack_railbend = 16;
/// Track damage flag: vegetation overgrowth.
-static int const dtrack_plants = 32;
+static constexpr int dtrack_plants = 32;
/// Track damage flag: track impassable for movement.
-static int const dtrack_nomove = 64;
+static constexpr int dtrack_nomove = 64;
/// Track damage flag: rails missing entirely.
-static int const dtrack_norail = 128;
+static constexpr int dtrack_norail = 128;
/*uszkodzenia taboru*/
/// Vehicle damage flag: thin wheel (locomotives).
-static int const dtrain_thinwheel = 1; /*dla lokomotyw*/
+static constexpr int dtrain_thinwheel = 1; /*dla lokomotyw*/
/// Vehicle damage flag: shifted load (wagons).
-static int const dtrain_loadshift = 1; /*dla wagonow*/
+static constexpr int dtrain_loadshift = 1; /*dla wagonow*/
/// Vehicle damage flag: wheel wear.
-static int const dtrain_wheelwear = 2;
+static constexpr int dtrain_wheelwear = 2;
/// Vehicle damage flag: bearing failure.
-static int const dtrain_bearing = 4;
+static constexpr int dtrain_bearing = 4;
/// Vehicle damage flag: coupling damage.
-static int const dtrain_coupling = 8;
+static constexpr int dtrain_coupling = 8;
/// Vehicle damage flag: ventilator failure (electric locomotive).
-static int const dtrain_ventilator = 16; /*dla lokomotywy el.*/
+static constexpr int dtrain_ventilator = 16; /*dla lokomotywy el.*/
/// Vehicle damage flag: load damage (wagons).
-static int const dtrain_loaddamage = 16; /*dla wagonow*/
+static constexpr int dtrain_loaddamage = 16; /*dla wagonow*/
/// Vehicle damage flag: engine failure (locomotives).
-static int const dtrain_engine = 32; /*dla lokomotyw*/
+static constexpr int dtrain_engine = 32; /*dla lokomotyw*/
/// Vehicle damage flag: load destroyed (wagons).
-static int const dtrain_loaddestroyed = 32; /*dla wagonow*/
+static constexpr int dtrain_loaddestroyed = 32; /*dla wagonow*/
/// Vehicle damage flag: axle damage.
-static int const dtrain_axle = 64;
+static constexpr int dtrain_axle = 64;
/// Vehicle damage flag: derailment.
-static int const dtrain_out = 128; /*wykolejenie*/
+static constexpr int dtrain_out = 128; /*wykolejenie*/
/// Vehicle damage flag: broken pantograph.
-static int const dtrain_pantograph = 256; /*polamanie pantografu*/
+static constexpr int dtrain_pantograph = 256; /*polamanie pantografu*/
/// Reason for a derailment event.
enum DerailReason
@@ -185,23 +185,23 @@ enum DerailReason
/*typ sprzegu*/
/// Coupling type: virtual — vehicles share a track and are aware of each other.
-static int const ctrain_virtual = 0; // gdy pojazdy na tym samym torze się widzą wzajemnie
+static constexpr int ctrain_virtual = 0; // gdy pojazdy na tym samym torze się widzą wzajemnie
/// Coupling type: physical coupler.
-static int const ctrain_coupler = 1; // sprzeg fizyczny
+static constexpr int ctrain_coupler = 1; // sprzeg fizyczny
/// Coupling type: pneumatic brake hose.
-static int const ctrain_pneumatic = 2; // przewody hamulcowe
+static constexpr int ctrain_pneumatic = 2; // przewody hamulcowe
/// Coupling type: control cable (multiple-unit).
-static int const ctrain_controll = 4; // przewody sterujące (ukrotnienie)
+static constexpr int ctrain_controll = 4; // przewody sterujące (ukrotnienie)
/// Coupling type: high-voltage power cable.
-static int const ctrain_power = 8; // przewody zasilające (WN)
+static constexpr int ctrain_power = 8; // przewody zasilające (WN)
/// Coupling type: passenger gangway.
-static int const ctrain_passenger = 16; // mostek przejściowy
+static constexpr int ctrain_passenger = 16; // mostek przejściowy
/// Coupling type: secondary 8 atm pneumatic line (yellow, main air).
-static int const ctrain_scndpneumatic = 32; // przewody 8 atm (żółte; zasilanie powietrzem)
+static constexpr int ctrain_scndpneumatic = 32; // przewody 8 atm (żółte; zasilanie powietrzem)
/// Coupling type: high-voltage train heating cable.
-static int const ctrain_heating = 64; // przewody ogrzewania WN
+static constexpr int ctrain_heating = 64; // przewody ogrzewania WN
/// Coupling type: permanent (inter-section) — not separable during ordinary shunting; encoded as negative in config files.
-static int const ctrain_depot = 128; // nie rozłączalny podczas zwykłych manewrów (międzyczłonowy), we wpisie wartość ujemna
+static constexpr int ctrain_depot = 128; // nie rozłączalny podczas zwykłych manewrów (międzyczłonowy), we wpisie wartość ujemna
/// Vehicle ends — front or rear (mutually exclusive).
enum end
{
@@ -338,15 +338,15 @@ enum control_t
};
/*typ hamulca elektrodynamicznego*/
/// Electrodynamic-brake type: no ED brake.
-static int const dbrake_none = 0;
+static constexpr int dbrake_none = 0;
/// Electrodynamic-brake type: passive (always on while moving).
-static int const dbrake_passive = 1;
+static constexpr int dbrake_passive = 1;
/// Electrodynamic-brake type: switchable (driver toggles).
-static int const dbrake_switch = 2;
+static constexpr int dbrake_switch = 2;
/// Electrodynamic-brake type: reversal (engaged via reverser).
-static int const dbrake_reversal = 4;
+static constexpr int dbrake_reversal = 4;
/// Electrodynamic-brake type: automatic (engages from main brake).
-static int const dbrake_automatic = 8;
+static constexpr int dbrake_automatic = 8;
/*dzwieki*/
/// Bit flags identifying sound events emitted by a vehicle. Combinable.
@@ -436,126 +436,126 @@ enum activation
// zamienione na flagi bitowe, aby szybko wybierać grupę (np. EZT+SZT)
// TODO: convert to enums, they're used as specific checks anyway
/// Vehicle type flag: default (no special handling).
-static int const dt_Default = 0;
+static constexpr int dt_Default = 0;
/// Vehicle type flag: EZT (electric multiple unit).
-static int const dt_EZT = 1;
+static constexpr int dt_EZT = 1;
/// Vehicle type flag: ET41 locomotive.
-static int const dt_ET41 = 2;
+static constexpr int dt_ET41 = 2;
/// Vehicle type flag: ET42 locomotive.
-static int const dt_ET42 = 4;
+static constexpr int dt_ET42 = 4;
/// Vehicle type flag: pseudo-diesel (electric drivetrain with diesel input model).
-static int const dt_PseudoDiesel = 8;
+static constexpr int dt_PseudoDiesel = 8;
/// Vehicle type flag: ET22 locomotive (added in Megapack).
-static int const dt_ET22 = 0x10; // używane od Megapacka
+static constexpr int dt_ET22 = 0x10; // używane od Megapacka
/// Vehicle type flag: SN61 (set from CHK only, not used in conditions).
-static int const dt_SN61 = 0x20; // nie używane w warunkach, ale ustawiane z CHK
+static constexpr int dt_SN61 = 0x20; // nie używane w warunkach, ale ustawiane z CHK
/// Vehicle type flag: EP05 locomotive.
-static int const dt_EP05 = 0x40;
+static constexpr int dt_EP05 = 0x40;
/// Vehicle type flag: ET40 locomotive.
-static int const dt_ET40 = 0x80;
+static constexpr int dt_ET40 = 0x80;
/// Vehicle type flag: ŠKODA 181 locomotive.
-static int const dt_181 = 0x100;
+static constexpr int dt_181 = 0x100;
/// Vehicle type flag: DMU (diesel multiple unit).
-static int const dt_DMU = 0x200;
+static constexpr int dt_DMU = 0x200;
// stałe dla asynchronów
/// EIM config index: dfic — frequency rise rate at start.
-static int const eimc_s_dfic = 0;
+static constexpr int eimc_s_dfic = 0;
/// EIM config index: dfmax — maximum frequency rate of change.
-static int const eimc_s_dfmax = 1;
+static constexpr int eimc_s_dfmax = 1;
/// EIM config index: p — number of pole pairs.
-static int const eimc_s_p = 2;
+static constexpr int eimc_s_p = 2;
/// EIM config index: cfu — voltage / frequency conversion coefficient.
-static int const eimc_s_cfu = 3;
+static constexpr int eimc_s_cfu = 3;
/// EIM config index: cim — current / current conversion coefficient.
-static int const eimc_s_cim = 4;
+static constexpr int eimc_s_cim = 4;
/// EIM config index: icif — magnetisation current ratio.
-static int const eimc_s_icif = 5;
+static constexpr int eimc_s_icif = 5;
/// EIM config index: Uzmax — maximum DC link voltage.
-static int const eimc_f_Uzmax = 7;
+static constexpr int eimc_f_Uzmax = 7;
/// EIM config index: Uzh — DC link voltage at field-weakening transition.
-static int const eimc_f_Uzh = 8;
+static constexpr int eimc_f_Uzh = 8;
/// EIM config index: DU — voltage drop at the converter.
-static int const eimc_f_DU = 9;
+static constexpr int eimc_f_DU = 9;
/// EIM config index: I0 — no-load magnetising current.
-static int const eimc_f_I0 = 10;
+static constexpr int eimc_f_I0 = 10;
/// EIM config index: cfu — V/f gain in normal mode.
-static int const eimc_f_cfu = 11;
+static constexpr int eimc_f_cfu = 11;
/// EIM config index: cfuH — V/f gain in field-weakening region.
-static int const eimc_f_cfuH = 12;
+static constexpr int eimc_f_cfuH = 12;
/// EIM config index: F0 — starting force at zero speed.
-static int const eimc_p_F0 = 13;
+static constexpr int eimc_p_F0 = 13;
/// EIM config index: a1 — force-frequency slope coefficient.
-static int const eimc_p_a1 = 14;
+static constexpr int eimc_p_a1 = 14;
/// EIM config index: Pmax — maximum power.
-static int const eimc_p_Pmax = 15;
+static constexpr int eimc_p_Pmax = 15;
/// EIM config index: Fh — force at field-weakening point.
-static int const eimc_p_Fh = 16;
+static constexpr int eimc_p_Fh = 16;
/// EIM config index: Ph — power at field-weakening point.
-static int const eimc_p_Ph = 17;
+static constexpr int eimc_p_Ph = 17;
/// EIM config index: Vh0 — speed where field weakening begins.
-static int const eimc_p_Vh0 = 18;
+static constexpr int eimc_p_Vh0 = 18;
/// EIM config index: Vh1 — speed of full field weakening.
-static int const eimc_p_Vh1 = 19;
+static constexpr int eimc_p_Vh1 = 19;
/// EIM config index: Imax — maximum motor current.
-static int const eimc_p_Imax = 20;
+static constexpr int eimc_p_Imax = 20;
/// EIM config index: abed — anti-skid set point.
-static int const eimc_p_abed = 21;
+static constexpr int eimc_p_abed = 21;
/// EIM config index: eped — EP brake intensity bias.
-static int const eimc_p_eped = 22;
+static constexpr int eimc_p_eped = 22;
// zmienne dla asynchronów
/// EIM variable index: FMAXMAX — absolute maximum allowable force.
-static int const eimv_FMAXMAX = 0;
+static constexpr int eimv_FMAXMAX = 0;
/// EIM variable index: Fmax — current force limit.
-static int const eimv_Fmax = 1;
+static constexpr int eimv_Fmax = 1;
/// EIM variable index: ks — slip coefficient.
-static int const eimv_ks = 2;
+static constexpr int eimv_ks = 2;
/// EIM variable index: df — frequency offset.
-static int const eimv_df = 3;
+static constexpr int eimv_df = 3;
/// EIM variable index: fp — base frequency.
-static int const eimv_fp = 4;
+static constexpr int eimv_fp = 4;
/// EIM variable index: U — applied voltage.
-static int const eimv_U = 5;
+static constexpr int eimv_U = 5;
/// EIM variable index: pole — pole-pair indicator.
-static int const eimv_pole = 6;
+static constexpr int eimv_pole = 6;
/// EIM variable index: Ic — control current.
-static int const eimv_Ic = 7;
+static constexpr int eimv_Ic = 7;
/// EIM variable index: If — field current.
-static int const eimv_If = 8;
+static constexpr int eimv_If = 8;
/// EIM variable index: M — torque.
-static int const eimv_M = 9;
+static constexpr int eimv_M = 9;
/// EIM variable index: Fr — actual force.
-static int const eimv_Fr = 10;
+static constexpr int eimv_Fr = 10;
/// EIM variable index: Ipoj — line current.
-static int const eimv_Ipoj = 11;
+static constexpr int eimv_Ipoj = 11;
/// EIM variable index: Pm — mechanical power.
-static int const eimv_Pm = 12;
+static constexpr int eimv_Pm = 12;
/// EIM variable index: Pe — electrical power.
-static int const eimv_Pe = 13;
+static constexpr int eimv_Pe = 13;
/// EIM variable index: eta — efficiency.
-static int const eimv_eta = 14;
+static constexpr int eimv_eta = 14;
/// EIM variable index: fkr — critical frequency.
-static int const eimv_fkr = 15;
+static constexpr int eimv_fkr = 15;
/// EIM variable index: Uzsmax — maximum measured DC link voltage.
-static int const eimv_Uzsmax = 16;
+static constexpr int eimv_Uzsmax = 16;
/// EIM variable index: Pmax — instantaneous power limit.
-static int const eimv_Pmax = 17;
+static constexpr int eimv_Pmax = 17;
/// EIM variable index: Fzad — set-point force.
-static int const eimv_Fzad = 18;
+static constexpr int eimv_Fzad = 18;
/// EIM variable index: Imax — maximum allowed current.
-static int const eimv_Imax = 19;
+static constexpr int eimv_Imax = 19;
/// EIM variable index: Fful — full force.
-static int const eimv_Fful = 20;
+static constexpr int eimv_Fful = 20;
/// Brake-of-mode flag: PS (pneumatic, primary).
-static int const bom_PS = 1;
+static constexpr int bom_PS = 1;
/// Brake-of-mode flag: PN (pneumatic, no electrodynamic).
-static int const bom_PN = 2;
+static constexpr int bom_PN = 2;
/// Brake-of-mode flag: EP (electro-pneumatic).
-static int const bom_EP = 4;
+static constexpr int bom_EP = 4;
/// Brake-of-mode flag: MED (mixed pneumatic+ED).
-static int const bom_MED = 8;
+static constexpr int bom_MED = 8;
/// Bit flags reporting vehicle problems that prevent driving.
enum TProblem // lista problemów taboru, które uniemożliwiają jazdę
diff --git a/McZapkie/Mover.cpp b/McZapkie/Mover.cpp
index f15d8e3a..e413869c 100644
--- a/McZapkie/Mover.cpp
+++ b/McZapkie/Mover.cpp
@@ -22,8 +22,8 @@ http://mozilla.org/MPL/2.0/.
// Jeśli jakieś zmienne nie są używane w mover.pas, też można je przenosić.
// Przeniesienie wszystkiego na raz zrobiło by zbyt wielki chaos do ogarnięcia.
-const double dEpsilon = 0.01; // 1cm (zależy od typu sprzęgu...)
-const double CouplerTune = 0.1; // skalowanie tlumiennosci
+constexpr double dEpsilon = 0.01; // 1cm (zależy od typu sprzęgu...)
+constexpr double CouplerTune = 0.1; // skalowanie tlumiennosci
int ConversionError = 0;
@@ -1228,7 +1228,7 @@ void TMoverParameters::CollisionDetect(int const End, double const dt)
if (coupler.CouplingFlag == faux || true == TestFlag(othervehicle->DamageFlag, dtrain_out))
{ // HACK: limit excessive speed derailment checks to vehicles which aren't part of the same consist
- auto const safevelocitylimit{15.0};
+ constexpr auto safevelocitylimit{15.0};
auto const velocitydifference{glm::length(glm::angleAxis(Rot.Rz, glm::dvec3{0, 1, 0}) * V - glm::angleAxis(othervehicle->Rot.Rz, glm::dvec3{0, 1, 0}) * othervehicle->V) *
3.6}; // m/s -> km/h
@@ -1356,8 +1356,8 @@ void TMoverParameters::Derail(DerailReason const Reason)
// *************************************************************************************************
double TMoverParameters::ComputeMovement(double dt, double dt1, const TTrackShape &Shape, TTrackParam &Track, TTractionParam &ElectricTraction, TLocation const &NewLoc, TRotation const &NewRot)
{
- const double Vepsilon = 1e-5;
- const double Aepsilon = 1e-3; // ASBSpeed=0.8;
+ constexpr double Vepsilon = 1e-5;
+ constexpr double Aepsilon = 1e-3; // ASBSpeed=0.8;
if (!TestFlag(DamageFlag, dtrain_out))
{ // Ra: to przepisywanie tu jest bez sensu
@@ -2117,7 +2117,7 @@ void TMoverParameters::HeatingCheck(double const Timestep)
return;
}
// ...detailed check if we're still here
- auto const heatingpowerthreshold{0.1};
+ constexpr auto heatingpowerthreshold{0.1};
// start with blank slate
auto voltage{0.0};
// then try specified power source
@@ -4122,7 +4122,7 @@ bool TMoverParameters::BrakeReleaser(int state)
// *************************************************************************************************
bool TMoverParameters::UniversalBrakeButton(int button, int state)
{
- const bool OK = true; // false tylko jeśli nie uda się wysłać, GF 20161124
+ constexpr bool OK = true; // false tylko jeśli nie uda się wysłać, GF 20161124
UniversalBrakeButtonActive[button] = state > 0;
int flag = 0;
if (Power24vIsAvailable || Power110vIsAvailable)
@@ -4481,8 +4481,8 @@ void TMoverParameters::UpdatePipePressure(double dt)
Pipe->Act();
}
- const double LBDelay = 100;
- const double kL = 0.5;
+ constexpr double LBDelay = 100;
+ constexpr double kL = 0.5;
// double dV;
// TMoverParameters *c; // T_MoverParameters
double temp;
@@ -4768,7 +4768,7 @@ void TMoverParameters::UpdateScndPipePressure(double dt)
Pipe2->Act();
}
- const double Spz = 0.5067;
+ constexpr double Spz = 0.5067;
TMoverParameters *c;
double dv1, dv2, dV;
@@ -5267,9 +5267,9 @@ double TMoverParameters::FrictionForce() const
double TMoverParameters::Adhesive(double staticfriction) const
{
double adhesion = 0.0;
- const double adh_factor = 0.25; // współczynnik określający, jak bardzo spada tarcie przy poślizgu
- const double slipfactor = 0.33; // współczynnik określający, jak szybko spada tarcie przy poślizgu
- const double sandfactor = 1.25; // współczynnik określający, jak mocno pomaga piasek
+ constexpr double adh_factor = 0.25; // współczynnik określający, jak bardzo spada tarcie przy poślizgu
+ constexpr double slipfactor = 0.33; // współczynnik określający, jak szybko spada tarcie przy poślizgu
+ constexpr double sandfactor = 1.25; // współczynnik określający, jak mocno pomaga piasek
/*
// ABu: male przerobki, tylko czy to da jakikolwiek skutek w FPS?
// w kazdym razie zaciemni kod na pewno :)
@@ -6715,7 +6715,7 @@ bool TMoverParameters::RelayReset(int const Relays, range_t const Notify)
double TMoverParameters::v2n(void)
{
// przelicza predkosc liniowa na obrotowa
- const double dmgn = 0.5;
+ constexpr double dmgn = 0.5;
double n, deltan = 0;
n = V / (M_PI * WheelDiameter); // predkosc obrotowa wynikajaca z liniowej [obr/s]
@@ -7912,7 +7912,7 @@ bool TMoverParameters::dizel_Update(double dt)
{
dizel_EngageChange(dt);
DU = dizel_AutoGearCheck();
- double const fillspeed{2};
+ constexpr double fillspeed{2};
dizel_fill = dizel_fill + fillspeed * dt * (dizel_fillcheck(MainCtrlPos, dt) - dizel_fill);
}
@@ -8262,14 +8262,14 @@ void TMoverParameters::dizel_HeatSet(float const Value)
void TMoverParameters::dizel_Heat(double const dt)
{
- auto const qs{44700.0};
- auto const Cs{11000.0};
- auto const Cw{4.189};
- auto const Co{1.885};
- auto const gwmin{400.0};
- auto const gwmax{4000.0};
- auto const gwmin2{400.0};
- auto const gwmax2{4000.0};
+ constexpr auto qs{44700.0};
+ constexpr auto Cs{11000.0};
+ constexpr auto Cw{4.189};
+ constexpr auto Co{1.885};
+ constexpr auto gwmin{400.0};
+ constexpr auto gwmax{4000.0};
+ constexpr auto gwmin2{400.0};
+ constexpr auto gwmax2{4000.0};
dizel_heat.Te = Global.AirTemperature;
@@ -8323,7 +8323,7 @@ void TMoverParameters::dizel_Heat(double const dt)
*/
auto const Qp = (true == WaterHeater.is_active && true == WaterPump.is_active && dizel_heat.Twy < 60 && dizel_heat.Twy2 < 60 ? 1 : 0) * 1000;
- auto const kurek07{1}; // unknown/unimplemented device TBD, TODO: identify and implement?
+ constexpr auto kurek07{1}; // unknown/unimplemented device TBD, TODO: identify and implement?
if (true == dizel_heat.auxiliary_water_circuit)
{
@@ -9041,7 +9041,7 @@ bool issection(std::string const &Name, std::string const &Input)
int s2NPW(std::string s)
{ // wylicza ilosc osi napednych z opisu ukladu osi
- const char A = 64;
+ constexpr char A = 64;
int NPW = 0;
for (std::size_t k = 0; k < s.size(); ++k)
{
@@ -9053,7 +9053,7 @@ int s2NPW(std::string s)
int s2NNW(std::string s)
{ // wylicza ilosc osi nienapedzanych z opisu ukladu osi
- const char Zero = 48;
+ constexpr char Zero = 48;
int NNW = 0;
for (std::size_t k = 0; k < s.size(); ++k)
{
@@ -9606,9 +9606,9 @@ void TMoverParameters::BrakeSubsystemDecode()
bool TMoverParameters::LoadFIZ(std::string chkpath)
{
chkPath = chkpath; // assign class path for reloading
- const int param_ok = 1;
- const int wheels_ok = 2;
- const int dimensions_ok = 4;
+ constexpr int param_ok = 1;
+ constexpr int wheels_ok = 2;
+ constexpr int dimensions_ok = 4;
ConversionError = 666;
LISTLINE = 0;
@@ -10388,7 +10388,7 @@ void TMoverParameters::LoadFIZ_Wheels(std::string const &line)
AxleInertialMoment = 1.0;
*/
// approximation formula by youby
- auto const k = 472.0; // arbitrary constant
+ constexpr auto k = 472.0; // arbitrary constant
AxleInertialMoment = k / 4.0 * std::pow(WheelDiameter, 4.0) * NAxles;
Mred = k * std::pow(WheelDiameter, 2.0) * NAxles;
}
@@ -11504,7 +11504,7 @@ void TMoverParameters::LoadFIZ_DList(std::string const &Input)
// Calculation of fuel consumption coefficient for futher calculation
const double dizel_max_power = dizel_nmax * (dizel_Mnmax - dizel_Mstand) * M_PI * 2 * 0.001; // power in kW
const double dizel_max_energy = dizel_max_power; // energy per one hour in kWh is equal to power in kW times 1 h
- const double fuel_density = 850; // g/l
+ constexpr double fuel_density = 850; // g/l
dizel_FuelConsumption = dizel_NominalFuelConsumptionRate * dizel_max_energy / fuel_density / dizel_nmax;
}
diff --git a/McZapkie/Oerlikon_ESt.cpp b/McZapkie/Oerlikon_ESt.cpp
index f0d89f46..654c1894 100644
--- a/McZapkie/Oerlikon_ESt.cpp
+++ b/McZapkie/Oerlikon_ESt.cpp
@@ -458,10 +458,10 @@ void TNESt3::SetLBP(double const P)
void TNESt3::SetSize( int const size, std::string const ¶ms ) // ustawianie dysz (rozmiaru ZR)
{
- static double const dNO1l = 1.250;
- static double const dNT1l = 0.510;
- static double const dOO1l = 0.907;
- static double const dOT1l = 0.524;
+ static constexpr double dNO1l = 1.250;
+ static constexpr double dNT1l = 0.510;
+ static constexpr double dOO1l = 0.907;
+ static constexpr double dOT1l = 0.524;
if (contains( params, "ESt3" ) )
{
diff --git a/McZapkie/Oerlikon_ESt.h b/McZapkie/Oerlikon_ESt.h
index f485a45b..dc7df462 100644
--- a/McZapkie/Oerlikon_ESt.h
+++ b/McZapkie/Oerlikon_ESt.h
@@ -45,26 +45,26 @@ Co brakuje:
- PZZ dla dodatkowego
*/
-static int const dMAX = 11; // dysze
-static int const dON = 0; // osobowy napelnianie (+ZP)
-static int const dOO = 1; // osobowy oproznianie
-static int const dTN = 2; // towarowy napelnianie (+ZP)
-static int const dTO = 3; // towarowy oproznianie
-static int const dP = 4; // zbiornik pomocniczy
-static int const dSd = 5; // zbiornik sterujacy
-static int const dSm = 6; // zbiornik sterujacy
-static int const dPd = 7; // duzy przelot zamykajcego
-static int const dPm = 8; // maly przelot zamykajacego
-static int const dPO = 9; // zasilanie pomocniczego O
-static int const dPT = 10; // zasilanie pomocniczego T
+static constexpr int dMAX = 11; // dysze
+static constexpr int dON = 0; // osobowy napelnianie (+ZP)
+static constexpr int dOO = 1; // osobowy oproznianie
+static constexpr int dTN = 2; // towarowy napelnianie (+ZP)
+static constexpr int dTO = 3; // towarowy oproznianie
+static constexpr int dP = 4; // zbiornik pomocniczy
+static constexpr int dSd = 5; // zbiornik sterujacy
+static constexpr int dSm = 6; // zbiornik sterujacy
+static constexpr int dPd = 7; // duzy przelot zamykajcego
+static constexpr int dPm = 8; // maly przelot zamykajacego
+static constexpr int dPO = 9; // zasilanie pomocniczego O
+static constexpr int dPT = 10; // zasilanie pomocniczego T
// przekladniki
-static int const p_none = 0;
-static int const p_rapid = 1;
-static int const p_pp = 2;
-static int const p_al2 = 3;
-static int const p_ppz = 4;
-static int const P_ed = 5;
+static constexpr int p_none = 0;
+static constexpr int p_rapid = 1;
+static constexpr int p_pp = 2;
+static constexpr int p_al2 = 3;
+static constexpr int p_ppz = 4;
+static constexpr int P_ed = 5;
class TPrzekladnik : public TReservoir // przekladnik (powtarzacz)
diff --git a/McZapkie/hamulce.cpp b/McZapkie/hamulce.cpp
index 81d4a1ad..71de6b86 100644
--- a/McZapkie/hamulce.cpp
+++ b/McZapkie/hamulce.cpp
@@ -20,7 +20,7 @@ Copyright (C) 2007-2014 Maciej Cierniak
//---FUNKCJE OGOLNE---
-static double const DPL = 0.25;
+static constexpr double DPL = 0.25;
double const TFV4aM::pos_table[11] = {-2, 6, -1, 0, -2, 1, 4, 6, 0, 0, 0};
double const TMHZ_EN57::pos_table[11] = {-1, 10, -1, 0, 0, 2, 9, 10, 0, 0, 0};
double const TMHZ_K5P::pos_table[11] = {-1, 3, -1, 0, 1, 1, 2, 3, 0, 0, 0};
@@ -108,7 +108,7 @@ double PF(double const P1, double const P2, double const S, double const DP)
/// Volumetric flow rate (signed).
double PF1(double const P1, double const P2, double const S)
{
- static double const DPS = 0.001;
+ static constexpr double DPS = 0.001;
double const PH = std::max(P1, P2) + 1.0; // wyzsze cisnienie absolutne
double const PL = P1 + P2 - PH + 2.0; // nizsze cisnienie absolutne
@@ -303,10 +303,10 @@ end; */
/// Cylinder pressure in bar.
double TBrakeCyl::P()
{
- static double const VS = 0.005;
- static double const pS = 0.05;
- static double const VD = 1.10;
- static double const cD = 1;
+ static constexpr double VS = 0.005;
+ static constexpr double pS = 0.05;
+ static constexpr double VD = 1.10;
+ static constexpr double cD = 1;
static double const pD = VD - cD;
const double VtoC = Cap > 0.0 ? Vol / Cap : 0.0; // stosunek cisnienia do objetosci.
@@ -2968,7 +2968,7 @@ void TDriverHandle::SetUniversalFlag(int flag)
/// Brake pipe volume change for this step.
double TFV4a::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
{
- static int const LBDelay = 100;
+ static constexpr int LBDelay = 100;
ep = PP; // SPKS!!
double LimPP = std::min(BPT[std::lround(i_bcp) + 2][1], HP);
@@ -3057,8 +3057,8 @@ void TFV4a::Init(double Press)
/// Brake pipe volume change for this step.
double TFV4aM::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
{
- int const LBDelay{100};
- double const xpM{0.3}; // mnoznik membrany komory pod
+ constexpr int LBDelay{100};
+ constexpr double xpM{0.3}; // mnoznik membrany komory pod
ep = PP / 2.0 * 1.5 + ep / 2.0 * 0.5; // SPKS!!
@@ -3293,7 +3293,7 @@ bool TFV4aM::EQ(double pos, double i_pos)
/// Brake pipe volume change for this step.
double TMHZ_EN57::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
{
- static int const LBDelay = 100;
+ static constexpr int LBDelay = 100;
double LimPP;
double dpPipe;
@@ -3502,7 +3502,7 @@ bool TMHZ_EN57::EQ(double pos, double i_pos)
/// Brake pipe volume change for this step.
double TMHZ_K5P::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
{
- static int const LBDelay = 100;
+ static constexpr int LBDelay = 100;
double LimCP;
double dpPipe;
@@ -3685,7 +3685,7 @@ bool TMHZ_K5P::EQ(double pos, double i_pos)
/// Brake pipe volume change for this step.
double TMHZ_6P::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
{
- static int const LBDelay = 100;
+ static constexpr int LBDelay = 100;
double LimCP;
double dpPipe;
@@ -3869,7 +3869,7 @@ bool TMHZ_6P::EQ(double pos, double i_pos)
/// Brake pipe volume change for this step.
double TM394::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
{
- static int const LBDelay = 65;
+ static constexpr int LBDelay = 65;
double LimPP;
double dpPipe;
@@ -3965,10 +3965,10 @@ double TM394::GetPos(int i)
/// Brake pipe volume change for this step.
double TH14K1::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
{
- int const LBDelay = 100; // szybkosc + zasilanie sterujacego
+ constexpr int LBDelay = 100; // szybkosc + zasilanie sterujacego
// static double const BPT_K[/*?*/ /*-1..4*/ (4) - (-1) + 1][2] =
//{ (10, 0), (4, 1), (0, 1), (4, 0), (4, -1), (15, -1) };
- double const NomPress = 5.0;
+ constexpr double NomPress = 5.0;
int BCP = std::lround(i_bcp);
if (i_bcp < -1)
@@ -4057,8 +4057,8 @@ double TH14K1::GetPos(int i)
/// Brake pipe volume change for this step.
double TSt113::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
{
- static int const LBDelay = 100; // szybkosc + zasilanie sterujacego
- static double const NomPress = 5.0;
+ static constexpr int LBDelay = 100; // szybkosc + zasilanie sterujacego
+ static constexpr double NomPress = 5.0;
double LimPP;
double dpMainValve;
@@ -4149,7 +4149,7 @@ void TSt113::Init(double Press)
/// Brake pipe volume change for this step.
double Ttest::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
{
- static int const LBDelay = 100;
+ static constexpr int LBDelay = 100;
double LimPP;
double dpPipe;
@@ -4302,7 +4302,7 @@ double TH1405::GetCP()
/// Brake pipe volume change for this step.
double TFVel6::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
{
- static int const LBDelay = 100;
+ static constexpr int LBDelay = 100;
double LimPP;
double dpMainValve;
@@ -4399,7 +4399,7 @@ void TFVel6::Init(double Press)
/// Brake pipe volume change for this step.
double TFVE408::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
{
- static int const LBDelay = 100;
+ static constexpr int LBDelay = 100;
double LimPP;
double dpMainValve;
diff --git a/McZapkie/hamulce.h b/McZapkie/hamulce.h
index 7c9fefe4..7c564e52 100644
--- a/McZapkie/hamulce.h
+++ b/McZapkie/hamulce.h
@@ -36,150 +36,150 @@ Knorr/West EP - żeby był
#include "friction.h" // Pascal unit
/// Number of positions of the local (auxiliary/manual) brake handle.
-static int const LocalBrakePosNo = 10; /*ilosc nastaw hamulca recznego lub pomocniczego*/
+static constexpr int LocalBrakePosNo = 10; /*ilosc nastaw hamulca recznego lub pomocniczego*/
/// Maximum number of positions of the main (train) brake handle.
-static int const MainBrakeMaxPos = 10; /*max. ilosc nastaw hamulca zasadniczego*/
+static constexpr int MainBrakeMaxPos = 10; /*max. ilosc nastaw hamulca zasadniczego*/
/*nastawy hamulca*/
/// Brake delay setting flag: G (goods/freight slow).
-static int const bdelay_G = 1; // G
+static constexpr int bdelay_G = 1; // G
/// Brake delay setting flag: P (passenger fast).
-static int const bdelay_P = 2; // P
+static constexpr int bdelay_P = 2; // P
/// Brake delay setting flag: R (rapid - high braking force).
-static int const bdelay_R = 4; // R
+static constexpr int bdelay_R = 4; // R
/// Brake delay setting flag: Mg (magnetic rail brake enabled).
-static int const bdelay_M = 8; // Mg
+static constexpr int bdelay_M = 8; // Mg
/*stan hamulca*/
/// Brake state flag: brake released (no action).
-static int const b_off = 0; // luzowanie
+static constexpr int b_off = 0; // luzowanie
/// Brake state flag: hold (lap) - keep current cylinder pressure.
-static int const b_hld = 1; // trzymanie
+static constexpr int b_hld = 1; // trzymanie
/// Brake state flag: applying - filling brake cylinder.
-static int const b_on = 2; // napelnianie
+static constexpr int b_on = 2; // napelnianie
/// Brake state flag: replenishing the auxiliary reservoir.
-static int const b_rfl = 4; // uzupelnianie
+static constexpr int b_rfl = 4; // uzupelnianie
/// Brake state flag: releaser engaged (vents the control reservoir to release brakes).
-static int const b_rls = 8; // odluzniacz
+static constexpr int b_rls = 8; // odluzniacz
/// Brake state flag: electro-pneumatic action active.
-static int const b_ep = 16; // elektropneumatyczny
+static constexpr int b_ep = 16; // elektropneumatyczny
/// Brake state flag: anti-slip protection holding the brake (preventing further filling).
-static int const b_asb = 32; // przeciwposlizg-wstrzymanie
+static constexpr int b_asb = 32; // przeciwposlizg-wstrzymanie
/// Brake state flag: anti-slip protection releasing the brake.
-static int const b_asb_unbrake = 64; // przeciwposlizg-luzowanie
+static constexpr int b_asb_unbrake = 64; // przeciwposlizg-luzowanie
/// Brake state flag: brake disabled / damaged.
-static int const b_dmg = 128; // wylaczony z dzialania
+static constexpr int b_dmg = 128; // wylaczony z dzialania
/*uszkodzenia hamulca*/
/// Brake damage flag: faulty filling phase.
-static int const df_on = 1; // napelnianie
+static constexpr int df_on = 1; // napelnianie
/// Brake damage flag: faulty release phase.
-static int const df_off = 2; // luzowanie
+static constexpr int df_off = 2; // luzowanie
/// Brake damage flag: leak in auxiliary reservoir (ZP).
-static int const df_br = 4; // wyplyw z ZP
+static constexpr int df_br = 4; // wyplyw z ZP
/// Brake damage flag: leak in valve pre-chamber.
-static int const df_vv = 8; // wyplyw z komory wstepnej
+static constexpr int df_vv = 8; // wyplyw z komory wstepnej
/// Brake damage flag: leak in brake cylinder.
-static int const df_bc = 16; // wyplyw z silownika
+static constexpr int df_bc = 16; // wyplyw z silownika
/// Brake damage flag: leak in control reservoir (ZS).
-static int const df_cv = 32; // wyplyw z ZS
+static constexpr int df_cv = 32; // wyplyw z ZS
/// Brake damage flag: stuck at low load step.
-static int const df_PP = 64; // zawsze niski stopien
+static constexpr int df_PP = 64; // zawsze niski stopien
/// Brake damage flag: stuck at high load step.
-static int const df_RR = 128; // zawsze wysoki stopien
+static constexpr int df_RR = 128; // zawsze wysoki stopien
/*indeksy dzwiekow FV4a*/
/// FV4a sound index: braking flow.
-static int const s_fv4a_b = 0; // hamowanie
+static constexpr int s_fv4a_b = 0; // hamowanie
/// FV4a sound index: release flow.
-static int const s_fv4a_u = 1; // luzowanie
+static constexpr int s_fv4a_u = 1; // luzowanie
/// FV4a sound index: emergency braking flow.
-static int const s_fv4a_e = 2; // hamowanie nagle
+static constexpr int s_fv4a_e = 2; // hamowanie nagle
/// FV4a sound index: control wave outflow.
-static int const s_fv4a_x = 3; // wyplyw sterujacego fala
+static constexpr int s_fv4a_x = 3; // wyplyw sterujacego fala
/// FV4a sound index: timing chamber outflow.
-static int const s_fv4a_t = 4; // wyplyw z czasowego
+static constexpr int s_fv4a_t = 4; // wyplyw z czasowego
/*pary cierne*/
/// Friction pair: P10 (default cast iron).
-static int const bp_P10 = 0;
+static constexpr int bp_P10 = 0;
/// Friction pair: P10 phosphoric cast iron with Bg block.
-static int const bp_P10Bg = 2; // żeliwo fosforowe P10
+static constexpr int bp_P10Bg = 2; // żeliwo fosforowe P10
/// Friction pair: P10 phosphoric cast iron with Bgu block.
-static int const bp_P10Bgu = 1;
+static constexpr int bp_P10Bgu = 1;
/// Friction pair: low-friction composite (b.n.t.) with Bg block.
-static int const bp_LLBg = 4; // komp. b.n.t.
+static constexpr int bp_LLBg = 4; // komp. b.n.t.
/// Friction pair: low-friction composite (b.n.t.) with Bgu block.
-static int const bp_LLBgu = 3;
+static constexpr int bp_LLBgu = 3;
/// Friction pair: low-friction composite (n.t.) with Bg block.
-static int const bp_LBg = 6; // komp. n.t.
+static constexpr int bp_LBg = 6; // komp. n.t.
/// Friction pair: low-friction composite (n.t.) with Bgu block.
-static int const bp_LBgu = 5;
+static constexpr int bp_LBgu = 5;
/// Friction pair: high-friction composite (w.t.) with Bg block.
-static int const bp_KBg = 8; // komp. w.t.
+static constexpr int bp_KBg = 8; // komp. w.t.
/// Friction pair: high-friction composite (w.t.) with Bgu block.
-static int const bp_KBgu = 7;
+static constexpr int bp_KBgu = 7;
/// Friction pair: disc brake type 1.
-static int const bp_D1 = 9; // tarcze
+static constexpr int bp_D1 = 9; // tarcze
/// Friction pair: disc brake type 2.
-static int const bp_D2 = 10;
+static constexpr int bp_D2 = 10;
/// Friction pair: Frenoplast FR513 composite.
-static int const bp_FR513 = 11; // Frenoplast FR513
+static constexpr int bp_FR513 = 11; // Frenoplast FR513
/// Friction pair: Cosid composite.
-static int const bp_Cosid = 12; // jakistam kompozyt :D
+static constexpr int bp_Cosid = 12; // jakistam kompozyt :D
/// Friction pair: PKP cast iron with Bg block.
-static int const bp_PKPBg = 13; // żeliwo PKP
+static constexpr int bp_PKPBg = 13; // żeliwo PKP
/// Friction pair: PKP cast iron with Bgu block.
-static int const bp_PKPBgu = 14;
+static constexpr int bp_PKPBgu = 14;
/// Friction pair flag: magnetic rail brake (added bitwise to other types).
-static int const bp_MHS = 128; // magnetyczny hamulec szynowy
+static constexpr int bp_MHS = 128; // magnetyczny hamulec szynowy
/// Friction pair: P10y phosphoric cast iron with Bg block.
-static int const bp_P10yBg = 15; // żeliwo fosforowe P10
+static constexpr int bp_P10yBg = 15; // żeliwo fosforowe P10
/// Friction pair: P10y phosphoric cast iron with Bgu block.
-static int const bp_P10yBgu = 16;
+static constexpr int bp_P10yBgu = 16;
/// Friction pair: Frenoplast FR510 composite.
-static int const bp_FR510 = 17; // Frenoplast FR510
+static constexpr int bp_FR510 = 17; // Frenoplast FR510
/// Sound flag: accelerator (rapid pressure drop in valve pre-chamber).
-static int const sf_Acc = 1; // przyspieszacz
+static constexpr int sf_Acc = 1; // przyspieszacz
/// Sound flag: brake transmission/load relay actuating.
-static int const sf_BR = 2; // przekladnia
+static constexpr int sf_BR = 2; // przekladnia
/// Sound flag: brake cylinder filling.
-static int const sf_CylB = 4; // cylinder - napelnianie
+static constexpr int sf_CylB = 4; // cylinder - napelnianie
/// Sound flag: brake cylinder venting.
-static int const sf_CylU = 8; // cylinder - oproznianie
+static constexpr int sf_CylU = 8; // cylinder - oproznianie
/// Sound flag: releaser actuated.
-static int const sf_rel = 16; // odluzniacz
+static constexpr int sf_rel = 16; // odluzniacz
/// Sound flag: electro-pneumatic valves switching.
-static int const sf_ep = 32; // zawory ep
+static constexpr int sf_ep = 32; // zawory ep
/// Brake handle position index: minimum position.
-static int const bh_MIN = 0; // minimalna pozycja
+static constexpr int bh_MIN = 0; // minimalna pozycja
/// Brake handle position index: maximum position.
-static int const bh_MAX = 1; // maksymalna pozycja
+static constexpr int bh_MAX = 1; // maksymalna pozycja
/// Brake handle position index: filling stroke (high-pressure overcharge); if not present, equivalent to running.
-static int const bh_FS = 2; // napelnianie uderzeniowe //jesli nie ma, to jazda
+static constexpr int bh_FS = 2; // napelnianie uderzeniowe //jesli nie ma, to jazda
/// Brake handle position index: running (driving) position.
-static int const bh_RP = 3; // jazda
+static constexpr int bh_RP = 3; // jazda
/// Brake handle position index: cut-off (double traction / neutral).
-static int const bh_NP = 4; // odciecie - podwojna trakcja
+static constexpr int bh_NP = 4; // odciecie - podwojna trakcja
/// Brake handle position index: minimum braking step (lap or first step).
-static int const bh_MB = 5; // odciecie - utrzymanie stopnia hamowania/pierwszy 1 stopien hamowania
+static constexpr int bh_MB = 5; // odciecie - utrzymanie stopnia hamowania/pierwszy 1 stopien hamowania
/// Brake handle position index: full service brake.
-static int const bh_FB = 6; // pelne
+static constexpr int bh_FB = 6; // pelne
/// Brake handle position index: emergency brake.
-static int const bh_EB = 7; // nagle
+static constexpr int bh_EB = 7; // nagle
/// Brake handle position index: EP release (full release for angular EP).
-static int const bh_EPR = 8; // ep - luzowanie //pelny luz dla ep kątowego
+static constexpr int bh_EPR = 8; // ep - luzowanie //pelny luz dla ep kątowego
/// Brake handle position index: EP hold/lap; if equal to release, button-only EP control.
-static int const bh_EPN = 9; // ep - utrzymanie //jesli rowne luzowaniu, wtedy sterowanie przyciskiem
+static constexpr int bh_EPN = 9; // ep - utrzymanie //jesli rowne luzowaniu, wtedy sterowanie przyciskiem
/// Brake handle position index: EP brake (full braking for angular EP).
-static int const bh_EPB = 10; // ep - hamowanie //pelne hamowanie dla ep kątowego
+static constexpr int bh_EPB = 10; // ep - hamowanie //pelne hamowanie dla ep kątowego
/// Diameter of the brake pipe (1") used in flow calculations.
-static double const SpgD = 0.7917;
+static constexpr double SpgD = 0.7917;
/// Cross-section of a 1" brake pipe expressed in l/m (used to keep volumes in liters and lengths in meters).
-static double const SpO = 0.5067; // przekroj przewodu 1" w l/m
+static constexpr double SpO = 0.5067; // przekroj przewodu 1" w l/m
// wyj: jednostka dosyc dziwna, ale wszystkie obliczenia
// i pojemnosci sa podane w litrach (rozsadne wielkosci)
// zas dlugosc pojazdow jest podana w metrach
diff --git a/application/application.cpp b/application/application.cpp
index 3f98ac4c..368fb463 100644
--- a/application/application.cpp
+++ b/application/application.cpp
@@ -444,7 +444,7 @@ void eu07_application::queue_quit(bool direct)
return;
}
- const command_relay relay;
+ constexpr command_relay relay;
relay.post(user_command::quitsimulation, 0.0, 0.0, GLFW_PRESS, 0);
}
@@ -901,7 +901,7 @@ void eu07_application::on_focus_change(bool focus)
{
if (Global.bInactivePause && m_network.has_value() && !m_network->client)
{ // jeśli ma być pauzowanie okna w tle
- const command_relay relay;
+ constexpr command_relay relay;
relay.post(user_command::focuspauseset, focus ? 1.0 : 0.0, 0.0, GLFW_PRESS, 0);
}
}
diff --git a/application/driveruilayer.cpp b/application/driveruilayer.cpp
index 5e851244..b6c8cac9 100644
--- a/application/driveruilayer.cpp
+++ b/application/driveruilayer.cpp
@@ -208,7 +208,7 @@ bool driver_ui::on_mouse_button(int const Button, int const Action)
void driver_ui::update()
{
- auto const pausemask{1 | 2};
+ constexpr auto pausemask{1 | 2};
const auto ispaused{false == DebugModeFlag && (Global.iPause & pausemask) != 0};
if (ispaused != m_paused && false == Global.ControlPicking)
{
diff --git a/application/driveruipanels.cpp b/application/driveruipanels.cpp
index ff6bf916..5261b278 100644
--- a/application/driveruipanels.cpp
+++ b/application/driveruipanels.cpp
@@ -591,7 +591,7 @@ debug_panel::render() {
if( true == render_section( "Vehicle", m_vehiclelines ) ) {
if( DebugModeFlag && m_input.mover && m_input.mover->DamageFlag != 0 ) {
if( true == ImGui::Button( "Stop and repair consist" ) ) {
- const command_relay relay;
+ constexpr command_relay relay;
relay.post(user_command::resetconsist, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &m_input.vehicle->name());
}
}
@@ -625,7 +625,7 @@ debug_panel::render() {
ImGui::Separator();
bool flag = DebugModeFlag;
if (ImGui::Checkbox("Debug Mode", &flag)) {
- const command_relay relay;
+ constexpr command_relay relay;
relay.post(user_command::debugtoggle, 0.0, 0.0, GLFW_RELEASE, 0);
}
}
@@ -647,7 +647,7 @@ debug_panel::render_section_scenario() {
auto fogrange = std::log( Global.fFogEnd );
if( ImGui::SliderFloat(
( to_string( std::exp( fogrange ), 0, 5 ) + " m###fogend" ).c_str(), &fogrange, std::log( 10.0f ), std::log( 50000.0f ), "Fog distance" ) ) {
- const command_relay relay;
+ constexpr command_relay relay;
relay.post(
user_command::setweather,
std::clamp( std::exp( fogrange ), 10.0f, 50000.0f ),
@@ -661,7 +661,7 @@ debug_panel::render_section_scenario() {
(to_string(Airtemperature, 1) + " deg C###Airtemperature").c_str(),
&Airtemperature, -35.0f, 40.0f, "Air Temperature"))
{
- const command_relay relay;
+ constexpr command_relay relay;
relay.post(
user_command::settemperature,
std::clamp(Airtemperature, -35.0f, 40.0f),
@@ -673,7 +673,7 @@ debug_panel::render_section_scenario() {
{
if( ImGui::SliderFloat(
( to_string( Global.Overcast, 2, 5 ) + " (" + Global.Weather + ")###overcast" ).c_str(), &Global.Overcast, 0.0f, 2.0f, "Cloud cover" ) ) {
- const command_relay relay;
+ constexpr command_relay relay;
relay.post(
user_command::setweather,
Global.fFogEnd,
@@ -685,7 +685,7 @@ debug_panel::render_section_scenario() {
{
if( ImGui::SliderFloat(
( to_string( Global.fMoveLight, 0, 5 ) + " (" + Global.Season + ")###movelight" ).c_str(), &Global.fMoveLight, 0.0f, 364.0f, "Day of year" ) ) {
- const command_relay relay;
+ constexpr command_relay relay;
relay.post(
user_command::setdatetime,
std::clamp( Global.fMoveLight, 0.0f, 365.0f ),
@@ -713,7 +713,7 @@ debug_panel::render_section_scenario() {
+ ":"
+ std::string( std::to_string( int( 100 + simulation::Time.data().wMinute ) ).substr( 1, 2 ) ) ) };
if( ImGui::SliderInt( ( timestring + " (" + Global.Period + ")###simulationtime" ).c_str(), &time, 0, 1439, "Time of day" ) ) {
- const command_relay relay;
+ constexpr command_relay relay;
relay.post(
user_command::setdatetime,
Global.fMoveLight,
@@ -1595,7 +1595,7 @@ debug_panel::render_section_settings() {
if (simulation::Train) {
float val = simulation::Train->get_radiovolume();
if( ImGui::SliderFloat( ( std::to_string( static_cast( val * 100 ) ) + "%###volumeradio" ).c_str(), &val, 0.0f, 1.0f, "Vehicle radio volume" ) ) {
- const command_relay relay;
+ constexpr command_relay relay;
relay.post(user_command::radiovolumeset, val, 0.0, GLFW_PRESS, 0);
}
}
diff --git a/application/editormode.cpp b/application/editormode.cpp
index 6dee5b71..a8451616 100644
--- a/application/editormode.cpp
+++ b/application/editormode.cpp
@@ -210,7 +210,7 @@ void editor_mode::snap_to_ground(scene::basic_node *node)
return;
// small tolerance so a node already resting on a surface still snaps cleanly to it
- double const epsilon = 0.05;
+ constexpr double epsilon = 0.05;
double bestY = -std::numeric_limits::max();
bool found = false;
diff --git a/application/uilayer.cpp b/application/uilayer.cpp
index f23b9789..c0b0fdd6 100644
--- a/application/uilayer.cpp
+++ b/application/uilayer.cpp
@@ -540,7 +540,7 @@ void ui_layer::render_menu_contents()
bool flag = DebugModeFlag;
if (ImGui::MenuItem(STR_C("Debug mode"), nullptr, &flag))
{
- const command_relay relay;
+ constexpr command_relay relay;
relay.post(user_command::debugtoggle, 0.0, 0.0, GLFW_RELEASE, 0);
}
ImGui::MenuItem(STR_C("Quit"), "F10", &m_quit_active);
diff --git a/audio/audio.h b/audio/audio.h
index 184c6d18..31c8f9cd 100644
--- a/audio/audio.h
+++ b/audio/audio.h
@@ -19,7 +19,7 @@ http://mozilla.org/MPL/2.0/.
namespace audio {
-ALuint const null_resource{ ~ALuint{0} };
+constexpr ALuint null_resource{ ~ALuint{0} };
// wrapper for audio sample
struct openal_buffer {
diff --git a/audio/audiorenderer.cpp b/audio/audiorenderer.cpp
index 34aa5472..fbf64778 100644
--- a/audio/audiorenderer.cpp
+++ b/audio/audiorenderer.cpp
@@ -22,8 +22,8 @@ namespace audio {
openal_renderer renderer;
bool event_volume_change { false };
-float const EU07_SOUND_CUTOFFRANGE { 3000.f }; // 2750 m = max expected emitter spawn range, plus safety margin
-float const EU07_SOUND_VELOCITYLIMIT { 250 / 3.6f }; // 343 m/sec ~= speed of sound; arbitrary limit of 250 km/h
+constexpr float EU07_SOUND_CUTOFFRANGE { 3000.f }; // 2750 m = max expected emitter spawn range, plus safety margin
+constexpr float EU07_SOUND_VELOCITYLIMIT { 250 / 3.6f }; // 343 m/sec ~= speed of sound; arbitrary limit of 250 km/h
// potentially clamps length of provided vector to 343 meters
// TBD: make a generic method for utilities out of this
diff --git a/audio/sound.h b/audio/sound.h
index 385a7283..27df60a9 100644
--- a/audio/sound.h
+++ b/audio/sound.h
@@ -13,12 +13,12 @@ http://mozilla.org/MPL/2.0/.
#include "utilities/Classes.h"
#include "utilities/Names.h"
-float const EU07_SOUND_GLOBALRANGE { -1.f };
-float const EU07_SOUND_CABCONTROLSCUTOFFRANGE { 7.5f };
-float const EU07_SOUND_CABANNOUNCEMENTCUTOFFRANGE{ -10.f };
-float const EU07_SOUND_BRAKINGCUTOFFRANGE { 100.f };
-float const EU07_SOUND_RUNNINGNOISECUTOFFRANGE { 200.f };
-float const EU07_SOUND_HANDHELDRADIORANGE { 3500.f };
+constexpr float EU07_SOUND_GLOBALRANGE { -1.f };
+constexpr float EU07_SOUND_CABCONTROLSCUTOFFRANGE { 7.5f };
+constexpr float EU07_SOUND_CABANNOUNCEMENTCUTOFFRANGE{ -10.f };
+constexpr float EU07_SOUND_BRAKINGCUTOFFRANGE { 100.f };
+constexpr float EU07_SOUND_RUNNINGNOISECUTOFFRANGE { 200.f };
+constexpr float EU07_SOUND_HANDHELDRADIORANGE { 3500.f };
enum class sound_type {
single,
@@ -46,7 +46,7 @@ enum class sound_placement {
custom, // source doesn't fit in any standard location or requires custom soundproofing
};
-auto const EU07_SOUNDPROOFING_NONE{ 1.f };
+constexpr auto EU07_SOUNDPROOFING_NONE{ 1.f };
auto const EU07_SOUNDPROOFING_SOME{ std::sqrt( 0.65f ) };
auto const EU07_SOUNDPROOFING_STRONG{ std::sqrt( 0.20f ) };
auto const EU07_SOUNDPROOFING_VERYSTRONG{ std::sqrt( 0.01f ) };
diff --git a/editor/editorTerrainStreamer.cpp b/editor/editorTerrainStreamer.cpp
index 73205d0d..57dcf17b 100644
--- a/editor/editorTerrainStreamer.cpp
+++ b/editor/editorTerrainStreamer.cpp
@@ -112,7 +112,7 @@ void terrain_streamer::save_heights(int Cx, int Cz, editor_terrain const &Terrai
if (!f)
return;
- char const magic[4] = {'E', 'T', 'C', '1'};
+ constexpr char magic[4] = {'E', 'T', 'C', '1'};
std::uint16_t const cells = static_cast(Terrain.cells());
f.write(magic, 4);
f.write(reinterpret_cast(&cells), sizeof(cells));
diff --git a/environment/moon.cpp b/environment/moon.cpp
index 15a16279..f0ba8074 100644
--- a/environment/moon.cpp
+++ b/environment/moon.cpp
@@ -129,8 +129,8 @@ void cMoon::move() {
m_body.oblecl = clamp_circular( 23.4393 - 3.563e-7 * daynumber );
// moon parameters
const double longascnode = clamp_circular( 125.1228 - 0.0529538083 * daynumber ); // N, degrees
- double const inclination = 5.1454; // i, degrees
- double const mndistance = 60.2666; // a, in earth radii
+ constexpr double inclination = 5.1454; // i, degrees
+ constexpr double mndistance = 60.2666; // a, in earth radii
// argument of perigee
double const perigeearg = clamp_circular( 318.0634 + 0.1643573223 * daynumber ); // w, degrees
// mean anomaly
@@ -279,7 +279,7 @@ void cMoon::irradiance() {
const double s2 = sin( degtorad * d2 );
m_body.erv += 0.000719*c2 + 0.000077*s2;
- const double solcon = 1367.0; // Solar constant, 1367 W/sq m
+ constexpr double solcon = 1367.0; // Solar constant, 1367 W/sq m
m_body.coszen = cos( degtorad * m_body.zenref );
if( m_body.coszen > 0.0 ) {
diff --git a/environment/skydome.cpp b/environment/skydome.cpp
index f5b936f5..7e6aeb83 100644
--- a/environment/skydome.cpp
+++ b/environment/skydome.cpp
@@ -60,7 +60,7 @@ CSkyDome::~CSkyDome() {
void CSkyDome::Generate() {
// radius of dome
- float const radius = 1.0f;
+ constexpr float radius = 1.0f;
float const offset = 0.1f * radius; // horizontal offset, a cheap way to prevent a gap between ground and horizon
// create geometry chunk
@@ -294,7 +294,7 @@ void CSkyDome::RebuildColors() {
color *= std::clamp( 1.0f - vertex.y * 0.75f, 0.0f, 1.f );
float const horizonboost = 1.5f + m_overcast;
- float const horizonbandwidth = 0.2f; // boost tapers to 0 by ~11.5 degrees elevation
+ constexpr float horizonbandwidth = 0.2f; // boost tapers to 0 by ~11.5 degrees elevation
float const horizonband = std::clamp( 1.0f - vertex.y / horizonbandwidth, 0.0f, 1.0f );
color *= std::lerp( 1.0, horizonboost, horizonband );
diff --git a/environment/sun.cpp b/environment/sun.cpp
index 7d46d4dc..1eb7e378 100644
--- a/environment/sun.cpp
+++ b/environment/sun.cpp
@@ -250,7 +250,7 @@ void cSun::irradiance() {
const double s2 = std::sin( glm::radians( d2 ) );
m_body.erv += 0.000719*c2 + 0.000077*s2;
- const double solcon = 1367.0; // Solar constant, 1367 W/sq m
+ constexpr double solcon = 1367.0; // Solar constant, 1367 W/sq m
m_body.coszen = std::cos( glm::radians( m_body.zenref ) );
if( m_body.coszen > 0.0 ) {
diff --git a/gl/ubo.h b/gl/ubo.h
index e4cb7c00..bce98b33 100644
--- a/gl/ubo.h
+++ b/gl/ubo.h
@@ -39,13 +39,13 @@ namespace gl
#pragma pack(push, 1)
- const size_t MAX_TEXTURES = 8;
- const size_t ENVMAP_SIZE = 1024;
- const size_t MAX_CASCADES = 3;
- const size_t HELPER_TEXTURES = 4;
- const size_t SHADOW_TEX = MAX_TEXTURES + 0;
- const size_t ENV_TEX = MAX_TEXTURES + 1;
- const size_t HEADLIGHT_TEX = MAX_TEXTURES + 2;
+ constexpr size_t MAX_TEXTURES = 8;
+ constexpr size_t ENVMAP_SIZE = 1024;
+ constexpr size_t MAX_CASCADES = 3;
+ constexpr size_t HELPER_TEXTURES = 4;
+ constexpr size_t SHADOW_TEX = MAX_TEXTURES + 0;
+ constexpr size_t ENV_TEX = MAX_TEXTURES + 1;
+ constexpr size_t HEADLIGHT_TEX = MAX_TEXTURES + 2;
struct scene_ubs
{
@@ -62,7 +62,7 @@ namespace gl
static_assert(sizeof(scene_ubs) == 400, "bad size of ubs");
- const size_t MAX_PARAMS = 3;
+ constexpr size_t MAX_PARAMS = 3;
struct model_ubs
{
@@ -94,7 +94,7 @@ namespace gl
// maximum number of instances per single GPU-instanced draw call.
// 256 mat4 = 16 KiB, the guaranteed minimum UBO size. Bigger batches must split.
- const size_t MAX_INSTANCES_PER_BATCH = 256;
+ constexpr size_t MAX_INSTANCES_PER_BATCH = 256;
struct instance_ubs
{
@@ -134,7 +134,7 @@ namespace gl
static_assert(sizeof(light_element_ubs) == 144, "bad size of ubs");
- const size_t MAX_LIGHTS = 8;
+ constexpr size_t MAX_LIGHTS = 8;
struct light_ubs
{
diff --git a/imgui/ImGuizmo.cpp b/imgui/ImGuizmo.cpp
index 8d4399c6..f7fe553f 100644
--- a/imgui/ImGuizmo.cpp
+++ b/imgui/ImGuizmo.cpp
@@ -49,10 +49,10 @@
namespace ImGuizmo
{
- static const float ZPI = 3.14159265358979323846f;
+ static constexpr float ZPI = 3.14159265358979323846f;
static const float RAD2DEG = (180.f / ZPI);
static const float DEG2RAD = (ZPI / 180.f);
- const float screenRotateSize = 0.06f;
+constexpr float screenRotateSize = 0.06f;
static OPERATION operator&(OPERATION lhs, OPERATION rhs)
{
@@ -741,24 +741,24 @@ namespace ImGuizmo
static Context gContext;
static const vec_t directionUnary[3] = { makeVect(1.f, 0.f, 0.f), makeVect(0.f, 1.f, 0.f), makeVect(0.f, 0.f, 1.f) };
- static const ImU32 directionColor[3] = { IM_COL32(0xAA, 0, 0, 0xFF), IM_COL32(0, 0xAA, 0, 0xFF), IM_COL32(0, 0, 0xAA, 0XFF) };
+ static constexpr ImU32 directionColor[3] = { IM_COL32(0xAA, 0, 0, 0xFF), IM_COL32(0, 0xAA, 0, 0xFF), IM_COL32(0, 0, 0xAA, 0XFF) };
// Alpha: 100%: FF, 87%: DE, 70%: B3, 54%: 8A, 50%: 80, 38%: 61, 12%: 1F
- static const ImU32 planeColor[3] = { IM_COL32(0xAA, 0, 0, 0x61), IM_COL32(0, 0xAA, 0, 0x61), IM_COL32(0, 0, 0xAA, 0x61) };
- static const ImU32 selectionColor = IM_COL32(0xFF, 0x80, 0x10, 0x8A);
- static const ImU32 inactiveColor = IM_COL32(0x99, 0x99, 0x99, 0x99);
- static const ImU32 translationLineColor = IM_COL32(0xAA, 0xAA, 0xAA, 0xAA);
+ static constexpr ImU32 planeColor[3] = { IM_COL32(0xAA, 0, 0, 0x61), IM_COL32(0, 0xAA, 0, 0x61), IM_COL32(0, 0, 0xAA, 0x61) };
+ static constexpr ImU32 selectionColor = IM_COL32(0xFF, 0x80, 0x10, 0x8A);
+ static constexpr ImU32 inactiveColor = IM_COL32(0x99, 0x99, 0x99, 0x99);
+ static constexpr ImU32 translationLineColor = IM_COL32(0xAA, 0xAA, 0xAA, 0xAA);
static const char* translationInfoMask[] = { "X : %5.3f", "Y : %5.3f", "Z : %5.3f",
"Y : %5.3f Z : %5.3f", "X : %5.3f Z : %5.3f", "X : %5.3f Y : %5.3f",
"X : %5.3f Y : %5.3f Z : %5.3f" };
static const char* scaleInfoMask[] = { "X : %5.2f", "Y : %5.2f", "Z : %5.2f", "XYZ : %5.2f" };
static const char* rotationInfoMask[] = { "X : %5.2f deg %5.2f rad", "Y : %5.2f deg %5.2f rad", "Z : %5.2f deg %5.2f rad", "Screen : %5.2f deg %5.2f rad" };
static const int translationInfoIndex[] = { 0,0,0, 1,0,0, 2,0,0, 1,2,0, 0,2,0, 0,1,0, 0,1,2 };
- static const float quadMin = 0.5f;
- static const float quadMax = 0.8f;
+ static constexpr float quadMin = 0.5f;
+ static constexpr float quadMax = 0.8f;
static const float quadUV[8] = { quadMin, quadMin, quadMin, quadMax, quadMax, quadMax, quadMax, quadMin };
- static const int halfCircleSegmentCount = 64;
- static const float snapTension = 0.5f;
+ static constexpr int halfCircleSegmentCount = 64;
+ static constexpr float snapTension = 0.5f;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
@@ -918,7 +918,7 @@ namespace ImGuizmo
void BeginFrame()
{
- const ImU32 flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoBringToFrontOnFocus;
+ constexpr ImU32 flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoBringToFrontOnFocus;
#ifdef IMGUI_HAS_VIEWPORT
ImGui::SetNextWindowSize(ImGui::GetMainViewport()->Size);
@@ -1562,8 +1562,8 @@ namespace ImGuizmo
}
vec_t midPoint = (aabb[i] + aabb[(i + 1) % 4]) * 0.5f;
ImVec2 midBound = worldToPos(midPoint, boundsMVP);
- static const float AnchorBigRadius = 8.f;
- static const float AnchorSmallRadius = 6.f;
+ static constexpr float AnchorBigRadius = 8.f;
+ static constexpr float AnchorSmallRadius = 6.f;
bool overBigAnchor = ImLengthSqr(worldBound1 - io.MousePos) <= (AnchorBigRadius * AnchorBigRadius);
bool overSmallAnchor = ImLengthSqr(midBound - io.MousePos) <= (AnchorBigRadius * AnchorBigRadius);
@@ -2536,7 +2536,7 @@ namespace ImGuizmo
const vec_t camTarget = viewInverse.v.position - viewInverse.v.dir * length;
// view/projection matrices
- const float distance = 3.f;
+ constexpr float distance = 3.f;
matrix_t cubeProjection, cubeView;
float fov = acosf(distance / (sqrtf(distance * distance + 3.f))) * RAD2DEG;
Perspective(fov / sqrtf(2.f), size.x / size.y, 0.01f, 1000.f, cubeProjection.m16);
diff --git a/imgui/imgui.cpp b/imgui/imgui.cpp
index 0738b018..fe2c3af3 100644
--- a/imgui/imgui.cpp
+++ b/imgui/imgui.cpp
@@ -1022,13 +1022,13 @@ CODE
#endif
// When using CTRL+TAB (or Gamepad Square+L/R) we delay the visual a little in order to reduce visual noise doing a fast switch.
-static const float NAV_WINDOWING_HIGHLIGHT_DELAY = 0.20f; // Time before the highlight and screen dimming starts fading in
-static const float NAV_WINDOWING_LIST_APPEAR_DELAY = 0.15f; // Time before the window list starts to appear
+static constexpr float NAV_WINDOWING_HIGHLIGHT_DELAY = 0.20f; // Time before the highlight and screen dimming starts fading in
+static constexpr float NAV_WINDOWING_LIST_APPEAR_DELAY = 0.15f; // Time before the window list starts to appear
// Window resizing from edges (when io.ConfigWindowsResizeFromEdges = true and ImGuiBackendFlags_HasMouseCursors is set in io.BackendFlags by back-end)
-static const float WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS = 4.0f; // Extend outside and inside windows. Affect FindHoveredWindow().
-static const float WINDOWS_RESIZE_FROM_EDGES_FEEDBACK_TIMER = 0.04f; // Reduce visual noise by only highlighting the border after a certain time.
-static const float WINDOWS_MOUSE_WHEEL_SCROLL_LOCK_TIMER = 2.00f; // Lock scrolled window (so it doesn't pick child windows that are scrolling through) for a certaint time, unless mouse moved.
+static constexpr float WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS = 4.0f; // Extend outside and inside windows. Affect FindHoveredWindow().
+static constexpr float WINDOWS_RESIZE_FROM_EDGES_FEEDBACK_TIMER = 0.04f; // Reduce visual noise by only highlighting the border after a certain time.
+static constexpr float WINDOWS_MOUSE_WHEEL_SCROLL_LOCK_TIMER = 2.00f; // Lock scrolled window (so it doesn't pick child windows that are scrolling through) for a certaint time, unless mouse moved.
//-------------------------------------------------------------------------
// [SECTION] FORWARD DECLARATIONS
@@ -1493,7 +1493,7 @@ int ImFormatStringV(char* buf, size_t buf_size, const char* fmt, va_list args)
// CRC32 needs a 1KB lookup table (not cache friendly)
// Although the code to generate the table is simple and shorter than the table itself, using a const table allows us to easily:
// - avoid an unnecessary branch/memory tap, - keep the ImHashXXX functions usable by static constructors, - make it thread-safe.
-static const ImU32 GCrc32LookupTable[256] =
+static constexpr ImU32 GCrc32LookupTable[256] =
{
0x00000000,0x77073096,0xEE0E612C,0x990951BA,0x076DC419,0x706AF48F,0xE963A535,0x9E6495A3,0x0EDB8832,0x79DCB8A4,0xE0D5E91E,0x97D2D988,0x09B64C2B,0x7EB17CBD,0xE7B82D07,0x90BF1D91,
0x1DB71064,0x6AB020F2,0xF3B97148,0x84BE41DE,0x1ADAD47D,0x6DDDE4EB,0xF4D4B551,0x83D385C7,0x136C9856,0x646BA8C0,0xFD62F97A,0x8A65C9EC,0x14015C4F,0x63066CD9,0xFA0F3D63,0x8D080DF5,
@@ -1808,7 +1808,7 @@ int ImTextCountUtf8BytesFromStr(const ImWchar* in_text, const ImWchar* in_text_e
ImVec4 ImGui::ColorConvertU32ToFloat4(ImU32 in)
{
- const float s = 1.0f/255.0f;
+ constexpr float s = 1.0f/255.0f;
return ImVec4(
((in >> IM_COL32_R_SHIFT) & 0xFF) * s,
((in >> IM_COL32_G_SHIFT) & 0xFF) * s,
@@ -2648,7 +2648,7 @@ void ImGui::RenderNavHighlight(const ImRect& bb, ImGuiID id, ImGuiNavHighlightFl
display_rect.ClipWith(window->ClipRect);
if (flags & ImGuiNavHighlightFlags_TypeDefault)
{
- const float THICKNESS = 2.0f;
+ constexpr float THICKNESS = 2.0f;
const float DISTANCE = 3.0f + THICKNESS * 0.5f;
display_rect.Expand(ImVec2(DISTANCE,DISTANCE));
const bool fully_visible = window->ClipRect.Contains(display_rect);
@@ -4524,7 +4524,7 @@ bool ImGui::IsMousePosValid(const ImVec2* mouse_pos)
// The assert is only to silence a false-positive in XCode Static Analysis.
// Because GImGui is not dereferenced in every code path, the static analyzer assume that it may be NULL (which it doesn't for other functions).
IM_ASSERT(GImGui != NULL);
- const float MOUSE_INVALID = -256000.0f;
+ constexpr float MOUSE_INVALID = -256000.0f;
const ImVec2 p = mouse_pos ? *mouse_pos : GImGui->IO.MousePos;
return p.x >= MOUSE_INVALID && p.y >= MOUSE_INVALID;
}
@@ -5142,7 +5142,7 @@ static bool ImGui::UpdateManualResize(ImGuiWindow* window, const ImVec2& size_au
nav_resize_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_PadDPad, ImGuiInputReadMode_Down);
if (nav_resize_delta.x != 0.0f || nav_resize_delta.y != 0.0f)
{
- const float NAV_RESIZE_SPEED = 600.0f;
+ constexpr float NAV_RESIZE_SPEED = 600.0f;
nav_resize_delta *= ImFloor(NAV_RESIZE_SPEED * g.IO.DeltaTime * ImMin(g.IO.DisplayFramebufferScale.x, g.IO.DisplayFramebufferScale.y));
g.NavWindowingToggleLayer = false;
g.NavDisableMouseHover = true;
@@ -7400,7 +7400,7 @@ void ImGui::BeginTooltipEx(ImGuiWindowFlags extra_flags, bool override_previous_
window->HiddenFramesCanSkipItems = 1;
ImFormatString(window_name, IM_ARRAYSIZE(window_name), "##Tooltip_%02d", ++g.TooltipOverrideCount);
}
- const ImGuiWindowFlags flags = ImGuiWindowFlags_Tooltip|ImGuiWindowFlags_NoInputs|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_AlwaysAutoResize;
+ constexpr ImGuiWindowFlags flags = ImGuiWindowFlags_Tooltip|ImGuiWindowFlags_NoInputs|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_AlwaysAutoResize;
Begin(window_name, NULL, flags | extra_flags);
}
@@ -7736,7 +7736,7 @@ ImVec2 ImGui::FindBestWindowPosForPopupEx(const ImVec2& ref_pos, const ImVec2& s
// Combo Box policy (we want a connecting edge)
if (policy == ImGuiPopupPositionPolicy_ComboBox)
{
- const ImGuiDir dir_prefered_order[ImGuiDir_COUNT] = { ImGuiDir_Down, ImGuiDir_Right, ImGuiDir_Left, ImGuiDir_Up };
+ constexpr ImGuiDir dir_prefered_order[ImGuiDir_COUNT] = { ImGuiDir_Down, ImGuiDir_Right, ImGuiDir_Left, ImGuiDir_Up };
for (int n = (*last_dir != ImGuiDir_None) ? -1 : 0; n < ImGuiDir_COUNT; n++)
{
const ImGuiDir dir = (n == -1) ? *last_dir : dir_prefered_order[n];
@@ -7755,7 +7755,7 @@ ImVec2 ImGui::FindBestWindowPosForPopupEx(const ImVec2& ref_pos, const ImVec2& s
}
// Default popup policy
- const ImGuiDir dir_prefered_order[ImGuiDir_COUNT] = { ImGuiDir_Right, ImGuiDir_Down, ImGuiDir_Up, ImGuiDir_Left };
+ constexpr ImGuiDir dir_prefered_order[ImGuiDir_COUNT] = { ImGuiDir_Right, ImGuiDir_Down, ImGuiDir_Up, ImGuiDir_Left };
for (int n = (*last_dir != ImGuiDir_None) ? -1 : 0; n < ImGuiDir_COUNT; n++)
{
const ImGuiDir dir = (n == -1) ? *last_dir : dir_prefered_order[n];
@@ -8046,7 +8046,7 @@ static void ImGui::NavProcessItem(ImGuiWindow* window, const ImRect& nav_bb, con
result->RectRel = nav_bb_rel;
}
- const float VISIBLE_RATIO = 0.70f;
+ constexpr float VISIBLE_RATIO = 0.70f;
if ((g.NavMoveRequestFlags & ImGuiNavMoveFlags_AlsoScoreVisibleSet) && window->ClipRect.Overlaps(nav_bb))
if (ImClamp(nav_bb.Max.y, window->ClipRect.Min.y, window->ClipRect.Max.y) - ImClamp(nav_bb.Min.y, window->ClipRect.Min.y, window->ClipRect.Max.y) >= (nav_bb.Max.y - nav_bb.Min.y) * VISIBLE_RATIO)
if (NavScoreItem(&g.NavMoveResultLocalVisibleSet, nav_bb))
@@ -8787,7 +8787,7 @@ static void ImGui::NavUpdateWindowing()
move_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_PadLStick, ImGuiInputReadMode_Down);
if (move_delta.x != 0.0f || move_delta.y != 0.0f)
{
- const float NAV_MOVE_SPEED = 800.0f;
+ constexpr float NAV_MOVE_SPEED = 800.0f;
const float move_speed = ImFloor(NAV_MOVE_SPEED * g.IO.DeltaTime * ImMin(g.IO.DisplayFramebufferScale.x, g.IO.DisplayFramebufferScale.y)); // FIXME: Doesn't code variable framerate very well
SetWindowPos(g.NavWindowingTarget->RootWindow, g.NavWindowingTarget->RootWindow->Pos + move_delta * move_speed, ImGuiCond_Always);
g.NavDisableMouseHover = true;
@@ -8907,7 +8907,7 @@ bool ImGui::BeginDragDropSource(ImGuiDragDropFlags flags)
bool source_drag_active = false;
ImGuiID source_id = 0;
ImGuiID source_parent_id = 0;
- const int mouse_button = 0;
+ constexpr int mouse_button = 0;
if (!(flags & ImGuiDragDropFlags_SourceExtern))
{
source_id = window->DC.LastItemId;
diff --git a/imgui/imgui.h b/imgui/imgui.h
index e0800e35..2fc8c7cf 100644
--- a/imgui/imgui.h
+++ b/imgui/imgui.h
@@ -1773,9 +1773,9 @@ struct ImColor
ImColor() { Value.x = Value.y = Value.z = Value.w = 0.0f; }
ImColor(int r, int g, int b, int a = 255) {
- const float sc = 1.0f/255.0f; Value.x = (float)r * sc; Value.y = (float)g * sc; Value.z = (float)b * sc; Value.w = (float)a * sc; }
+ constexpr float sc = 1.0f/255.0f; Value.x = (float)r * sc; Value.y = (float)g * sc; Value.z = (float)b * sc; Value.w = (float)a * sc; }
ImColor(ImU32 rgba) {
- const float sc = 1.0f/255.0f; Value.x = (float)((rgba>>IM_COL32_R_SHIFT)&0xFF) * sc; Value.y = (float)((rgba>>IM_COL32_G_SHIFT)&0xFF) * sc; Value.z = (float)((rgba>>IM_COL32_B_SHIFT)&0xFF) * sc; Value.w = (float)((rgba>>IM_COL32_A_SHIFT)&0xFF) * sc; }
+ constexpr float sc = 1.0f/255.0f; Value.x = (float)((rgba>>IM_COL32_R_SHIFT)&0xFF) * sc; Value.y = (float)((rgba>>IM_COL32_G_SHIFT)&0xFF) * sc; Value.z = (float)((rgba>>IM_COL32_B_SHIFT)&0xFF) * sc; Value.w = (float)((rgba>>IM_COL32_A_SHIFT)&0xFF) * sc; }
ImColor(float r, float g, float b, float a = 1.0f) { Value.x = r; Value.y = g; Value.z = b; Value.w = a; }
ImColor(const ImVec4& col) { Value = col; }
operator ImU32() const { return ImGui::ColorConvertFloat4ToU32(Value); }
@@ -2065,7 +2065,7 @@ struct ImFontGlyphRangesBuilder
ImFontGlyphRangesBuilder() { Clear(); }
void Clear() {
- const int size_in_bytes = 0x10000 / 8; UsedChars.resize(size_in_bytes / (int)sizeof(ImU32)); memset(UsedChars.Data, 0, (size_t)size_in_bytes); }
+ constexpr int size_in_bytes = 0x10000 / 8; UsedChars.resize(size_in_bytes / (int)sizeof(ImU32)); memset(UsedChars.Data, 0, (size_t)size_in_bytes); }
bool GetBit(int n) const {
const int off = (n >> 5);
const ImU32 mask = 1u << (n & 31); return (UsedChars[off] & mask) != 0; } // Get bit n in the array
diff --git a/imgui/imgui_demo.cpp b/imgui/imgui_demo.cpp
index a5352c6e..effd6416 100644
--- a/imgui/imgui_demo.cpp
+++ b/imgui/imgui_demo.cpp
@@ -1282,16 +1282,16 @@ static void ShowDemoWindowWidgets()
ImS64 LLONG_MAX = 9223372036854775807LL;
ImU64 ULLONG_MAX = (2ULL * 9223372036854775807LL + 1);
#endif
- const char s8_zero = 0, s8_one = 1, s8_fifty = 50, s8_min = -128, s8_max = 127;
- const ImU8 u8_zero = 0, u8_one = 1, u8_fifty = 50, u8_min = 0, u8_max = 255;
- const short s16_zero = 0, s16_one = 1, s16_fifty = 50, s16_min = -32768, s16_max = 32767;
- const ImU16 u16_zero = 0, u16_one = 1, u16_fifty = 50, u16_min = 0, u16_max = 65535;
- const ImS32 s32_zero = 0, s32_one = 1, s32_fifty = 50, s32_min = INT_MIN/2, s32_max = INT_MAX/2, s32_hi_a = INT_MAX/2 - 100, s32_hi_b = INT_MAX/2;
- const ImU32 u32_zero = 0, u32_one = 1, u32_fifty = 50, u32_min = 0, u32_max = UINT_MAX/2, u32_hi_a = UINT_MAX/2 - 100, u32_hi_b = UINT_MAX/2;
- const ImS64 s64_zero = 0, s64_one = 1, s64_fifty = 50, s64_min = LLONG_MIN/2, s64_max = LLONG_MAX/2, s64_hi_a = LLONG_MAX/2 - 100, s64_hi_b = LLONG_MAX/2;
- const ImU64 u64_zero = 0, u64_one = 1, u64_fifty = 50, u64_min = 0, u64_max = ULLONG_MAX/2, u64_hi_a = ULLONG_MAX/2 - 100, u64_hi_b = ULLONG_MAX/2;
- const float f32_zero = 0.f, f32_one = 1.f, f32_lo_a = -10000000000.0f, f32_hi_a = +10000000000.0f;
- const double f64_zero = 0., f64_one = 1., f64_lo_a = -1000000000000000.0, f64_hi_a = +1000000000000000.0;
+ constexpr char s8_zero = 0, s8_one = 1, s8_fifty = 50, s8_min = -128, s8_max = 127;
+ constexpr ImU8 u8_zero = 0, u8_one = 1, u8_fifty = 50, u8_min = 0, u8_max = 255;
+ constexpr short s16_zero = 0, s16_one = 1, s16_fifty = 50, s16_min = -32768, s16_max = 32767;
+ constexpr ImU16 u16_zero = 0, u16_one = 1, u16_fifty = 50, u16_min = 0, u16_max = 65535;
+ constexpr ImS32 s32_zero = 0, s32_one = 1, s32_fifty = 50, s32_min = INT_MIN/2, s32_max = INT_MAX/2, s32_hi_a = INT_MAX/2 - 100, s32_hi_b = INT_MAX/2;
+ constexpr ImU32 u32_zero = 0, u32_one = 1, u32_fifty = 50, u32_min = 0, u32_max = UINT_MAX/2, u32_hi_a = UINT_MAX/2 - 100, u32_hi_b = UINT_MAX/2;
+ constexpr ImS64 s64_zero = 0, s64_one = 1, s64_fifty = 50, s64_min = LLONG_MIN/2, s64_max = LLONG_MAX/2, s64_hi_a = LLONG_MAX/2 - 100, s64_hi_b = LLONG_MAX/2;
+ constexpr ImU64 u64_zero = 0, u64_one = 1, u64_fifty = 50, u64_min = 0, u64_max = ULLONG_MAX/2, u64_hi_a = ULLONG_MAX/2 - 100, u64_hi_b = ULLONG_MAX/2;
+ constexpr float f32_zero = 0.f, f32_one = 1.f, f32_lo_a = -10000000000.0f, f32_hi_a = +10000000000.0f;
+ constexpr double f64_zero = 0., f64_one = 1., f64_lo_a = -1000000000000000.0, f64_hi_a = +1000000000000000.0;
// State
static char s8_v = 127;
@@ -1305,7 +1305,7 @@ static void ShowDemoWindowWidgets()
static float f32_v = 0.123f;
static double f64_v = 90000.01234567890123456789;
- const float drag_speed = 0.2f;
+ constexpr float drag_speed = 0.2f;
static bool drag_clamp = false;
ImGui::Text("Drags:");
ImGui::Checkbox("Clamp integers to 0..50", &drag_clamp); ImGui::SameLine(); HelpMarker("As with every widgets in dear imgui, we never modify values unless there is a user interaction.\nYou can override the clamping limits by using CTRL+Click to input a value.");
@@ -1398,7 +1398,7 @@ static void ShowDemoWindowWidgets()
if (ImGui::TreeNode("Vertical Sliders"))
{
- const float spacing = 4;
+ constexpr float spacing = 4;
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(spacing, spacing));
static int int_value = 0;
@@ -1426,7 +1426,7 @@ static void ShowDemoWindowWidgets()
ImGui::SameLine();
ImGui::PushID("set2");
static float values2[4] = { 0.20f, 0.80f, 0.40f, 0.25f };
- const int rows = 3;
+ constexpr int rows = 3;
const ImVec2 small_slider_size(18, (160.0f-(rows-1)*spacing)/rows);
for (int nx = 0; nx < 4; nx++)
{
@@ -1868,7 +1868,7 @@ static void ShowDemoWindowLayout()
// Manually wrapping (we should eventually provide this as an automatic layout feature, but for now you can do it manually)
ImGui::Text("Manually wrapping:");
const ImGuiStyle & style = ImGui::GetStyle();
- const int buttons_count = 20;
+ constexpr int buttons_count = 20;
const float window_visible_x2 = ImGui::GetWindowPos().x + ImGui::GetWindowContentRegionMax().x;
for (int n = 0; n < buttons_count; n++)
{
@@ -1888,7 +1888,7 @@ static void ShowDemoWindowLayout()
{
if (ImGui::TreeNode("Basic"))
{
- const ImGuiTabBarFlags tab_bar_flags = ImGuiTabBarFlags_None;
+ constexpr ImGuiTabBarFlags tab_bar_flags = ImGuiTabBarFlags_None;
if (ImGui::BeginTabBar("MyTabBar", tab_bar_flags))
{
if (ImGui::BeginTabItem("Avocado"))
@@ -1977,7 +1977,7 @@ static void ShowDemoWindowLayout()
}
// Capture the group size and create widgets using the same size
const ImVec2 size = ImGui::GetItemRectSize();
- const float values[5] = { 0.5f, 0.20f, 0.80f, 0.60f, 0.25f };
+ constexpr float values[5] = { 0.5f, 0.20f, 0.80f, 0.60f, 0.25f };
ImGui::PlotHistogram("##values", values, IM_ARRAYSIZE(values), 0, NULL, 0.0f, 1.0f, size);
ImGui::Button("ACTION", ImVec2((size.x - ImGui::GetStyle().ItemSpacing.x)*0.5f, size.y));
@@ -2084,7 +2084,7 @@ static void ShowDemoWindowLayout()
ImGui::BeginGroup();
ImGui::Text("%s", i == 0 ? "Top" : i == 1 ? "25%" : i == 2 ? "Center" : i == 3 ? "75%" : "Bottom");
- const ImGuiWindowFlags child_flags = ImGuiWindowFlags_MenuBar;
+ constexpr ImGuiWindowFlags child_flags = ImGuiWindowFlags_MenuBar;
ImGui::BeginChild(ImGui::GetID((void*)(intptr_t)i), ImVec2(child_w, 200.0f), true, child_flags);
if (scroll_to_off)
ImGui::SetScrollY(scroll_to_off_px);
@@ -2657,7 +2657,7 @@ static void ShowDemoWindowColumns()
ImGui::SetNextWindowContentSize(ImVec2(1500.0f, 0.0f));
ImGui::BeginChild("##ScrollingRegion", ImVec2(0, ImGui::GetFontSize() * 20), false, ImGuiWindowFlags_HorizontalScrollbar);
ImGui::Columns(10);
- const int ITEMS_COUNT = 2000;
+ constexpr int ITEMS_COUNT = 2000;
ImGuiListClipper clipper(ITEMS_COUNT); // Also demonstrate using the clipper for large list
while (clipper.Step())
{
@@ -4144,7 +4144,7 @@ static void ShowExampleAppConstrainedResize(bool* p_open)
// Demonstrate creating a simple static window with no decoration + a context-menu to choose which corner of the screen to use.
static void ShowExampleAppSimpleOverlay(bool* p_open)
{
- const float DISTANCE = 10.0f;
+ constexpr float DISTANCE = 10.0f;
static int corner = 0;
const ImGuiIO & io = ImGui::GetIO();
if (corner != -1)
@@ -4241,10 +4241,10 @@ static void ShowExampleAppCustomRendering(bool* p_open)
const ImVec2 p = ImGui::GetCursorScreenPos();
const ImU32 col = ImColor(colf);
float x = p.x + 4.0f, y = p.y + 4.0f;
- const float spacing = 10.0f;
- const ImDrawCornerFlags corners_none = 0;
- const ImDrawCornerFlags corners_all = ImDrawCornerFlags_All;
- const ImDrawCornerFlags corners_tl_br = ImDrawCornerFlags_TopLeft | ImDrawCornerFlags_BotRight;
+ constexpr float spacing = 10.0f;
+ constexpr ImDrawCornerFlags corners_none = 0;
+ constexpr ImDrawCornerFlags corners_all = ImDrawCornerFlags_All;
+ constexpr ImDrawCornerFlags corners_tl_br = ImDrawCornerFlags_TopLeft | ImDrawCornerFlags_BotRight;
for (int n = 0; n < 2; n++)
{
// First line uses a thickness of 1.0f, second line uses the configurable thickness
diff --git a/imgui/imgui_draw.cpp b/imgui/imgui_draw.cpp
index 0f3fbf2e..9ece2fbd 100644
--- a/imgui/imgui_draw.cpp
+++ b/imgui/imgui_draw.cpp
@@ -606,7 +606,7 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32
if (Flags & ImDrawListFlags_AntiAliasedLines)
{
// Anti-aliased stroke
- const float AA_SIZE = 1.0f;
+ constexpr float AA_SIZE = 1.0f;
const ImU32 col_trans = col & ~IM_COL32_A_MASK;
const int idx_count = thick_line ? count*18 : count*12;
@@ -789,7 +789,7 @@ void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_coun
if (Flags & ImDrawListFlags_AntiAliasedFill)
{
// Anti-aliased Fill
- const float AA_SIZE = 1.0f;
+ constexpr float AA_SIZE = 1.0f;
const ImU32 col_trans = col & ~IM_COL32_A_MASK;
const int idx_count = (points_count-2)*3 + points_count*6;
const int vtx_count = (points_count*2);
@@ -1438,10 +1438,10 @@ ImFontConfig::ImFontConfig()
// A work of art lies ahead! (. = white layer, X = black layer, others are blank)
// The white texels on the top left are the ones we'll use everywhere in Dear ImGui to render filled shapes.
-const int FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF = 108;
-const int FONT_ATLAS_DEFAULT_TEX_DATA_H = 27;
-const unsigned int FONT_ATLAS_DEFAULT_TEX_DATA_ID = 0x80000000;
-static const char FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS[FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF * FONT_ATLAS_DEFAULT_TEX_DATA_H + 1] =
+constexpr int FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF = 108;
+constexpr int FONT_ATLAS_DEFAULT_TEX_DATA_H = 27;
+constexpr unsigned int FONT_ATLAS_DEFAULT_TEX_DATA_ID = 0x80000000;
+static constexpr char FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS[FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF * FONT_ATLAS_DEFAULT_TEX_DATA_H + 1] =
{
"..- -XXXXXXX- X - X -XXXXXXX - XXXXXXX- XX "
"..- -X.....X- X.X - X.X -X.....X - X.....X- X..X "
@@ -1995,7 +1995,7 @@ bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
// 5. Start packing
// Pack our extra data rectangles first, so it will be on the upper-left corner of our texture (UV will have small values).
- const int TEX_HEIGHT_MAX = 1024 * 32;
+ constexpr int TEX_HEIGHT_MAX = 1024 * 32;
stbtt_pack_context spc = {};
stbtt_PackBegin(&spc, NULL, atlas->TexWidth, TEX_HEIGHT_MAX, 0, atlas->TexGlyphPadding, NULL);
ImFontAtlasBuildPackCustomRects(atlas, spc.pack_info);
@@ -2211,7 +2211,7 @@ void ImFontAtlasBuildFinish(ImFontAtlas* atlas)
ImFont* font = atlas->Fonts[i];
if (font->EllipsisChar != (ImWchar)-1)
continue;
- const ImWchar ellipsis_variants[] = { (ImWchar)0x2026, (ImWchar)0x0085 };
+ constexpr ImWchar ellipsis_variants[] = { (ImWchar)0x2026, (ImWchar)0x0085 };
for (int j = 0; j < IM_ARRAYSIZE(ellipsis_variants); j++)
if (font->FindGlyphNoFallback(ellipsis_variants[j]) != NULL) // Verify glyph exists
{
@@ -2224,7 +2224,7 @@ void ImFontAtlasBuildFinish(ImFontAtlas* atlas)
// Retrieve list of range (2 int per range, values are inclusive)
const ImWchar* ImFontAtlas::GetGlyphRangesDefault()
{
- static const ImWchar ranges[] =
+ static constexpr ImWchar ranges[] =
{
0x0020, 0x00FF, // Basic Latin + Latin Supplement
0,
@@ -2467,7 +2467,7 @@ void ImFontGlyphRangesBuilder::AddRanges(const ImWchar* ranges)
void ImFontGlyphRangesBuilder::BuildRanges(ImVector* out_ranges)
{
- const int max_codepoint = 0x10000;
+ constexpr int max_codepoint = 0x10000;
for (int n = 0; n < max_codepoint; n++)
if (GetBit(n))
{
@@ -3100,7 +3100,7 @@ void ImGui::RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, Im
const float inv_rounding = 1.0f / rounding;
const float arc0_b = ImAcos01(1.0f - (p0.x - rect.Min.x) * inv_rounding);
const float arc0_e = ImAcos01(1.0f - (p1.x - rect.Min.x) * inv_rounding);
- const float half_pi = IM_PI * 0.5f; // We will == compare to this because we know this is the exact value ImAcos01 can return.
+ constexpr float half_pi = IM_PI * 0.5f; // We will == compare to this because we know this is the exact value ImAcos01 can return.
const float x0 = ImMax(p0.x, rect.Min.x + rounding);
if (arc0_b == arc0_e)
{
@@ -3199,7 +3199,7 @@ static const unsigned char *stb_decompress_token(const unsigned char *i)
static unsigned int stb_adler32(unsigned int adler32, unsigned char *buffer, unsigned int buflen)
{
- const unsigned long ADLER_MOD = 65521;
+ constexpr unsigned long ADLER_MOD = 65521;
unsigned long s1 = adler32 & 0xffff, s2 = adler32 >> 16;
unsigned long blocklen, i;
@@ -3273,7 +3273,7 @@ static unsigned int stb_decompress(unsigned char *output, const unsigned char *i
// Exported using misc/fonts/binary_to_compressed_c.cpp (with compression + base85 string encoding).
// The purpose of encoding as base85 instead of "0x00,0x01,..." style is only save on _source code_ size.
//-----------------------------------------------------------------------------
-static const char proggy_clean_ttf_compressed_data_base85[11980+1] =
+static constexpr char proggy_clean_ttf_compressed_data_base85[11980+1] =
"7])#######hV0qs'/###[),##/l:$#Q6>##5[n42>c-TH`->>#/e>11NNV=Bv(*:.F?uu#(gRU.o0XGH`$vhLG1hxt9?W`#,5LsCp#-i>.r$<$6pD>Lb';9Crc6tgXmKVeU2cD4Eo3R/"
"2*>]b(MC;$jPfY.;h^`IWM9Qo#t'X#(v#Y9w0#1D$CIf;W'#pWUPXOuxXuU(H9M(1=Ke$$'5F%)]0^#0X@U.a= 'A' && c <= 'Z' && ((1 << (c - 'A')) & ignored_uppercase_mask) == 0)
@@ -3409,7 +3409,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
ImGuiIO& io = g.IO;
const ImGuiStyle& style = g.Style;
- const bool RENDER_SELECTION_WHEN_INACTIVE = false;
+ constexpr bool RENDER_SELECTION_WHEN_INACTIVE = false;
const bool is_multiline = (flags & ImGuiInputTextFlags_Multiline) != 0;
const bool is_readonly = (flags & ImGuiInputTextFlags_ReadOnly) != 0;
const bool is_password = (flags & ImGuiInputTextFlags_Password) != 0;
@@ -3934,7 +3934,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
// Set upper limit of single-line InputTextEx() at 2 million characters strings. The current pathological worst case is a long line
// without any carriage return, which would makes ImFont::RenderText() reserve too many vertices and probably crash. Avoid it altogether.
// Note that we only use this limit on single-line InputText(), so a pathologically large line on a InputTextMultiline() would still crash.
- const int buf_display_max_length = 2 * 1024 * 1024;
+ constexpr int buf_display_max_length = 2 * 1024 * 1024;
const char* buf_display = buf_display_from_state ? state->TextA.Data : buf; //-V595
const char* buf_display_end = NULL; // We have specialized paths below for setting the length
if (is_displaying_hint)
@@ -4329,7 +4329,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
TextEx(label, label_display_end);
Spacing();
}
- const ImGuiColorEditFlags picker_flags_to_forward = ImGuiColorEditFlags__DataTypeMask | ImGuiColorEditFlags__PickerMask | ImGuiColorEditFlags__InputMask | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_AlphaBar;
+ constexpr ImGuiColorEditFlags picker_flags_to_forward = ImGuiColorEditFlags__DataTypeMask | ImGuiColorEditFlags__PickerMask | ImGuiColorEditFlags__InputMask | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_AlphaBar;
const ImGuiColorEditFlags picker_flags = (flags_untouched & picker_flags_to_forward) | ImGuiColorEditFlags__DisplayMask | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_AlphaPreviewHalf;
SetNextItemWidth(square_sz * 12.0f); // Use 256 + bar sizes?
value_changed |= ColorPicker4("##picker", col, picker_flags, &g.ColorPickerRef.x);
@@ -4869,7 +4869,7 @@ bool ImGui::ColorButton(const char* desc_id, const ImVec4& col, ImGuiColorEditFl
const float grid_step = ImMin(size.x, size.y) / 2.99f;
const float rounding = ImMin(g.Style.FrameRounding, grid_step * 0.5f);
ImRect bb_inner = bb;
- const float off = -0.75f; // The border (using Col_FrameBg) tends to look off when color is near-opaque and rounding is enabled. This offset seemed like a good middle ground to reduce those artifacts.
+ constexpr float off = -0.75f; // The border (using Col_FrameBg) tends to look off when color is near-opaque and rounding is enabled. This offset seemed like a good middle ground to reduce those artifacts.
bb_inner.Expand(off);
if ((flags & ImGuiColorEditFlags_AlphaPreviewHalf) && col_rgb.w < 1.0f)
{
@@ -5318,7 +5318,7 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
// Render
const ImU32 text_col = GetColorU32(ImGuiCol_Text);
- const ImGuiNavHighlightFlags nav_highlight_flags = ImGuiNavHighlightFlags_TypeThin;
+ constexpr ImGuiNavHighlightFlags nav_highlight_flags = ImGuiNavHighlightFlags_TypeThin;
if (display_frame)
{
// Framed type
@@ -5336,8 +5336,8 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
if (g.LogEnabled)
{
// NB: '##' is normally used to hide text (as a library-wide feature), so we need to specify the text range to make sure the ## aren't stripped out here.
- const char log_prefix[] = "\n##";
- const char log_suffix[] = "##";
+ constexpr char log_prefix[] = "\n##";
+ constexpr char log_suffix[] = "##";
LogRenderedText(&text_pos, log_prefix, log_prefix+3);
RenderTextClipped(text_pos, frame_bb.Max, label, label_end, &label_size);
LogRenderedText(&text_pos, log_suffix, log_suffix+2);
@@ -5998,7 +5998,7 @@ bool ImGui::BeginMainMenuBar()
SetNextWindowSize(ImVec2(g.IO.DisplaySize.x, g.NextWindowData.MenuBarOffsetMinVal.y + g.FontBaseSize + g.Style.FramePadding.y));
PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(0,0));
- const ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_MenuBar;
+ constexpr ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_MenuBar;
const bool is_open = Begin("##MainMenuBar", NULL, window_flags) && BeginMenuBar();
PopStyleVar(2);
g.NextWindowData.MenuBarOffsetMinVal = ImVec2(0.0f, 0.0f);
@@ -6072,7 +6072,7 @@ void ImGui::EndMenuBar()
{
// To do so we claim focus back, restore NavId and then process the movement request for yet another frame.
// This involve a one-frame delay which isn't very problematic in this situation. We could remove it by scoring in advance for multiple window (probably not worth the hassle/cost)
- const ImGuiNavLayer layer = ImGuiNavLayer_Menu;
+ constexpr ImGuiNavLayer layer = ImGuiNavLayer_Menu;
IM_ASSERT(window->DC.NavLayerActiveMaskNext & (1 << layer)); // Sanity check
FocusWindow(window);
SetNavIDWithRectRel(window->NavLastIds[layer], layer, window->NavRectRel[layer]);
@@ -6570,7 +6570,7 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
}
// Compute width
- const float initial_offset_x = 0.0f; // g.Style.ItemInnerSpacing.x;
+ constexpr float initial_offset_x = 0.0f; // g.Style.ItemInnerSpacing.x;
const float width_avail = ImMax(tab_bar->BarRect.GetWidth() - initial_offset_x, 0.0f);
const float width_excess = (width_avail < width_total_contents) ? (width_total_contents - width_avail) : 0.0f;
if (width_excess > 0.0f && (tab_bar->Flags & ImGuiTabBarFlags_FittingPolicyResizeDown))
@@ -7229,7 +7229,7 @@ float ImGui::GetColumnNormFromOffset(const ImGuiColumns* columns, float offset)
return offset / (columns->OffMaxX - columns->OffMinX);
}
-static const float COLUMNS_HIT_RECT_HALF_WIDTH = 4.0f;
+static constexpr float COLUMNS_HIT_RECT_HALF_WIDTH = 4.0f;
static float GetDraggedColumnOffset(ImGuiColumns* columns, int column_index)
{
@@ -7637,7 +7637,7 @@ bool ImGui::BufferingBar( const char* label, float value, const ImVec2& size_arg
const float t = g.FrameCount * 0.1f; // g.Time;
const float r = size.y / 2;
- const float speed = 1.5f;
+ constexpr float speed = 1.5f;
const float a = speed * 0;
const float b = speed * 0.333f;
@@ -7676,11 +7676,11 @@ bool ImGui::Spinner( const char* label, float radius, int thickness, const ImU32
const auto progress { g.FrameCount * 0.1f };
- const int num_segments = 30;
+ constexpr int num_segments = 30;
const int start = abs( ImSin( progress * 1.8f )*( num_segments - 5 ) );
const float a_min = IM_PI * 2.0f * ( (float)start ) / (float)num_segments;
- const float a_max = IM_PI * 2.0f * ( (float)num_segments - 3 ) / (float)num_segments;
+ constexpr float a_max = IM_PI * 2.0f * ( (float)num_segments - 3 ) / (float)num_segments;
const auto centre = ImVec2( pos.x + radius, pos.y + radius + style.FramePadding.y );
diff --git a/imgui/imstb_truetype.h b/imgui/imstb_truetype.h
index 69038b17..a49c88bb 100644
--- a/imgui/imstb_truetype.h
+++ b/imgui/imstb_truetype.h
@@ -2495,7 +2495,7 @@ static stbtt_int32 stbtt__GetGlyphGPOSInfoAdvance(const stbtt_fontinfo *info, i
int straw, needle;
const stbtt_uint16 valueFormat1 = ttUSHORT(table + 4);
const stbtt_uint16 valueFormat2 = ttUSHORT(table + 6);
- const stbtt_int32 valueRecordPairSizeInBytes = 2;
+ constexpr stbtt_int32 valueRecordPairSizeInBytes = 2;
const stbtt_uint16 pairSetCount = ttUSHORT(table + 8);
const stbtt_uint16 pairPosOffset = ttUSHORT(table + 10 + 2 * coverageIndex);
stbtt_uint8 *pairValueTable = table + pairPosOffset;
@@ -3362,7 +3362,7 @@ static void stbtt__rasterize(stbtt__bitmap *result, stbtt__point *pts, int *wcou
#if STBTT_RASTERIZER_VERSION == 1
int vsubsample = result->h < 8 ? 15 : 5;
#elif STBTT_RASTERIZER_VERSION == 2
- const int vsubsample = 1;
+ constexpr int vsubsample = 1;
#else
#error "Unrecognized value of STBTT_RASTERIZER_VERSION"
#endif
diff --git a/input/drivermouseinput.cpp b/input/drivermouseinput.cpp
index cc1ca799..545a8197 100644
--- a/input/drivermouseinput.cpp
+++ b/input/drivermouseinput.cpp
@@ -22,7 +22,7 @@ http://mozilla.org/MPL/2.0/.
#include "utilities/Logs.h"
#include "utilities/utilities.h"
-auto const EU07_CONTROLLER_MOUSESLIDERSIZE{ 0.6 };
+constexpr auto EU07_CONTROLLER_MOUSESLIDERSIZE{ 0.6 };
void
mouse_slider::bind( user_command const &Command ) {
diff --git a/input/messaging.cpp b/input/messaging.cpp
index e079f001..be2bfc50 100644
--- a/input/messaging.cpp
+++ b/input/messaging.cpp
@@ -29,7 +29,7 @@ extern "C"
namespace multiplayer {
-std::uint32_t const EU07_MESSAGEHEADER { MAKE_ID4( 'E','U','0','7' ) };
+constexpr std::uint32_t EU07_MESSAGEHEADER { MAKE_ID4( 'E','U','0','7' ) };
void
Navigate(std::string const &ClassName, UINT Msg, WPARAM wParam, LPARAM lParam) {
@@ -68,7 +68,7 @@ OnCommandGet(DaneRozkaz *pRozkaz)
|| typeid(*event) == typeid(lights_event)
|| event->m_sibling != 0 ) {
// tylko jawne albo niejawne Multiple
- const command_relay relay;
+ constexpr command_relay relay;
relay.post(user_command::queueevent, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &event->name());
}
}
diff --git a/launcher/launcheruilayer.cpp b/launcher/launcheruilayer.cpp
index 7b05e2aa..bc9c8cc0 100644
--- a/launcher/launcheruilayer.cpp
+++ b/launcher/launcheruilayer.cpp
@@ -34,7 +34,7 @@ void launcher_ui::on_window_resize(int w, int h)
void launcher_ui::render_()
{
- const ImGuiWindowFlags flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove;
+ constexpr ImGuiWindowFlags flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove;
const float topbar_height = 50 * Global.ui_scale;
const auto topbar_button_size = ImVec2(150 * Global.ui_scale, topbar_height - 16);
ImGui::SetNextWindowPos(ImVec2(0, 0));
diff --git a/model/AnimModel.h b/model/AnimModel.h
index 19d40945..42fd1947 100644
--- a/model/AnimModel.h
+++ b/model/AnimModel.h
@@ -20,8 +20,8 @@ http://mozilla.org/MPL/2.0/.
#include "vehicle/DynObj.h"
#include "scene/scenenode.h"
-const int iMaxNumLights = 8;
-float const DefaultDarkThresholdLevel { 0.325f };
+constexpr int iMaxNumLights = 8;
+constexpr float DefaultDarkThresholdLevel { 0.325f };
// typy stanu świateł
enum TLightState
diff --git a/model/Model3d.h b/model/Model3d.h
index 66198ca6..8a8b3b41 100644
--- a/model/Model3d.h
+++ b/model/Model3d.h
@@ -18,10 +18,10 @@ http://mozilla.org/MPL/2.0/.
#define EU07_USE_GEOMETRYINDEXING
// Ra: specjalne typy submodeli, poza tym GL_TRIANGLES itp.
-const int TP_ROTATOR = 256;
-const int TP_FREESPOTLIGHT = 257;
-const int TP_STARS = 258;
-const int TP_TEXT = 259;
+constexpr int TP_ROTATOR = 256;
+constexpr int TP_FREESPOTLIGHT = 257;
+constexpr int TP_STARS = 258;
+constexpr int TP_TEXT = 259;
enum class TAnimType // rodzaj animacji
{
diff --git a/model/ResourceManager.h b/model/ResourceManager.h
index c9f3cb0b..397ee878 100644
--- a/model/ResourceManager.h
+++ b/model/ResourceManager.h
@@ -43,7 +43,7 @@ public:
std::min(
m_resourcesweepindex + m_unusedresourcesweepsize,
m_container.size() );
- auto const blanktimestamp { std::chrono::steady_clock::time_point() };
+ constexpr auto blanktimestamp { std::chrono::steady_clock::time_point() };
int releasecount{ 0 };
for( auto resourceindex = m_resourcesweepindex; resourceindex < sweeplastindex; ++resourceindex ) {
if( m_container[resourceindex].second != blanktimestamp
diff --git a/model/Texture.cpp b/model/Texture.cpp
index 662b7992..3da85b3f 100644
--- a/model/Texture.cpp
+++ b/model/Texture.cpp
@@ -963,7 +963,7 @@ opengl_texture::create( bool const Static ) {
glTexParameteri(target, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
wrap_mode_s = GL_CLAMP_TO_BORDER;
wrap_mode_t = GL_CLAMP_TO_BORDER;
- const float borderColor[] = { 0.0f, 0.0f, 0.0f, 0.0f };
+ constexpr float borderColor[] = { 0.0f, 0.0f, 0.0f, 0.0f };
glTexParameterfv(target, GL_TEXTURE_BORDER_COLOR, borderColor);
}
glTexParameteri( target, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
diff --git a/network/backend/asio.h b/network/backend/asio.h
index f2079a9d..0f0d2200 100644
--- a/network/backend/asio.h
+++ b/network/backend/asio.h
@@ -9,8 +9,8 @@
namespace network::tcp
{
- const uint32_t NETWORK_MAGIC = 0x37305545;
- const uint32_t MAX_MSG_SIZE = 100000;
+constexpr uint32_t NETWORK_MAGIC = 0x37305545;
+constexpr uint32_t MAX_MSG_SIZE = 100000;
class connection : public network::connection
{
diff --git a/network/network.cpp b/network/network.cpp
index c9de1b16..e028399b 100644
--- a/network/network.cpp
+++ b/network/network.cpp
@@ -7,7 +7,7 @@
#include "application/application.h"
#include "utilities/Globals.h"
-std::uint32_t const EU07_NETWORK_VERSION = 2;
+constexpr std::uint32_t EU07_NETWORK_VERSION = 2;
namespace network {
diff --git a/rendering/geometrybank.h b/rendering/geometrybank.h
index ecc49f72..3a8a0eef 100644
--- a/rendering/geometrybank.h
+++ b/rendering/geometrybank.h
@@ -51,8 +51,8 @@ enum stream {
texture = 0x8
};
-unsigned int const basic_streams { position | normal | texture };
-unsigned int const color_streams { position | color | texture };
+constexpr unsigned int basic_streams { position | normal | texture };
+constexpr unsigned int color_streams { position | color | texture };
struct stream_units {
diff --git a/rendering/opengl33precipitation.cpp b/rendering/opengl33precipitation.cpp
index ef8e06b9..25df4eb0 100644
--- a/rendering/opengl33precipitation.cpp
+++ b/rendering/opengl33precipitation.cpp
@@ -25,11 +25,11 @@ opengl33_precipitation::create( int const Tesselation ) {
m_uvs.clear();
m_indices.clear();
- auto const heightfactor { 10.f }; // height-to-radius factor
- auto const verticaltexturestretchfactor { 1.5f }; // crude motion blur
+ constexpr auto heightfactor { 10.f }; // height-to-radius factor
+ constexpr auto verticaltexturestretchfactor { 1.5f }; // crude motion blur
// create geometry chunk
- auto const latitudes { 3 }; // just a cylinder with end cones
+ constexpr auto latitudes { 3 }; // just a cylinder with end cones
auto const longitudes { Tesselation };
auto const longitudehalfstep { 0.5f * static_cast( 2.0 * M_PI * 1.f / longitudes ) }; // for crude uv correction
diff --git a/rendering/opengl33renderer.cpp b/rendering/opengl33renderer.cpp
index c1511dd7..5efe3f13 100644
--- a/rendering/opengl33renderer.cpp
+++ b/rendering/opengl33renderer.cpp
@@ -107,7 +107,7 @@ bool opengl33_renderer::Init(GLFWwindow *Window)
WriteLog("...gfx data pre-loading done");
// prepare basic geometry chunks
- float const size = 2.5f / 2.0f;
+ constexpr float size = 2.5f / 2.0f;
auto const geometrybank = Create_Bank();
gfx::vertex_array billboard_array{
@@ -571,7 +571,7 @@ bool opengl33_renderer::Render()
{
m_sunlight = Global.DayLight;
// quantize sun angle to reduce shadow crawl
- auto const quantizationstep{0.004f};
+ constexpr auto quantizationstep{0.004f};
m_sunlight.direction = glm::normalize(quantizationstep * glm::roundEven(m_sunlight.direction * (1.f / quantizationstep)));
}
// generate new frame
@@ -4134,7 +4134,7 @@ void opengl33_renderer::Render_vr_models()
tmpmat = glm::dmat3(tmpmat);
glMultMatrixd(glm::value_ptr(glm::inverse(tmpmat)));
const std::vector list = vr->get_render_models();
- const material_data data;
+ constexpr material_data data;
for (TModel3d *mdl : list)
Render(mdl, &data, 0.0);
::glPopMatrix();
@@ -5219,7 +5219,7 @@ void opengl33_renderer::Update_Lights(light_array &Lights)
auto const &ownerdimensions{ scenelight.owner->MoverParameters->Dim };
auto const up{ static_cast( scenelight.owner->VectorUp() ) };
auto const size{ static_cast( std::max( ownerdimensions.W, ownerdimensions.H ) * 1.0 ) }; // ensure square ratio
- auto const cone{ 5.f };
+ constexpr auto cone{ 5.f };
auto const offset{ 75.f * ( 5.f / cone ) };
headlights.position() =
scenelight.owner->GetPosition()
diff --git a/rendering/opengl33renderer.h b/rendering/opengl33renderer.h
index 82814a46..66333ceb 100644
--- a/rendering/opengl33renderer.h
+++ b/rendering/opengl33renderer.h
@@ -140,7 +140,7 @@ class opengl33_renderer : public gfx_renderer {
void Update_AnimModel(TAnimModel *model);
// members
- GLenum static const sunlight{0};
+ constexpr GLenum static sunlight{0};
static std::unique_ptr create_func();
diff --git a/rendering/openglprecipitation.cpp b/rendering/openglprecipitation.cpp
index ce73800d..a7d97bcd 100644
--- a/rendering/openglprecipitation.cpp
+++ b/rendering/openglprecipitation.cpp
@@ -28,11 +28,11 @@ opengl_precipitation::create( int const Tesselation ) {
m_uvs.clear();
m_indices.clear();
- auto const heightfactor { 10.f }; // height-to-radius factor
- auto const verticaltexturestretchfactor { 1.5f }; // crude motion blur
+ constexpr auto heightfactor { 10.f }; // height-to-radius factor
+ constexpr auto verticaltexturestretchfactor { 1.5f }; // crude motion blur
// create geometry chunk
- auto const latitudes { 3 }; // just a cylinder with end cones
+ constexpr auto latitudes { 3 }; // just a cylinder with end cones
auto const longitudes { Tesselation };
auto const longitudehalfstep { 0.5f * static_cast( 2.0 * M_PI * 1.f / longitudes ) }; // for crude uv correction
diff --git a/rendering/openglrenderer.cpp b/rendering/openglrenderer.cpp
index dffd4c53..f38d0b2c 100644
--- a/rendering/openglrenderer.cpp
+++ b/rendering/openglrenderer.cpp
@@ -31,7 +31,7 @@ int constexpr EU07_PICKBUFFERSIZE { 1024 }; // size of (square) textures bound w
int constexpr EU07_ENVIRONMENTBUFFERSIZE { 256 }; // size of (square) environmental cube map texture
int constexpr EU07_REFLECTIONFIDELITYOFFSET { 250 }; // artificial increase of range for reflection pass detail reduction
-float const EU07_OPACITYDEFAULT { 0.5f };
+constexpr float EU07_OPACITYDEFAULT { 0.5f };
bool
opengl_renderer::Init( GLFWwindow *Window ) {
@@ -301,7 +301,7 @@ opengl_renderer::Init( GLFWwindow *Window ) {
}
// prepare basic geometry chunks
auto const geometrybank = Create_Bank();
- float const size = 2.5f;
+ constexpr float size = 2.5f;
gfx::vertex_array billboard_array{
{ { -size, size, 0.f }, glm::vec3(), { 1.f, 1.f } },
{ { size, size, 0.f }, glm::vec3(), { 0.f, 1.f } },
@@ -328,7 +328,7 @@ opengl_renderer::Render() {
if( simulation::is_ready ) {
m_sunlight = Global.DayLight;
// quantize sun angle to reduce shadow crawl
- auto const quantizationstep { 0.004f };
+ constexpr auto quantizationstep { 0.004f };
m_sunlight.direction = glm::normalize( quantizationstep * glm::roundEven( m_sunlight.direction * ( 1.f / quantizationstep ) ) );
}
// generate new frame
diff --git a/rendering/openglrenderer.h b/rendering/openglrenderer.h
index 25c17ddb..d65769b1 100644
--- a/rendering/openglrenderer.h
+++ b/rendering/openglrenderer.h
@@ -129,7 +129,7 @@ public:
opengl_material const & Material( TSubModel const * Submodel ) const;
// members
- GLenum static const sunlight { GL_LIGHT0 };
+ constexpr GLenum static sunlight { GL_LIGHT0 };
static std::unique_ptr create_func();
diff --git a/rendering/particles.cpp b/rendering/particles.cpp
index 6b21f966..2d06f5b9 100644
--- a/rendering/particles.cpp
+++ b/rendering/particles.cpp
@@ -332,7 +332,7 @@ smoke_source::initialize( smoke_particle &Particle ) {
if( m_ownertype == owner_type::vehicle ) {
Particle.opacity *= m_owner.vehicle->MoverParameters->dizel_fill;
- auto const enginerevolutionsfactor { 1.5f }; // high engine revolutions increase initial particle velocity
+ constexpr auto enginerevolutionsfactor { 1.5f }; // high engine revolutions increase initial particle velocity
switch( m_owner.vehicle->MoverParameters->EngineType ) {
case TEngineType::DieselElectric: {
if (m_owner.vehicle->MoverParameters->dizel_spinup == true)
diff --git a/rendering/precipitation.cpp b/rendering/precipitation.cpp
index 3f9ecaec..9d880a7d 100644
--- a/rendering/precipitation.cpp
+++ b/rendering/precipitation.cpp
@@ -22,7 +22,7 @@ basic_precipitation::~basic_precipitation() {
bool
basic_precipitation::init() {
- auto const heightfactor { 10.f }; // height-to-radius factor
+ constexpr auto heightfactor { 10.f }; // height-to-radius factor
m_moverate *= heightfactor;
return true;
diff --git a/scene/scene.cpp b/scene/scene.cpp
index baabc19c..f9e0842d 100644
--- a/scene/scene.cpp
+++ b/scene/scene.cpp
@@ -25,8 +25,8 @@ http://mozilla.org/MPL/2.0/.
namespace scene {
std::string const EU07_FILEEXTENSION_REGION { ".sbt" };
-std::uint32_t const EU07_FILEHEADER { MAKE_ID4( 'E','U','0','7' ) };
-std::uint32_t const EU07_FILEVERSION_REGION { MAKE_ID4( 'S', 'B', 'T', '2' ) };
+constexpr std::uint32_t EU07_FILEHEADER { MAKE_ID4( 'E','U','0','7' ) };
+constexpr std::uint32_t EU07_FILEVERSION_REGION { MAKE_ID4( 'S', 'B', 'T', '2' ) };
std::map Hierarchy;
// potentially activates event handler with the same name as provided node, and within handler activation range
@@ -682,7 +682,7 @@ basic_cell::launch_event( TEventLauncher *Launcher, bool local_only ) {
simulation::Events.AddToQuery( Launcher->Event1, nullptr );
}
} else {
- const command_relay commandrelay;
+ constexpr command_relay commandrelay;
if (Global.shiftState && Launcher->Event2 != nullptr)
commandrelay.post(user_command::queueevent, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &Launcher->Event2->name());
else if (Launcher->Event1)
@@ -716,7 +716,7 @@ basic_section::update_traction( TDynamicObject *Vehicle, int const Pantographind
auto pantograph = Vehicle->pants[ Pantographindex ].fParamPants;
auto const pantographposition = position + vLeft * pantograph->vPos.z + vUp * pantograph->vPos.y + vFront * pantograph->vPos.x;
- auto const radius { EU07_CELLSIZE * 0.5 }; // redius around point of interest
+ constexpr auto radius { EU07_CELLSIZE * 0.5 }; // redius around point of interest
for( auto &cell : m_cells ) {
// we reject early cells which aren't within our area of interest
@@ -915,7 +915,7 @@ basic_section::find( glm::dvec3 const &Point, TTraction const *Other, int const
endpointfound,
endpointnearest { -1 };
- auto const radius { 0.0 }; // { EU07_CELLSIZE * 0.5 }; // experimentally limited, check if it has any negative effect
+ constexpr auto radius { 0.0 }; // { EU07_CELLSIZE * 0.5 }; // experimentally limited, check if it has any negative effect
for( auto &cell : m_cells ) {
// we reject early cells which aren't within our area of interest
@@ -940,7 +940,7 @@ basic_section::center( glm::dvec3 Center ) {
// set accordingly center points of the section's partitioning cells
// NOTE: we should also update origin point for the contained nodes, but in practice we can skip this
// as all nodes will be added only after the proper center point was set, and won't change
- auto const centeroffset = -( EU07_SECTIONSIZE / EU07_CELLSIZE / 2 * EU07_CELLSIZE ) + EU07_CELLSIZE / 2;
+ constexpr auto centeroffset = -( EU07_SECTIONSIZE / EU07_CELLSIZE / 2 * EU07_CELLSIZE ) + EU07_CELLSIZE / 2;
glm::dvec3 sectioncornercenter { m_area.center + glm::dvec3{ centeroffset, 0, centeroffset } };
auto row { 0 }, column { 0 };
for( auto &cell : m_cells ) {
@@ -1054,7 +1054,7 @@ basic_region::update_events() {
if( false == simulation::is_ready ) { return; }
// render events and sounds from sectors near enough to the viewer
- auto const range = EU07_SECTIONSIZE; // arbitrary range
+ constexpr auto range = EU07_SECTIONSIZE; // arbitrary range
auto const §ionlist = sections( Global.pCamera.Pos, range );
for( auto *section : sectionlist ) {
section->update_events( Global.pCamera.Pos, range );
@@ -1065,7 +1065,7 @@ basic_region::update_events() {
void
basic_region::update_sounds() {
// render events and sounds from sectors near enough to the viewer
- auto const range = 2750.f; // audible range of 100 db sound
+ constexpr auto range = 2750.f; // audible range of 100 db sound
auto const §ionlist = sections( Global.pCamera.Pos, range );
for( auto *section : sectionlist ) {
section->update_sounds( Global.pCamera.Pos, range );
@@ -1253,7 +1253,7 @@ basic_region::TrackJoin( TTrack *Track ) {
void
basic_region::RadioStop( glm::dvec3 const &Location ) {
- auto const range = 2000.f;
+ constexpr auto range = 2000.f;
auto const §ionlist = sections( Location, range );
for( auto *section : sectionlist ) {
section->radio_stop( Location, range );
@@ -1484,7 +1484,7 @@ basic_region::sections( glm::dvec3 const &Point, float const Radius ) {
int const originx = centerx - sectioncount / 2;
int const originz = centerz - sectioncount / 2;
- auto const padding { 0.0 }; // { EU07_SECTIONSIZE * 0.25 }; // TODO: check if we can get away with padding of 0
+ constexpr auto padding { 0.0 }; // { EU07_SECTIONSIZE * 0.25 }; // TODO: check if we can get away with padding of 0
for( int row = originz; row <= originz + sectioncount; ++row ) {
if( row < 0 ) { continue; }
@@ -1508,7 +1508,7 @@ basic_region::sections( glm::dvec3 const &Point, float const Radius ) {
bool
basic_region::point_inside( glm::dvec3 const &Location ) {
- double const regionboundary = EU07_REGIONSIDESECTIONCOUNT / 2 * EU07_SECTIONSIZE;
+ constexpr double regionboundary = EU07_REGIONSIDESECTIONCOUNT / 2 * EU07_SECTIONSIZE;
return Location.x > -regionboundary && Location.x < regionboundary && Location.z > -regionboundary && Location.z < regionboundary;
}
@@ -1522,7 +1522,7 @@ basic_region::RaTriangleDivider( shape_node &Shape, std::deque &Shap
return false;
}
- auto const margin { 200.0 };
+ constexpr auto margin { 200.0 };
auto x0 = EU07_SECTIONSIZE * std::floor( 0.001 * Shape.m_data.area.center.x ) - margin;
auto x1 = x0 + EU07_SECTIONSIZE + margin * 2;
auto z0 = EU07_SECTIONSIZE * std::floor( 0.001 * Shape.m_data.area.center.z ) - margin;
@@ -1706,7 +1706,7 @@ basic_region::section( glm::dvec3 const &Location ) {
// there's no guarantee the section exists at this point, so check and if needed, create it
section = new basic_section();
// assign center of the section
- auto const centeroffset = -( EU07_REGIONSIDESECTIONCOUNT / 2 * EU07_SECTIONSIZE ) + EU07_SECTIONSIZE / 2;
+ constexpr auto centeroffset = -( EU07_REGIONSIDESECTIONCOUNT / 2 * EU07_SECTIONSIZE ) + EU07_SECTIONSIZE / 2;
glm::dvec3 regioncornercenter { centeroffset, 0, centeroffset };
section->center( regioncornercenter + glm::dvec3{ column * EU07_SECTIONSIZE, 0.0, row * EU07_SECTIONSIZE } );
}
diff --git a/scripting/PyInt.cpp b/scripting/PyInt.cpp
index 158a3328..6cc514a8 100644
--- a/scripting/PyInt.cpp
+++ b/scripting/PyInt.cpp
@@ -120,11 +120,11 @@ void render_task::run()
const int screenWidth = static_cast(PyLong_AsLong(outputWidth));
const int screenHeight = static_cast(PyLong_AsLong(outputHeight));
- const bool useRgb = false && !Global.gfx_usegles;
+ constexpr bool useRgb = false && !Global.gfx_usegles;
- const int glFormat = useRgb ? GL_SRGB8 : GL_SRGB8_ALPHA8;
- const int glComponents = useRgb ? GL_RGB : GL_RGBA;
- const size_t bytesPerPixel = useRgb ? 3u : 4u;
+ constexpr int glFormat = useRgb ? GL_SRGB8 : GL_SRGB8_ALPHA8;
+ constexpr int glComponents = useRgb ? GL_RGB : GL_RGBA;
+ constexpr size_t bytesPerPixel = useRgb ? 3u : 4u;
const size_t expectedBytes = static_cast(screenWidth) * static_cast(screenHeight) * bytesPerPixel;
Py_ssize_t pythonBufferBytes = 0;
diff --git a/scripting/PyInt.h b/scripting/PyInt.h
index b957ad29..5b64c28d 100644
--- a/scripting/PyInt.h
+++ b/scripting/PyInt.h
@@ -126,7 +126,7 @@ class python_taskqueue
private:
// types
- static int const WORKERCOUNT{1};
+ static constexpr int WORKERCOUNT{1};
using worker_array = std::array;
using rendertask_sequence = threading::lockable>>;
using uploadtask_sequence = threading::lockable>>;
diff --git a/scripting/lua.cpp b/scripting/lua.cpp
index 4e67bb87..b5e25abe 100644
--- a/scripting/lua.cpp
+++ b/scripting/lua.cpp
@@ -288,7 +288,7 @@ int lua::scriptapi_dynobj_putvalues(lua_State *L)
auto [str, num1, num2] = get_memcell_values(L, 2);
if (!dyn)
return 0;
- const TLocation loc{};
+ constexpr TLocation loc{};
if (dyn->Mechanik)
dyn->Mechanik->PutCommand(str, num1, num2, loc);
else
diff --git a/simulation/simulationtime.cpp b/simulation/simulationtime.cpp
index 88ac24da..96540255 100644
--- a/simulation/simulationtime.cpp
+++ b/simulation/simulationtime.cpp
@@ -175,7 +175,7 @@ scenario_time::julian_day() const {
// for dates in Julian calendar
int JD = K1 + K2 + m_time.wDay + 59;
// for dates in Gregorian calendar; 2299160 is October 15th, 1582
- const int gregorianswitchday = 2299160;
+ constexpr int gregorianswitchday = 2299160;
if( JD > gregorianswitchday ) {
const int K3 = std::floor( std::floor( yy * 0.01 + 49 ) * 0.75 ) - 38;
diff --git a/utilities/color.h b/utilities/color.h
index 76aecf16..18dc410a 100644
--- a/utilities/color.h
+++ b/utilities/color.h
@@ -15,7 +15,7 @@ glm::vec3
XYZtoRGB( glm::vec3 const &XYZ ) {
// M^-1 for Adobe RGB from http://www.brucelindbloom.com/Eqn_RGB_XYZ_Matrix.html
- float const mi[ 3 ][ 3 ] = { 2.041369f, -0.969266f, 0.0134474f, -0.5649464f, 1.8760108f, -0.1183897f, -0.3446944f, 0.041556f, 1.0154096f };
+ constexpr float mi[ 3 ][ 3 ] = { 2.041369f, -0.969266f, 0.0134474f, -0.5649464f, 1.8760108f, -0.1183897f, -0.3446944f, 0.041556f, 1.0154096f };
// m^-1 for sRGB:
// float const mi[ 3 ][ 3 ] = { 3.240479f, -0.969256f, 0.055648f, -1.53715f, 1.875991f, -0.204043f, -0.49853f, 0.041556f, 1.057311f };
diff --git a/utilities/utilities.cpp b/utilities/utilities.cpp
index c595e202..c7895c9d 100644
--- a/utilities/utilities.cpp
+++ b/utilities/utilities.cpp
@@ -312,9 +312,9 @@ char charsetconversiontable[] = "E?,?\"_++?%Sstzz"
std::string Bezogonkow(std::string Input, bool const Underscorestospaces)
{
- char const extendedcharsetbit{static_cast(0x80)};
- char const space{' '};
- char const underscore{'_'};
+ constexpr char extendedcharsetbit{static_cast(0x80)};
+ constexpr char space{' '};
+ constexpr char underscore{'_'};
for (auto &input : Input)
{
diff --git a/vehicle/Camera.cpp b/vehicle/Camera.cpp
index c1885fb8..3c8bdd10 100644
--- a/vehicle/Camera.cpp
+++ b/vehicle/Camera.cpp
@@ -56,11 +56,11 @@ static double ComputeAxisSpeed(double param, double walkspeed, double maxspeed,
bool
TCamera::OnCommand( command_data const &Command ) {
- auto const walkspeed { 1.0 };
- auto const runspeed { 10.0 };
+ constexpr auto walkspeed { 1.0 };
+ constexpr auto runspeed { 10.0 };
// threshold position on stick between walk lerp and walk/run lerp
- auto const stickthreshold = 2.0 / 3.0;
+ constexpr auto stickthreshold = 2.0 / 3.0;
bool iscameracommand { true };
switch( Command.command ) {
diff --git a/vehicle/Driver.cpp b/vehicle/Driver.cpp
index 840bf3e2..fdb3f74a 100644
--- a/vehicle/Driver.cpp
+++ b/vehicle/Driver.cpp
@@ -145,17 +145,17 @@ Tutaj łączymy teorię z praktyką - tu nic nie działa i nikt nie wie dlaczego
// 7. samouczacy sie algorytm hamowania
// stałe
-const double EasyReactionTime = 0.5; //[s] przebłyski świadomości dla zwykłej jazdy
-const double HardReactionTime = 0.2;
-const double EasyAcceleration = 0.85; //[m/ss]
-const double HardAcceleration = 9.81;
-const double PassengetTrainAcceleration = 0.40;
-const double HeavyPassengetTrainAcceleration = 0.20;
-const double CargoTrainAcceleration = 0.25;
-const double HeavyCargoTrainAcceleration = 0.10;
-const double PrepareTime = 2.0; //[s] przebłyski świadomości przy odpalaniu
+constexpr double EasyReactionTime = 0.5; //[s] przebłyski świadomości dla zwykłej jazdy
+constexpr double HardReactionTime = 0.2;
+constexpr double EasyAcceleration = 0.85; //[m/ss]
+constexpr double HardAcceleration = 9.81;
+constexpr double PassengetTrainAcceleration = 0.40;
+constexpr double HeavyPassengetTrainAcceleration = 0.20;
+constexpr double CargoTrainAcceleration = 0.25;
+constexpr double HeavyCargoTrainAcceleration = 0.10;
+constexpr double PrepareTime = 2.0; //[s] przebłyski świadomości przy odpalaniu
bool WriteLogFlag = false;
-double const deltalog = 0.05; // przyrost czasu
+constexpr double deltalog = 0.05; // przyrost czasu
std::string StopReasonTable[] = {
// przyczyny zatrzymania ruchu AI
@@ -844,7 +844,7 @@ void TController::TableCheck(double fDistance)
}
};
-auto const passengerstopmaxdistance { 400.0 }; // maximum allowed distance between passenger stop point and consist head
+constexpr auto passengerstopmaxdistance { 400.0 }; // maximum allowed distance between passenger stop point and consist head
TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fNext, double &fAcc)
{ // ustalenie parametrów, zwraca typ komendy, jeśli sygnał podaje prędkość do jazdy
@@ -1396,7 +1396,7 @@ TController::TableUpdateEvent( double &Velocity, TCommandType &Command, TSpeedPo
// NOTE: magnet induction calculation presumes the driver is located in the front vehicle
// TBD, TODO: take into account actual position of controlled/occupied vehicle in the consist, whichever comes first
auto const magnetlocation { pVehicles[ front ]->MoverParameters->SecuritySystem.MagnetLocation };
- auto const magnetrange { 1.0 };
+ constexpr auto magnetrange { 1.0 };
auto const ismagnetpassed { Point.fDist < -( magnetlocation + magnetrange ) };
if( Point.fDist < -magnetlocation ) {
// NOTE: normally we'd activate the magnet once the leading vehicle passes it
@@ -2294,8 +2294,8 @@ void TController::AutoRewident()
double TController::ESMVelocity(bool Main)
{
- const double fCurrentCoeff = 0.9;
- const double fFrictionCoeff = 0.85;
+ constexpr double fCurrentCoeff = 0.9;
+ constexpr double fFrictionCoeff = 0.85;
double ESMVel = 9999;
int MCPN = mvControlling->MainCtrlActualPos;
int SCPN = mvControlling->ScndCtrlActualPos;
diff --git a/vehicle/Driver.h b/vehicle/Driver.h
index 9cad987b..fe1b66d7 100644
--- a/vehicle/Driver.h
+++ b/vehicle/Driver.h
@@ -19,12 +19,12 @@ http://mozilla.org/MPL/2.0/.
#include "utilities/translation.h"
#include "application/driverhints.h"
-auto const EU07_AI_ACCELERATION = 0.05;
-auto const EU07_AI_NOACCELERATION = -0.05;
-auto const EU07_AI_BRAKINGTESTACCELERATION = -0.06;
-auto const EU07_AI_NOMOVEMENT = 0.05; // standstill velocity threshold
-auto const EU07_AI_MOVEMENT = 1.0; // deliberate movement velocity threshold
-auto const EU07_AI_SPEEDLIMITEXTENDSBEYONDSCANRANGE = 10000.0;
+constexpr auto EU07_AI_ACCELERATION = 0.05;
+constexpr auto EU07_AI_NOACCELERATION = -0.05;
+constexpr auto EU07_AI_BRAKINGTESTACCELERATION = -0.06;
+constexpr auto EU07_AI_NOMOVEMENT = 0.05; // standstill velocity threshold
+constexpr auto EU07_AI_MOVEMENT = 1.0; // deliberate movement velocity threshold
+constexpr auto EU07_AI_SPEEDLIMITEXTENDSBEYONDSCANRANGE = 10000.0;
enum TOrders
{ // rozkazy dla AI
@@ -183,20 +183,20 @@ class TSpeedPos
};
//----------------------------------------------------------------------------
-static const bool Aggressive = true;
-static const bool Easyman = false;
-static const bool AIdriver = true;
-static const bool Humandriver = false;
-static const int maxorders = 64; // ilość rozkazów w tabelce
-static const int maxdriverfails = 4; // ile błędów może zrobić AI zanim zmieni nastawienie
+static constexpr bool Aggressive = true;
+static constexpr bool Easyman = false;
+static constexpr bool AIdriver = true;
+static constexpr bool Humandriver = false;
+static constexpr int maxorders = 64; // ilość rozkazów w tabelce
+static constexpr int maxdriverfails = 4; // ile błędów może zrobić AI zanim zmieni nastawienie
extern bool WriteLogFlag; // logowanie parametrów fizycznych
-static const int BrakeAccTableSize = 20;
+static constexpr int BrakeAccTableSize = 20;
-static const int gbh_NP = -2; //odciecie w hamulcu ogolnym
-static const int gbh_RP = 0; //jazda w hamulcu ogolnym
-static const int gbh_FS = -1; //napelnianie uderzeniowe w hamulcu ogolnym
-static const int gbh_MIN = -2; //minimalna pozycja w hamulcu ogolnym
-static const int gbh_MAX = 6; //maksymalna pozycja w hamulcu ogolnym
+static constexpr int gbh_NP = -2; //odciecie w hamulcu ogolnym
+static constexpr int gbh_RP = 0; //jazda w hamulcu ogolnym
+static constexpr int gbh_FS = -1; //napelnianie uderzeniowe w hamulcu ogolnym
+static constexpr int gbh_MIN = -2; //minimalna pozycja w hamulcu ogolnym
+static constexpr int gbh_MAX = 6; //maksymalna pozycja w hamulcu ogolnym
//----------------------------------------------------------------------------
class TController {
diff --git a/vehicle/DynObj.cpp b/vehicle/DynObj.cpp
index 3d037d7e..262aff71 100644
--- a/vehicle/DynObj.cpp
+++ b/vehicle/DynObj.cpp
@@ -40,7 +40,7 @@ http://mozilla.org/MPL/2.0/.
#define vWorldLeft glm::cross(vWorldUp, vWorldFront)
#define M_2PI 6.283185307179586476925286766559;
-const float maxrot = (float)(M_PI / 3.0); // 60°
+constexpr float maxrot = (float)(M_PI / 3.0); // 60°
std::string const TDynamicObject::MED_labels[] = {
"masa: ", "amax: ", "Fzad: ", "FmPN: ", "FmED: ", "FrED: ", "FzPN: ", "nPrF: "
@@ -2154,7 +2154,7 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424"
switch( ActPar.front() ) {
case 'F': {
// fixed flat size
- auto const indexstart { 1 };
+ constexpr auto indexstart { 1 };
auto const indexend { ActPar.find_first_not_of( "1234567890", indexstart ) };
fixedflatsize = std::atoi( ActPar.substr( indexstart, indexend ).c_str() );
ActPar.erase( 0, indexend );
@@ -2162,7 +2162,7 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424"
}
case 'R': {
// random flat size
- auto const indexstart { 1 };
+ constexpr auto indexstart { 1 };
auto const indexend { ActPar.find_first_not_of( "1234567890", indexstart ) };
randomflatsize = std::atoi( ActPar.substr( indexstart, indexend ).c_str() );
ActPar.erase( 0, indexend );
@@ -2170,7 +2170,7 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424"
}
case 'P': {
// random flat probability
- auto const indexstart { 1 };
+ constexpr auto indexstart { 1 };
auto const indexend { ActPar.find_first_not_of( "1234567890", indexstart ) };
flatchance = std::atoi( ActPar.substr( indexstart, indexend ).c_str() );
ActPar.erase( 0, indexend );
@@ -2178,7 +2178,7 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424"
}
case 'H': {
// truck hunting
- auto const indexstart { 1 };
+ constexpr auto indexstart { 1 };
auto const indexend { ActPar.find_first_not_of( "1234567890", indexstart ) };
auto const huntingchance { std::atoi( ActPar.substr( indexstart, indexend ).c_str() ) };
MoverParameters->TruckHunting = Random(0, 100) < huntingchance;
@@ -2230,7 +2230,7 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424"
// immediately followed by max load override
// TBD: make it instead an optional sub-parameter?
{
- auto const indexstart { 0 };
+ constexpr auto indexstart { 0 };
auto const indexend { ActPar.find_first_not_of( "1234567890", indexstart ) };
MoverParameters->MaxLoad = std::atoi( ActPar.substr( indexstart, indexend ).c_str() );
ActPar.erase( 0, indexend );
@@ -4728,7 +4728,7 @@ void TDynamicObject::RenderSounds() {
}
}
// NBMX Obsluga drzwi, MC: zuniwersalnione
- std::array const sides { right, left };
+ constexpr std::array sides { right, left };
for( auto const side : sides ) {
auto const &door { MoverParameters->Doors.instances[ side ] };
@@ -7701,7 +7701,7 @@ TDynamicObject *
TDynamicObject::FindPantographCarrier() {
// try first within a single unit, broaden to all vehicles under our control if first attempt fails
- std::array const couplings = { permanent, control };
+ constexpr std::array couplings = { permanent, control };
for( auto const coupling : couplings ) {
auto *result =
diff --git a/vehicle/DynObj.h b/vehicle/DynObj.h
index 226fa02c..151ff2f6 100644
--- a/vehicle/DynObj.h
+++ b/vehicle/DynObj.h
@@ -29,24 +29,24 @@ http://mozilla.org/MPL/2.0/.
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
-int const ANIM_WHEELS = 0; // koła
-int const ANIM_DOORS = 1; // drzwi
-int const ANIM_LEVERS = 2; // elementy obracane (wycieraczki, koła skrętne, przestawiacze, klocki ham.)
-int const ANIM_BUFFERS = 3; // elementy przesuwane (zderzaki)
-int const ANIM_BOOGIES = 4; // wózki (są skręcane w dwóch osiach)
-int const ANIM_PANTS = 5; // pantografy
-int const ANIM_STEAMS = 6; // napęd parowozu
-int const ANIM_DOORSTEPS = 7;
-int const ANIM_MIRRORS = 8;
-int const ANIM_WIPERS = 9;
-int const ANIM_TYPES = 10; // Ra: ilość typów animacji
+constexpr int ANIM_WHEELS = 0; // koła
+constexpr int ANIM_DOORS = 1; // drzwi
+constexpr int ANIM_LEVERS = 2; // elementy obracane (wycieraczki, koła skrętne, przestawiacze, klocki ham.)
+constexpr int ANIM_BUFFERS = 3; // elementy przesuwane (zderzaki)
+constexpr int ANIM_BOOGIES = 4; // wózki (są skręcane w dwóch osiach)
+constexpr int ANIM_PANTS = 5; // pantografy
+constexpr int ANIM_STEAMS = 6; // napęd parowozu
+constexpr int ANIM_DOORSTEPS = 7;
+constexpr int ANIM_MIRRORS = 8;
+constexpr int ANIM_WIPERS = 9;
+constexpr int ANIM_TYPES = 10; // Ra: ilość typów animacji
class TAnim;
//typedef void(__closure *TUpdate)(TAnim *pAnim); // typ funkcji aktualizującej położenie submodeli
typedef std::function TUpdate; // __closure is Borland-specific extension
// McZapkie-250202
-int const MaxAxles = 16; // ABu 280105: zmienione z 8 na 16
+constexpr int MaxAxles = 16; // ABu 280105: zmienione z 8 na 16
// const MaxAnimatedAxles=16; //i to tez.
// const MaxAnimatedDoors=16; //NBMX wrzesien 2003
/*
diff --git a/vehicle/Train.cpp b/vehicle/Train.cpp
index bddbc53b..980b7dc9 100644
--- a/vehicle/Train.cpp
+++ b/vehicle/Train.cpp
@@ -1117,8 +1117,8 @@ void TTrain::OnCommand_aidriverdisable(TTrain *Train, command_data const &Comman
}
}
-auto const EU07_CONTROLLER_BASERETURNDELAY{0.5f};
-auto const EU07_CONTROLLER_KEYBOARDETURNDELAY{1.5f};
+constexpr auto EU07_CONTROLLER_BASERETURNDELAY{0.5f};
+constexpr auto EU07_CONTROLLER_KEYBOARDETURNDELAY{1.5f};
void TTrain::OnCommand_jointcontrollerset(TTrain *Train, command_data const &Command)
{
@@ -6091,7 +6091,7 @@ void TTrain::OnCommand_redmarkerstoggle(TTrain *Train, command_data const &Comma
auto locationRear = vehicle->RearPosition() - glm::dvec3(Command.location);
int const CouplNr{std::clamp(vehicle->DirectionGet() * (glm::dot(locationHead, locationHead) > glm::dot(locationRear, locationRear) ? 1 : -1), 0, 1)}; // z [-1,1] zrobić [0,1]
- auto const lightset{redmarker_left | redmarker_right};
+ constexpr auto lightset{redmarker_left | redmarker_right};
vehicle->MoverParameters->iLights[CouplNr] =
false == TestFlag(vehicle->MoverParameters->iLights[CouplNr], lightset) ?
@@ -6116,7 +6116,7 @@ void TTrain::OnCommand_endsignalstoggle(TTrain *Train, command_data const &Comma
std::clamp(vehicle->DirectionGet() * (glm::length2(vehicle->HeadPosition() - glm::dvec3(Command.location)) > glm::length2(vehicle->RearPosition() - glm::dvec3(Command.location)) ? 1 : -1), 0,
1)}; // z [-1,1] zrobić [0,1]
- auto const lightset{rearendsignals};
+ constexpr auto lightset{rearendsignals};
vehicle->MoverParameters->iLights[CouplNr] =
false == TestFlag(vehicle->MoverParameters->iLights[CouplNr], lightset) ?
@@ -8295,10 +8295,10 @@ void TTrain::OnCommand_cabchangeforward(TTrain *Train, command_data const &Comma
if (Command.action == GLFW_PRESS)
{
auto const *owner{(Train->DynamicObject->ctOwner != nullptr ? Train->DynamicObject->ctOwner : Train->DynamicObject->Mechanik)};
- auto const movedirection{1};
+ constexpr auto movedirection{1};
if (false == Train->CabChange(movedirection))
{
- auto const exitdirection{(movedirection > 0 ? front : rear)};
+ constexpr auto exitdirection{(movedirection > 0 ? front : rear)};
if (TestFlag(Train->mvOccupied->Couplers[exitdirection].CouplingFlag, gangway))
{
// przejscie do nastepnego pojazdu
@@ -8326,11 +8326,11 @@ void TTrain::OnCommand_cabchangebackward(TTrain *Train, command_data const &Comm
if (Command.action == GLFW_PRESS)
{
auto const *owner{(Train->DynamicObject->ctOwner != nullptr ? Train->DynamicObject->ctOwner : Train->DynamicObject->Mechanik)};
- auto const movedirection{-1};
+ constexpr auto movedirection{-1};
if (false == Train->CabChange(movedirection))
{
// current vehicle doesn't extend any farther in this direction, check if we there's one connected we can move to
- auto const exitdirection{(movedirection > 0 ? front : rear)};
+ constexpr auto exitdirection{(movedirection > 0 ? front : rear)};
if (TestFlag(Train->mvOccupied->Couplers[exitdirection].CouplingFlag, gangway))
{
// przejscie do nastepnego pojazdu
@@ -8580,7 +8580,7 @@ bool TTrain::Update(double const Deltatime)
}
// McZapkie: predkosc wyswietlana na tachometrze brana jest z obrotow kol
- auto const maxtacho{3.0};
+ constexpr auto maxtacho{3.0};
double maxSpeed = mvControlled->Vmax * 1.05; // zachowanie starej logiki jak nie ma definicji max tarczki
if (mvOccupied->maxTachoSpeed != 0)
@@ -9396,7 +9396,7 @@ bool TTrain::Update(double const Deltatime)
if (ggJointCtrl.SubModel != nullptr)
{
// joint master controller moves forward to adjust power and backward to adjust brakes
- auto const brakerangemultiplier{/* NOTE: scaling disabled as it was conflicting with associating sounds with control positions
+ constexpr auto brakerangemultiplier{/* NOTE: scaling disabled as it was conflicting with associating sounds with control positions
( mvControlled->CoupledCtrl ?
mvControlled->MainCtrlPosNo + mvControlled->ScndCtrlPosNo :
mvControlled->MainCtrlPosNo )
@@ -9816,7 +9816,7 @@ void TTrain::update_sounds(double const Deltatime)
{
double volume{0.0};
- double const brakevolumescale{0.5};
+ constexpr double brakevolumescale{0.5};
// Winger-160404 - syczenie pomocniczego (luzowanie)
if (m_lastlocalbrakepressure != -1.f)
diff --git a/vehicle/Train.h b/vehicle/Train.h
index 613c99e5..37d5ce74 100644
--- a/vehicle/Train.h
+++ b/vehicle/Train.h
@@ -24,11 +24,11 @@ http://mozilla.org/MPL/2.0/.
// typedef enum {st_Off, st_Starting, st_On, st_ShuttingDown} T4State;
-const double fCzuwakBlink = 0.15;
-const float fConverterPrzekaznik = 1.5f; // hunter-261211: do przekaznika nadmiarowego przetwornicy
+constexpr double fCzuwakBlink = 0.15;
+constexpr float fConverterPrzekaznik = 1.5f; // hunter-261211: do przekaznika nadmiarowego przetwornicy
// 0.33f
// const double fBuzzerTime= 5.0f;
-const float fHaslerTime = 1.2f;
+constexpr float fHaslerTime = 1.2f;
class TCab {
diff --git a/world/Event.cpp b/world/Event.cpp
index c735464a..b6011978 100644
--- a/world/Event.cpp
+++ b/world/Event.cpp
@@ -1755,7 +1755,7 @@ void
lights_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) {
// TBD, TODO: remove light count limit?
- auto const lightcountlimit { 8 };
+ constexpr auto lightcountlimit { 8 };
m_lights.resize( lightcountlimit );
int lightidx { 0 };
diff --git a/world/Segment.cpp b/world/Segment.cpp
index 0750a839..387522df 100644
--- a/world/Segment.cpp
+++ b/world/Segment.cpp
@@ -162,7 +162,7 @@ double TSegment::RombergIntegral(double const fA, double const fB) const
{
double fH = fB - fA;
- const int ms_iOrder = 5;
+ constexpr int ms_iOrder = 5;
double ms_apfRom[2][ms_iOrder];
@@ -193,7 +193,7 @@ double TSegment::RombergIntegral(double const fA, double const fB) const
double TSegment::GetTFromS(double const s) const
{
// initial guess for Newton's method
- const double fTolerance = 0.001;
+ constexpr double fTolerance = 0.001;
const double fRatio = s / RombergIntegral(0, 1);
double fTime = std::lerp( 0.0, 1.0, fRatio );
@@ -291,7 +291,7 @@ TSegment::find_nearest_point( glm::dvec3 const &Point ) const {
}
}
-const double fDirectionOffset = 0.1; // długość wektora do wyliczenia kierunku
+constexpr double fDirectionOffset = 0.1; // długość wektora do wyliczenia kierunku
glm::dvec3 TSegment::GetDirection(double const fDistance) const
{ // takie toporne liczenie pochodnej dla podanego dystansu od Point1
diff --git a/world/Track.cpp b/world/Track.cpp
index 72dd5893..641d09db 100644
--- a/world/Track.cpp
+++ b/world/Track.cpp
@@ -32,17 +32,17 @@ http://mozilla.org/MPL/2.0/.
// 101206 Ra: trapezoidalne drogi i tory
// 110720 Ra: rozprucie zwrotnicy i odcinki izolowane
-static float const fMaxOffset = 0.1f; // double(0.1f)==0.100000001490116
+static constexpr float fMaxOffset = 0.1f; // double(0.1f)==0.100000001490116
// const int NextMask[4]={0,1,0,1}; //tor następny dla stanów 0, 1, 2, 3
// const int PrevMask[4]={0,0,1,1}; //tor poprzedni dla stanów 0, 1, 2, 3
-const int iLewo4[4] = {5, 3, 4, 6}; // segmenty (1..6) do skręcania w lewo
-const int iPrawo4[4] = {-4, -6, -3, -5}; // segmenty (1..6) do skręcania w prawo
-const int iProsto4[4] = {1, -1, 2, -2}; // segmenty (1..6) do jazdy prosto
-const int iEnds4[13] = {3, 0, 2, 1, 2, 0, -1, 1, 3, 2, 0, 3, 1}; // numer sąsiedniego toru na końcu segmentu "-1"
-const int iLewo3[4] = {1, 3, 2, 1}; // segmenty do skręcania w lewo
-const int iPrawo3[4] = {-2, -1, -3, -2}; // segmenty do skręcania w prawo
-const int iProsto3[4] = {1, -1, 2, 1}; // segmenty do jazdy prosto
-const int iEnds3[13] = {3, 0, 2, 1, 2, 0, -1, 1, 0, 2, 0, 3, 1}; // numer sąsiedniego toru na końcu segmentu "-1"
+constexpr int iLewo4[4] = {5, 3, 4, 6}; // segmenty (1..6) do skręcania w lewo
+constexpr int iPrawo4[4] = {-4, -6, -3, -5}; // segmenty (1..6) do skręcania w prawo
+constexpr int iProsto4[4] = {1, -1, 2, -2}; // segmenty (1..6) do jazdy prosto
+constexpr int iEnds4[13] = {3, 0, 2, 1, 2, 0, -1, 1, 3, 2, 0, 3, 1}; // numer sąsiedniego toru na końcu segmentu "-1"
+constexpr int iLewo3[4] = {1, 3, 2, 1}; // segmenty do skręcania w lewo
+constexpr int iPrawo3[4] = {-2, -1, -3, -2}; // segmenty do skręcania w prawo
+constexpr int iProsto3[4] = {1, -1, 2, 1}; // segmenty do jazdy prosto
+constexpr int iEnds3[13] = {3, 0, 2, 1, 2, 0, -1, 1, 0, 2, 0, 3, 1}; // numer sąsiedniego toru na końcu segmentu "-1"
TIsolated *TIsolated::pRoot = nullptr;
TTrack::profiles_array TTrack::m_profiles;
@@ -543,7 +543,7 @@ void TTrack::Load(cParser *parser, glm::dvec3 const &pOrigin)
if (iCategoryFlag & 1)
{ // zero na główce szyny
// TODO: delay these calculations unti rail profile and thus height is known
- auto const railheight { 0.18 };
+ constexpr auto railheight { 0.18 };
p1.y += railheight;
p2.y += railheight;
// na przechyłce doliczyć jeszcze pół przechyłki
@@ -638,7 +638,7 @@ void TTrack::Load(cParser *parser, glm::dvec3 const &pOrigin)
if (iCategoryFlag & 1)
{ // zero na główce szyny
// TODO: delay these calculations unti rail profile and thus height is known
- auto const railheight { 0.18 };
+ constexpr auto railheight { 0.18 };
p1.y += railheight;
p2.y += railheight;
// na przechyłce doliczyć jeszcze pół przechyłki?
@@ -703,7 +703,7 @@ void TTrack::Load(cParser *parser, glm::dvec3 const &pOrigin)
if (iCategoryFlag & 1)
{ // zero na główce szyny
// TODO: delay these calculations unti rail profile and thus height is known
- auto const railheight{ 0.18 };
+ constexpr auto railheight{ 0.18 };
p3.y += railheight;
p4.y += railheight;
// na przechyłce doliczyć jeszcze pół przechyłki?
@@ -1078,7 +1078,7 @@ bool TTrack::AddDynamicObject(TDynamicObject *Dynamic)
return true;
};
-const int numPts = 4;
+constexpr int numPts = 4;
bool TTrack::CheckDynamicObject(TDynamicObject *Dynamic)
{ // sprawdzenie, czy pojazd jest przypisany do toru
@@ -1407,7 +1407,7 @@ void TTrack::create_geometry( gfx::geometrybank_handle const &Bank ) {
// positive jointlength: the switch is typically used along the main track, negative: along the diverging track
// TODO: determine this from names of textures assigned to the tracks
// auto const jointlength { static_cast( std::ceil( SwitchExtension->Segments[ 0 ]->RaSegCount() * 0.15 ) ) };
- auto const jointlength { 0 }; // temporary until implementation of the above
+ constexpr auto jointlength { 0 }; // temporary until implementation of the above
if (SwitchExtension->RightSwitch)
{ // nowa wersja z SPKS, ale odwrotnie lewa/prawa
gfx::vertex_array vertices;
@@ -3282,14 +3282,14 @@ TTrack::create_switch_trackbed( gfx::vertex_array &Output ) {
create_track_bed_profile( trackbedprofile, SwitchExtension->pPrevs[ 1 ], SwitchExtension->pNexts[ 1 ] );
SwitchExtension->Segments[ 1 ]->RenderLoft( trackbedvertices2, m_origin, trackbedprofile, true, texturelength );
// ...then combine them into a single geometry sequence
- auto const segmentsize { 10 };
+ constexpr auto segmentsize { 10 };
auto const segmentcount { trackbedvertices1.size() / segmentsize };
auto *sampler1 { trackbedvertices1.data() };
auto *sampler2 { trackbedvertices2.data() };
auto const isright { SwitchExtension->RightSwitch };
auto const isleft { false == isright };
auto const samplersoffset { isright ? 2 : 0 };
- auto const geometryoffset { 0.025f };
+ constexpr auto geometryoffset { 0.025f };
for( int segment = 0; segment < segmentcount; ++segment ) {
// main trackbed
// lower outer edge to avoid z-fighting
diff --git a/world/mtable.h b/world/mtable.h
index 4541cd05..d8d06fa0 100644
--- a/world/mtable.h
+++ b/world/mtable.h
@@ -17,7 +17,7 @@ http://mozilla.org/MPL/2.0/.
namespace Mtable
{
-static int const MaxTTableSize = 100; // można by to robić dynamicznie
+static constexpr int MaxTTableSize = 100; // można by to robić dynamicznie
static auto hrsd = ".";
// Ra: pozycja zerowa rozkładu chyba nie ma sensu