diff --git a/application/drivermode.cpp b/application/drivermode.cpp index 9efb88ea..0aa033e1 100644 --- a/application/drivermode.cpp +++ b/application/drivermode.cpp @@ -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}; diff --git a/application/driveruipanels.cpp b/application/driveruipanels.cpp index 10c25861..f316f175 100644 --- a/application/driveruipanels.cpp +++ b/application/driveruipanels.cpp @@ -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 diff --git a/application/driveruipanels.h b/application/driveruipanels.h index 11b65c35..da4cad87 100644 --- a/application/driveruipanels.h +++ b/application/driveruipanels.h @@ -100,9 +100,6 @@ private: bool render_section( std::vector 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 diff --git a/application/scenarioloaderuilayer.cpp b/application/scenarioloaderuilayer.cpp index 7b53e543..b43c4fbd 100644 --- a/application/scenarioloaderuilayer.cpp +++ b/application/scenarioloaderuilayer.cpp @@ -202,7 +202,7 @@ void scenarioloader_ui::render_() // Gradient at the lower half of the screen if (!Global.NvRenderer) { - const auto tex = reinterpret_cast(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)); } diff --git a/gl/buffer.cpp b/gl/buffer.cpp index 0321a70b..8b8bd486 100644 --- a/gl/buffer.cpp +++ b/gl/buffer.cpp @@ -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) diff --git a/gl/buffer.h b/gl/buffer.h index ee5d91e5..8b4e7d9c 100644 --- a/gl/buffer.h +++ b/gl/buffer.h @@ -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); }; } diff --git a/gl/ubo.cpp b/gl/ubo.cpp index 1ef45198..cecf84f0 100644 --- a/gl/ubo.cpp +++ b/gl/ubo.cpp @@ -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); } diff --git a/gl/ubo.h b/gl/ubo.h index b22b17e1..c4fa0f18 100644 --- a/gl/ubo.h +++ b/gl/ubo.h @@ -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 void update(const T &data, size_t offset = 0) { update(reinterpret_cast(&data), offset, sizeof(data)); diff --git a/launcher/scenery_list.cpp b/launcher/scenery_list.cpp index c17d06a0..7a54b3e2 100644 --- a/launcher/scenery_list.cpp +++ b/launcher/scenery_list.cpp @@ -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(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(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(); diff --git a/launcher/vehicle_picker.cpp b/launcher/vehicle_picker.cpp index 252993e4..43d7b198 100644 --- a/launcher/vehicle_picker.cpp +++ b/launcher/vehicle_picker.cpp @@ -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(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(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(); diff --git a/model/Model3d.cpp b/model/Model3d.cpp index b483d16e..b96160ad 100644 --- a/model/Model3d.cpp +++ b/model/Model3d.cpp @@ -604,7 +604,7 @@ std::pair 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 { diff --git a/network/network.cpp b/network/network.cpp index 342db5a3..ae83bf78 100644 --- a/network/network.cpp +++ b/network/network.cpp @@ -125,7 +125,7 @@ void network::server::handle_message(std::shared_ptr conn, const mes } if (msg.type == message::CLIENT_HELLO) { - auto cmd = dynamic_cast(msg); + const auto& cmd = dynamic_cast(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 conn, const mes WriteLog("net: client accepted", logtype::net); } else if (msg.type == message::REQUEST_COMMAND) { - auto cmd = dynamic_cast(msg); + const auto& cmd = dynamic_cast(msg); for (auto const &kv : cmd.commands) client_commands_queue.emplace(kv); @@ -189,7 +189,7 @@ std::tuple 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>(frame_time).count(); if (counter == 1 && size < MAX_BUFFER_SIZE * 2.0f) { @@ -241,7 +241,7 @@ void network::client::handle_message(std::shared_ptr conn, const mes } if (msg.type == message::SERVER_HELLO) { - auto cmd = dynamic_cast(msg); + const auto& cmd = dynamic_cast(msg); conn->state = connection::ACTIVE; if (!Global.ready_to_load) { diff --git a/rendering/opengl33renderer.cpp b/rendering/opengl33renderer.cpp index bf46f3b7..cf5795fa 100644 --- a/rendering/opengl33renderer.cpp +++ b/rendering/opengl33renderer.cpp @@ -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(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(); diff --git a/rendering/openglrenderer.cpp b/rendering/openglrenderer.cpp index 868e5122..d159c31a 100644 --- a/rendering/openglrenderer.cpp +++ b/rendering/openglrenderer.cpp @@ -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 ), diff --git a/rendering/particles.cpp b/rendering/particles.cpp index 12eaa737..eb02bf41 100644 --- a/rendering/particles.cpp +++ b/rendering/particles.cpp @@ -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) diff --git a/scene/scene.cpp b/scene/scene.cpp index c2100449..0675fe3b 100644 --- a/scene/scene.cpp +++ b/scene/scene.cpp @@ -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 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) { diff --git a/scene/sceneeditor.cpp b/scene/sceneeditor.cpp index 792de5a1..be8755a2 100644 --- a/scene/sceneeditor.cpp +++ b/scene/sceneeditor.cpp @@ -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( Offset * std::max( 1.0, distance * 0.01 ) ) }; if( Node->group() <= 1 ) { diff --git a/utilities/U8.h b/utilities/U8.h new file mode 100644 index 00000000..a0a94381 --- /dev/null +++ b/utilities/U8.h @@ -0,0 +1,3 @@ +#pragma once + +#define U8(str) (const char *)u8##str \ No newline at end of file diff --git a/utilities/utilities.cpp b/utilities/utilities.cpp index fc1d7a53..cbfd034f 100644 --- a/utilities/utilities.cpp +++ b/utilities/utilities.cpp @@ -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) { diff --git a/widgets/cameraview_extcam.cpp b/widgets/cameraview_extcam.cpp index 1328b485..80deddbe 100644 --- a/widgets/cameraview_extcam.cpp +++ b/widgets/cameraview_extcam.cpp @@ -113,7 +113,7 @@ void ui::cameraview_panel::render_contents() } ImVec2 surface_size = ImGui::GetContentRegionAvail(); - ImGui::Image(reinterpret_cast(texture->id), surface_size); + ImGui::Image((ImTextureID)(intptr_t)(texture->id), surface_size); } void ui::cameraview_panel::capture_func() diff --git a/widgets/map.cpp b/widgets/map.cpp index 297c0351..379b0311 100644 --- a/widgets/map.cpp +++ b/widgets/map.cpp @@ -299,7 +299,7 @@ void ui::map_panel::render_contents() ImVec2 window_origin = ImGui::GetCursorPos(); ImVec2 screen_origin = ImGui::GetCursorScreenPos(); - ImGui::ImageButton(reinterpret_cast(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()) { diff --git a/widgets/map_objects.cpp b/widgets/map_objects.cpp index 4ed6c98a..d67c73f5 100644 --- a/widgets/map_objects.cpp +++ b/widgets/map_objects.cpp @@ -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); } } diff --git a/world/Event.cpp b/world/Event.cpp index fad60bc4..3cbb53ab 100644 --- a/world/Event.cpp +++ b/world/Event.cpp @@ -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() ); } } }