From 0a7c42c4a9653a35871aa6caadc48aaff3964a89 Mon Sep 17 00:00:00 2001 From: jerrrrycho Date: Sat, 10 Oct 2026 17:08:45 +0200 Subject: [PATCH] refactor(sonar): take read-only pointer and reference parameters as const (cpp:S995) TTrain command handlers keep their signature, it is fixed by the handler table. Co-Authored-By: Claude Opus 5.5 --- McZapkie/MOVER.h | 2 +- McZapkie/Mover.cpp | 2 +- environment/skydome.cpp | 4 ++-- environment/skydome.h | 4 ++-- extras/piped_proc.cpp | 4 ++-- extras/piped_proc.h | 2 +- gl/framebuffer.cpp | 2 +- gl/framebuffer.h | 2 +- input/drivermouseinput.cpp | 2 +- input/gamepadinput.cpp | 2 +- input/gamepadinput.h | 2 +- input/messaging.cpp | 2 +- input/messaging.h | 2 +- scripting/PyInt.cpp | 2 +- scripting/PyInt.h | 2 +- scripting/pythonscreenviewer.cpp | 8 ++++---- scripting/pythonscreenviewer.h | 8 ++++---- utilities/Float3d.cpp | 2 +- utilities/Float3d.h | 2 +- vehicle/AirCoupler.cpp | 2 +- vehicle/AirCoupler.h | 2 +- 21 files changed, 30 insertions(+), 30 deletions(-) diff --git a/McZapkie/MOVER.h b/McZapkie/MOVER.h index ad95da25..9cd02ec5 100644 --- a/McZapkie/MOVER.h +++ b/McZapkie/MOVER.h @@ -2311,7 +2311,7 @@ class TMoverParameters bool CurrentSwitch(bool const State); bool IsMotorOverloadRelayHighThresholdOn() const; void UpdateBatteryVoltage(double dt); - double ComputeMovement(double dt, double dt1, const TTrackShape &Shape, TTrackParam &Track, TTractionParam &ElectricTraction, TLocation const &NewLoc, + double ComputeMovement(double dt, double dt1, const TTrackShape &Shape, TTrackParam const &Track, TTractionParam const &ElectricTraction, TLocation const &NewLoc, 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); diff --git a/McZapkie/Mover.cpp b/McZapkie/Mover.cpp index 2290a3aa..4159fa29 100644 --- a/McZapkie/Mover.cpp +++ b/McZapkie/Mover.cpp @@ -1352,7 +1352,7 @@ void TMoverParameters::Derail(DerailReason const Reason) // ************************************************************************************************* // Oblicza przemieszczenie taboru // ************************************************************************************************* -double TMoverParameters::ComputeMovement(double dt, double dt1, const TTrackShape &Shape, TTrackParam &Track, TTractionParam &ElectricTraction, TLocation const &NewLoc, TRotation const &NewRot) +double TMoverParameters::ComputeMovement(double dt, double dt1, const TTrackShape &Shape, TTrackParam const &Track, TTractionParam const &ElectricTraction, TLocation const &NewLoc, TRotation const &NewRot) { if (!TestFlag(DamageFlag, dtrain_out)) diff --git a/environment/skydome.cpp b/environment/skydome.cpp index 6af83aaa..6eebfb7e 100644 --- a/environment/skydome.cpp +++ b/environment/skydome.cpp @@ -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 ) const { +float CSkyDome::PerezFunctionO1( float const 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 ) const { +float CSkyDome::PerezFunctionO2( float const 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 477d731b..bc22f9c7 100644 --- a/environment/skydome.h +++ b/environment/skydome.h @@ -62,7 +62,7 @@ private: // coloring 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; + float PerezFunctionO1( float const Perezcoeffs[ 5 ], const float Thetasun, const float Zenithval ) const; + float PerezFunctionO2( float const Perezcoeffs[ 5 ], const float Icostheta, const float Gamma, const float Cosgamma2, const float Zenithval ) const; }; diff --git a/extras/piped_proc.cpp b/extras/piped_proc.cpp index f7e4e67c..492c79ca 100644 --- a/extras/piped_proc.cpp +++ b/extras/piped_proc.cpp @@ -26,7 +26,7 @@ size_t piped_proc::read(unsigned char *buf, size_t len) return fread(buf, 1, len, file); } -size_t piped_proc::write(unsigned char *buf, size_t len) +size_t piped_proc::write(unsigned char const *buf, size_t len) { if (!file) return 0; @@ -97,7 +97,7 @@ size_t piped_proc::read(unsigned char *buf, size_t len) return read; } -size_t piped_proc::write(unsigned char *buf, size_t len) +size_t piped_proc::write(unsigned char const *buf, size_t len) { if (!pipe_wr) return 0; diff --git a/extras/piped_proc.h b/extras/piped_proc.h index e4f625ce..170fe3f5 100644 --- a/extras/piped_proc.h +++ b/extras/piped_proc.h @@ -25,6 +25,6 @@ HANDLE pipe_wr = nullptr; public: explicit piped_proc(std::string cmd, bool write = false); size_t read(unsigned char *buf, size_t len); - size_t write(unsigned char *buf, size_t len); + size_t write(unsigned char const *buf, size_t len); ~piped_proc(); }; diff --git a/gl/framebuffer.cpp b/gl/framebuffer.cpp index 898c8e07..2c2b242a 100644 --- a/gl/framebuffer.cpp +++ b/gl/framebuffer.cpp @@ -80,7 +80,7 @@ void gl::framebuffer::blit_from(framebuffer *other, int w, int h, GLbitfield mas blit(other, this, 0, 0, w, h, mask, attachment); } -void gl::framebuffer::blit(framebuffer *src, framebuffer *dst, int sx, int sy, int w, int h, GLbitfield mask, GLenum attachment) +void gl::framebuffer::blit(framebuffer const *src, framebuffer const *dst, int sx, int sy, int w, int h, GLbitfield mask, GLenum attachment) { glBindFramebuffer(GL_READ_FRAMEBUFFER, src ? *src : 0); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, dst ? *dst : 0); diff --git a/gl/framebuffer.h b/gl/framebuffer.h index e5dccf57..f8bee46a 100644 --- a/gl/framebuffer.h +++ b/gl/framebuffer.h @@ -26,7 +26,7 @@ namespace gl void blit_to(framebuffer *other, int w, int h, GLbitfield mask, GLenum attachment); void blit_from(framebuffer *other, int w, int h, GLbitfield mask, GLenum attachment); - static void blit(framebuffer *src, framebuffer *dst, int sx, int sy, int w, int h, GLbitfield mask, GLenum attachment); + static void blit(framebuffer const *src, framebuffer const *dst, int sx, int sy, int w, int h, GLbitfield mask, GLenum attachment); using bindable::bind; static void bind(GLuint id); diff --git a/input/drivermouseinput.cpp b/input/drivermouseinput.cpp index f7f65776..ffe9185f 100644 --- a/input/drivermouseinput.cpp +++ b/input/drivermouseinput.cpp @@ -315,7 +315,7 @@ drivermouse_input::button( int const Button, int const Action ) { // left mouse button launches on_click event associated with to the node if (Button == GLFW_MOUSE_BUTTON_LEFT && Action == GLFW_PRESS) { GfxRenderer->Pick_Node_Callback( - [](scene::basic_node *node) { + [](scene::basic_node const *node) { if( node == nullptr || typeid(*node) != typeid(TAnimModel) ) return; diff --git a/input/gamepadinput.cpp b/input/gamepadinput.cpp index 87e4d0f1..94d626cc 100644 --- a/input/gamepadinput.cpp +++ b/input/gamepadinput.cpp @@ -124,7 +124,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 ) const { +gamepad_input::bind( std::vector< std::reference_wrapper > const &Targets, cParser &Input, std::unordered_map const &Translator, std::string const Point ) const { for( auto const &bindingtarget : Targets ) { // grab command(s) associated with the input pin diff --git a/input/gamepadinput.h b/input/gamepadinput.h index e5648a0d..776f65d9 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 ) const; + void bind( std::vector< std::reference_wrapper > const &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/messaging.cpp b/input/messaging.cpp index 32a33707..d494200e 100644 --- a/input/messaging.cpp +++ b/input/messaging.cpp @@ -43,7 +43,7 @@ Navigate([[maybe_unused]] std::string const &ClassName, [[maybe_unused]] UINT Ms } void -OnCommandGet(multiplayer::DaneRozkaz *pRozkaz) +OnCommandGet(multiplayer::DaneRozkaz const *pRozkaz) { // odebranie komunikatu z serwera if (pRozkaz->iSygn == EU07_MESSAGEHEADER ) switch (pRozkaz->iComm) diff --git a/input/messaging.h b/input/messaging.h index f3592b27..40434db2 100644 --- a/input/messaging.h +++ b/input/messaging.h @@ -38,7 +38,7 @@ struct DaneRozkaz2 { // struktura komunikacji z EU07.EXE void Navigate( std::string const &ClassName, UINT Msg, WPARAM wParam, LPARAM lParam ); -void OnCommandGet( multiplayer::DaneRozkaz *pRozkaz ); +void OnCommandGet( multiplayer::DaneRozkaz const *pRozkaz ); void WyslijEvent( const std::string &e, const std::string &d ); void WyslijString( const std::string &t, int n ); diff --git a/scripting/PyInt.cpp b/scripting/PyInt.cpp index c4952e71..f5f22e56 100644 --- a/scripting/PyInt.cpp +++ b/scripting/PyInt.cpp @@ -530,7 +530,7 @@ auto python_taskqueue::fetch_renderer(std::string const Renderer) -> PyObject * return renderer; } -void python_taskqueue::run(GLFWwindow *Context, rendertask_sequence &Tasks, uploadtask_sequence &Upload_Tasks, threading::condition_variable &Condition, std::atomic &Exit) +void python_taskqueue::run(GLFWwindow *Context, rendertask_sequence &Tasks, uploadtask_sequence &Upload_Tasks, threading::condition_variable &Condition, std::atomic const &Exit) { if (Context) diff --git a/scripting/PyInt.h b/scripting/PyInt.h index 17eaade4..db33a3d1 100644 --- a/scripting/PyInt.h +++ b/scripting/PyInt.h @@ -132,7 +132,7 @@ class python_taskqueue using uploadtask_sequence = threading::lockable>>; // methods auto fetch_renderer(std::string const Renderer) -> PyObject *; - void run(GLFWwindow *Context, rendertask_sequence &Tasks, uploadtask_sequence &Upload_Tasks, threading::condition_variable &Condition, std::atomic &Exit); + void run(GLFWwindow *Context, rendertask_sequence &Tasks, uploadtask_sequence &Upload_Tasks, threading::condition_variable &Condition, std::atomic const &Exit); void error(); // members diff --git a/scripting/pythonscreenviewer.cpp b/scripting/pythonscreenviewer.cpp index 06fd6899..e4730201 100644 --- a/scripting/pythonscreenviewer.cpp +++ b/scripting/pythonscreenviewer.cpp @@ -188,7 +188,7 @@ void python_screen_viewer::threadfunc() } } -void python_screen_viewer::notify_window_fb_size(GLFWwindow *window, int w, int h) const +void python_screen_viewer::notify_window_fb_size(GLFWwindow const *window, int w, int h) const { for (auto const &conf : m_windows) { if (conf->window == window) { @@ -199,7 +199,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) const +void python_screen_viewer::notify_window_size(GLFWwindow const *window, int w, int h) const { for (auto const &conf : m_windows) { if (conf->window == window) { @@ -210,7 +210,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) const +void python_screen_viewer::notify_cursor_pos(GLFWwindow const *window, double x, double y) const { for (auto const &conf : m_windows) { if (conf->window == window) { @@ -221,7 +221,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) const +void python_screen_viewer::notify_click(GLFWwindow const *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 22efe6e8..1049e1dd 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) 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; + void notify_window_size(GLFWwindow const *window, int w, int h) const; + void notify_window_fb_size(GLFWwindow const *window, int w, int h) const; + void notify_cursor_pos(GLFWwindow const *window, double x, double y) const; + void notify_click(GLFWwindow const *window, int button, int action) const; }; diff --git a/utilities/Float3d.cpp b/utilities/Float3d.cpp index 5cd4341c..a1e4f0db 100644 --- a/utilities/Float3d.cpp +++ b/utilities/Float3d.cpp @@ -31,7 +31,7 @@ void float4x4::serialize_float32(std::ostream &s) const sn_utils::ls_float32(s, element); } -void float4x4::Quaternion(float4 *q) +void float4x4::Quaternion(float4 const *q) { // konwersja kwaternionu obrotu na macierz obrotu float xx = q->x * q->x; float yy = q->y * q->y; diff --git a/utilities/Float3d.h b/utilities/Float3d.h index 759ff171..f379ab8a 100644 --- a/utilities/Float3d.h +++ b/utilities/Float3d.h @@ -253,7 +253,7 @@ public: return false; return true; } - void Quaternion(float4 *q); + void Quaternion(float4 const *q); inline float3 *TranslationGet() { return (float3 *)(e + 12); diff --git a/vehicle/AirCoupler.cpp b/vehicle/AirCoupler.cpp index 98edadf6..cf6b3bc5 100644 --- a/vehicle/AirCoupler.cpp +++ b/vehicle/AirCoupler.cpp @@ -49,7 +49,7 @@ void AirCoupler::Clear() /** * Looks for submodels in the model and updates pointers. */ -void AirCoupler::Init(std::string const &asName, TModel3d *Model) +void AirCoupler::Init(std::string const &asName, TModel3d const *Model) { if (!Model) return; diff --git a/vehicle/AirCoupler.h b/vehicle/AirCoupler.h index 42c1215f..2de380fa 100644 --- a/vehicle/AirCoupler.h +++ b/vehicle/AirCoupler.h @@ -27,7 +27,7 @@ public: ///Reset members. void Clear(); ///Looks for submodels. - void Init(std::string const &asName, TModel3d *Model); + void Init(std::string const &asName, TModel3d const *Model); ///Loads info about coupler. void Load(cParser *Parser, TModel3d *Model); int GetStatus() const;