18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-21 15:34:58 +01:00

refactor(sonar): use auto where the type is spelled out on the right (cpp:S5827)

This commit is contained in:
jerrrrycho
2026-10-10 15:52:25 +02:00
parent f8c6e358bd
commit 413009e59e
19 changed files with 39 additions and 39 deletions

View File

@@ -733,7 +733,7 @@ void TMoverParameters::BrakeLevelSet(double b)
fBrakeCtrlPos = Handle->GetPos(bh_MAX);
// TODO: verify whether BrakeCtrlPosR and fBrakeCtrlPos can be rolled into single variable
BrakeCtrlPosR = fBrakeCtrlPos;
int x = static_cast<int>(std::floor(fBrakeCtrlPos)); // jeśli odwołujemy się do BrakeCtrlPos w pośrednich, to musi być
auto x = static_cast<int>(std::floor(fBrakeCtrlPos)); // jeśli odwołujemy się do BrakeCtrlPos w pośrednich, to musi być
// obcięte a nie zaokrągone
while (x > BrakeCtrlPos && BrakeCtrlPos < BrakeCtrlPosNo) // jeśli zwiększyło się o 1
if (!IncBrakeLevelOld()) // T_MoverParameters::

View File

@@ -211,7 +211,7 @@ double TNESt3::GetPF( double const PP, double const dt, double const Vel ) // pr
double dV{ 0.0 };
double dV1{ 0.0 };
double const nastG = static_cast<double>(BrakeDelayFlag & bdelay_G);
auto const nastG = static_cast<double>(BrakeDelayFlag & bdelay_G);
// sprawdzanie stanu
CheckState(BCP, dV1);

View File

