mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-24 00:19:12 +01:00
refactor(sonar): make read-only local references and pointers const (cpp:S5350)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1187,10 +1187,10 @@ void TMoverParameters::CollisionDetect(int const End, double const dt)
|
||||
return;
|
||||
} // shouldn't normally happen but, eh
|
||||
|
||||
auto &thiscoupler{Couplers[End]};
|
||||
auto const &thiscoupler{Couplers[End]};
|
||||
auto *othervehicle{Neighbours[End].vehicle->MoverParameters};
|
||||
auto const otherend{Neighbours[End].vehicle_end};
|
||||
auto &othercoupler{othervehicle->Couplers[otherend]};
|
||||
auto const &othercoupler{othervehicle->Couplers[otherend]};
|
||||
|
||||
auto velocity{V};
|
||||
auto othervehiclevelocity{othervehicle->V};
|
||||
@@ -1830,7 +1830,7 @@ void TMoverParameters::PowerCouplersCheck(double const /*Deltatime*/, coupling c
|
||||
for (auto side = 0; side < 2; ++side)
|
||||
{
|
||||
|
||||
auto &thiscoupler{Couplers[side]};
|
||||
auto const &thiscoupler{Couplers[side]};
|
||||
// NOTE: in the loop we actually update the state of the coupler on the opposite end of the vehicle
|
||||
auto &oppositecoupler{Couplers[side == end::front ? end::rear : end::front]};
|
||||
|
||||
@@ -2275,7 +2275,7 @@ void TMoverParameters::PantographsCheck(double const /*Timestep*/)
|
||||
using enum start_t;
|
||||
|
||||
{
|
||||
auto &valve{PantsValve};
|
||||
auto const &valve{PantsValve};
|
||||
auto const lowvoltagepower{valve.solenoid ? Power24vIsAvailable || Power110vIsAvailable : true};
|
||||
auto const autostart{valve.start_type == automatic || valve.start_type == manualwithautofallback};
|
||||
auto const manualcontrol{valve.start_type == manual || valve.start_type == manualwithautofallback};
|
||||
@@ -6211,7 +6211,7 @@ double TMoverParameters::TractionForce(double dt)
|
||||
if (true == Mains && !SecuritySystem.is_engine_blocked())
|
||||
{
|
||||
double ActiveInverters = 0.0;
|
||||
for (auto &inv : Inverters)
|
||||
for (auto const &inv : Inverters)
|
||||
{
|
||||
if (inv.IsActive)
|
||||
ActiveInverters += 1.0;
|
||||
@@ -8946,7 +8946,7 @@ double TMoverParameters::GetTrainsetVoltage(int const Coupling) const
|
||||
{
|
||||
continue;
|
||||
}
|
||||
auto *connectedpowercoupling = (Coupling & (coupling::highvoltage | coupling::heating)) != 0 ? &thiscoupler.Connected->Couplers[thiscoupler.ConnectedNr].power_high :
|
||||
auto const *connectedpowercoupling = (Coupling & (coupling::highvoltage | coupling::heating)) != 0 ? &thiscoupler.Connected->Couplers[thiscoupler.ConnectedNr].power_high :
|
||||
(Coupling & coupling::power110v) != 0 ? &thiscoupler.Connected->Couplers[thiscoupler.ConnectedNr].power_110v :
|
||||
(Coupling & coupling::power24v) != 0 ? &thiscoupler.Connected->Couplers[thiscoupler.ConnectedNr].power_24v :
|
||||
nullptr;
|
||||
|
||||
@@ -1259,7 +1259,7 @@ debug_panel::update_section_scantable( std::vector<text_line> &Output ) const {
|
||||
#ifdef WITH_UART
|
||||
void
|
||||
debug_panel::update_section_uart( std::vector<text_line> &Output ) const {
|
||||
uart_status *status = &UartStatus;
|
||||
uart_status const *status = &UartStatus;
|
||||
|
||||
Output.emplace_back(
|
||||
("Port: " + status->port_name).c_str(),
|
||||
|
||||
@@ -87,7 +87,7 @@ void gl::buffer::download(targets target, void *data, int offset, GLsizeiptr siz
|
||||
}
|
||||
else
|
||||
{
|
||||
void *glbuf = glMapBufferRange(glenum_target(target), offset, size, GL_MAP_READ_BIT);
|
||||
void const *glbuf = glMapBufferRange(glenum_target(target), offset, size, GL_MAP_READ_BIT);
|
||||
memcpy(data, glbuf, size);
|
||||
glUnmapBuffer(glenum_target(target));
|
||||
}
|
||||
|
||||
@@ -339,7 +339,7 @@ void gl::program::init()
|
||||
|
||||
for (auto [texturename, textureentry] : texture_conf)
|
||||
{
|
||||
shader::texture_entry &e = textureentry;
|
||||
shader::texture_entry const &e = textureentry;
|
||||
GLuint loc = glGetUniformLocation(*this, texturename.c_str());
|
||||
glUniform1i(loc, static_cast<GLint>(e.id));
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ drivermouse_input::recall_bindings() {
|
||||
}
|
||||
// TODO: binding targets for mouse buttons
|
||||
|
||||
for( auto &bindingtarget : bindingtargets ) {
|
||||
for( auto const &bindingtarget : bindingtargets ) {
|
||||
// grab command(s) associated with the input pin
|
||||
auto const bindingcommandname{ entryparser.getToken<std::string>() };
|
||||
if( true == bindingcommandname.empty() ) {
|
||||
|
||||
@@ -126,7 +126,7 @@ gamepad_input::poll() {
|
||||
void
|
||||
gamepad_input::bind( std::vector< std::reference_wrapper<user_command> > &Targets, cParser &Input, std::unordered_map<std::string, user_command> const &Translator, std::string const Point ) const {
|
||||
|
||||
for( auto &bindingtarget : Targets ) {
|
||||
for( auto const &bindingtarget : Targets ) {
|
||||
// grab command(s) associated with the input pin
|
||||
auto const bindingcommandname{ Input.getToken<std::string>() };
|
||||
if( true == bindingcommandname.empty() ) {
|
||||
|
||||
@@ -62,7 +62,7 @@ OnCommandGet(multiplayer::DaneRozkaz *pRozkaz)
|
||||
std::string( pRozkaz->cString + 1, (unsigned)pRozkaz->cString[0] ) + " rcvd" );
|
||||
|
||||
if( Global.iMultiplayer ) {
|
||||
auto *foundevent = simulation::Events.FindEvent( std::string( pRozkaz->cString + 1, (unsigned)pRozkaz->cString[0] ) );
|
||||
auto const *foundevent = simulation::Events.FindEvent( std::string( pRozkaz->cString + 1, (unsigned)pRozkaz->cString[0] ) );
|
||||
if (foundevent != nullptr && (typeid(*foundevent) == typeid(multi_event)
|
||||
|| typeid(*foundevent) == typeid(lights_event)
|
||||
|| foundevent->m_sibling != nullptr)) {
|
||||
@@ -136,7 +136,7 @@ OnCommandGet(multiplayer::DaneRozkaz *pRozkaz)
|
||||
+ " rcvd" );
|
||||
if (pRozkaz->cString[0]) {
|
||||
// jeśli długość nazwy jest niezerowa szukamy pierwszego pojazdu o takiej nazwie i odsyłamy parametry ramką #7
|
||||
auto *vehicle = pRozkaz->cString[1] == '*' ? simulation::Train->Dynamic() : simulation::Vehicles.find(std::string{pRozkaz->cString + 1, (unsigned)pRozkaz->cString[0]});
|
||||
auto const *vehicle = pRozkaz->cString[1] == '*' ? simulation::Train->Dynamic() : simulation::Vehicles.find(std::string{pRozkaz->cString + 1, (unsigned)pRozkaz->cString[0]});
|
||||
if( vehicle != nullptr ) {
|
||||
WyslijNamiary( vehicle ); // wysłanie informacji o pojeździe
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
glm::ivec2 size() const
|
||||
{
|
||||
if (image != null_handle) {
|
||||
auto &tex = GfxRenderer->Texture(image);
|
||||
auto const &tex = GfxRenderer->Texture(image);
|
||||
return glm::ivec2(tex.get_width(), tex.get_height());
|
||||
}
|
||||
return glm::ivec2();
|
||||
|
||||
@@ -87,7 +87,7 @@ public:
|
||||
opengl_dlgeometrybank() = default;
|
||||
// destructor:
|
||||
~opengl_dlgeometrybank() {
|
||||
for( auto &chunkrecord : m_chunkrecords ) {
|
||||
for( auto const &chunkrecord : m_chunkrecords ) {
|
||||
::glDeleteLists( chunkrecord.list, 1 ); } }
|
||||
|
||||
private:
|
||||
|
||||
@@ -363,7 +363,7 @@ void python_taskqueue::exit()
|
||||
// which the previous code did not do (cancel() is a no-op stub).
|
||||
{
|
||||
std::scoped_lock lock(m_tasks.mutex);
|
||||
for (auto &task : m_tasks.data)
|
||||
for (auto const &task : m_tasks.data)
|
||||
{
|
||||
task->cancel();
|
||||
}
|
||||
@@ -609,7 +609,7 @@ void python_taskqueue::update()
|
||||
{
|
||||
std::scoped_lock lock(m_uploadtasks.mutex);
|
||||
|
||||
for (auto &task : m_uploadtasks.data)
|
||||
for (auto const &task : m_uploadtasks.data)
|
||||
task->upload();
|
||||
|
||||
m_uploadtasks.data.clear();
|
||||
|
||||
@@ -79,7 +79,7 @@ python_screen_viewer::~python_screen_viewer()
|
||||
|
||||
void python_screen_viewer::threadfunc()
|
||||
{
|
||||
for (auto &window : m_windows) {
|
||||
for (auto const &window : m_windows) {
|
||||
glfwMakeContextCurrent(window->window);
|
||||
|
||||
glfwSwapInterval(Global.python_vsync ? 1 : 0);
|
||||
@@ -115,7 +115,7 @@ void python_screen_viewer::threadfunc()
|
||||
{
|
||||
auto start_time = std::chrono::high_resolution_clock::now();
|
||||
|
||||
for (auto &window : m_windows) {
|
||||
for (auto const &window : m_windows) {
|
||||
|
||||
unsigned char *image = nullptr;
|
||||
int format;
|
||||
@@ -190,7 +190,7 @@ void python_screen_viewer::threadfunc()
|
||||
|
||||
void python_screen_viewer::notify_window_fb_size(GLFWwindow *window, int w, int h) const
|
||||
{
|
||||
for (auto &conf : m_windows) {
|
||||
for (auto const &conf : m_windows) {
|
||||
if (conf->window == window) {
|
||||
conf->fb_size.x = w;
|
||||
conf->fb_size.y = h;
|
||||
@@ -201,7 +201,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
|
||||
{
|
||||
for (auto &conf : m_windows) {
|
||||
for (auto const &conf : m_windows) {
|
||||
if (conf->window == window) {
|
||||
conf->window_size.x = w;
|
||||
conf->window_size.y = h;
|
||||
@@ -212,7 +212,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
|
||||
{
|
||||
for (auto &conf : m_windows) {
|
||||
for (auto const &conf : m_windows) {
|
||||
if (conf->window == window) {
|
||||
conf->cursor_pos.x = static_cast<int>(x);
|
||||
conf->cursor_pos.y = static_cast<int>(y);
|
||||
@@ -226,7 +226,7 @@ void python_screen_viewer::notify_click(GLFWwindow *window, int button, int acti
|
||||
if (button != GLFW_MOUSE_BUTTON_LEFT || action != GLFW_PRESS)
|
||||
return;
|
||||
|
||||
for (auto &conf : m_windows) {
|
||||
for (auto const &conf : m_windows) {
|
||||
if (conf->window == window) {
|
||||
auto pos = glm::vec2(conf->cursor_pos) / glm::vec2(conf->window_size);
|
||||
pos.y = 1.0f - pos.y;
|
||||
|
||||
@@ -2116,7 +2116,7 @@ void TTrain::OnCommand_trainbrakeoperationtoggle(TTrain *Train, command_data con
|
||||
}
|
||||
}
|
||||
|
||||
void TTrain::OnCommand_trainbrakeoperationtoggle(TTrain *Train, command_data const &Command)
|
||||
void TTrain::OnCommand_trainbrakeoperationtoggle(TTrain *Train, command_data const &Command)
|
||||
{
|
||||
|
||||
if (Command.action == GLFW_PRESS)
|
||||
@@ -3464,7 +3464,7 @@ void TTrain::update_pantograph_valves()
|
||||
OnCommand_pantographtoggleselected(Train, Command);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TTrain::update_pantograph_valves()
|
||||
{
|
||||
using enum operation_t;
|
||||
@@ -8743,7 +8743,7 @@ bool TTrain::Update(double const Deltatime)
|
||||
}
|
||||
}
|
||||
else
|
||||
fConverterTimer = 0;
|
||||
fConverterTimer = 0;
|
||||
//------------------
|
||||
auto const lowvoltagepower{mvOccupied->Power24vIsAvailable || mvOccupied->Power110vIsAvailable};
|
||||
|
||||
@@ -9169,7 +9169,7 @@ bool TTrain::Update(double const Deltatime)
|
||||
btLampkaDistanceCounter.Turn(false);
|
||||
// universal devices state indicators
|
||||
for (auto &universal : btUniversals)
|
||||
{
|
||||
{
|
||||
universal.Turn(false);
|
||||
}
|
||||
}
|
||||
@@ -10120,7 +10120,7 @@ void TTrain::update_sounds_radio()
|
||||
|
||||
radio_message_played = false;
|
||||
if (false == m_radiomessages.empty())
|
||||
{
|
||||
{
|
||||
// erase completed radio messages from the list
|
||||
std::erase_if(m_radiomessages, [](auto const &source) { return false == source.second->is_playing(); });
|
||||
}
|
||||
@@ -10347,7 +10347,7 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName)
|
||||
m_controlmapper.clear();
|
||||
// clear python screens
|
||||
m_screens.clear();
|
||||
// reset sound positions
|
||||
// reset sound positions
|
||||
auto const nullvector{glm::vec3()};
|
||||
std::vector<std::reference_wrapper<std::optional<sound_source>>> sounds = {
|
||||
dsbReverserKey, dsbNastawnikJazdy, dsbNastawnikBocz, dsbSwitch, dsbPneumaticSwitch, rsHiss, rsHissU, rsHissE, rsHissX, rsHissT, rsSBHiss,
|
||||
@@ -10355,7 +10355,7 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName)
|
||||
m_rainsound, m_radiostop};
|
||||
for (auto const &sound : sounds)
|
||||
{
|
||||
if (sound.get())
|
||||
if (sound.get())
|
||||
{
|
||||
sound.get()->offset(nullvector);
|
||||
}
|
||||
@@ -10650,7 +10650,7 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName)
|
||||
{rsHuntingNoise, caboffset},
|
||||
{dsbHasler, caboffset},
|
||||
{dsbBuzzer, btLampkaCzuwaka.model_offset()},
|
||||
{dsbBuzzerShp, btLampkaCzuwaka.model_offset()},
|
||||
{dsbBuzzerShp, btLampkaCzuwaka.model_offset()},
|
||||
{dsbSlipAlarm, caboffset},
|
||||
{m_distancecounterclear, btLampkaCzuwaka.model_offset()},
|
||||
{m_rainsound, caboffset},
|
||||
@@ -10658,7 +10658,7 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName)
|
||||
};
|
||||
for (auto const &[soundsource, soundoffset] : soundlocations)
|
||||
{
|
||||
if (soundsource.get() && soundsource.get()->offset() == nullvector)
|
||||
if (soundsource.get() && soundsource.get()->offset() == nullvector)
|
||||
{
|
||||
soundsource.get()->offset(soundoffset);
|
||||
}
|
||||
@@ -11464,7 +11464,7 @@ void TTrain::set_cab_controls(int const Cab)
|
||||
ggAutoSandButton.PutValue(mvControlled->SandDoseAutoAllow ? 1.f : 0.f);
|
||||
}
|
||||
// radio
|
||||
ggRadioVolumeSelector.PutValue(m_radiovolume);
|
||||
ggRadioVolumeSelector.PutValue(m_radiovolume);
|
||||
|
||||
// finding each inverter - not so optimal, but action ins performed only during changing cabin
|
||||
bool kier = DynamicObject->DirectionGet() * mvOccupied->CabOccupied > 0;
|
||||
|
||||
@@ -19,7 +19,7 @@ void perfgraph_panel::render_contents() {
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
|
||||
Timer::stopwatch *stopwatch = nullptr;
|
||||
Timer::stopwatch const *stopwatch = nullptr;
|
||||
|
||||
if (current_timer == gfx_total)
|
||||
stopwatch = &Timer::subsystem.gfx_total;
|
||||
|
||||
@@ -27,7 +27,7 @@ void ui::time_panel::render_contents()
|
||||
|
||||
void ui::time_panel::open()
|
||||
{
|
||||
auto &data = simulation::Time.data();
|
||||
auto const &data = simulation::Time.data();
|
||||
time = (float)data.wHour + (float)data.wMinute / 60.0f;
|
||||
|
||||
yearday = simulation::Time.year_day();
|
||||
|
||||
@@ -12,7 +12,7 @@ ui::vehiclelist_panel::vehiclelist_panel(ui_layer &parent)
|
||||
void ui::vehiclelist_panel::render_contents()
|
||||
{
|
||||
if (m_first_show && Global.gui_trainingdefault) {
|
||||
for (TDynamicObject *vehicle : simulation::Vehicles.sequence())
|
||||
for (TDynamicObject const *vehicle : simulation::Vehicles.sequence())
|
||||
{
|
||||
if (!vehicle->Mechanik || vehicle->name() != ToLower(Global.local_start_vehicle))
|
||||
continue;
|
||||
@@ -26,7 +26,7 @@ void ui::vehiclelist_panel::render_contents()
|
||||
return;
|
||||
}
|
||||
|
||||
for (TDynamicObject *vehicle : simulation::Vehicles.sequence())
|
||||
for (TDynamicObject const *vehicle : simulation::Vehicles.sequence())
|
||||
{
|
||||
if (!vehicle->Mechanik)
|
||||
continue;
|
||||
|
||||
@@ -280,7 +280,7 @@ memory_table::InitCells() const {
|
||||
void
|
||||
memory_table::log_all() const {
|
||||
|
||||
for( auto *cell : m_items ) {
|
||||
for( auto const *cell : m_items ) {
|
||||
cell->LogValues();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user