16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-17 23:39:18 +02:00

Merge pull request #109 from docentYT/fix-compilation-warnings

Fix compilation warnings
This commit is contained in:
2026-06-16 11:14:25 +02:00
committed by GitHub
23 changed files with 53 additions and 51 deletions

View File

@@ -597,7 +597,7 @@ void driver_mode::update_camera(double const Deltatime)
}
else
{
if (false == FreeFlyModeFlag)
if (false == FreeFlyModeFlag && simulation::Train)
{
// reset cached view angle in the cab
simulation::Train->pMechViewAngle = {Camera.Angle.x, Camera.Angle.y};

View File

@@ -29,6 +29,7 @@ http://mozilla.org/MPL/2.0/.
#include "rendering/renderer.h"
#include "utilities/Logs.h"
#include "widgets/vehicleparams.h"
#include "utilities/U8.h"
#define DRIVER_HINT_CONTENT
#include "application/driverhints.h"
@@ -390,7 +391,7 @@ timetable_panel::update() {
}
else {
// header
m_tablelines.emplace_back( "┌─────┬────────────────────────────────────┬─────────┬─────┐", Global.UITextColor );
m_tablelines.emplace_back(U8("┌─────┬────────────────────────────────────┬─────────┬─────┐"), Global.UITextColor);
TMTableLine const *tableline;
for( int i = table.StationStart; i <= table.StationCount; ++i ) {
@@ -422,11 +423,11 @@ timetable_panel::update() {
auto const arrival { (
tableline->Ah >= 0 ?
std::to_string( int( 100 + tableline->Ah ) ).substr( 1, 2 ) + ":" + to_minutes_str( tableline->Am, true, 3 ) :
"" ) };
U8("") ) };
auto const departure { (
tableline->Dh >= 0 ?
std::to_string( int( 100 + tableline->Dh ) ).substr( 1, 2 ) + ":" + to_minutes_str( tableline->Dm, true, 3 ) :
"" ) };
U8("") ) };
auto const candepart { (
( table.StationStart < table.StationIndex )
&& ( i < table.StationIndex )
@@ -445,25 +446,25 @@ timetable_panel::update() {
candepart ? colors::uitextgreen : // czas minął i odjazd był, to nazwa stacji będzie na zielono
isatpassengerstop ? colors::uitextorange :
Global.UITextColor ) };
auto const trackcount{ ( tableline->TrackNo == 1 ? "" : "" ) };
std::string const trackcount{ ( tableline->TrackNo == 1 ? U8("") : U8("" )) };
m_tablelines.emplace_back(
( "" + vmax + "" + station + trackcount + arrival + "" + traveltime + "" ),
( U8("") + vmax + U8("") + station + trackcount + arrival + U8("") + traveltime + U8("") ),
linecolor );
m_tablelines.emplace_back(
( "│ │ " + location + tableline->StationWare + trackcount + departure + " │ │" ),
( U8("│ │ ") + location + tableline->StationWare + trackcount + departure + U8(" │ │") ),
linecolor );
// divider/footer
if( i < table.StationCount ) {
auto const *nexttableline { tableline + 1 };
std::string const vmaxnext{ ( tableline->vmax == nexttableline->vmax ? "│ ├" : "├─────┼" ) };
auto const trackcountnext{ ( nexttableline->TrackNo == 1 ? "" : "" ) };
std::string const vmaxnext{ ( tableline->vmax == nexttableline->vmax ? U8("│ ├") : U8("├─────┼") ) };
auto const trackcountnext{ ( nexttableline->TrackNo == 1 ? U8("") : U8("") ) };
m_tablelines.emplace_back(
vmaxnext + "────────────────────────────────────" + trackcountnext + "─────────┼─────┤",
vmaxnext + U8("────────────────────────────────────") + trackcountnext + U8("─────────┼─────┤"),
Global.UITextColor );
}
else {
m_tablelines.emplace_back(
"└─────┴────────────────────────────────────┴─────────┴─────┘",
U8("└─────┴────────────────────────────────────┴─────────┴─────┘"),
Global.UITextColor );
}
}
@@ -1537,6 +1538,7 @@ bool debug_panel::render_section_developer()
m_input.vehicle->MoverParameters->reload_FIZ(); // reload fiz
}
ImGui::PopStyleColor();
return true;
}
bool