@@ -588,7 +588,7 @@ debug_panel::render() {
#ifdef WITH_UART
if(true == render_section( "UART", m_uartlines)) {
int ports_num = static_cast<int>(UartStatus.available_ports.size());
char **avlports = new char*[ports_num];
auto avlports = new char*[ports_num];
for (int i=0; i < ports_num; i++) {
avlports[i] = (char *) UartStatus.available_ports[i].c_str();
}

View File

@@ -41,7 +41,7 @@ bool has_gl_extension(char const *name) {
GLint count = 0;
glGetIntegerv(GL_NUM_EXTENSIONS, &count);
for (GLint i = 0; i < count; ++i) {
char const *ext = reinterpret_cast<char const *>(glGetStringi(GL_EXTENSIONS, i));
auto ext = reinterpret_cast<char const *>(glGetStringi(GL_EXTENSIONS, i));
if (ext != nullptr && std::strcmp(ext, name) == 0) {
return true;
}

View File

@@ -855,7 +855,7 @@ command_queue::pop( command_data &Command, uint32_t const Recipient ) {
bool command_queue::is_network_target(uint32_t const Recipient) const {
if (const command_target target = (command_target)(Recipient & ~0xffff); target == command_target::entity)
if (const auto target = (command_target)(Recipient & ~0xffff); target == command_target::entity)
return false;
return true;

View File

@@ -76,7 +76,7 @@ OnCommandGet(multiplayer::DaneRozkaz *pRozkaz)
case 3: // rozkaz dla AI
if (Global.iMultiplayer)
{
int i = int(pRozkaz->cString[8]); // długość pierwszego łańcucha (z przodu dwa floaty)
auto i = int(pRozkaz->cString[8]); // długość pierwszego łańcucha (z przodu dwa floaty)
CommLog(
Now() + " " + std::to_string(pRozkaz->iComm) + " " +
std::string(pRozkaz->cString + 11 + i, (unsigned)pRozkaz->cString[10 + i]) +

View File

@@ -92,7 +92,7 @@ void network::tcp::connection::handle_data(const asio::error_code &err, size_t b
void network::tcp::connection::write_message(const message &msg, std::ostream &stream) const
{
size_t beg = (size_t)stream.tellp();
auto beg = (size_t)stream.tellp();
sn_utils::ls_uint32(stream, NETWORK_MAGIC);
sn_utils::ls_uint32(stream, 0);
@@ -149,7 +149,7 @@ network::tcp::server::server(std::shared_ptr<std::istream> buf, asio::io_context
void network::tcp::server::accept_conn()
{
std::shared_ptr<connection> conn = std::make_shared<connection>(m_io_ctx);
auto conn = std::make_shared<connection>(m_io_ctx);
conn->set_handler(std::bind(&server::handle_message, this, conn, std::placeholders::_1));
m_acceptor.async_accept(conn->m_socket, std::bind(&server::handle_accept, this, conn, std::placeholders::_1));
@@ -183,7 +183,7 @@ void network::tcp::client::connect()
if (this->conn)
return;
std::shared_ptr<connection> conn = std::make_shared<connection>(io_ctx, true, resume_frame_counter);
auto conn = std::make_shared<connection>(io_ctx, true, resume_frame_counter);
conn->set_handler(std::bind(&client::handle_message, this, conn, std::placeholders::_1));
asio::ip::tcp::endpoint endpoint(

View File

@@ -103,7 +103,7 @@ void network::frame_info::deserialize(std::istream &stream)
std::shared_ptr<network::message> network::deserialize_message(std::istream &stream)
{
message::type_e type = (message::type_e)sn_utils::ld_uint16(stream);
auto type = (message::type_e)sn_utils::ld_uint16(stream);
std::shared_ptr<message> msg;

View File

@@ -131,7 +131,7 @@ void flip_dxt1_image(void *data, int width, int height)
int y;
struct dxt1_block temp1;
struct dxt1_block temp2;
struct dxt1_block *blocks = (struct dxt1_block *)data;
auto blocks = (struct dxt1_block *)data;
width = (width + 3) / 4;
height = (height + 3) / 4;
@@ -162,7 +162,7 @@ void flip_dxt23_image(void *data, int width, int height)
int y;
struct dxt23_block temp1;
struct dxt23_block temp2;
struct dxt23_block *blocks = (struct dxt23_block *)data;
auto blocks = (struct dxt23_block *)data;
width = (width + 3) / 4;
height = (height + 3) / 4;
@@ -193,7 +193,7 @@ void flip_dxt45_image(void *data, int width, int height)
int y;
struct dxt45_block temp1;
struct dxt45_block temp2;
struct dxt45_block *blocks = (struct dxt45_block *)data;
auto blocks = (struct dxt45_block *)data;
width = (width + 3) / 4;
height = (height + 3) / 4;

View File

@@ -120,7 +120,7 @@ opengl33_particles::render() {
if (!m_shader) {
gl::shader vert("smoke.vert");
gl::shader frag("smoke.frag");
gl::program *prog = new gl::program({vert, frag});
auto prog = new gl::program({vert, frag});
m_shader = std::unique_ptr<gl::program>(prog);
}

View File

@@ -55,7 +55,7 @@ void screenshot_manager::screenshot_save_thread( char *img, int w, int h )
void screenshot_manager::make_screenshot()
{
char *img = new char[Global.fb_size.x * Global.fb_size.y * 4];
auto img = new char[Global.fb_size.x * Global.fb_size.y * 4];
glReadPixels(0, 0, Global.fb_size.x, Global.fb_size.y, Global.gfx_usegles ? GL_RGBA : GL_RGB, GL_UNSIGNED_BYTE, (GLvoid*)img);
//m7t: use pbo

View File

@@ -197,7 +197,7 @@ void sn_utils::ls_int64(std::ostream &s, int64_t v)
void sn_utils::ls_float32(std::ostream &s, float t)
{
uint32_t v = std::bit_cast<uint32_t>(t);
auto v = std::bit_cast<uint32_t>(t);
uint8_t buf[4];
buf[0] = static_cast<uint8_t>(v);
buf[1] = static_cast<uint8_t>(v >> 8);
@@ -208,7 +208,7 @@ void sn_utils::ls_float32(std::ostream &s, float t)
void sn_utils::ls_float64(std::ostream &s, double t)
{
uint64_t v = std::bit_cast<uint64_t>(t);
auto v = std::bit_cast<uint64_t>(t);
uint8_t buf[8];
buf[0] = static_cast<uint8_t>(v);
buf[1] = static_cast<uint8_t>(v >> 8);

View File

@@ -117,8 +117,8 @@ void render_task::run()
if (outputWidth != nullptr && outputHeight != nullptr && m_target != nullptr)
{
const int screenWidth = static_cast<int>(PyLong_AsLong(outputWidth));
const int screenHeight = static_cast<int>(PyLong_AsLong(outputHeight));
const auto screenWidth = static_cast<int>(PyLong_AsLong(outputWidth));
const auto screenHeight = static_cast<int>(PyLong_AsLong(outputHeight));
const bool useRgb = false && !Global.gfx_usegles;

View File

@@ -7,25 +7,25 @@
void texture_window_resize(GLFWwindow *win, int w, int h)
{
python_screen_viewer *texwindow = (python_screen_viewer*)glfwGetWindowUserPointer(win);
auto texwindow = (python_screen_viewer*)glfwGetWindowUserPointer(win);
texwindow->notify_window_size(win, w, h);
}
void texture_window_fb_resize(GLFWwindow *win, int w, int h)
{
python_screen_viewer *texwindow = (python_screen_viewer*)glfwGetWindowUserPointer(win);
auto texwindow = (python_screen_viewer*)glfwGetWindowUserPointer(win);
texwindow->notify_window_fb_size(win, w, h);
}
void texture_window_mouse_button(GLFWwindow *win, int button, int action, int /*mods*/)
{
python_screen_viewer *texwindow = (python_screen_viewer*)glfwGetWindowUserPointer(win);
auto texwindow = (python_screen_viewer*)glfwGetWindowUserPointer(win);
texwindow->notify_click(win, button, action);
}
void texture_window_cursor_pos(GLFWwindow *win, double x, double y)
{
python_screen_viewer *texwindow = (python_screen_viewer*)glfwGetWindowUserPointer(win);
auto texwindow = (python_screen_viewer*)glfwGetWindowUserPointer(win);
texwindow->notify_cursor_pos(win, x, y);
}

View File

@@ -95,7 +95,7 @@ void UpdateTimers(bool pause)
oldCount = count;
// Keep track of the time lapse and frame count
#if __unix__
double fTime = (double)(count / 1000000000);
auto fTime = (double)(count / 1000000000);
#elif _WIN32_WINNT >= _WIN32_WINNT_VISTA
double fTime = ::GetTickCount64() * 0.001f; // Get current time in seconds
#elif _WIN32

View File

@@ -82,7 +82,7 @@ HSVtoRGB( glm::vec3 const &HSV ) {
float hh = HSV.x;
if( hh >= 360.0 ) hh = 0.0;
hh /= 60.0f;
int const i = (int)hh;
auto const i = (int)hh;
float const ff = hh - static_cast<float>(i);
float const p = HSV.z * ( 1.f - HSV.y );
float const q = HSV.z * ( 1.f - HSV.y * ff );

View File

@@ -496,7 +496,7 @@ void uart_input::poll()
);
}
if( true == conf.radiovolumeenable ) {
int8_t requested_volume = static_cast<int8_t>((buffer[12] & 0xF0) >> 4);
auto requested_volume = static_cast<int8_t>((buffer[12] & 0xF0) >> 4);
relay.post(
user_command::radiovolumeset,
requested_volume == 0xF ? 1.0 : requested_volume * (1.0 / 15.0),
@@ -534,16 +534,16 @@ void uart_input::poll()
SYSTEMTIME time = simulation::Time.data();
uint16_t tacho = Global.iPause ? 0 : static_cast<uint16_t>(trainstate.velocity * conf.tachoscale);
uint16_t tank_press = (uint16_t)std::min(conf.tankuart, trainstate.reservoir_pressure * 0.1f / conf.tankmax * conf.tankuart);
uint16_t pipe_press = (uint16_t)std::min(conf.pipeuart, trainstate.pipe_pressure * 0.1f / conf.pipemax * conf.pipeuart);
uint16_t brake_press = (uint16_t)std::min(conf.brakeuart, trainstate.brake_pressure * 0.1f / conf.brakemax * conf.brakeuart);
uint16_t pantograph_press = (uint16_t)std::min(conf.pantographuart, trainstate.pantograph_pressure * 0.1f / conf.pantographmax * conf.pantographuart );
uint16_t hv_voltage = (uint16_t)std::min(conf.hvuart, trainstate.hv_voltage / conf.hvmax * conf.hvuart);
uint16_t current1 = (uint16_t)std::min(conf.currentuart, trainstate.hv_current[0] / conf.currentmax * conf.currentuart);
uint16_t current2 = (uint16_t)std::min(conf.currentuart, trainstate.hv_current[1] / conf.currentmax * conf.currentuart);
uint16_t current3 = (uint16_t)std::min(conf.currentuart, trainstate.hv_current[2] / conf.currentmax * conf.currentuart);
auto tank_press = (uint16_t)std::min(conf.tankuart, trainstate.reservoir_pressure * 0.1f / conf.tankmax * conf.tankuart);
auto pipe_press = (uint16_t)std::min(conf.pipeuart, trainstate.pipe_pressure * 0.1f / conf.pipemax * conf.pipeuart);
auto brake_press = (uint16_t)std::min(conf.brakeuart, trainstate.brake_pressure * 0.1f / conf.brakemax * conf.brakeuart);
auto pantograph_press = (uint16_t)std::min(conf.pantographuart, trainstate.pantograph_pressure * 0.1f / conf.pantographmax * conf.pantographuart );
auto hv_voltage = (uint16_t)std::min(conf.hvuart, trainstate.hv_voltage / conf.hvmax * conf.hvuart);
auto current1 = (uint16_t)std::min(conf.currentuart, trainstate.hv_current[0] / conf.currentmax * conf.currentuart);
auto current2 = (uint16_t)std::min(conf.currentuart, trainstate.hv_current[1] / conf.currentmax * conf.currentuart);
auto current3 = (uint16_t)std::min(conf.currentuart, trainstate.hv_current[2] / conf.currentmax * conf.currentuart);
uint32_t odometer = static_cast<uint32_t>(trainstate.distance * 10000.0);
uint16_t lv_voltage = (uint16_t)std::min( conf.lvuart, trainstate.lv_voltage / conf.lvmax * conf.lvuart );
auto lv_voltage = (uint16_t)std::min( conf.lvuart, trainstate.lv_voltage / conf.lvmax * conf.lvuart );
if( trainstate.cab > 0 ) {
// NOTE: moving from a cab to engine room doesn't change cab indicator
m_trainstatecab = trainstate.cab - 1;

View File

@@ -122,8 +122,8 @@ void ui::cameraview_panel::capture_func()
piped_proc proc(cmdline);
size_t frame_size = Global.extcam_res.x * Global.extcam_res.y * 3;
uint8_t *read_buffer = new uint8_t[frame_size];
uint8_t *active_buffer = new uint8_t[frame_size];
auto read_buffer = new uint8_t[frame_size];
auto active_buffer = new uint8_t[frame_size];
size_t bufpos = 0;
@@ -172,7 +172,7 @@ void ui::cameraview_panel::record_func()
piped_proc proc(cmdline, true);
size_t frame_size = Global.extcam_res.x * Global.extcam_res.y * 3;
uint8_t *read_buffer = new uint8_t[frame_size];
auto read_buffer = new uint8_t[frame_size];
uint32_t last_cnt = 0;
size_t bufpos = frame_size;

View File

@@ -37,7 +37,7 @@ void ui::vehiclelist_panel::render_contents()
if (vehicle->Mechanik)
timetable = vehicle->Mechanik->TrainName() + ", ";
std::string label = std::string(name + ", " + timetable + std::to_string(speed) + " km/h###");
auto label = std::string(name + ", " + timetable + std::to_string(speed) + " km/h###");
ImGui::PushID(vehicle);
if (ImGui::Button(label.c_str())) {