mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 15:09:19 +02:00
reformat: set variables to constexpr where possible
This commit is contained in:
@@ -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 ) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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<side, 2> const sides { right, left };
|
||||
constexpr std::array<side, 2> 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<coupling, 2> const couplings = { permanent, control };
|
||||
constexpr std::array<coupling, 2> couplings = { permanent, control };
|
||||
|
||||
for( auto const coupling : couplings ) {
|
||||
auto *result =
|
||||
|
||||
@@ -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<void(TAnim *)> 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
|
||||
/*
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user