diff --git a/McZapkie/MOVER.h b/McZapkie/MOVER.h index 7b075e91..0d220464 100644 --- a/McZapkie/MOVER.h +++ b/McZapkie/MOVER.h @@ -2099,7 +2099,7 @@ class TMoverParameters int CabActive = 0; // numer kabiny, z której jest sterowanie: 1 lub -1; w przeciwnym razie brak sterowania - rozrzad int CabOccupied = 0; // numer kabiny, w ktorej jest obsada (zwykle jedna na skład) // TODO: move to TController bool CabMaster = false; // czy pojazd jest nadrzędny w składzie - inline bool IsCabMaster() + inline bool IsCabMaster() const { return CabActive == CabOccupied && CabMaster; } // czy aktualna kabina jest na pewno tą, z której można sterować @@ -2306,7 +2306,7 @@ class TMoverParameters bool DirectionForward(); bool DirectionBackward(void); /*! kierunek ruchu*/ bool EIMDirectionChangeAllow(void) const; - inline double IsVehicleEIMBrakingFactor() + inline double IsVehicleEIMBrakingFactor() const { return DynamicBrakeFlag && ResistorsFlag ? 0.0 : eimv[eimv_Ipoj] < 0 ? -1.0 : 1.0; } @@ -2322,16 +2322,16 @@ class TMoverParameters TRotation const &NewRot); // oblicza przesuniecie pojazdu double FastComputeMovement(double dt, const TTrackShape &Shape, TTrackParam &Track, TLocation const &NewLoc, TRotation const &NewRot); // oblicza przesuniecie pojazdu - wersja zoptymalizowana void compute_movement_(double const Deltatime); - double ShowEngineRotation(int VehN); + double ShowEngineRotation(int VehN) const; // Q ******************************************************************************************* double GetTrainsetVoltage(int const Coupling = coupling::heating | coupling::highvoltage) const; double GetTrainsetHighVoltage() const; bool switch_physics(bool const State); - double LocalBrakeRatio(void); - double ManualBrakeRatio(void); - double PipeRatio(void); /*ile napelniac*/ - double RealPipeRatio(void); /*jak szybko*/ + double LocalBrakeRatio(void) const; + double ManualBrakeRatio(void) const; + double PipeRatio(void) const; /*ile napelniac*/ + double RealPipeRatio(void) const; /*jak szybko*/ double BrakeVP(void) const; double EngineRPMRatio() const; // returns current engine revolutions as percentage of max engine revolutions, in range 0-1 double EngineIdleRPM() const; @@ -2340,7 +2340,7 @@ class TMoverParameters /*! przesylanie komend sterujacych*/ bool SendCtrlToNext(std::string const CtrlCommand, double const ctrlvalue, double const dir, int const Couplertype = coupling::control); bool SetInternalCommand(std::string NewCommand, double NewValue1, double NewValue2, int const Couplertype = coupling::control); - double GetExternalCommand(std::string &Command); + double GetExternalCommand(std::string &Command) const; bool RunCommand(std::string Command, double CValue1, double CValue2, int const Couplertype = coupling::control); bool RunInternalCommand(); void PutCommand(std::string NewCommand, double NewValue1, double NewValue2, const TLocation &NewLocation); @@ -2362,7 +2362,7 @@ class TMoverParameters /*! pomocniczy nastawnik:*/ bool IncScndCtrl(int CtrlSpeed); bool DecScndCtrl(int CtrlSpeed); - int GetVirtualScndPos(); + int GetVirtualScndPos() const; bool IsScndCtrlNoPowerPos() const; bool IsScndCtrlMaxPowerPos() const; @@ -2429,7 +2429,7 @@ class TMoverParameters double TractionForce(double dt); double FrictionForce() const; double BrakeForceR(double ratio, double velocity); - double BrakeForceP(double press, double velocity); + double BrakeForceP(double press, double velocity) const; double BrakeForce(const TTrackParam &Track); double CouplerForce(int const End, double dt); void CollisionDetect(int const End, double const dt); @@ -2487,8 +2487,8 @@ class TMoverParameters /*funkcje uzalezniajace sile pociagowa od predkosci: v2n, n2r, current, momentum*/ double v2n(void); double Current(double n, double U); - double Momentum(double I); - double MomentumF(double I, double Iw, int SCP); + double Momentum(double I) const; + double MomentumF(double I, double Iw, int SCP) const; bool CutOffEngine(void); // odlaczenie udszkodzonych silnikow /*funkcje automatycznego rozruchu np EN57*/ @@ -2577,9 +2577,9 @@ class TMoverParameters void LoadFIZ_DimmerList(std::string const &Input); void LoadFIZ_CompressorList(std::string const &Input); void LoadFIZ_PowerParamsDecode(TPowerParameters &Powerparameters, std::string const Prefix, std::string const &Input); - TPowerType LoadFIZ_PowerDecode(std::string const &Power); - TPowerSource LoadFIZ_SourceDecode(std::string const &Source); - TEngineType LoadFIZ_EngineDecode(std::string const &Engine); + TPowerType LoadFIZ_PowerDecode(std::string const &Power) const; + TPowerSource LoadFIZ_SourceDecode(std::string const &Source) const; + TEngineType LoadFIZ_EngineDecode(std::string const &Engine) const; bool readMPT0(std::string const &line); bool readMPT(std::string const &line); // Q 20160717 bool readMPTElectricSeries(std::string const &line); diff --git a/McZapkie/Mover.cpp b/McZapkie/Mover.cpp index 65173284..efbbb2ed 100644 --- a/McZapkie/Mover.cpp +++ b/McZapkie/Mover.cpp @@ -1068,7 +1068,7 @@ ZN //masa // Q: 20160714 // Oblicza iloraz aktualnej pozycji do maksymalnej hamulca pomocnicznego // ***************************************************************************** -double TMoverParameters::LocalBrakeRatio(void) +double TMoverParameters::LocalBrakeRatio(void) const { double LBR; if (BrakeHandle == TBrakeHandle::MHZ_EN57) @@ -1092,7 +1092,7 @@ double TMoverParameters::LocalBrakeRatio(void) // Q: 20160714 // Oblicza iloraz aktualnej pozycji do maksymalnej hamulca ręcznego // ***************************************************************************** -double TMoverParameters::ManualBrakeRatio(void) +double TMoverParameters::ManualBrakeRatio(void) const { double MBR; @@ -1119,7 +1119,7 @@ double TMoverParameters::BrakeVP(void) const // Q: 20160713 // Zwraca iloraz różnicy między przewodem kontrolnym i głównym oraz DeltaPipePress // ***************************************************************************** -double TMoverParameters::RealPipeRatio(void) +double TMoverParameters::RealPipeRatio(void) const { double rpp; @@ -1134,7 +1134,7 @@ double TMoverParameters::RealPipeRatio(void) // Q: 20160713 // Zwraca iloraz ciśnienia w przewodzie do DeltaPipePress // ***************************************************************************** -double TMoverParameters::PipeRatio(void) +double TMoverParameters::PipeRatio(void) const { double pr; @@ -2000,7 +2000,7 @@ void TMoverParameters::PowerCouplersCheck(double const /*Deltatime*/, coupling c } } -double TMoverParameters::ShowEngineRotation(int VehN) +double TMoverParameters::ShowEngineRotation(int VehN) const { // Zwraca wartość prędkości obrotowej silnika wybranego pojazdu. Do 3 pojazdów (3×SN61). int b; switch (VehN) @@ -2871,7 +2871,7 @@ bool TMoverParameters::DecScndCtrl(int CtrlSpeed) return OK; } -int TMoverParameters::GetVirtualScndPos() +int TMoverParameters::GetVirtualScndPos() const { if (TrainType == dt_ET42) { @@ -5187,7 +5187,7 @@ double TMoverParameters::BrakeForceR(double ratio, double velocity) return BrakeForceP(press * ratio, velocity); } -double TMoverParameters::BrakeForceP(double press, double velocity) +double TMoverParameters::BrakeForceP(double press, double velocity) const { double BFP = 0; double K = ((press * P2FTrans - BrakeCylSpring) * BrakeCylMult[0] - BrakeSlckAdj) * BrakeRigEff; @@ -6768,7 +6768,7 @@ double TMoverParameters::v2n(void) // Q: 20160714 // Oblicza moment siły wytwarzany przez silnik // ************************************************************************************************* -double TMoverParameters::Momentum(double I) +double TMoverParameters::Momentum(double I) const { // liczy moment sily wytwarzany przez silnik elektryczny} int SP; @@ -6786,7 +6786,7 @@ double TMoverParameters::Momentum(double I) // Q: 20160714 // Oblicza moment siły do sterowania wzbudzeniem // ************************************************************************************************* -double TMoverParameters::MomentumF(double I, double Iw, int SCP) +double TMoverParameters::MomentumF(double I, double Iw, int SCP) const { // umozliwia dokladne sterowanie wzbudzeniem @@ -11735,7 +11735,7 @@ void TMoverParameters::LoadFIZ_PowerParamsDecode(TPowerParameters &Powerparamete } } -TPowerType TMoverParameters::LoadFIZ_PowerDecode(std::string const &Power) +TPowerType TMoverParameters::LoadFIZ_PowerDecode(std::string const &Power) const { std::map powertypes{ @@ -11744,7 +11744,7 @@ TPowerType TMoverParameters::LoadFIZ_PowerDecode(std::string const &Power) return lookup != powertypes.end() ? lookup->second : TPowerType::NoPower; } -TPowerSource TMoverParameters::LoadFIZ_SourceDecode(std::string const &Source) +TPowerSource TMoverParameters::LoadFIZ_SourceDecode(std::string const &Source) const { std::map powersources{{"Transducer", TPowerSource::Transducer}, {"Generator", TPowerSource::Generator}, @@ -11756,7 +11756,7 @@ TPowerSource TMoverParameters::LoadFIZ_SourceDecode(std::string const &Source) return lookup != powersources.end() ? lookup->second : TPowerSource::NotDefined; } -TEngineType TMoverParameters::LoadFIZ_EngineDecode(std::string const &Engine) +TEngineType TMoverParameters::LoadFIZ_EngineDecode(std::string const &Engine) const { std::map enginetypes{{"ElectricSeriesMotor", TEngineType::ElectricSeriesMotor}, @@ -12187,7 +12187,7 @@ void TMoverParameters::PutCommand(std::string NewCommand, double NewValue1, doub // Q: 20160714 // Pobiera komendę z parametru funkcji oraz wartość zmiennej jako return // ************************************************************************************************* -double TMoverParameters::GetExternalCommand(std::string &Command) +double TMoverParameters::GetExternalCommand(std::string &Command) const { Command = CommandOut; return ValueOut; diff --git a/McZapkie/Oerlikon_ESt.cpp b/McZapkie/Oerlikon_ESt.cpp index 6ea9ba7a..52b69deb 100644 --- a/McZapkie/Oerlikon_ESt.cpp +++ b/McZapkie/Oerlikon_ESt.cpp @@ -294,7 +294,7 @@ double TNESt3::GetPF( double const PP, double const dt, double const Vel ) // pr return dV - dV1; } -void TNESt3::EStParams( double const /*i_crc*/ ) // parametry charakterystyczne dla ESt +void TNESt3::EStParams( double const /*i_crc*/ ) const // parametry charakterystyczne dla ESt { } @@ -384,7 +384,7 @@ void TNESt3::CheckReleaser(double const dt) // odluzniacz } } -double TNESt3::CVs(double const /*BP*/) // napelniacz sterujacego +double TNESt3::CVs(double const /*BP*/) const // napelniacz sterujacego { double const CVP{ CntrlRes->P() }; double const MPP{ Miedzypoj->P() }; @@ -398,7 +398,7 @@ double TNESt3::CVs(double const /*BP*/) // napelniacz sterujacego return Nozzles[dSm]; } -double TNESt3::BVs(double const BCP) // napelniacz pomocniczego +double TNESt3::BVs(double const BCP) const // napelniacz pomocniczego { double const CVP{ CntrlRes->P() }; double const MPP{ Miedzypoj->P() }; diff --git a/McZapkie/Oerlikon_ESt.h b/McZapkie/Oerlikon_ESt.h index 1f2e71c6..e336dc55 100644 --- a/McZapkie/Oerlikon_ESt.h +++ b/McZapkie/Oerlikon_ESt.h @@ -208,12 +208,12 @@ class TNESt3 : public TBrake { {} void Init( double const PP, double const HPP, double const LPP, double const BP, int const BDF ) override; double GetPF( double const PP, double const dt, double const Vel ) override; // przeplyw miedzy komora wstepna i PG - void EStParams(double i_crc); // parametry charakterystyczne dla ESt + void EStParams(double i_crc) const; // parametry charakterystyczne dla ESt double GetCRP() override; void CheckState(double const BCP, double &dV1); // glowny przyrzad rozrzadczy void CheckReleaser(double const dt); // odluzniacz - double CVs(double const BP); // napelniacz sterujacego - double BVs(double const BCP); // napelniacz pomocniczego + double CVs(double const BP) const; // napelniacz sterujacego + double BVs(double const BCP) const; // napelniacz pomocniczego void SetSize( int const size, std::string const ¶ms ); // ustawianie dysz (rozmiaru ZR), przekladniki void PLC(double const mass) override; // wspolczynnik cisnienia przystawki wazacej void SetLP(double const TM, double const LM, double const TBP) override; // parametry przystawki wazacej diff --git a/McZapkie/hamulce.cpp b/McZapkie/hamulce.cpp index dca30aee..d4693b8c 100644 --- a/McZapkie/hamulce.cpp +++ b/McZapkie/hamulce.cpp @@ -450,7 +450,7 @@ double TBrake::GetFC(double const Vel, double const N) /// Returns the gauge pressure inside the brake cylinder. // cisnienie cylindra hamulcowego -double TBrake::GetBCP() +double TBrake::GetBCP() const { return BrakeCyl->P(); } @@ -464,14 +464,14 @@ double TBrake::GetEDBCP() /// Returns the auxiliary reservoir (ZP) pressure. // cisnienie zbiornika pomocniczego -double TBrake::GetBRP() +double TBrake::GetBRP() const { return BrakeRes->P(); } /// Returns the valve pre-chamber pressure. // cisnienie komory wstepnej -double TBrake::GetVRP() +double TBrake::GetVRP() const { return ValveRes->P(); } @@ -516,7 +516,7 @@ double TBrake::GetHPFlow(double const HP, double const dt) /// /// Returns the piston force from the cylinder pressure (BCA * 100 * P). /// -double TBrake::GetBCF() +double TBrake::GetBCF() const { return BCA * 100 * BrakeCyl->P(); } @@ -572,7 +572,7 @@ void TBrake::ASB(int const state) } /// Returns the raw BrakeStatus bitfield. -int TBrake::GetStatus() +int TBrake::GetStatus() const { return BrakeStatus; } @@ -927,7 +927,7 @@ void TESt::CheckState(double const BCP, double & /*dV1*/) /// /// Brake cylinder (or impulse) pressure. /// Opening coefficient (0 closed, 1 fully open). -double TESt::CVs(double const BP) +double TESt::CVs(double const BP) const { double VVP; double BVP; @@ -958,7 +958,7 @@ double TESt::CVs(double const BP) /// /// Brake cylinder pressure. /// Opening coefficient. -double TESt::BVs(double const BCP) +double TESt::BVs(double const BCP) const { double VVP; double BVP; @@ -1086,7 +1086,7 @@ void TESt::Init(double const PP, double const HPP, double const LPP, double cons /// derived variants and currently a no-op. /// /// Characteristic value. -void TESt::EStParams(double const /*i_crc*/) {} +void TESt::EStParams(double const /*i_crc*/) const {} /// Returns the control reservoir (ZS) pressure. double TESt::GetCRP() @@ -2188,7 +2188,7 @@ void TCV1::CheckState(double const BCP, double &dV1) /// /// Cylinder pressure. /// Opening coefficient. -double TCV1::CVs(double const BP) +double TCV1::CVs(double const BP) const { // przeplyw ZS <-> PG if (BP > 0.05) @@ -2204,7 +2204,7 @@ double TCV1::CVs(double const BP) /// /// Cylinder pressure. /// Opening coefficient. -double TCV1::BVs(double const BCP) +double TCV1::BVs(double const BCP) const { double VVP; double BVP; @@ -2578,7 +2578,7 @@ void TKE::CheckState(double const BCP, double & /*dV1*/) /// /// Cylinder (or impulse) pressure. /// Opening coefficient. -double TKE::CVs(double const BP) +double TKE::CVs(double const BP) const { double VVP; double BVP; @@ -2604,7 +2604,7 @@ double TKE::CVs(double const BP) /// /// Impulse-chamber pressure. /// Opening coefficient. -double TKE::BVs(double const /*BCP*/) +double TKE::BVs(double const /*BCP*/) const { double VVP; double BVP; @@ -3239,7 +3239,7 @@ double TFV4aM::GetRP() /// /// Continuous handle position. /// Interpolated target pressure [bar]. -double TFV4aM::LPP_RP(double pos) // cisnienie z zaokraglonej pozycji; +double TFV4aM::LPP_RP(double pos) const // cisnienie z zaokraglonej pozycji; { int const i_pos = static_cast(2 + std::floor(pos)); // zaokraglone w dol @@ -3248,7 +3248,7 @@ double TFV4aM::LPP_RP(double pos) // cisnienie z zaokraglonej pozycji; /// Returns true if pos is within ±0.5 of i_pos (detent test). /// Continuous handle position. /// Detent centre. -bool TFV4aM::EQ(double pos, double i_pos) +bool TFV4aM::EQ(double pos, double i_pos) const { return pos <= i_pos + 0.5 && pos > i_pos - 0.5; } @@ -3425,7 +3425,7 @@ double TMHZ_EN57::GetEP(double pos) /// /// Continuous handle position. /// Target brake-pipe pressure [bar]. -double TMHZ_EN57::LPP_RP(double pos) // cisnienie z zaokraglonej pozycji; +double TMHZ_EN57::LPP_RP(double pos) const // cisnienie z zaokraglonej pozycji; { if (pos > 8.5) return 5.0 - 0.15 * pos - 0.35; @@ -3456,7 +3456,7 @@ void TMHZ_EN57::SetParams(bool AO, bool MO, double OverP, double, double OMP, do } /// Returns true if pos is within ±0.5 of i_pos (detent test). -bool TMHZ_EN57::EQ(double pos, double i_pos) +bool TMHZ_EN57::EQ(double pos, double i_pos) const { return pos <= i_pos + 0.5 && pos > i_pos - 0.5; } @@ -3636,7 +3636,7 @@ void TMHZ_K5P::SetParams(bool AO, bool MO, double OverP, double FSF, double OMP, } /// Returns true if pos is within ±0.5 of i_pos (detent test). -bool TMHZ_K5P::EQ(double pos, double i_pos) +bool TMHZ_K5P::EQ(double pos, double i_pos) const { return pos <= i_pos + 0.5 && pos > i_pos - 0.5; } @@ -3815,7 +3815,7 @@ void TMHZ_6P::SetParams(bool AO, bool MO, double OverP, double FSF, double OMP, } /// Returns true if pos is within ±0.5 of i_pos (detent test). -bool TMHZ_6P::EQ(double pos, double i_pos) +bool TMHZ_6P::EQ(double pos, double i_pos) const { return pos <= i_pos + 0.5 && pos > i_pos - 0.5; } diff --git a/McZapkie/hamulce.h b/McZapkie/hamulce.h index 47fb7913..9df2b88c 100644 --- a/McZapkie/hamulce.h +++ b/McZapkie/hamulce.h @@ -399,7 +399,7 @@ class TBrake /// Returns the piston force produced by the brake cylinder pressure. /// /// Force in arbitrary engine units (BCA * 100 * P). - double GetBCF(); // sila tlokowa z tloka + double GetBCF() const; // sila tlokowa z tloka /// /// Computes the airflow drawn from the high-pressure (8 bar / main) line for one step. /// @@ -408,16 +408,16 @@ class TBrake /// Net flow from the high-pressure line. virtual double GetHPFlow(double const HP, double const dt); // przeplyw - 8 bar /// Returns brake cylinder gauge pressure [bar]. - double GetBCP(); // cisnienie cylindrow hamulcowych + double GetBCP() const; // cisnienie cylindrow hamulcowych /// /// Returns brake cylinder pressure originating only from the pneumatic /// (main) brake — used to drive the ED (electrodynamic) brake e.g. in EP09. /// virtual double GetEDBCP(); // cisnienie tylko z hamulca zasadniczego, uzywane do hamulca ED w EP09 /// Returns auxiliary reservoir (ZP) pressure [bar]. - double GetBRP(); // cisnienie zbiornika pomocniczego + double GetBRP() const; // cisnienie zbiornika pomocniczego /// Returns valve pre-chamber pressure [bar]. - double GetVRP(); // cisnienie komory wstepnej rozdzielacza + double GetVRP() const; // cisnienie komory wstepnej rozdzielacza /// Returns control reservoir (ZS) pressure [bar]; defaults to the auxiliary reservoir for valves without a dedicated ZS. virtual double GetCRP(); // cisnienie zbiornika sterujacego /// @@ -468,7 +468,7 @@ class TBrake /// Two-bit value: bit1 = hold (b_asb), bit0 = release (b_asb_unbrake). void ASB(int state); // hamulec przeciwposlizgowy /// Returns the raw BrakeStatus flags (for sound/visual cues). - int GetStatus(); // flaga statusu, moze sie przydac do odglosow + int GetStatus() const; // flaga statusu, moze sie przydac do odglosow /// Sets the anti-slip target pressure. /// Pressure [bar]. void SetASBP(double const Press); // ustalenie cisnienia pp @@ -581,7 +581,7 @@ class TESt : public TBrake double GetPF(double const PP, double const dt, double const Vel) override; // przeplyw miedzy komora wstepna i PG /// Sets ESt-specific characteristic parameters (placeholder; used by some variants). /// Characteristic value. - void EStParams(double i_crc); // parametry charakterystyczne dla ESt + void EStParams(double i_crc) const; // parametry charakterystyczne dla ESt /// Returns the control reservoir (ZS) pressure. double GetCRP() override; /// @@ -601,14 +601,14 @@ class TESt : public TBrake /// /// Cylinder pressure (or impulse-chamber pressure). /// Dimensionless opening coefficient. - double CVs(double BP); // napelniacz sterujacego + double CVs(double BP) const; // napelniacz sterujacego /// /// Returns the effective opening factor of the auxiliary-reservoir filling /// slide valve (ZP <-> pre-chamber path). /// /// Brake cylinder pressure. /// Dimensionless opening coefficient. - double BVs(double BCP); // napelniacz pomocniczego + double BVs(double BCP) const; // napelniacz pomocniczego /// Vents the valve, brake and control reservoirs to zero. void ForceEmptiness() override; // wymuszenie bycia pustym @@ -874,9 +874,9 @@ class TCV1 : public TBrake /// In/out brake pipe flow correction. void CheckState(double const BCP, double &dV1); /// Returns the ZS-filling slide valve opening factor for the given cylinder pressure. - double CVs(double const BP); + double CVs(double const BP) const; /// Returns the ZP-filling slide valve opening factor for the given cylinder pressure. - double BVs(double const BCP); + double BVs(double const BCP) const; /// Vents valve, brake and control reservoirs to zero. void ForceEmptiness() override; // wymuszenie bycia pustym @@ -982,9 +982,9 @@ class TKE : public TBrake /// Drives the releaser logic for KE — bleeds the control reservoir while engaged. void CheckReleaser(double const dt); // odluzniacz /// ZS-filling slide valve opening factor for the given cylinder pressure. - double CVs(double const BP); // napelniacz sterujacego + double CVs(double const BP) const; // napelniacz sterujacego /// ZP-filling slide valve opening factor for the given cylinder pressure. - double BVs(double const BCP); // napelniacz pomocniczego + double BVs(double const BCP) const; // napelniacz pomocniczego /// Recomputes LoadC for the current vehicle mass. void PLC(double const mass) override; // wspolczynnik cisnienia przystawki wazacej /// Stores the load-weighing parameters. @@ -1140,9 +1140,9 @@ class TFV4aM : public TDriverHandle /// Returns the brake pipe pressure target interpolated from BPT[] for the given handle position. /// /// Handle position. - double LPP_RP(double pos); + double LPP_RP(double pos) const; /// Returns true if pos is within ±0.5 of i_pos (detent comparison). - bool EQ(double pos, double i_pos); + bool EQ(double pos, double i_pos) const; public: /// Computes brake pipe flow for the FV4a/M handle (interpolated BPT, wave modelling, accelerator). @@ -1190,9 +1190,9 @@ class TMHZ_EN57 : public TDriverHandle static double const pos_table[11]; //= { -2, 10, -1, 0, 0, 2, 9, 10, 0, 0, 0 }; /// Returns the brake pipe pressure target for the given handle position (piecewise). - double LPP_RP(double pos); + double LPP_RP(double pos) const; /// Returns true if pos is within ±0.5 of i_pos. - bool EQ(double pos, double i_pos); + bool EQ(double pos, double i_pos) const; public: /// Computes brake pipe flow for MHZ_EN57 (covers handle positions -1..10 with EP/pneumatic mix). @@ -1246,7 +1246,7 @@ class TMHZ_K5P : public TDriverHandle static double const pos_table[11]; //= { -2, 10, -1, 0, 0, 2, 9, 10, 0, 0, 0 }; /// Returns true if pos is within ±0.5 of i_pos. - bool EQ(double pos, double i_pos); + bool EQ(double pos, double i_pos) const; public: /// Computes brake pipe flow for the K5P 5-position handle (release / cut-off / brake / emergency). @@ -1299,7 +1299,7 @@ class TMHZ_6P : public TDriverHandle static double const pos_table[11]; //= { -2, 10, -1, 0, 0, 2, 9, 10, 0, 0, 0 }; /// Returns true if pos is within ±0.5 of i_pos. - bool EQ(double pos, double i_pos); + bool EQ(double pos, double i_pos) const; public: /// Computes brake pipe flow for the 6P handle. diff --git a/application/applicationmode.h b/application/applicationmode.h index feea3bdb..4f32fc5f 100644 --- a/application/applicationmode.h +++ b/application/applicationmode.h @@ -25,19 +25,19 @@ public: virtual bool update() = 0; // draws mode-specific user interface inline - void render_ui() { + void render_ui() const { if( m_userinterface != nullptr ) { m_userinterface->render(); } } inline - void begin_ui_frame() { + void begin_ui_frame() const { if( m_userinterface != nullptr ) { m_userinterface->begin_ui_frame(); } } inline - void set_progress( float const Progress = 0.f, float const Subtaskprogress = 0.f ) { + void set_progress( float const Progress = 0.f, float const Subtaskprogress = 0.f ) const { if( m_userinterface != nullptr ) { m_userinterface->set_progress( Progress, Subtaskprogress ); } } inline - void set_tooltip( std::string const &Tooltip ) { + void set_tooltip( std::string const &Tooltip ) const { if( m_userinterface != nullptr ) { m_userinterface->set_tooltip( Tooltip ); } } // maintenance method, called when the mode is activated diff --git a/application/driveruipanels.cpp b/application/driveruipanels.cpp index d39296f4..203a9245 100644 --- a/application/driveruipanels.cpp +++ b/application/driveruipanels.cpp @@ -1057,7 +1057,7 @@ debug_panel::update_vehicle_brake() const { } void -debug_panel::update_section_engine( std::vector &Output ) { +debug_panel::update_section_engine( std::vector &Output ) const { if( m_input.vehicle == nullptr ) { return; } if( m_input.mover == nullptr ) { return; } @@ -1138,7 +1138,7 @@ debug_panel::update_section_engine( std::vector &Output ) { } void -debug_panel::update_section_ai( std::vector &Output ) { +debug_panel::update_section_ai( std::vector &Output ) const { if( m_input.mover == nullptr ) { return; } if( m_input.mechanik == nullptr ) { return; } @@ -1262,7 +1262,7 @@ debug_panel::update_section_ai( std::vector &Output ) { } void -debug_panel::update_section_scantable( std::vector &Output ) { +debug_panel::update_section_scantable( std::vector &Output ) const { if( m_input.mechanik == nullptr ) { return; } @@ -1284,7 +1284,7 @@ debug_panel::update_section_scantable( std::vector &Output ) { #ifdef WITH_UART void -debug_panel::update_section_uart( std::vector &Output ) { +debug_panel::update_section_uart( std::vector &Output ) const { uart_status *status = &UartStatus; Output.emplace_back( @@ -1312,7 +1312,7 @@ debug_panel::update_section_uart( std::vector &Output ) { #endif void -debug_panel::update_section_scenario( std::vector &Output ) { +debug_panel::update_section_scenario( std::vector &Output ) const { auto textline = "vehicles: " + to_string( Timer::subsystem.sim_dynamics.average(), 2 ) + " msec" @@ -1378,7 +1378,7 @@ debug_panel::update_section_eventqueue( std::vector &Output ) { } void -debug_panel::update_section_powergrid( std::vector &Output ) { +debug_panel::update_section_powergrid( std::vector &Output ) const { auto const lowpowercolor { glm::vec4( 164.0f / 255.0f, 132.0f / 255.0f, 84.0f / 255.0f, 1.f ) }; auto const nopowercolor { glm::vec4( 164.0f / 255.0f, 84.0f / 255.0f, 84.0f / 255.0f, 1.f ) }; @@ -1420,7 +1420,7 @@ debug_panel::update_section_powergrid( std::vector &Output ) { } void -debug_panel::update_section_camera( std::vector &Output ) { +debug_panel::update_section_camera( std::vector &Output ) const { if( m_input.camera == nullptr ) { return; } @@ -1446,7 +1446,7 @@ debug_panel::update_section_camera( std::vector &Output ) { } void -debug_panel::update_section_renderer( std::vector &Output ) { +debug_panel::update_section_renderer( std::vector &Output ) const { // gfx renderer data auto textline = @@ -1526,7 +1526,7 @@ debug_panel::render_section( std::string const &Header, std::vector c } bool -debug_panel::render_section( std::vector const &Lines ) { +debug_panel::render_section( std::vector const &Lines ) const { for( auto const &line : Lines ) { ImGui::PushStyleColor( ImGuiCol_Text, { line.color.r, line.color.g, line.color.b, line.color.a } ); @@ -1537,7 +1537,7 @@ debug_panel::render_section( std::vector const &Lines ) { return true; } -bool debug_panel::render_section_developer() +bool debug_panel::render_section_developer() const { if (false == ImGui::CollapsingHeader("Developer tools")) return false; @@ -1553,7 +1553,7 @@ bool debug_panel::render_section_developer() } bool -debug_panel::render_section_settings() { +debug_panel::render_section_settings() const { if( false == ImGui::CollapsingHeader( "Settings" ) ) { return false; } diff --git a/application/driveruipanels.h b/application/driveruipanels.h index fe35e1d7..84aec269 100644 --- a/application/driveruipanels.h +++ b/application/driveruipanels.h @@ -81,27 +81,27 @@ private: // methods // generate and send section data to provided output void update_section_vehicle( std::vector &Output ); - void update_section_engine( std::vector &Output ); - void update_section_ai( std::vector &Output ); - void update_section_scantable( std::vector &Output ); - void update_section_scenario( std::vector &Output ); + void update_section_engine( std::vector &Output ) const; + void update_section_ai( std::vector &Output ) const; + void update_section_scantable( std::vector &Output ) const; + void update_section_scenario( std::vector &Output ) const; void update_section_eventqueue( std::vector &Output ); - void update_section_powergrid( std::vector &Output ); - void update_section_camera( std::vector &Output ); - void update_section_renderer( std::vector &Output ); + void update_section_powergrid( std::vector &Output ) const; + void update_section_camera( std::vector &Output ) const; + void update_section_renderer( std::vector &Output ) const; #ifdef WITH_UART - void update_section_uart( std::vector &Output ); + void update_section_uart( std::vector &Output ) const; #endif // section update helpers std::string update_vehicle_coupler( int const Side ); std::string update_vehicle_brake() const; // renders provided lines, under specified collapsing header bool render_section( std::string const &Header, std::vector const &Lines ); - bool render_section( std::vector const &Lines ); + bool render_section( std::vector const &Lines ) const; bool render_section_scenario(); bool render_section_eventqueue(); - bool render_section_settings(); - bool render_section_developer(); + bool render_section_settings() const; + bool render_section_developer() const; // members std::array m_buffer; std::array m_eventsearch; diff --git a/environment/skydome.cpp b/environment/skydome.cpp index c1b1729b..6af83aaa 100644 --- a/environment/skydome.cpp +++ b/environment/skydome.cpp @@ -146,7 +146,7 @@ void CSkyDome::SetOvercastFactor( float const Overcast ) { m_overcast = std::clamp( Overcast, 0.0f, 1.0f ) * 0.75f; // going above 0.65 makes the model go pretty bad, appearance-wise } -void CSkyDome::GetPerez( float *Perez, float Distribution[ 5 ][ 2 ], const float Turbidity ) { +void CSkyDome::GetPerez( float *Perez, float Distribution[ 5 ][ 2 ], const float Turbidity ) const { Perez[ 0 ] = Distribution[ 0 ][ 0 ] * Turbidity + Distribution[ 0 ][ 1 ]; Perez[ 1 ] = Distribution[ 1 ][ 0 ] * Turbidity + Distribution[ 1 ][ 1 ]; @@ -155,7 +155,7 @@ void CSkyDome::GetPerez( float *Perez, float Distribution[ 5 ][ 2 ], const float Perez[ 4 ] = Distribution[ 4 ][ 0 ] * Turbidity + Distribution[ 4 ][ 1 ]; } -float CSkyDome::GetZenith( float Zenithmatrix[ 3 ][ 4 ], const float Theta, const float Turbidity ) { +float CSkyDome::GetZenith( float Zenithmatrix[ 3 ][ 4 ], const float Theta, const float Turbidity ) const { const float theta2 = Theta*Theta; const float theta3 = Theta*theta2; @@ -166,7 +166,7 @@ float CSkyDome::GetZenith( float Zenithmatrix[ 3 ][ 4 ], const float Theta, cons } -float CSkyDome::PerezFunctionO1( float Perezcoeffs[ 5 ], const float Thetasun, const float Zenithval ) { +float CSkyDome::PerezFunctionO1( float Perezcoeffs[ 5 ], const float Thetasun, const float Zenithval ) const { const float val = static_cast(( 1.0f + Perezcoeffs[ 0 ] * std::exp( Perezcoeffs[ 1 ] ) ) * ( 1.0f + Perezcoeffs[ 2 ] * std::exp( Perezcoeffs[ 3 ] * Thetasun ) + Perezcoeffs[ 4 ] * std::pow( std::cos( Thetasun ), 2 ) )); @@ -174,7 +174,7 @@ float CSkyDome::PerezFunctionO1( float Perezcoeffs[ 5 ], const float Thetasun, c return Zenithval / val; } -float CSkyDome::PerezFunctionO2( float Perezcoeffs[ 5 ], const float Icostheta, const float Gamma, const float Cosgamma2, const float Zenithval ) { +float CSkyDome::PerezFunctionO2( float Perezcoeffs[ 5 ], const float Icostheta, const float Gamma, const float Cosgamma2, const float Zenithval ) const { // iCosTheta = 1.0f / cosf(theta) // cosGamma2 = SQR( cosf( gamma ) ) return Zenithval * ( 1.0f + Perezcoeffs[ 0 ] * std::exp( Perezcoeffs[ 1 ] * Icostheta ) ) * diff --git a/environment/skydome.h b/environment/skydome.h index 7ee4c9e0..bf5f8533 100644 --- a/environment/skydome.h +++ b/environment/skydome.h @@ -20,8 +20,8 @@ public: void Update( glm::vec3 const &Sun ); // retrieves average colour of the sky dome - glm::vec3 GetAverageColor() { return m_averagecolour * 8.f / 6.f; } - glm::vec3 GetAverageHorizonColor() { return m_averagehorizoncolour; } + glm::vec3 GetAverageColor() const { return m_averagecolour * 8.f / 6.f; } + glm::vec3 GetAverageHorizonColor() const { return m_averagehorizoncolour; } std::vector const & vertices() const { return m_vertices; } @@ -60,9 +60,9 @@ private: static float m_zenithymatrix[ 3 ][ 4 ]; // coloring - void GetPerez( float *Perez, float Distribution[ 5 ][ 2 ], const float Turbidity ); - float GetZenith( float Zenithmatrix[ 3 ][ 4 ], const float Theta, const float Turbidity ); - float PerezFunctionO1( float Perezcoeffs[ 5 ], const float Thetasun, const float Zenithval ); - float PerezFunctionO2( float Perezcoeffs[ 5 ], const float Icostheta, const float Gamma, const float Cosgamma2, const float Zenithval ); + void GetPerez( float *Perez, float Distribution[ 5 ][ 2 ], const float Turbidity ) const; + float GetZenith( float Zenithmatrix[ 3 ][ 4 ], const float Theta, const float Turbidity ) const; + float PerezFunctionO1( float Perezcoeffs[ 5 ], const float Thetasun, const float Zenithval ) const; + float PerezFunctionO2( float Perezcoeffs[ 5 ], const float Icostheta, const float Gamma, const float Cosgamma2, const float Zenithval ) const; }; diff --git a/gl/buffer.cpp b/gl/buffer.cpp index b80cee3e..04ec479c 100644 --- a/gl/buffer.cpp +++ b/gl/buffer.cpp @@ -22,7 +22,7 @@ GLenum gl::buffer::glenum_target(gl::buffer::targets target) return mapping[target]; } -void gl::buffer::bind(targets target) +void gl::buffer::bind(targets target) const { if (binding_points[target] == *this) return; @@ -31,7 +31,7 @@ void gl::buffer::bind(targets target) binding_points[target] = *this; } -void gl::buffer::bind_base(targets target, GLuint index) +void gl::buffer::bind_base(targets target, GLuint index) const { glBindBufferBase(glenum_target(target), index, *this); binding_points[target] = *this; diff --git a/gl/buffer.h b/gl/buffer.h index 8b4e7d9c..3e66b516 100644 --- a/gl/buffer.h +++ b/gl/buffer.h @@ -34,8 +34,8 @@ namespace gl buffer(); ~buffer(); - void bind(targets target); - void bind_base(targets target, GLuint index); + void bind(targets target) const; + void bind_base(targets target, GLuint index) const; static void unbind(targets target); static void unbind(); diff --git a/gl/cubemap.cpp b/gl/cubemap.cpp index ca0e6c08..07aa1b1c 100644 --- a/gl/cubemap.cpp +++ b/gl/cubemap.cpp @@ -15,7 +15,7 @@ gl::cubemap::~cubemap() glDeleteTextures(1, *this); } -void gl::cubemap::alloc(GLint format, int width, int height, GLenum components, GLenum type) +void gl::cubemap::alloc(GLint format, int width, int height, GLenum components, GLenum type) const { glBindTexture(GL_TEXTURE_CUBE_MAP, *this); for (GLuint tgt = GL_TEXTURE_CUBE_MAP_POSITIVE_X; tgt <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z; tgt++) @@ -29,13 +29,13 @@ void gl::cubemap::alloc(GLint format, int width, int height, GLenum components, glBindTexture(GL_TEXTURE_CUBE_MAP, 0); } -void gl::cubemap::bind(int unit) +void gl::cubemap::bind(int unit) const { glActiveTexture(unit); glBindTexture(GL_TEXTURE_CUBE_MAP, *this); } -void gl::cubemap::generate_mipmaps() +void gl::cubemap::generate_mipmaps() const { glBindTexture(GL_TEXTURE_CUBE_MAP, *this); glGenerateMipmap(GL_TEXTURE_CUBE_MAP); diff --git a/gl/cubemap.h b/gl/cubemap.h index e874c221..f5706b65 100644 --- a/gl/cubemap.h +++ b/gl/cubemap.h @@ -12,8 +12,8 @@ namespace gl cubemap(); ~cubemap(); - void alloc(GLint format, int width, int height, GLenum components, GLenum type); - void bind(int unit); - void generate_mipmaps(); + void alloc(GLint format, int width, int height, GLenum components, GLenum type) const; + void bind(int unit) const; + void generate_mipmaps() const; }; } diff --git a/gl/query.cpp b/gl/query.cpp index 3f3b56af..ab58f0cf 100644 --- a/gl/query.cpp +++ b/gl/query.cpp @@ -49,7 +49,7 @@ std::optional gl::query::result() return std::nullopt; } -GLenum gl::query::glenum_target(targets target) +GLenum gl::query::glenum_target(targets target) const { static GLenum mapping[6] = { diff --git a/gl/query.h b/gl/query.h index 83114092..67e62b4f 100644 --- a/gl/query.h +++ b/gl/query.h @@ -22,7 +22,7 @@ private: thread_local static query* active_queries[6]; protected: - GLenum glenum_target(targets target); + GLenum glenum_target(targets target) const; public: query(targets target); diff --git a/gl/shader.cpp b/gl/shader.cpp index 79948a3e..cb18c6f4 100644 --- a/gl/shader.cpp +++ b/gl/shader.cpp @@ -52,7 +52,7 @@ bool has_gl_extension(char const *name) { } // anonymous namespace -std::string gl::shader::read_file(const std::string &filename) +std::string gl::shader::read_file(const std::string &filename) const { std::stringstream stream; std::ifstream f; @@ -299,7 +299,7 @@ void gl::shader::parse_param_entries(std::string &str) } } -void gl::shader::log_error(const std::string &str) +void gl::shader::log_error(const std::string &str) const { ErrorLog("bad shader: " + name + ": " + str, logtype::shader); } diff --git a/gl/shader.h b/gl/shader.h index 4cd25f07..fdda9af8 100644 --- a/gl/shader.h +++ b/gl/shader.h @@ -73,12 +73,12 @@ namespace gl void parse_texture_entries(std::string &str); void parse_param_entries(std::string &str); - std::string read_file(const std::string &filename); + std::string read_file(const std::string &filename) const; static std::unordered_map components_mapping; static std::unordered_map defaultparams_mapping; - void log_error(const std::string &str); + void log_error(const std::string &str) const; }; class program : public object, public bindable diff --git a/input/command.cpp b/input/command.cpp index 9a373fef..89a35846 100644 --- a/input/command.cpp +++ b/input/command.cpp @@ -854,7 +854,7 @@ command_queue::pop( command_data &Command, uint32_t const Recipient ) { return true; } -bool command_queue::is_network_target(uint32_t const Recipient) { +bool command_queue::is_network_target(uint32_t const Recipient) const { const command_target target = (command_target)(Recipient & ~0xffff); if (target == command_target::entity) diff --git a/input/command.h b/input/command.h index f6252f04..226813d8 100644 --- a/input/command.h +++ b/input/command.h @@ -469,7 +469,7 @@ public: update(); // checks if given command must be scheduled on server bool - is_network_target(const uint32_t Recipient); + is_network_target(const uint32_t Recipient) const; // pops commands from intercept queue commands_map pop_intercept_queue(); diff --git a/input/drivermouseinput.cpp b/input/drivermouseinput.cpp index 874c96a7..20ba1abf 100644 --- a/input/drivermouseinput.cpp +++ b/input/drivermouseinput.cpp @@ -1116,7 +1116,7 @@ drivermouse_input::default_bindings() { } user_command -drivermouse_input::adjust_command( user_command Command ) { +drivermouse_input::adjust_command( user_command Command ) const { if( true == Global.shiftState && Command != user_command::none ) { diff --git a/input/drivermouseinput.h b/input/drivermouseinput.h index c64797c5..180e0335 100644 --- a/input/drivermouseinput.h +++ b/input/drivermouseinput.h @@ -91,7 +91,7 @@ private: default_bindings(); // potentially replaces supplied command with a more relevant one user_command - adjust_command( user_command Command ); + adjust_command( user_command Command ) const; // members command_relay m_relay; diff --git a/input/gamepadinput.cpp b/input/gamepadinput.cpp index b0024181..6d603815 100644 --- a/input/gamepadinput.cpp +++ b/input/gamepadinput.cpp @@ -125,7 +125,7 @@ gamepad_input::poll() { } void -gamepad_input::bind( std::vector< std::reference_wrapper > &Targets, cParser &Input, std::unordered_map const &Translator, std::string const Point ) { +gamepad_input::bind( std::vector< std::reference_wrapper > &Targets, cParser &Input, std::unordered_map const &Translator, std::string const Point ) const { for( auto &bindingtarget : Targets ) { // grab command(s) associated with the input pin diff --git a/input/gamepadinput.h b/input/gamepadinput.h index ba8d4e38..e5648a0d 100644 --- a/input/gamepadinput.h +++ b/input/gamepadinput.h @@ -77,7 +77,7 @@ private: using inputaxis_sequence = std::vector; // methods bool recall_bindings(); - void bind( std::vector< std::reference_wrapper > &Targets, cParser &Input, std::unordered_map const &Translator, std::string const Point ); + void bind( std::vector< std::reference_wrapper > &Targets, cParser &Input, std::unordered_map const &Translator, std::string const Point ) const; void on_button( int const Button, int const Action ); void process_axes(); diff --git a/input/keyboardinput.cpp b/input/keyboardinput.cpp index 8e089213..922f4405 100644 --- a/input/keyboardinput.cpp +++ b/input/keyboardinput.cpp @@ -225,7 +225,7 @@ keyboard_input::recall_bindings() { return true; } -void keyboard_input::dump_bindings() +void keyboard_input::dump_bindings() const { std::fstream stream("eu07_input-keyboard.ini", std::ios_base::binary | std::ios_base::trunc | std::ios_base::out); diff --git a/input/keyboardinput.h b/input/keyboardinput.h index 1c1b5f2a..832d5eef 100644 --- a/input/keyboardinput.h +++ b/input/keyboardinput.h @@ -67,7 +67,7 @@ public: std::string binding_hint( user_command const Command ) const; void - dump_bindings(); + dump_bindings() const; // members static std::unordered_map keytonamemap; diff --git a/launcher/textures_scanner.cpp b/launcher/textures_scanner.cpp index f057acf1..86c19e24 100644 --- a/launcher/textures_scanner.cpp +++ b/launcher/textures_scanner.cpp @@ -145,7 +145,7 @@ void ui::vehicles_bank::parse_texture_info(const std::string &target, const std: vehicle->matching_skinsets.push_back(std::make_shared(std::move(set))); } -std::shared_ptr ui::vehicles_bank::parse_meta(const std::string &str) +std::shared_ptr ui::vehicles_bank::parse_meta(const std::string &str) const { std::istringstream stream(str); diff --git a/launcher/textures_scanner.h b/launcher/textures_scanner.h index affa0b94..5f4cb084 100644 --- a/launcher/textures_scanner.h +++ b/launcher/textures_scanner.h @@ -87,7 +87,7 @@ private: void parse_texture_rule(const std::string &target, const std::string ¶m); void parse_texture_info(const std::string &target, const std::string ¶m, std::shared_ptr meta); - std::shared_ptr parse_meta(const std::string &str); + std::shared_ptr parse_meta(const std::string &str) const; std::shared_ptr get_vehicle(const std::string &name); vehicle_type ctx_type = vehicle_type::unknown; diff --git a/network/backend/asio.cpp b/network/backend/asio.cpp index 11e0ac6d..f0d03641 100644 --- a/network/backend/asio.cpp +++ b/network/backend/asio.cpp @@ -91,7 +91,7 @@ void network::tcp::connection::handle_data(const asio::error_code &err, size_t b read_header(); } -void network::tcp::connection::write_message(const message &msg, std::ostream &stream) +void network::tcp::connection::write_message(const message &msg, std::ostream &stream) const { size_t beg = (size_t)stream.tellp(); @@ -198,7 +198,7 @@ void network::tcp::client::connect() } -void network::tcp::client::handle_accept(const asio::error_code &err) +void network::tcp::client::handle_accept(const asio::error_code &err) const { if (!err) { diff --git a/network/backend/asio.h b/network/backend/asio.h index b508e60f..68b63e2f 100644 --- a/network/backend/asio.h +++ b/network/backend/asio.h @@ -32,7 +32,7 @@ namespace network::tcp std::string m_header_buffer; std::string m_body_buffer; - void write_message(const message &msg, std::ostream &stream); + void write_message(const message &msg, std::ostream &stream) const; void send_data(std::shared_ptr buffer); void read_header(); void handle_header(const asio::error_code &err, size_t bytes_transferred); @@ -55,7 +55,7 @@ namespace network::tcp class client : public network::client { private: - void handle_accept(const asio::error_code &err); + void handle_accept(const asio::error_code &err) const; asio::io_context &io_ctx; std::string host; uint32_t port; diff --git a/network/manager.cpp b/network/manager.cpp index 0c2d50ca..e4b312df 100644 --- a/network/manager.cpp +++ b/network/manager.cpp @@ -17,7 +17,7 @@ network::server_manager::server_manager() backbuffer = std::make_shared("backbuffer.bin", std::ios::out | std::ios::in | std::ios::trunc | std::ios::binary); } -command_queue::commands_map network::server_manager::pop_commands() +command_queue::commands_map network::server_manager::pop_commands() const { command_queue::commands_map map; @@ -27,7 +27,7 @@ command_queue::commands_map network::server_manager::pop_commands() return map; } -void network::server_manager::push_delta(double render_dt, double dt, double sync, const command_queue::commands_map &commands) +void network::server_manager::push_delta(double render_dt, double dt, double sync, const command_queue::commands_map &commands) const { if (dt == 0.0 && commands.empty()) return; diff --git a/network/manager.h b/network/manager.h index 572a8c6b..85f39d6c 100644 --- a/network/manager.h +++ b/network/manager.h @@ -14,8 +14,8 @@ namespace network public: server_manager(); - void push_delta(double render_dt, double dt, double sync, const command_queue::commands_map &commands); - command_queue::commands_map pop_commands(); + void push_delta(double render_dt, double dt, double sync, const command_queue::commands_map &commands) const; + command_queue::commands_map pop_commands() const; void create_server(const std::string &backend, const std::string &conf); }; diff --git a/network/network.cpp b/network/network.cpp index 3125c5a5..615d79b5 100644 --- a/network/network.cpp +++ b/network/network.cpp @@ -220,7 +220,7 @@ std::tuple network::client::get_nex } } -void network::client::send_commands(command_queue::commands_map commands) +void network::client::send_commands(command_queue::commands_map commands) const { if (!conn || conn->state == connection::DEAD || commands.empty()) return; diff --git a/network/network.h b/network/network.h index 5f3d5cca..a0dff096 100644 --- a/network/network.h +++ b/network/network.h @@ -97,11 +97,11 @@ namespace network public: void update(); std::tuple get_next_delta(int counter); - void send_commands(command_queue::commands_map commands); - int get_frame_counter() { + void send_commands(command_queue::commands_map commands) const; + int get_frame_counter() const { return static_cast(resume_frame_counter); } - int get_awaiting_frames() { + int get_awaiting_frames() const { return static_cast(delta_queue.size()); } }; diff --git a/rendering/opengl33light.cpp b/rendering/opengl33light.cpp index ea1baf78..5b6334eb 100644 --- a/rendering/opengl33light.cpp +++ b/rendering/opengl33light.cpp @@ -16,7 +16,7 @@ void opengl33_light::apply_intensity(float const Factor) { factor = Factor; } -void opengl33_light::apply_angle() {} +void opengl33_light::apply_angle() const {} //--------------------------------------------------------------------------- diff --git a/rendering/opengl33light.h b/rendering/opengl33light.h index b87564aa..b36bad97 100644 --- a/rendering/opengl33light.h +++ b/rendering/opengl33light.h @@ -18,7 +18,7 @@ struct opengl33_light : public basic_light { float factor; void apply_intensity(float const Factor = 1.0f); - void apply_angle(); + void apply_angle() const; opengl33_light &operator=(basic_light const &Right) { basic_light::operator=(Right); diff --git a/rendering/openglgeometrybank.cpp b/rendering/openglgeometrybank.cpp index 725d76d2..d020bb56 100644 --- a/rendering/openglgeometrybank.cpp +++ b/rendering/openglgeometrybank.cpp @@ -194,7 +194,7 @@ opengl_vbogeometrybank::setup_buffer() { } void -opengl_vbogeometrybank::bind_buffer() { +opengl_vbogeometrybank::bind_buffer() const { ::glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, m_indexbuffer ); ::glBindBuffer( GL_ARRAY_BUFFER, m_vertexbuffer ); diff --git a/rendering/openglgeometrybank.h b/rendering/openglgeometrybank.h index ec6bdd89..d636a353 100644 --- a/rendering/openglgeometrybank.h +++ b/rendering/openglgeometrybank.h @@ -58,7 +58,7 @@ private: void setup_buffer(); void - bind_buffer(); + bind_buffer() const; void delete_buffer(); static diff --git a/rendering/particles.cpp b/rendering/particles.cpp index d96e5bae..01e2f21f 100644 --- a/rendering/particles.cpp +++ b/rendering/particles.cpp @@ -56,7 +56,7 @@ smoke_source::particle_emitter::deserialize( cParser &Input ) { } void -smoke_source::particle_emitter::initialize( smoke_particle &Particle ) { +smoke_source::particle_emitter::initialize( smoke_particle &Particle ) const { auto const polarangle { glm::radians( LocalRandom( inclination[ value_limit::min ], inclination[ value_limit::max ] ) ) }; // theta auto const azimuthalangle { glm::radians( LocalRandom( -180, 180 ) ) }; // phi diff --git a/rendering/particles.h b/rendering/particles.h index 5ee44230..ddc5d421 100644 --- a/rendering/particles.h +++ b/rendering/particles.h @@ -122,7 +122,7 @@ private: glm::vec3 color { 16.f / 255.f }; void deserialize( cParser &Input ); - void initialize( smoke_particle &Particle ); + void initialize( smoke_particle &Particle ) const; }; using bounding_box = glm::dvec3[ 2 ]; // bounding box of owned particles diff --git a/scene/sceneeditor.cpp b/scene/sceneeditor.cpp index 4516425d..e5ae8d4f 100644 --- a/scene/sceneeditor.cpp +++ b/scene/sceneeditor.cpp @@ -102,7 +102,7 @@ basic_editor::translate_node( scene::basic_node *Node, float const Offset ) { } void -basic_editor::translate_instance( TAnimModel *Instance, glm::dvec3 const &Location ) { +basic_editor::translate_instance( TAnimModel *Instance, glm::dvec3 const &Location ) const { simulation::Region->erase( Instance ); Instance->location( Location ); @@ -110,7 +110,7 @@ basic_editor::translate_instance( TAnimModel *Instance, glm::dvec3 const &Locati } void -basic_editor::translate_instance( TAnimModel *Instance, float const Offset ) { +basic_editor::translate_instance( TAnimModel *Instance, float const Offset ) const { auto location { Instance->location() }; location.y += Offset; @@ -118,7 +118,7 @@ basic_editor::translate_instance( TAnimModel *Instance, float const Offset ) { } void -basic_editor::translate_memorycell( TMemCell *Memorycell, glm::dvec3 const &Location ) { +basic_editor::translate_memorycell( TMemCell *Memorycell, glm::dvec3 const &Location ) const { simulation::Region->erase( Memorycell ); Memorycell->location( Location ); @@ -126,7 +126,7 @@ basic_editor::translate_memorycell( TMemCell *Memorycell, glm::dvec3 const &Loca } void -basic_editor::translate_memorycell( TMemCell *Memorycell, float const Offset ) { +basic_editor::translate_memorycell( TMemCell *Memorycell, float const Offset ) const { auto location { Memorycell->location() }; location.y += Offset; @@ -184,7 +184,7 @@ basic_editor::rotate_node( scene::basic_node *Node, glm::vec3 const &Angle ) { } void -basic_editor::rotate_instance( TAnimModel *Instance, glm::vec3 const &Angle ) { +basic_editor::rotate_instance( TAnimModel *Instance, glm::vec3 const &Angle ) const { auto targetangle { Instance->Angles() + Angle }; diff --git a/scene/sceneeditor.h b/scene/sceneeditor.h index bcff58b6..c72bd081 100644 --- a/scene/sceneeditor.h +++ b/scene/sceneeditor.h @@ -46,17 +46,17 @@ private: void translate_node( scene::basic_node *Node, float const Offset ); void - translate_instance( TAnimModel *Instance, glm::dvec3 const &Location ); + translate_instance( TAnimModel *Instance, glm::dvec3 const &Location ) const; void - translate_instance( TAnimModel *Instance, float const Offset ); + translate_instance( TAnimModel *Instance, float const Offset ) const; void - translate_memorycell( TMemCell *Memorycell, glm::dvec3 const &Location ); + translate_memorycell( TMemCell *Memorycell, glm::dvec3 const &Location ) const; void - translate_memorycell( TMemCell *Memorycell, float const Offset ); + translate_memorycell( TMemCell *Memorycell, float const Offset ) const; void rotate_node( scene::basic_node *Node, glm::vec3 const &Angle ); void - rotate_instance( TAnimModel *Instance, glm::vec3 const &Angle ); + rotate_instance( TAnimModel *Instance, glm::vec3 const &Angle ) const; }; } // scene diff --git a/scripting/PyInt.cpp b/scripting/PyInt.cpp index 6ebfe639..656e655b 100644 --- a/scripting/PyInt.cpp +++ b/scripting/PyInt.cpp @@ -225,7 +225,7 @@ void render_task::run() } } -void render_task::upload() +void render_task::upload() const { if (Global.python_uploadmain && m_target && m_target->shared_tex) { @@ -233,7 +233,7 @@ void render_task::upload() } } -void render_task::cancel() {} +void render_task::cancel() const {} // initializes the module. returns true on success auto python_taskqueue::init() -> bool @@ -465,7 +465,7 @@ void python_taskqueue::acquire_lock() } // releases the python gil and swaps the main thread out -void python_taskqueue::release_lock() +void python_taskqueue::release_lock() const { PyEval_SaveThread(); diff --git a/scripting/PyInt.h b/scripting/PyInt.h index 1f1511a0..17eaade4 100644 --- a/scripting/PyInt.h +++ b/scripting/PyInt.h @@ -80,8 +80,8 @@ class render_task render_task(PyObject *Renderer, std::shared_ptr Input, std::shared_ptr Target) : m_renderer(Renderer), m_input(Input), m_target(Target) {} // methods void run(); - void upload(); - void cancel(); + void upload() const; + void cancel() const; auto target() const -> std::shared_ptr { return m_target; @@ -120,7 +120,7 @@ class python_taskqueue // acquires the python gil and sets the main thread as current void acquire_lock(); // releases the python gil and swaps the main thread out - void release_lock(); + void release_lock() const; void update(); diff --git a/scripting/pythonscreenviewer.cpp b/scripting/pythonscreenviewer.cpp index f2aed041..1b5e696e 100644 --- a/scripting/pythonscreenviewer.cpp +++ b/scripting/pythonscreenviewer.cpp @@ -189,7 +189,7 @@ void python_screen_viewer::threadfunc() } } -void python_screen_viewer::notify_window_fb_size(GLFWwindow *window, int w, int h) +void python_screen_viewer::notify_window_fb_size(GLFWwindow *window, int w, int h) const { for (auto &conf : m_windows) { if (conf->window == window) { @@ -200,7 +200,7 @@ void python_screen_viewer::notify_window_fb_size(GLFWwindow *window, int w, int } } -void python_screen_viewer::notify_window_size(GLFWwindow *window, int w, int h) +void python_screen_viewer::notify_window_size(GLFWwindow *window, int w, int h) const { for (auto &conf : m_windows) { if (conf->window == window) { @@ -211,7 +211,7 @@ void python_screen_viewer::notify_window_size(GLFWwindow *window, int w, int h) } } -void python_screen_viewer::notify_cursor_pos(GLFWwindow *window, double x, double y) +void python_screen_viewer::notify_cursor_pos(GLFWwindow *window, double x, double y) const { for (auto &conf : m_windows) { if (conf->window == window) { @@ -222,7 +222,7 @@ void python_screen_viewer::notify_cursor_pos(GLFWwindow *window, double x, doubl } } -void python_screen_viewer::notify_click(GLFWwindow *window, int button, int action) +void python_screen_viewer::notify_click(GLFWwindow *window, int button, int action) const { if (button != GLFW_MOUSE_BUTTON_LEFT || action != GLFW_PRESS) return; diff --git a/scripting/pythonscreenviewer.h b/scripting/pythonscreenviewer.h index bd0634c3..22efe6e8 100644 --- a/scripting/pythonscreenviewer.h +++ b/scripting/pythonscreenviewer.h @@ -38,8 +38,8 @@ public: python_screen_viewer(std::shared_ptr rt, std::shared_ptr> touchlist, std::string name); ~python_screen_viewer(); - void notify_window_size(GLFWwindow *window, int w, int h); - void notify_window_fb_size(GLFWwindow *window, int w, int h); - void notify_cursor_pos(GLFWwindow *window, double x, double y); - void notify_click(GLFWwindow *window, int button, int action); + void notify_window_size(GLFWwindow *window, int w, int h) const; + void notify_window_fb_size(GLFWwindow *window, int w, int h) const; + void notify_cursor_pos(GLFWwindow *window, double x, double y) const; + void notify_click(GLFWwindow *window, int button, int action) const; }; diff --git a/simulation/simulationenvironment.cpp b/simulation/simulationenvironment.cpp index 3c11c14d..5570dffe 100644 --- a/simulation/simulationenvironment.cpp +++ b/simulation/simulationenvironment.cpp @@ -59,7 +59,7 @@ world_environment::compute_season( int const Yearday ) { // calculates current weather void -world_environment::compute_weather() { +world_environment::compute_weather() const { Global.Weather = Global.Overcast <= 0.10 ? "clear:" : Global.Overcast <= 0.50 ? "scattered:" : diff --git a/simulation/simulationenvironment.h b/simulation/simulationenvironment.h index f4114d53..218a2d18 100644 --- a/simulation/simulationenvironment.h +++ b/simulation/simulationenvironment.h @@ -38,7 +38,7 @@ public: // calculates current season of the year based on set simulation date void compute_season( int const Yearday ); // calculates current weather - void compute_weather(); + void compute_weather() const; // data access inline auto const & sun() const { diff --git a/simulation/simulationtime.cpp b/simulation/simulationtime.cpp index f04b4b47..4ed3ef3d 100644 --- a/simulation/simulationtime.cpp +++ b/simulation/simulationtime.cpp @@ -146,7 +146,7 @@ scenario_time::year_day( int Day, const int Month, const int Year ) const { } void -scenario_time::daymonth( WORD &Day, WORD &Month, WORD const Year, WORD const Yearday ) { +scenario_time::daymonth( WORD &Day, WORD &Month, WORD const Year, WORD const Yearday ) const { WORD daytab[ 2 ][ 13 ] = { { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 }, diff --git a/simulation/simulationtime.h b/simulation/simulationtime.h index 49e1a012..aae98ee8 100644 --- a/simulation/simulationtime.h +++ b/simulation/simulationtime.h @@ -56,7 +56,7 @@ private: convert_transition_time( SYSTEMTIME &Time ) const; // calculates day and month from given day of year void - daymonth( WORD &Day, WORD &Month, WORD const Year, WORD const Yearday ); + daymonth( WORD &Day, WORD &Month, WORD const Year, WORD const Yearday ) const; // calculates day of year from given date int year_day( int Day, int const Month, int const Year ) const; diff --git a/utilities/Float3d.cpp b/utilities/Float3d.cpp index 737a8f32..de95f88e 100644 --- a/utilities/Float3d.cpp +++ b/utilities/Float3d.cpp @@ -25,7 +25,7 @@ void float4x4::deserialize_float64(std::istream &s) e[i] = (float)sn_utils::ld_float64(s); } -void float4x4::serialize_float32(std::ostream &s) +void float4x4::serialize_float32(std::ostream &s) const { for (size_t i = 0; i < 16; i++) sn_utils::ls_float32(s, e[i]); diff --git a/utilities/Float3d.h b/utilities/Float3d.h index 93d07519..45c04cc2 100644 --- a/utilities/Float3d.h +++ b/utilities/Float3d.h @@ -217,7 +217,7 @@ public: void deserialize_float32(std::istream&); void deserialize_float64(std::istream&); - void serialize_float32(std::ostream&); + void serialize_float32(std::ostream&) const; float4x4() = default; float4x4(const float f[16]) { @@ -254,7 +254,7 @@ public: } }; inline float4x4 &Rotation(float const angle, float3 const &axis); - inline bool IdentityIs() + inline bool IdentityIs() const { // sprawdzenie jednostkowości for (int i = 0; i < 16; ++i) if (e[i] != (i % 5 ? 0.0 : 1.0)) // jedynki tylko na 0, 5, 10 i 15 diff --git a/utilities/headtrack.cpp b/utilities/headtrack.cpp index 75cb301f..b6085bc1 100644 --- a/utilities/headtrack.cpp +++ b/utilities/headtrack.cpp @@ -19,7 +19,7 @@ void headtrack::find_joy() { joy_id = -1; } -float headtrack::get_axis(const float *data, int count, int axis, float mul) { +float headtrack::get_axis(const float *data, int count, int axis, float mul) const { if (axis < 0) return 0.0f; if (axis >= count) diff --git a/utilities/headtrack.h b/utilities/headtrack.h index e22cbe79..65d804d2 100644 --- a/utilities/headtrack.h +++ b/utilities/headtrack.h @@ -5,7 +5,7 @@ class headtrack int joy_id = -1; void find_joy(); - float get_axis(const float *data, int count, int axis, float mul); + float get_axis(const float *data, int count, int axis, float mul) const; public: headtrack(); diff --git a/vehicle/AirCoupler.cpp b/vehicle/AirCoupler.cpp index 97b8fd7b..98edadf6 100644 --- a/vehicle/AirCoupler.cpp +++ b/vehicle/AirCoupler.cpp @@ -25,7 +25,7 @@ AirCoupler::~AirCoupler() = default; * \return 2 when \(slanted\) TModel3d \c ModelxOn exists * \return 0 when neither of them exist */ -int AirCoupler::GetStatus() +int AirCoupler::GetStatus() const { if (ModelxOn) return 2; diff --git a/vehicle/AirCoupler.h b/vehicle/AirCoupler.h index a502f77c..42c1215f 100644 --- a/vehicle/AirCoupler.h +++ b/vehicle/AirCoupler.h @@ -30,7 +30,7 @@ public: void Init(std::string const &asName, TModel3d *Model); ///Loads info about coupler. void Load(cParser *Parser, TModel3d *Model); - int GetStatus(); + int GetStatus() const; inline void TurnOn() ///Turns on straight coupler. { On = true; diff --git a/vehicle/Button.h b/vehicle/Button.h index d85ee209..691915b5 100644 --- a/vehicle/Button.h +++ b/vehicle/Button.h @@ -27,7 +27,7 @@ public: bool GetValue() const { return m_state; } inline - bool Active() { + bool Active() const { return pModelOn != nullptr || pModelOff != nullptr; } void Update( bool const Power = true ); bool Init( std::string const &asName, TModel3d const *pModel, bool bNewOn = false ); @@ -36,7 +36,7 @@ public: // returns offset of submodel associated with the button from the model centre glm::vec3 model_offset() const; void gain(float new_volume); - inline uint8_t b() { return m_state ? 1 : 0; }; + inline uint8_t b() const { return m_state ? 1 : 0; }; private: // methods diff --git a/vehicle/Camera.cpp b/vehicle/Camera.cpp index e24bd3f3..19405c8c 100644 --- a/vehicle/Camera.cpp +++ b/vehicle/Camera.cpp @@ -194,7 +194,7 @@ void TCamera::Update() } } -bool TCamera::SetMatrix( glm::dmat4 &Matrix ) { +bool TCamera::SetMatrix( glm::dmat4 &Matrix ) const { Matrix = glm::rotate(Matrix, -(double)Angle.x, glm::dvec3(1, 0, 0)); Matrix = glm::rotate(Matrix, -(double)Angle.y, glm::dvec3(0, 1, 0)); // w zewnętrznym widoku: kierunek patrzenia diff --git a/vehicle/Camera.h b/vehicle/Camera.h index 4b91caf2..5e2f7281 100644 --- a/vehicle/Camera.h +++ b/vehicle/Camera.h @@ -22,7 +22,7 @@ class TCamera { void OnCursorMove(double const x, double const y); bool OnCommand( command_data const &Command ); void Update(); - bool SetMatrix(glm::dmat4 &Matrix); + bool SetMatrix(glm::dmat4 &Matrix) const; void RaLook(); glm::vec3 Angle; // pitch, yaw, roll diff --git a/vehicle/Gauge.cpp b/vehicle/Gauge.cpp index 182d5878..9cb9ef3a 100644 --- a/vehicle/Gauge.cpp +++ b/vehicle/Gauge.cpp @@ -457,7 +457,7 @@ float TGauge::GetScaledValue() const { } void -TGauge::UpdateAnimation( TSubModel *Submodel ) { +TGauge::UpdateAnimation( TSubModel *Submodel ) const { if( Submodel == nullptr ) { return; } diff --git a/vehicle/Gauge.h b/vehicle/Gauge.h index 3942fc45..fdef9c58 100644 --- a/vehicle/Gauge.h +++ b/vehicle/Gauge.h @@ -82,7 +82,7 @@ private: float GetScaledValue() const; void - UpdateAnimation( TSubModel *Submodel ); + UpdateAnimation( TSubModel *Submodel ) const; // members TGaugeAnimation m_animation { TGaugeAnimation::gt_Unknown }; // typ ruchu diff --git a/vehicle/Train.cpp b/vehicle/Train.cpp index 08839cd5..a3d6db85 100644 --- a/vehicle/Train.cpp +++ b/vehicle/Train.cpp @@ -10167,7 +10167,7 @@ void TTrain::update_sounds(double const Deltatime) update_sounds_radio(); } -void TTrain::update_sounds_resonancenoise(sound_source &Sound) +void TTrain::update_sounds_resonancenoise(sound_source &Sound) const { // frequency calculation auto const normalizer{mvOccupied->Vmax * 0.01f}; diff --git a/vehicle/Train.h b/vehicle/Train.h index b863199c..18a45f4d 100644 --- a/vehicle/Train.h +++ b/vehicle/Train.h @@ -214,7 +214,7 @@ class TTrain { // update function subroutines void update_sounds( double const Deltatime ); void update_sounds_runningnoise( sound_source &Sound ); - void update_sounds_resonancenoise( sound_source &Sound ); + void update_sounds_resonancenoise( sound_source &Sound ) const; void update_sounds_radio(); inline end cab_to_end( int const End ) const { diff --git a/widgets/map_objects.cpp b/widgets/map_objects.cpp index d67c73f5..02b54340 100644 --- a/widgets/map_objects.cpp +++ b/widgets/map_objects.cpp @@ -5,7 +5,7 @@ map::objects map::Objects; -map::sorted_object_list map::objects::find_in_range(glm::vec3 from, float distance) +map::sorted_object_list map::objects::find_in_range(glm::vec3 from, float distance) const { sorted_object_list items; diff --git a/widgets/map_objects.h b/widgets/map_objects.h index 52ae5db3..7dfc2bbb 100644 --- a/widgets/map_objects.h +++ b/widgets/map_objects.h @@ -87,7 +87,7 @@ struct objects bool poi_dirty = true; // returns objects in range from vec3, NaN in Y ignores it - sorted_object_list find_in_range(glm::vec3 from, float distance); + sorted_object_list find_in_range(glm::vec3 from, float distance) const; }; extern objects Objects; diff --git a/widgets/trainingcard.cpp b/widgets/trainingcard.cpp index 180653bf..37cc4b91 100644 --- a/widgets/trainingcard.cpp +++ b/widgets/trainingcard.cpp @@ -187,7 +187,7 @@ void trainingcard_panel::render_contents() } } -const std::string *trainingcard_panel::is_recording() +const std::string *trainingcard_panel::is_recording() const { if (!start_time_wall) return nullptr; diff --git a/widgets/trainingcard.h b/widgets/trainingcard.h index 9e4eafe9..c485e79c 100644 --- a/widgets/trainingcard.h +++ b/widgets/trainingcard.h @@ -31,7 +31,7 @@ class trainingcard_panel : public ui_panel ~trainingcard_panel(); void render_contents() override; - const std::string *is_recording(); + const std::string *is_recording() const; std::string recording_timestamp; }; diff --git a/world/EvLaunch.cpp b/world/EvLaunch.cpp index a838b909..ed16228e 100644 --- a/world/EvLaunch.cpp +++ b/world/EvLaunch.cpp @@ -156,7 +156,7 @@ bool TEventLauncher::Load(cParser *parser) return true; } -bool TEventLauncher::check_activation_key() { +bool TEventLauncher::check_activation_key() const { if (iKey <= 0) return false; @@ -211,7 +211,7 @@ bool TEventLauncher::check_activation() { return bCond; } -bool TEventLauncher::check_conditions() { +bool TEventLauncher::check_conditions() const { auto bCond { true }; diff --git a/world/EvLaunch.h b/world/EvLaunch.h index 780f8d8f..4756c72b 100644 --- a/world/EvLaunch.h +++ b/world/EvLaunch.h @@ -30,10 +30,10 @@ public: // methods bool Load( cParser *parser ); - bool check_activation_key(); + bool check_activation_key() const; bool check_activation(); // checks conditions associated with the event. returns: true if the conditions are met - bool check_conditions(); + bool check_conditions() const; inline auto key() const { return iKey; } diff --git a/world/MemCell.cpp b/world/MemCell.cpp index 76e9e4f1..919ad38a 100644 --- a/world/MemCell.cpp +++ b/world/MemCell.cpp @@ -258,7 +258,7 @@ TMemCell::export_as_text_( std::ostream &Output ) const { // legacy method, initializes traction after deserialization from scenario file void -memory_table::InitCells() { +memory_table::InitCells() const { for( auto *cell : m_items ) { // Ra: eventy komórek pamięci, wykonywane po wysłaniu komendy do zatrzymanego pojazdu @@ -275,7 +275,7 @@ memory_table::InitCells() { // legacy method, sends content of all cells to the log void -memory_table::log_all() { +memory_table::log_all() const { for( auto *cell : m_items ) { cell->LogValues(); diff --git a/world/MemCell.h b/world/MemCell.h index b6a40082..26c0341c 100644 --- a/world/MemCell.h +++ b/world/MemCell.h @@ -85,10 +85,10 @@ class memory_table : public basic_table { public: // legacy method, initializes traction after deserialization from scenario file void - InitCells(); + InitCells() const; // legacy method, sends content of all cells to the log void - log_all(); + log_all() const; }; //--------------------------------------------------------------------------- diff --git a/world/Segment.cpp b/world/Segment.cpp index d05e83f3..dd55ae95 100644 --- a/world/Segment.cpp +++ b/world/Segment.cpp @@ -335,7 +335,7 @@ glm::dvec3 TSegment::GetDirection(double const fDistance) const return FastGetPoint(t2) - FastGetPoint(t1); } -glm::dvec3 TSegment::FastGetDirection(double fDistance, double fOffset) +glm::dvec3 TSegment::FastGetDirection(double fDistance, double fOffset) const { // takie toporne liczenie pochodnej dla parametru 0.0÷1.0 double t1 = fDistance - fOffset; if (t1 <= 0.0) diff --git a/world/Segment.h b/world/Segment.h index 184784ea..d6d1ae9b 100644 --- a/world/Segment.h +++ b/world/Segment.h @@ -93,7 +93,7 @@ public: GetDirection() const { return CPointOut; }; glm::dvec3 - FastGetDirection(double const fDistance, double const fOffset); + FastGetDirection(double const fDistance, double const fOffset) const; /* Math3D::vector3 GetPoint(double const fDistance) const; diff --git a/world/Spring.cpp b/world/Spring.cpp index e53de505..0ef99f62 100644 --- a/world/Spring.cpp +++ b/world/Spring.cpp @@ -17,7 +17,7 @@ void TSpring::Init(double nKs, double nKd) { kd = static_cast(Kd); } -glm::dvec3 TSpring::ComputateForces(glm::dvec3 const &pPosition1, glm::dvec3 const &pPosition2) { +glm::dvec3 TSpring::ComputateForces(glm::dvec3 const &pPosition1, glm::dvec3 const &pPosition2) const { glm::vec3 springForce; // p1 = &system[spring->p1]; // p2 = &system[spring->p2]; diff --git a/world/Spring.h b/world/Spring.h index 6800ba29..9e4ce685 100644 --- a/world/Spring.h +++ b/world/Spring.h @@ -27,7 +27,7 @@ public: // void Init(TParticnp1, TParticle *np2, double nKs= 0.5f, double nKd= 0.002f, // double nrestLen= -1.0f); void Init(double nKs = 0.5f, double nKd = 0.002f); - glm::dvec3 ComputateForces(glm::dvec3 const &pPosition1, glm::dvec3 const &pPosition2); + glm::dvec3 ComputateForces(glm::dvec3 const &pPosition1, glm::dvec3 const &pPosition2) const; //private: // members double restLen { 0.01 }; // LENGTH OF SPRING AT REST diff --git a/world/Traction.cpp b/world/Traction.cpp index a3f15195..da171a84 100644 --- a/world/Traction.cpp +++ b/world/Traction.cpp @@ -349,7 +349,7 @@ TTraction::create_geometry( gfx::geometrybank_handle const &Bank ) { return elementcount; } -int TTraction::TestPoint(glm::dvec3 const &Point) +int TTraction::TestPoint(glm::dvec3 const &Point) const { // sprawdzanie, czy przęsła można połączyć if( hvNext[0] == nullptr && glm::all(glm::epsilonEqual(Point, pPoint1, 0.025)) ) { diff --git a/world/Traction.h b/world/Traction.h index 0133e409..6506dfb3 100644 --- a/world/Traction.h +++ b/world/Traction.h @@ -68,7 +68,7 @@ class TTraction : public scene::basic_node // creates geometry data in specified geometry bank. returns: number of created elements, or NULL // NOTE: deleting nodes doesn't currently release geometry data owned by the node. TODO: implement erasing individual geometry chunks and banks std::size_t create_geometry( gfx::geometrybank_handle const &Bank ); - int TestPoint(glm::dvec3 const &Point); + int TestPoint(glm::dvec3 const &Point) const; void Connect(int my, TTraction *with, int to); void Init(); bool WhereIs(); diff --git a/world/mtable.cpp b/world/mtable.cpp index 2b89eeac..616db94c 100644 --- a/world/mtable.cpp +++ b/world/mtable.cpp @@ -14,7 +14,7 @@ http://mozilla.org/MPL/2.0/. #include "utilities/dictionary.h" #include "utilities/utilities.h" -double TTrainParameters::CheckTrainLatency() +double TTrainParameters::CheckTrainLatency() const { if (LastStationLatency > 1.0 || LastStationLatency < 0) return LastStationLatency; /*spoznienie + lub do przodu - z tolerancja 1 min*/ @@ -22,7 +22,7 @@ double TTrainParameters::CheckTrainLatency() return 0; } -double TTrainParameters::WatchMTable(double DistCounter) +double TTrainParameters::WatchMTable(double DistCounter) const { // zwraca odleglość do najblizszej stacji z zatrzymaniem double dist; @@ -163,7 +163,7 @@ void TTrainParameters::StationIndexInc() ++StationIndex; } -bool TTrainParameters::IsTimeToGo(double hh, double mm) +bool TTrainParameters::IsTimeToGo(double hh, double mm) const // sprawdzenie, czy można już odjechać z aktualnego zatrzymania // StationIndex to numer następnego po dodarciu do aktualnego { @@ -629,7 +629,7 @@ TTrainParameters::load_sounds() { } } -bool TTrainParameters::DirectionChange() +bool TTrainParameters::DirectionChange() const // sprawdzenie, czy po zatrzymaniu wykonać kolejne komendy { if (StationIndex > 0 && StationIndex < StationCount) // dla ostatniej stacji nie diff --git a/world/mtable.h b/world/mtable.h index 06595ef0..7f1747a0 100644 --- a/world/mtable.h +++ b/world/mtable.h @@ -65,17 +65,17 @@ class TTrainParameters std::string NextStationName; double LastStationLatency; int Direction; /*kierunek jazdy w/g kilometrazu*/ - double CheckTrainLatency(); + double CheckTrainLatency() const; /*todo: str hh:mm to int i z powrotem*/ std::string ShowRelation() const; - double WatchMTable(double DistCounter); + double WatchMTable(double DistCounter) const; std::string NextStop() const; sound_source next_stop_sound() const; sound_source last_stop_sound() const; bool IsStop() const; bool IsLastStop() const; bool IsMaintenance() const; - bool IsTimeToGo(double hh, double mm); + bool IsTimeToGo(double hh, double mm) const; // returns: difference between specified time and scheduled departure from current stop, in seconds double seconds_until_departure( double const Hour, double const Minute ) const; bool UpdateMTable(double hh, double mm, std::string const &NewName); @@ -85,7 +85,7 @@ class TTrainParameters void NewName(std::string const &NewTrainName); void UpdateVelocity(int StationCount, double vActual); bool LoadTTfile(std::string scnpath, int iPlus, double vmax); - bool DirectionChange(); + bool DirectionChange() const; void StationIndexInc(); void serialize( dictionary_source *Output ) const; // returns: radio channel associated with current station, or -1 diff --git a/world/station.cpp b/world/station.cpp index 684a7d8f..90b443e8 100644 --- a/world/station.cpp +++ b/world/station.cpp @@ -22,7 +22,7 @@ basic_station Station; // exchanges load with consist attached to specified vehicle, operating on specified schedule double -basic_station::update_load( TDynamicObject *First, Mtable::TTrainParameters &Schedule, int const Platform ) { +basic_station::update_load( TDynamicObject *First, Mtable::TTrainParameters &Schedule, int const Platform ) const { // TODO: filter out maintenance stops when determining first and last stop auto const firststop { Schedule.StationIndex == 1 }; diff --git a/world/station.h b/world/station.h index ecc60992..5c4a9507 100644 --- a/world/station.h +++ b/world/station.h @@ -18,7 +18,7 @@ public: // methods // exchanges load with consist attached to specified vehicle, operating on specified schedule; returns: time needed for exchange, in seconds double - update_load( TDynamicObject *First, Mtable::TTrainParameters &Schedule, int const Platform ); + update_load( TDynamicObject *First, Mtable::TTrainParameters &Schedule, int const Platform ) const; }; namespace simulation {