View File

@@ -100,9 +100,6 @@ private:
bool render_section( std::vector<text_line> const &Lines );
bool render_section_scenario();
bool render_section_eventqueue();
#ifdef WITH_UART
bool render_section_uart();
#endif
bool render_section_settings();
bool render_section_developer();
// members

View File

@@ -202,7 +202,7 @@ void scenarioloader_ui::render_()
// Gradient at the lower half of the screen
if (!Global.NvRenderer)
{
const auto tex = reinterpret_cast<ImTextureID>(m_gradient_overlay_tex);
const ImTextureID tex = (ImTextureID)(intptr_t)m_gradient_overlay_tex; // See https://github.com/ocornut/imgui/wiki/Image-Loading-and-Displaying-Examples#example-for-opengl-users
draw_list->AddImage(tex, ImVec2(0, Global.window_size.y / 2), ImVec2(Global.window_size.x, Global.window_size.y), ImVec2(0, 0), ImVec2(1, 1));
}

View File

@@ -61,19 +61,19 @@ gl::buffer::~buffer()
glDeleteBuffers(1, *this);
}
void gl::buffer::allocate(targets target, int size, GLenum hint)
void gl::buffer::allocate(targets target, GLsizeiptr size, GLenum hint)
{
bind(target);
glBufferData(glenum_target(target), size, nullptr, hint);
}
void gl::buffer::upload(targets target, const void *data, int offset, int size)
void gl::buffer::upload(targets target, const void *data, int offset, GLsizeiptr size)
{
bind(target);
glBufferSubData(glenum_target(target), offset, size, data);
}
void gl::buffer::download(targets target, void *data, int offset, int size)
void gl::buffer::download(targets target, void *data, int offset, GLsizeiptr size)
{
bind(target);
if (GLAD_GL_VERSION_3_3)

View File

@@ -39,8 +39,8 @@ namespace gl
static void unbind(targets target);
static void unbind();
void allocate(targets target, int size, GLenum hint);
void upload(targets target, const void *data, int offset, int size);
void download(targets target, void *data, int offset, int size);
void allocate(targets target, GLsizeiptr size, GLenum hint);
void upload(targets target, const void *data, int offset, GLsizeiptr size);
void download(targets target, void *data, int offset, GLsizeiptr size);
};
}

View File

@@ -1,7 +1,7 @@
#include "stdafx.h"
#include "ubo.h"
gl::ubo::ubo(int size, int idx, GLenum hint)
gl::ubo::ubo(size_t size, int idx, GLenum hint)
{
allocate(buffer::UNIFORM_BUFFER, size, hint);
index = idx;
@@ -13,7 +13,7 @@ void gl::ubo::bind_uniform()
bind_base(buffer::UNIFORM_BUFFER, index);
}
void gl::ubo::update(const uint8_t *data, int offset, int size)
void gl::ubo::update(const uint8_t *data, int offset, GLsizeiptr size)
{
upload(buffer::UNIFORM_BUFFER, data, offset, size);
}

View File

@@ -22,11 +22,11 @@ namespace gl
int index;
public:
ubo(int size, int index, GLenum hint = GL_DYNAMIC_DRAW);
ubo(size_t size, int index, GLenum hint = GL_DYNAMIC_DRAW);
void bind_uniform();
void update(const uint8_t *data, int offset, int size);
void update(const uint8_t *data, int offset, GLsizeiptr size);
template <typename T> void update(const T &data, size_t offset = 0)
{
update(reinterpret_cast<const uint8_t*>(&data), offset, sizeof(data));

View File

@@ -291,7 +291,7 @@ void ui::scenerylist_panel::draw_trainset(trainset_desc &trainset)
glm::ivec2 size = mini->size();
float width = 30.0f / size.y * size.x;
float beforeX = ImGui::GetCursorPosX();
ImGui::Image(reinterpret_cast<void*>(mini->get()), ImVec2(width, 30), ImVec2(0, 1), ImVec2(1, 0));
ImGui::Image((ImTextureID)(intptr_t)(mini->get()), ImVec2(width, 30), ImVec2(0, 1), ImVec2(1, 0));
float afterX = ImGui::GetCursorPosX();
ImGui::SameLine(beforeX);
@@ -299,7 +299,7 @@ void ui::scenerylist_panel::draw_trainset(trainset_desc &trainset)
if (ImGui::BeginDragDropSource(ImGuiDragDropFlags_SourceAutoExpirePayload)) {
vehicle_moved data(trainset, dyn_desc, position - 1);
ImGui::Image(reinterpret_cast<void*>(mini->get()), ImVec2(width, 30), ImVec2(0, 1), ImVec2(1, 0));
ImGui::Image((ImTextureID)(intptr_t)mini->get(), ImVec2(width, 30), ImVec2(0, 1), ImVec2(1, 0));
ImGui::SetDragDropPayload("vehicle_set", &data, sizeof(vehicle_moved));
ImGui::EndDragDropSource();

View File

@@ -274,7 +274,7 @@ bool ui::vehiclepicker_panel::selectable_image(const char *desc, bool selected,
glm::ivec2 size = image->size();
float width = 30.0f / size.y * size.x;
ImGui::SameLine(ImGui::GetContentRegionAvail().x - width);
ImGui::Image(reinterpret_cast<void*>(tex), ImVec2(width, 30), ImVec2(0, 1), ImVec2(1, 0));
ImGui::Image((ImTextureID)(intptr_t)tex, ImVec2(width, 30), ImVec2(0, 1), ImVec2(1, 0));
if (pickable) {
ImGui::PushID((void*)image);
@@ -282,7 +282,7 @@ bool ui::vehiclepicker_panel::selectable_image(const char *desc, bool selected,
ImGui::InvisibleButton(desc, ImVec2(width, 30));
if (ImGui::BeginDragDropSource(ImGuiDragDropFlags_SourceAutoExpirePayload)) {
ImGui::Image(reinterpret_cast<void*>(tex), ImVec2(width, 30), ImVec2(0, 1), ImVec2(1, 0));
ImGui::Image((ImTextureID)(intptr_t)tex, ImVec2(width, 30), ImVec2(0, 1), ImVec2(1, 0));
ImGui::SetDragDropPayload("vehicle_pure", &pickable, sizeof(skin_set*));
ImGui::EndDragDropSource();

View File

@@ -604,7 +604,7 @@ std::pair<int, int> TSubModel::Load(cParser &parser, bool dynamic)
parser >> vertex->normal.x >> vertex->normal.y >> vertex->normal.z;
if (glm::length2(vertex->normal) > 0.0f)
{
glm::normalize(vertex->normal);
vertex->normal = glm::normalize(vertex->normal);
}
else
{

View File

@@ -125,7 +125,7 @@ void network::server::handle_message(std::shared_ptr<connection> conn, const mes
}
if (msg.type == message::CLIENT_HELLO) {
auto cmd = dynamic_cast<const client_hello&>(msg);
const auto& cmd = dynamic_cast<const client_hello&>(msg);
if (cmd.version != EU07_NETWORK_VERSION // wrong version
|| !Global.ready_to_load) { // not ready yet
@@ -148,7 +148,7 @@ void network::server::handle_message(std::shared_ptr<connection> conn, const mes
WriteLog("net: client accepted", logtype::net);
}
else if (msg.type == message::REQUEST_COMMAND) {
auto cmd = dynamic_cast<const request_command&>(msg);
const auto& cmd = dynamic_cast<const request_command&>(msg);
for (auto const &kv : cmd.commands)
client_commands_queue.emplace(kv);
@@ -189,7 +189,7 @@ std::tuple<double, double, command_queue::commands_map> network::client::get_nex
float size = delta_queue.size() - consume_counter;
auto entry = delta_queue.front();
const auto& entry = delta_queue.front();
float mult = entry.render_dt / std::chrono::duration_cast<std::chrono::duration<float>>(frame_time).count();
if (counter == 1 && size < MAX_BUFFER_SIZE * 2.0f) {
@@ -241,7 +241,7 @@ void network::client::handle_message(std::shared_ptr<connection> conn, const mes
}
if (msg.type == message::SERVER_HELLO) {
auto cmd = dynamic_cast<const server_hello&>(msg);
const auto& cmd = dynamic_cast<const server_hello&>(msg);
conn->state = connection::ACTIVE;
if (!Global.ready_to_load) {

View File

@@ -706,7 +706,7 @@ void opengl33_renderer::draw_debug_ui()
ImGui::SetNextWindowSize(ImVec2S(400, 400));
if (ImGui::Begin("Pickbuffer") && m_pick_tex) {
ImGui::Image(reinterpret_cast<void *>(m_pick_tex->id), ImGui::GetContentRegionAvail(), ImVec2(0, 1.0), ImVec2(1.0, 0));
ImGui::Image((ImTextureID)(intptr_t)(m_pick_tex->id), ImGui::GetContentRegionAvail(), ImVec2(0, 1.0), ImVec2(1.0, 0));
}
ImGui::End();

View File

@@ -4085,7 +4085,7 @@ opengl_renderer::Update_Pick_Control() {
#endif
m_pickcontrolitem = control;
// return control;
for( auto callback : m_control_pick_requests ) {
for( auto& callback : m_control_pick_requests ) {
callback( m_pickcontrolitem, glm::vec2() );
}
m_control_pick_requests.clear();
@@ -4134,7 +4134,7 @@ opengl_renderer::Update_Pick_Node() {
#endif
m_picksceneryitem = node;
// return node;
for( auto callback : m_node_pick_requests ) {
for( auto& callback : m_node_pick_requests ) {
callback( m_picksceneryitem );
}
m_node_pick_requests.clear();
@@ -4313,7 +4313,7 @@ void opengl_renderer::MakeScreenshot()
void
opengl_renderer::Update_Lights( light_array &Lights ) {
// arrange the light array from closest to farthest from current position of the camera
auto const camera = m_renderpass.camera.position();
auto const &camera = m_renderpass.camera.position();
std::sort(
std::begin( Lights.data ),
std::end( Lights.data ),

View File

@@ -173,7 +173,7 @@ smoke_source::update( double const Timedelta, bool const Onlydespawn ) {
if (Global.AirTemperature <= 5.f || m_owner.vehicle->MoverParameters->dizel_heat.Ts < 45.f)
{
m_emitter.color == glm::vec3{128, 128, 128};
m_emitter.color = glm::vec3{128, 128, 128};
}
if (m_owner.vehicle->MoverParameters->dizel_spinup == true)

View File

@@ -1054,7 +1054,7 @@ basic_region::on_click( TAnimModel const *Instance ) {
if( Instance->name().empty() || ( Instance->name() == "none" ) ) { return; }
auto const location { Instance->location() };
auto const& location { Instance->location() };
if( point_inside( location ) ) {
section( location ).on_click( Instance );
@@ -1329,7 +1329,7 @@ basic_region::insert( shape_node Shape, scratch_data &Scratchpad, bool const Tra
if( ( false == Scratchpad.location.offset.empty() )
&& ( Scratchpad.location.offset.top() != glm::dvec3( 0, 0, 0 ) ) ) {
// ...and move
auto const offset = Scratchpad.location.offset.top();
auto const& offset = Scratchpad.location.offset.top();
for( auto &vertex : shape.m_data.vertices ) {
vertex.position += offset;
}
@@ -1383,7 +1383,7 @@ basic_region::insert( lines_node Lines, scratch_data &Scratchpad ) {
if( ( false == Scratchpad.location.offset.empty() )
&& ( Scratchpad.location.offset.top() != glm::dvec3( 0, 0, 0 ) ) ) {
// ...and move
auto const offset = Scratchpad.location.offset.top();
auto const &offset = Scratchpad.location.offset.top();
for( auto &vertex : Lines.m_data.vertices ) {
vertex.position += offset;
}
@@ -1759,7 +1759,7 @@ void basic_region::update_poi_geometry()
{
std::vector<gfx::basic_vertex> vertices;
gfx::userdata_array userdata;
for (const auto sem : map::Objects.entries)
for (const auto &sem : map::Objects.entries)
vertices.push_back(std::move(sem->vertex()));
if (!m_map_poipoints) {

View File

@@ -61,8 +61,7 @@ void
basic_editor::translate( scene::basic_node *Node, float const Offset ) {
// NOTE: offset scaling is calculated early so the same multiplier can be applied to potential whole group
auto location { Node->location() };
auto const distance { glm::length( location - glm::dvec3{ Global.pCamera.Pos } ) };
auto const distance { glm::length( Node->location() - Global.pCamera.Pos ) };
auto const offset { static_cast<float>( Offset * std::max( 1.0, distance * 0.01 ) ) };
if( Node->group() <= 1 ) {

3
utilities/U8.h Normal file
View File

@@ -0,0 +1,3 @@
#pragma once
#define U8(str) (const char *)u8##str

View File

@@ -27,6 +27,8 @@ Copyright (C) 2007-2014 Maciej Cierniak
#include "utilities/utilities.h"
#include "utilities/Globals.h"
#include "utilities/parser.h"
#include "utilities/U8.h"
//#include "utilities/Logs.h"
@@ -204,7 +206,7 @@ std::string to_hex_str(int const Value, int const Width)
return o.str();
};
std::string const fractionlabels[] = {" ", "¹", "²", "³", "", "", "", "", "", ""};
std::string const fractionlabels[] = {U8(" "), U8("¹"), U8("²"), U8("³"), U8(""), U8(""), U8(""), U8(""), U8(""), U8("")};
std::string to_minutes_str(float const Minutes, bool const Leadingzero, int const Width)
{

View File

@@ -113,7 +113,7 @@ void ui::cameraview_panel::render_contents()
}
ImVec2 surface_size = ImGui::GetContentRegionAvail();
ImGui::Image(reinterpret_cast<void*>(texture->id), surface_size);
ImGui::Image((ImTextureID)(intptr_t)(texture->id), surface_size);
}
void ui::cameraview_panel::capture_func()

View File

@@ -299,7 +299,7 @@ void ui::map_panel::render_contents()
ImVec2 window_origin = ImGui::GetCursorPos();
ImVec2 screen_origin = ImGui::GetCursorScreenPos();
ImGui::ImageButton(reinterpret_cast<void *>(m_tex->id), surface_size_im, ImVec2(0, surface_size.y / fb_size), ImVec2(surface_size.x / fb_size, 0), 0);
ImGui::ImageButton((ImTextureID)(intptr_t)(m_tex->id), surface_size_im, ImVec2(0, surface_size.y / fb_size), ImVec2(surface_size.x / fb_size, 0), 0);
if (ImGui::IsItemHovered())
{

View File

@@ -25,7 +25,7 @@ map::sorted_object_list map::objects::find_in_range(glm::vec3 from, float distan
float dist = glm::distance2(entry_location, search_point);
if (dist < max_distance2)
{
items.emplace(dist, std::move(entry));
items.emplace(dist, entry);
}
}

View File

@@ -537,13 +537,12 @@ updatevalues_event::run_() {
// targetcell->LogValues();
if( targetcell->Track == nullptr ) { continue; }
// McZapkie-100302 - updatevalues oprocz zmiany wartosci robi putcommand dla wszystkich 'dynamic' na danym torze
auto const location { targetcell->location() };
for( auto vehicle : targetcell->Track->Dynamics ) {
if( vehicle->Mechanik ) {
WriteLog( " Vehicle: [" + vehicle->name() + "]" );
targetcell->PutCommand(
vehicle->Mechanik,
&location );
&targetcell->location() );
}
}
}