diff --git a/Console/PoKeys55.cpp b/Console/PoKeys55.cpp index 40d23c83..1e320543 100644 --- a/Console/PoKeys55.cpp +++ b/Console/PoKeys55.cpp @@ -19,8 +19,8 @@ http://mozilla.org/MPL/2.0/. // HID\Vid_1dc3&Pid_1001&Rev_1000&MI_01 - MI_01 to jest interfejs komunikacyjny (00-joystick, // 02-klawiatura) -HANDLE WriteHandle = INVALID_HANDLE_VALUE; -HANDLE ReadHandle = INVALID_HANDLE_VALUE; +auto WriteHandle = INVALID_HANDLE_VALUE; +auto ReadHandle = INVALID_HANDLE_VALUE; // GUID InterfaceClassGuid={0x4d1e55b2,0xf16f,0x11cf,0x88,0xcb,0x00,0x11,0x11,0x00,0x00,0x30}; //{4d1e55b2-f16f-11cf-88cb-001111000030} @@ -59,8 +59,8 @@ bool TPoKeys55::Connect() GUID InterfaceClassGuid = {0x4d1e55b2, 0xf16f, 0x11cf, 0x88, 0xcb, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30}; // wszystkie HID tak mają HDEVINFO DeviceInfoTable; - PSP_DEVICE_INTERFACE_DATA InterfaceDataStructure = new SP_DEVICE_INTERFACE_DATA; - PSP_DEVICE_INTERFACE_DETAIL_DATA DetailedInterfaceDataStructure = + auto InterfaceDataStructure = new SP_DEVICE_INTERFACE_DATA; + auto DetailedInterfaceDataStructure = new SP_DEVICE_INTERFACE_DETAIL_DATA; SP_DEVINFO_DATA DevInfoData; DWORD InterfaceIndex = 0; diff --git a/EU07.cpp b/EU07.cpp index e1be8584..fd66c3fd 100644 --- a/EU07.cpp +++ b/EU07.cpp @@ -65,7 +65,7 @@ LONG WINAPI CrashHandler(EXCEPTION_POINTERS *ExceptionInfo) dumpInfo.ClientPointers = FALSE; // Wybrana kombinacja flag - MINIDUMP_TYPE dumpType = MINIDUMP_TYPE(MiniDumpWithFullMemory | MiniDumpWithHandleData | MiniDumpWithThreadInfo | MiniDumpWithUnloadedModules | MiniDumpWithIndirectlyReferencedMemory | + auto dumpType = MINIDUMP_TYPE(MiniDumpWithFullMemory | MiniDumpWithHandleData | MiniDumpWithThreadInfo | MiniDumpWithUnloadedModules | MiniDumpWithIndirectlyReferencedMemory | MiniDumpWithFullMemoryInfo | MiniDumpWithTokenInformation); MessageBoxA(nullptr, "Simulator crash occured :(\n", "Simulator crashed :(", MB_ICONERROR); diff --git a/application/application.cpp b/application/application.cpp index 030a441b..4657aff0 100644 --- a/application/application.cpp +++ b/application/application.cpp @@ -203,7 +203,7 @@ void eu07_application::DiscordRPCService() { // initialize discord-rpc WriteLog("Initializing Discord Rich Presence..."); - static const char *discord_app_id = "1343662664504840222"; + static auto discord_app_id = "1343662664504840222"; DiscordEventHandlers handlers; memset(&handlers, 0, sizeof(handlers)); Discord_Initialize(discord_app_id, &handlers, 1, nullptr); diff --git a/application/drivermode.cpp b/application/drivermode.cpp index 80fd3b17..a002bc0b 100644 --- a/application/drivermode.cpp +++ b/application/drivermode.cpp @@ -575,7 +575,7 @@ void driver_mode::update_camera(double const Deltatime) } else { - TDynamicObject *d = std::get(simulation::Region->find_vehicle(Camera.Pos, 300, false, false)); + auto d = std::get(simulation::Region->find_vehicle(Camera.Pos, 300, false, false)); if (!d) d = std::get(simulation::Region->find_vehicle(Camera.Pos, 1000, false, false)); // dalej szukanie, jesli bliżej nie ma @@ -963,7 +963,7 @@ void driver_mode::OnKeyDown(int cKey) // only available in free fly mode break; - TDynamicObject *dynamic = std::get(simulation::Region->find_vehicle(Global.pCamera.Pos, 50, false, false)); + auto dynamic = std::get(simulation::Region->find_vehicle(Global.pCamera.Pos, 50, false, false)); if (dynamic) { m_relay.post(user_command::entervehicle, Global.ctrlState ? GLFW_MOD_CONTROL : 0, simulation::Train ? simulation::Train->id() : 0, GLFW_PRESS, 0, dynamic->GetPosition(), diff --git a/application/driveruipanels.cpp b/application/driveruipanels.cpp index 729b854c..03a7692b 100644 --- a/application/driveruipanels.cpp +++ b/application/driveruipanels.cpp @@ -612,7 +612,7 @@ debug_panel::render() { #ifdef WITH_UART if(true == render_section( "UART", m_uartlines)) { int ports_num = 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(); } diff --git a/application/editormode.cpp b/application/editormode.cpp index 111152ae..e8a33283 100644 --- a/application/editormode.cpp +++ b/application/editormode.cpp @@ -1090,7 +1090,7 @@ void editor_mode::handle_terrain_sculpt(double Deltatime) void editor_mode::capture_terrain() { - TAnimModel *model = dynamic_cast(m_node); + auto model = dynamic_cast(m_node); if (model == nullptr || model->pModel == nullptr) { WriteLog("Editor: select a model instance to capture as terrain", logtype::generic); @@ -1231,9 +1231,9 @@ void editor_mode::render_gizmo() glm::mat4 const projection = glm::perspective(fovy, aspect, 0.1f, 10000.0f); // rotation/scale are only meaningful for instanced models; other node types translate only - TAnimModel *model = dynamic_cast(m_node); + auto model = dynamic_cast(m_node); - glm::vec3 const relativepos = glm::vec3(m_node->location() - camerapos); + auto const relativepos = glm::vec3(m_node->location() - camerapos); glm::vec3 const angles = model ? model->Angles() : glm::vec3(0.0f); glm::vec3 const scalevec = model ? model->Scale() : glm::vec3(1.0f); @@ -1246,7 +1246,7 @@ void editor_mode::render_gizmo() // map the editor's transform mode onto ImGuizmo; fall back to translate for non-models ImGuizmo::OPERATION operation = ImGuizmo::TRANSLATE; - EditorSnapshot::Action action = EditorSnapshot::Action::Move; + auto action = EditorSnapshot::Action::Move; if (model && m_gizmo_op == gizmo_operation::rotate) { operation = ImGuizmo::ROTATE; @@ -1473,7 +1473,7 @@ void editor_mode::on_key(int const Key, int const Scancode, int const Action, in case GLFW_KEY_DELETE: if (is_press(Action)) { - TAnimModel *model = dynamic_cast(m_node); + auto model = dynamic_cast(m_node); if (model) { // record deletion for undo (serialize full node) diff --git a/application/scenarioloaderuilayer.cpp b/application/scenarioloaderuilayer.cpp index c4e7df3d..e5c02cb8 100644 --- a/application/scenarioloaderuilayer.cpp +++ b/application/scenarioloaderuilayer.cpp @@ -67,7 +67,7 @@ scenarioloader_ui::scenarioloader_ui() std::vector scenarioloader_ui::get_random_trivia() { WriteLog("Loading random trivia..."); - std::vector trivia = std::vector(); + auto trivia = std::vector(); if (!FileExists("lang/trivia_" + Global.asLang + ".json") && !FileExists("lang/trivia_en.json")) @@ -203,7 +203,7 @@ void scenarioloader_ui::render_() // Gradient at the lower half of the screen if (!Global.NvRenderer) { - 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 + const auto 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)); } @@ -284,7 +284,7 @@ void scenarioloader_ui::render_() if (!sceneryName.empty()) { ImVec2 text_size = ImGui::CalcTextSize(sceneryName.c_str()); - ImVec2 text_pos = ImVec2(screen_size.x - 16 * scale - text_size.x, 16 * scale); + auto text_pos = ImVec2(screen_size.x - 16 * scale - text_size.x, 16 * scale); draw_list->AddText(text_pos, IM_COL32_WHITE, sceneryName.c_str()); } diff --git a/audio/audio.cpp b/audio/audio.cpp index 1c72d1bc..6bb1b4e9 100644 --- a/audio/audio.cpp +++ b/audio/audio.cpp @@ -36,7 +36,7 @@ openal_buffer::openal_buffer( std::string const &Filename ) : sf_command(sf, SFC_SET_NORM_FLOAT, nullptr, SF_TRUE); - float *fbuf = new float[si.frames * si.channels]; + auto fbuf = new float[si.frames * si.channels]; if (sf_readf_float(sf, fbuf, si.frames) != si.frames) throw std::runtime_error("sound: incomplete file"); @@ -47,7 +47,7 @@ openal_buffer::openal_buffer( std::string const &Filename ) : if (si.channels != 1) WriteLog("sound: warning: mixing multichannel file to mono"); - int16_t *buf = new int16_t[si.frames]; + auto buf = new int16_t[si.frames]; for (size_t i = 0; i < si.frames; i++) { float accum = 0; diff --git a/gl/shader.cpp b/gl/shader.cpp index 0b8b3e4d..e2a5a034 100644 --- a/gl/shader.cpp +++ b/gl/shader.cpp @@ -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(glGetStringi(GL_EXTENSIONS, i)); + auto ext = reinterpret_cast(glGetStringi(GL_EXTENSIONS, i)); if (ext != nullptr && std::strcmp(ext, name) == 0) { return true; } diff --git a/imgui/ImGuizmo.cpp b/imgui/ImGuizmo.cpp index 41caa41a..b92d056d 100644 --- a/imgui/ImGuizmo.cpp +++ b/imgui/ImGuizmo.cpp @@ -1210,7 +1210,7 @@ namespace ImGuizmo { continue; } - ImVec2* circlePos = (ImVec2*) alloca(sizeof(ImVec2) * (circleMul * halfCircleSegmentCount + 1)); + auto circlePos = (ImVec2*) alloca(sizeof(ImVec2) * (circleMul * halfCircleSegmentCount + 1)); float angleStart = atan2f(cameraToModelNormalized[(4 - axis) % 3], cameraToModelNormalized[(3 - axis) % 3]) + ZPI * 0.5f; @@ -2357,7 +2357,7 @@ namespace ImGuizmo ImVec2 faceCoordsScreen[4]; ImU32 color; }; - CubeFace* faces = (CubeFace*)_malloca(sizeof(CubeFace) * matrixCount * 6); + auto faces = (CubeFace*)_malloca(sizeof(CubeFace) * matrixCount * 6); if (!faces) { @@ -2440,8 +2440,8 @@ namespace ImGuizmo } } qsort(faces, cubeFaceCount, sizeof(CubeFace), [](void const* _a, void const* _b) { - CubeFace* a = (CubeFace*)_a; - CubeFace* b = (CubeFace*)_b; + auto a = (CubeFace*)_a; + auto b = (CubeFace*)_b; if (a->z < b->z) { return 1; diff --git a/imgui/imgui.cpp b/imgui/imgui.cpp index 93b15ddb..71613547 100644 --- a/imgui/imgui.cpp +++ b/imgui/imgui.cpp @@ -1377,7 +1377,7 @@ char* ImStrdupcpy(char* dst, size_t* p_dst_size, const char* src) const char* ImStrchrRange(const char* str, const char* str_end, char c) { - const char* p = (const char*)memchr(str, (int)c, str_end - str); + auto p = (const char*)memchr(str, (int)c, str_end - str); return p; } @@ -1392,7 +1392,7 @@ int ImStrlenW(const ImWchar* str) // Find end-of-line. Return pointer will point to either first \n, either str_end. const char* ImStreolRange(const char* str, const char* str_end) { - const char* p = (const char*)memchr(str, '\n', str_end - str); + auto p = (const char*)memchr(str, '\n', str_end - str); return p ? p : str_end; } @@ -1519,7 +1519,7 @@ static const ImU32 GCrc32LookupTable[256] = ImU32 ImHashData(const void* data_p, size_t data_size, ImU32 seed) { ImU32 crc = ~seed; - const unsigned char* data = (const unsigned char*)data_p; + auto data = (const unsigned char*)data_p; const ImU32* crc32_lut = GCrc32LookupTable; while (data_size-- != 0) crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ *data++]; @@ -1536,7 +1536,7 @@ ImU32 ImHashStr(const char* data_p, size_t data_size, ImU32 seed) { seed = ~seed; ImU32 crc = seed; - const unsigned char* data = (const unsigned char*)data_p; + auto data = (const unsigned char*)data_p; const ImU32* crc32_lut = GCrc32LookupTable; if (data_size != 0) { @@ -1628,7 +1628,7 @@ void* ImFileLoadToMemory(const char* filename, const char* file_open_mode, size_ int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char* in_text_end) { unsigned int c = (unsigned int)-1; - const unsigned char* str = (const unsigned char*)in_text; + auto str = (const unsigned char*)in_text; if (!(*str & 0x80)) { c = (unsigned int)(*str++); @@ -3278,7 +3278,7 @@ void ImGui::SetAllocatorFunctions(void* (*alloc_func)(size_t sz, void* user_data ImGuiContext* ImGui::CreateContext(ImFontAtlas* shared_font_atlas) { - ImGuiContext* ctx = IM_NEW(ImGuiContext)(shared_font_atlas); + auto ctx = IM_NEW(ImGuiContext)(shared_font_atlas); if (GImGui == NULL) SetCurrentContext(ctx); Initialize(ctx); @@ -4859,7 +4859,7 @@ static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFl //IMGUI_DEBUG_LOG("CreateNewWindow '%s', flags = 0x%08X\n", name, flags); // Create window the first time - ImGuiWindow* window = IM_NEW(ImGuiWindow)(&g, name); + auto window = IM_NEW(ImGuiWindow)(&g, name); window->Flags = flags; g.WindowsById.SetVoidPtr(window->ID, window); @@ -4953,7 +4953,7 @@ static ImVec2 CalcWindowAutoFitSize(ImGuiWindow* window, const ImVec2& size_cont { ImGuiContext& g = *GImGui; ImGuiStyle& style = g.Style; - ImVec2 size_decorations = ImVec2(0.0f, window->TitleBarHeight() + window->MenuBarHeight()); + auto size_decorations = ImVec2(0.0f, window->TitleBarHeight() + window->MenuBarHeight()); ImVec2 size_pad = window->WindowPadding * 2.0f; ImVec2 size_desired = size_contents + size_pad + size_decorations; if (window->Flags & ImGuiWindowFlags_Tooltip) @@ -5340,7 +5340,7 @@ void ImGui::RenderWindowTitleBarContents(ImGuiWindow* window, const ImRect& titl // Title bar text (with: horizontal alignment, avoiding collapse/close button, optional "unsaved document" marker) // FIXME: Refactor text alignment facilities along with RenderText helpers, this is WAY too much messy code.. - const char* UNSAVED_DOCUMENT_MARKER = "*"; + auto UNSAVED_DOCUMENT_MARKER = "*"; const float marker_size_x = (flags & ImGuiWindowFlags_UnsavedDocument) ? CalcTextSize(UNSAVED_DOCUMENT_MARKER, NULL, false).x : 0.0f; const ImVec2 text_size = CalcTextSize(name, NULL, true) + ImVec2(marker_size_x, 0.0f); @@ -5365,7 +5365,7 @@ void ImGui::RenderWindowTitleBarContents(ImGuiWindow* window, const ImRect& titl if (flags & ImGuiWindowFlags_UnsavedDocument) { ImVec2 marker_pos = ImVec2(ImMax(layout_r.Min.x, layout_r.Min.x + (layout_r.GetWidth() - text_size.x) * style.WindowTitleAlign.x) + text_size.x, layout_r.Min.y) + ImVec2(2 - marker_size_x, 0.0f); - ImVec2 off = ImVec2(0.0f, (float)(int)(-g.FontSize * 0.25f)); + auto off = ImVec2(0.0f, (float)(int)(-g.FontSize * 0.25f)); RenderTextClipped(marker_pos + off, layout_r.Max + off, UNSAVED_DOCUMENT_MARKER, NULL, NULL, ImVec2(0, style.WindowTitleAlign.y), &clip_r); } } @@ -5718,7 +5718,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) { // When reading the current size we need to read it after size constraints have been applied. // When we use InnerRect here we are intentionally reading last frame size, same for ScrollbarSizes values before we set them again. - ImVec2 avail_size_from_current_frame = ImVec2(window->SizeFull.x, window->SizeFull.y - decoration_up_height); + auto avail_size_from_current_frame = ImVec2(window->SizeFull.x, window->SizeFull.y - decoration_up_height); ImVec2 avail_size_from_last_frame = window->InnerRect.GetSize() + window->ScrollbarSizes; ImVec2 needed_size_from_last_frame = window_just_created ? ImVec2(0, 0) : window->ContentSize + window->WindowPadding * 2.0f; float size_x_for_scrollbars = use_current_size_for_scrollbar_x ? avail_size_from_current_frame.x : avail_size_from_last_frame.x; @@ -6396,7 +6396,7 @@ void ImGui::PushStyleVar(ImGuiStyleVar idx, float val) if (var_info->Type == ImGuiDataType_Float && var_info->Count == 1) { ImGuiContext& g = *GImGui; - float* pvar = (float*)var_info->GetVarPtr(&g.Style); + auto pvar = (float*)var_info->GetVarPtr(&g.Style); g.StyleModifiers.push_back(ImGuiStyleMod(idx, *pvar)); *pvar = val; return; @@ -6410,7 +6410,7 @@ void ImGui::PushStyleVar(ImGuiStyleVar idx, const ImVec2& val) if (var_info->Type == ImGuiDataType_Float && var_info->Count == 2) { ImGuiContext& g = *GImGui; - ImVec2* pvar = (ImVec2*)var_info->GetVarPtr(&g.Style); + auto pvar = (ImVec2*)var_info->GetVarPtr(&g.Style); g.StyleModifiers.push_back(ImGuiStyleMod(idx, *pvar)); *pvar = val; return; @@ -7803,7 +7803,7 @@ ImVec2 ImGui::FindBestWindowPosForPopup(ImGuiWindow* window) } if (window->Flags & ImGuiWindowFlags_Popup) { - ImRect r_avoid = ImRect(window->Pos.x - 1, window->Pos.y - 1, window->Pos.x + 1, window->Pos.y + 1); + auto r_avoid = ImRect(window->Pos.x - 1, window->Pos.y - 1, window->Pos.x + 1, window->Pos.y + 1); return FindBestWindowPosForPopupEx(window->Pos, window->Size, &window->AutoPosLastDirection, r_outer, r_avoid); } if (window->Flags & ImGuiWindowFlags_Tooltip) @@ -8561,7 +8561,7 @@ static void ImGui::NavUpdateMoveResult() } else { - ImRect rect_abs = ImRect(result->RectRel.Min + result->Window->Pos, result->RectRel.Max + result->Window->Pos); + auto rect_abs = ImRect(result->RectRel.Min + result->Window->Pos, result->RectRel.Max + result->Window->Pos); delta_scroll = ScrollToBringRectIntoView(result->Window, rect_abs); } @@ -9419,7 +9419,7 @@ ImGuiWindowSettings* ImGui::FindOrCreateWindowSettings(const char* name) void ImGui::LoadIniSettingsFromDisk(const char* ini_filename) { size_t file_data_size = 0; - char* file_data = (char*)ImFileLoadToMemory(ini_filename, "rb", &file_data_size); + auto file_data = (char*)ImFileLoadToMemory(ini_filename, "rb", &file_data_size); if (!file_data) return; LoadIniSettingsFromMemory(file_data, (size_t)file_data_size); @@ -9447,7 +9447,7 @@ void ImGui::LoadIniSettingsFromMemory(const char* ini_data, size_t ini_size) // For our convenience and to make the code simpler, we'll also write zero-terminators within the buffer. So let's create a writable copy.. if (ini_size == 0) ini_size = strlen(ini_data); - char* buf = (char*)IM_ALLOC(ini_size + 1); + auto buf = (char*)IM_ALLOC(ini_size + 1); char* buf_end = buf + ini_size; memcpy(buf, ini_data, ini_size); buf[ini_size] = 0; @@ -9473,7 +9473,7 @@ void ImGui::LoadIniSettingsFromMemory(const char* ini_data, size_t ini_size) line_end[-1] = 0; const char* name_end = line_end - 1; const char* type_start = line + 1; - char* type_end = (char*)(intptr_t)ImStrchrRange(type_start, name_end, ']'); + auto type_end = (char*)(intptr_t)ImStrchrRange(type_start, name_end, ']'); const char* name_start = type_end ? ImStrchrRange(type_end + 1, name_end, '[') : NULL; if (!type_end || !name_start) { @@ -9541,7 +9541,7 @@ static void* SettingsHandlerWindow_ReadOpen(ImGuiContext*, ImGuiSettingsHandler* static void SettingsHandlerWindow_ReadLine(ImGuiContext*, ImGuiSettingsHandler*, void* entry, const char* line) { - ImGuiWindowSettings* settings = (ImGuiWindowSettings*)entry; + auto settings = (ImGuiWindowSettings*)entry; int x, y; int i; if (sscanf(line, "Pos=%i,%i", &x, &y) == 2) settings->Pos = ImVec2ih((short)x, (short)y); @@ -9636,7 +9636,7 @@ static const char* GetClipboardTextFn_DefaultImpl(void*) ::CloseClipboard(); return NULL; } - if (ImWchar* wbuf_global = (ImWchar*)::GlobalLock(wbuf_handle)) + if (auto wbuf_global = (ImWchar*)::GlobalLock(wbuf_handle)) { int buf_len = ImTextCountUtf8BytesFromStr(wbuf_global, NULL) + 1; buf_local.resize(buf_len); @@ -9658,7 +9658,7 @@ static void SetClipboardTextFn_DefaultImpl(void*, const char* text) ::CloseClipboard(); return; } - ImWchar* wbuf_global = (ImWchar*)::GlobalLock(wbuf_handle); + auto wbuf_global = (ImWchar*)::GlobalLock(wbuf_handle); ImTextStrFromUtf8(wbuf_global, wbuf_length, text, NULL); ::GlobalUnlock(wbuf_handle); ::EmptyClipboard(); @@ -9752,7 +9752,7 @@ static void ImeSetInputScreenPosFn_DefaultImpl(int x, int y) { // Notify OS Input Method Editor of text input position ImGuiIO& io = ImGui::GetIO(); - if (HWND hwnd = (HWND)io.ImeWindowHandle) + if (auto hwnd = (HWND)io.ImeWindowHandle) if (HIMC himc = ::ImmGetContext(hwnd)) { COMPOSITIONFORM cf; diff --git a/imgui/imgui_demo.cpp b/imgui/imgui_demo.cpp index b8576e58..d56af070 100644 --- a/imgui/imgui_demo.cpp +++ b/imgui/imgui_demo.cpp @@ -769,8 +769,8 @@ static void ShowDemoWindowWidgets() float zoom = 4.0f; ImGui::Text("Min: (%.2f, %.2f)", region_x, region_y); ImGui::Text("Max: (%.2f, %.2f)", region_x + region_sz, region_y + region_sz); - ImVec2 uv0 = ImVec2((region_x) / my_tex_w, (region_y) / my_tex_h); - ImVec2 uv1 = ImVec2((region_x + region_sz) / my_tex_w, (region_y + region_sz) / my_tex_h); + auto uv0 = ImVec2((region_x) / my_tex_w, (region_y) / my_tex_h); + auto uv1 = ImVec2((region_x + region_sz) / my_tex_w, (region_y + region_sz) / my_tex_h); ImGui::Image(my_tex_id, ImVec2(region_sz * zoom, region_sz * zoom), uv0, uv1, ImVec4(1.0f, 1.0f, 1.0f, 1.0f), ImVec4(1.0f, 1.0f, 1.0f, 0.5f)); ImGui::EndTooltip(); } @@ -932,7 +932,7 @@ static void ShowDemoWindowWidgets() { for (int x = 0; x < 3; x++) { - ImVec2 alignment = ImVec2((float)x / 2.0f, (float)y / 2.0f); + auto alignment = ImVec2((float)x / 2.0f, (float)y / 2.0f); char name[32]; sprintf(name, "(%.1f,%.1f)", alignment.x, alignment.y); if (x > 0) ImGui::SameLine(); @@ -1003,7 +1003,7 @@ static void ShowDemoWindowWidgets() { if (data->EventFlag == ImGuiInputTextFlags_CallbackResize) { - ImVector* my_str = (ImVector*)data->UserData; + auto my_str = (ImVector*)data->UserData; IM_ASSERT(my_str->begin() == data->Buf); my_str->resize(data->BufSize); // NB: On resizing calls, generally data->BufSize == data->BufTextLen + 1 data->Buf = my_str->begin(); @@ -1100,7 +1100,7 @@ static void ShowDemoWindowWidgets() if (ImGui::TreeNode("Color/Picker Widgets")) { - static ImVec4 color = ImVec4(114.0f/255.0f, 144.0f/255.0f, 154.0f/255.0f, 200.0f/255.0f); + static auto color = ImVec4(114.0f/255.0f, 144.0f/255.0f, 154.0f/255.0f, 200.0f/255.0f); static bool alpha_preview = true; static bool alpha_half_preview = false; @@ -3250,8 +3250,8 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref) } if (ImGui::TreeNode("Atlas texture", "Atlas texture (%dx%d pixels)", atlas->TexWidth, atlas->TexHeight)) { - ImVec4 tint_col = ImVec4(1.0f, 1.0f, 1.0f, 1.0f); - ImVec4 border_col = ImVec4(1.0f, 1.0f, 1.0f, 0.5f); + auto tint_col = ImVec4(1.0f, 1.0f, 1.0f, 1.0f); + auto border_col = ImVec4(1.0f, 1.0f, 1.0f, 0.5f); ImGui::Image(atlas->TexID, ImVec2((float)atlas->TexWidth, (float)atlas->TexHeight), ImVec2(0, 0), ImVec2(1, 1), tint_col, border_col); ImGui::TreePop(); } @@ -3602,7 +3602,7 @@ struct ExampleAppConsole static int TextEditCallbackStub(ImGuiInputTextCallbackData* data) // In C++11 you are better off using lambdas for this sort of forwarding callbacks { - ExampleAppConsole* console = (ExampleAppConsole*)data->UserData; + auto console = (ExampleAppConsole*)data->UserData; return console->TextEditCallback(data); } @@ -4146,8 +4146,8 @@ static void ShowExampleAppSimpleOverlay(bool* p_open) ImGuiIO& io = ImGui::GetIO(); if (corner != -1) { - ImVec2 window_pos = ImVec2((corner & 1) ? io.DisplaySize.x - DISTANCE : DISTANCE, (corner & 2) ? io.DisplaySize.y - DISTANCE : DISTANCE); - ImVec2 window_pos_pivot = ImVec2((corner & 1) ? 1.0f : 0.0f, (corner & 2) ? 1.0f : 0.0f); + auto window_pos = ImVec2((corner & 1) ? io.DisplaySize.x - DISTANCE : DISTANCE, (corner & 2) ? io.DisplaySize.y - DISTANCE : DISTANCE); + auto window_pos_pivot = ImVec2((corner & 1) ? 1.0f : 0.0f, (corner & 2) ? 1.0f : 0.0f); ImGui::SetNextWindowPos(window_pos, ImGuiCond_Always, window_pos_pivot); } ImGui::SetNextWindowBgAlpha(0.35f); // Forward background @@ -4231,7 +4231,7 @@ static void ShowExampleAppCustomRendering(bool* p_open) { static float sz = 36.0f; static float thickness = 3.0f; - static ImVec4 colf = ImVec4(1.0f, 1.0f, 0.4f, 1.0f); + static auto colf = ImVec4(1.0f, 1.0f, 0.4f, 1.0f); ImGui::DragFloat("Size", &sz, 0.2f, 2.0f, 72.0f, "%.0f"); ImGui::DragFloat("Thickness", &thickness, 0.05f, 1.0f, 8.0f, "%.02f"); ImGui::ColorEdit4("Color", &colf.x); @@ -4295,7 +4295,7 @@ static void ShowExampleAppCustomRendering(bool* p_open) bool adding_preview = false; ImGui::InvisibleButton("canvas", canvas_size); - ImVec2 mouse_pos_in_canvas = ImVec2(ImGui::GetIO().MousePos.x - canvas_pos.x, ImGui::GetIO().MousePos.y - canvas_pos.y); + auto mouse_pos_in_canvas = ImVec2(ImGui::GetIO().MousePos.x - canvas_pos.x, ImGui::GetIO().MousePos.y - canvas_pos.y); if (adding_line) { adding_preview = true; @@ -4334,7 +4334,7 @@ static void ShowExampleAppCustomRendering(bool* p_open) ImGui::Checkbox("Draw in Foreground draw list", &draw_fg); ImVec2 window_pos = ImGui::GetWindowPos(); ImVec2 window_size = ImGui::GetWindowSize(); - ImVec2 window_center = ImVec2(window_pos.x + window_size.x * 0.5f, window_pos.y + window_size.y * 0.5f); + auto window_center = ImVec2(window_pos.x + window_size.x * 0.5f, window_pos.y + window_size.y * 0.5f); if (draw_bg) ImGui::GetBackgroundDrawList()->AddCircle(window_center, window_size.x * 0.6f, IM_COL32(255, 0, 0, 200), 32, 10+4); if (draw_fg) diff --git a/imgui/imgui_draw.cpp b/imgui/imgui_draw.cpp index 845cd04e..27a04e8a 100644 --- a/imgui/imgui_draw.cpp +++ b/imgui/imgui_draw.cpp @@ -391,7 +391,7 @@ void ImDrawList::ClearFreeMemory() ImDrawList* ImDrawList::CloneOutput() const { - ImDrawList* dst = IM_NEW(ImDrawList(_Data)); + auto dst = IM_NEW(ImDrawList(_Data)); dst->CmdBuffer = CmdBuffer; dst->IdxBuffer = IdxBuffer; dst->VtxBuffer = VtxBuffer; @@ -614,7 +614,7 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32 PrimReserve(idx_count, vtx_count); // Temporary buffer - ImVec2* temp_normals = (ImVec2*)alloca(points_count * (thick_line ? 5 : 3) * sizeof(ImVec2)); //-V630 + auto temp_normals = (ImVec2*)alloca(points_count * (thick_line ? 5 : 3) * sizeof(ImVec2)); //-V630 ImVec2* temp_points = temp_normals + points_count; for (int i1 = 0; i1 < count; i1++) @@ -805,7 +805,7 @@ void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_coun } // Compute normals - ImVec2* temp_normals = (ImVec2*)alloca(points_count * sizeof(ImVec2)); //-V630 + auto temp_normals = (ImVec2*)alloca(points_count * sizeof(ImVec2)); //-V630 for (int i0 = points_count-1, i1 = 0; i1 < points_count; i0 = i1++) { const ImVec2& p0 = points[i0]; @@ -1385,7 +1385,7 @@ void ImGui::ShadeVertsLinearUV(ImDrawList* draw_list, int vert_start_idx, int ve { const ImVec2 size = b - a; const ImVec2 uv_size = uv_b - uv_a; - const ImVec2 scale = ImVec2( + const auto scale = ImVec2( size.x != 0.0f ? (uv_size.x / size.x) : 0.0f, size.y != 0.0f ? (uv_size.y / size.y) : 0.0f); @@ -1704,7 +1704,7 @@ ImFont* ImFontAtlas::AddFontFromMemoryTTF(void* ttf_data, int ttf_size, float si ImFont* ImFontAtlas::AddFontFromMemoryCompressedTTF(const void* compressed_ttf_data, int compressed_ttf_size, float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges) { const unsigned int buf_decompressed_size = stb_decompress_length((const unsigned char*)compressed_ttf_data); - unsigned char* buf_decompressed_data = (unsigned char *)IM_ALLOC(buf_decompressed_size); + auto buf_decompressed_data = (unsigned char *)IM_ALLOC(buf_decompressed_size); stb_decompress(buf_decompressed_data, (const unsigned char*)compressed_ttf_data, (unsigned int)compressed_ttf_size); ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig(); @@ -2124,7 +2124,7 @@ void ImFontAtlasBuildSetupFont(ImFontAtlas* atlas, ImFont* font, ImFontConfig* f void ImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas, void* stbrp_context_opaque) { - stbrp_context* pack_context = (stbrp_context*)stbrp_context_opaque; + auto pack_context = (stbrp_context*)stbrp_context_opaque; IM_ASSERT(pack_context != NULL); ImVector& user_rects = atlas->CustomRects; @@ -2740,7 +2740,7 @@ ImVec2 ImFont::CalcTextSizeA(float size, float max_width, float wrap_width, cons const float line_height = size; const float scale = size / FontSize; - ImVec2 text_size = ImVec2(0,0); + auto text_size = ImVec2(0,0); float line_width = 0.0f; const bool word_wrap_enabled = (wrap_width > 0.0f); @@ -3088,8 +3088,8 @@ void ImGui::RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, Im if (x_start_norm > x_end_norm) ImSwap(x_start_norm, x_end_norm); - ImVec2 p0 = ImVec2(ImLerp(rect.Min.x, rect.Max.x, x_start_norm), rect.Min.y); - ImVec2 p1 = ImVec2(ImLerp(rect.Min.x, rect.Max.x, x_end_norm), rect.Max.y); + auto p0 = ImVec2(ImLerp(rect.Min.x, rect.Max.x, x_start_norm), rect.Min.y); + auto p1 = ImVec2(ImLerp(rect.Min.x, rect.Max.x, x_end_norm), rect.Max.y); if (rounding == 0.0f) { draw_list->AddRectFilled(p0, p1, col, 0.0f); diff --git a/imgui/imgui_impl_opengl3.cpp b/imgui/imgui_impl_opengl3.cpp index e4bf631c..d328db49 100644 --- a/imgui/imgui_impl_opengl3.cpp +++ b/imgui/imgui_impl_opengl3.cpp @@ -408,7 +408,7 @@ bool ImGui_ImplOpenGL3_CreateDeviceObjects() int glsl_version = 130; sscanf(g_GlslVersionString, "#version %d", &glsl_version); - const GLchar* vertex_shader_glsl_120 = + auto vertex_shader_glsl_120 = "uniform mat4 ProjMtx;\n" "attribute vec2 Position;\n" "attribute vec2 UV;\n" @@ -422,7 +422,7 @@ bool ImGui_ImplOpenGL3_CreateDeviceObjects() " gl_Position = ProjMtx * vec4(Position.xy,0,1);\n" "}\n"; - const GLchar* vertex_shader_glsl_130 = + auto vertex_shader_glsl_130 = "uniform mat4 ProjMtx;\n" "in vec2 Position;\n" "in vec2 UV;\n" @@ -436,7 +436,7 @@ bool ImGui_ImplOpenGL3_CreateDeviceObjects() " gl_Position = ProjMtx * vec4(Position.xy,0,1);\n" "}\n"; - const GLchar* vertex_shader_glsl_300_es = + auto vertex_shader_glsl_300_es = "precision mediump float;\n" "layout (location = 0) in vec2 Position;\n" "layout (location = 1) in vec2 UV;\n" @@ -451,7 +451,7 @@ bool ImGui_ImplOpenGL3_CreateDeviceObjects() " gl_Position = ProjMtx * vec4(Position.xy,0,1);\n" "}\n"; - const GLchar* vertex_shader_glsl_410_core = + auto vertex_shader_glsl_410_core = "layout (location = 0) in vec2 Position;\n" "layout (location = 1) in vec2 UV;\n" "layout (location = 2) in vec4 Color;\n" @@ -465,7 +465,7 @@ bool ImGui_ImplOpenGL3_CreateDeviceObjects() " gl_Position = ProjMtx * vec4(Position.xy,0,1);\n" "}\n"; - const GLchar* fragment_shader_glsl_120 = + auto fragment_shader_glsl_120 = "#ifdef GL_ES\n" " precision mediump float;\n" "#endif\n" @@ -477,7 +477,7 @@ bool ImGui_ImplOpenGL3_CreateDeviceObjects() " gl_FragColor = Frag_Color * texture2D(Texture, Frag_UV.st);\n" "}\n"; - const GLchar* fragment_shader_glsl_130 = + auto fragment_shader_glsl_130 = "uniform sampler2D Texture;\n" "in vec2 Frag_UV;\n" "in vec4 Frag_Color;\n" @@ -487,7 +487,7 @@ bool ImGui_ImplOpenGL3_CreateDeviceObjects() " Out_Color = FBOUT(Frag_Color * texture(Texture, Frag_UV.st));\n" "}\n"; - const GLchar* fragment_shader_glsl_300_es = + auto fragment_shader_glsl_300_es = "precision mediump float;\n" "uniform sampler2D Texture;\n" "in vec2 Frag_UV;\n" @@ -498,7 +498,7 @@ bool ImGui_ImplOpenGL3_CreateDeviceObjects() " Out_Color = FBOUT(Frag_Color * texture(Texture, Frag_UV.st));\n" "}\n"; - const GLchar* fragment_shader_glsl_410_core = + auto fragment_shader_glsl_410_core = "in vec2 Frag_UV;\n" "in vec4 Frag_Color;\n" "uniform sampler2D Texture;\n" @@ -539,8 +539,8 @@ bool ImGui_ImplOpenGL3_CreateDeviceObjects() glCompileShader(g_VertHandle); CheckShader(g_VertHandle, "vertex shader"); - const GLchar* fbout_copy = "vec4 FBOUT(vec4 x) { return x; }\n"; - const GLchar* fbout_gamma = "vec4 FBOUT(vec4 x) { return vec4(pow(x.rgb, vec3(1.0 / 2.2)), x.a); }\n"; + auto fbout_copy = "vec4 FBOUT(vec4 x) { return x; }\n"; + auto fbout_gamma = "vec4 FBOUT(vec4 x) { return vec4(pow(x.rgb, vec3(1.0 / 2.2)), x.a); }\n"; const GLchar* fragment_shader_with_version[3] = { g_GlslVersionString, Global.gfx_shadergamma ? fbout_gamma : fbout_copy, fragment_shader }; g_FragHandle = glCreateShader(GL_FRAGMENT_SHADER); diff --git a/imgui/imgui_widgets.cpp b/imgui/imgui_widgets.cpp index d9ca11e5..4c6c5f62 100644 --- a/imgui/imgui_widgets.cpp +++ b/imgui/imgui_widgets.cpp @@ -169,7 +169,7 @@ void ImGui::TextEx(const char* text, const char* text_end, ImGuiTextFlags flags) int lines_skipped = 0; while (line < text_end && lines_skipped < lines_skippable) { - const char* line_end = (const char*)memchr(line, '\n', text_end - line); + auto line_end = (const char*)memchr(line, '\n', text_end - line); if (!line_end) line_end = text_end; if ((flags & ImGuiTextFlags_NoWidthForLargeClippedText) == 0) @@ -190,7 +190,7 @@ void ImGui::TextEx(const char* text, const char* text_end, ImGuiTextFlags flags) if (IsClippedEx(line_rect, 0, false)) break; - const char* line_end = (const char*)memchr(line, '\n', text_end - line); + auto line_end = (const char*)memchr(line, '\n', text_end - line); if (!line_end) line_end = text_end; text_size.x = ImMax(text_size.x, CalcTextSize(line, line_end).x); @@ -205,7 +205,7 @@ void ImGui::TextEx(const char* text, const char* text_end, ImGuiTextFlags flags) int lines_skipped = 0; while (line < text_end) { - const char* line_end = (const char*)memchr(line, '\n', text_end - line); + auto line_end = (const char*)memchr(line, '\n', text_end - line); if (!line_end) line_end = text_end; if ((flags & ImGuiTextFlags_NoWidthForLargeClippedText) == 0) @@ -1124,7 +1124,7 @@ void ImGui::ProgressBar(float fraction, const ImVec2& size_arg, const char* over fraction = ImSaturate(fraction); RenderFrame(bb.Min, bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding); bb.Expand(ImVec2(-style.FrameBorderSize, -style.FrameBorderSize)); - const ImVec2 fill_br = ImVec2(ImLerp(bb.Min.x, bb.Max.x, fraction), bb.Max.y); + const auto fill_br = ImVec2(ImLerp(bb.Min.x, bb.Max.x, fraction), bb.Max.y); RenderRectFilledRangeH(window->DrawList, bb, GetColorU32(ImGuiCol_PlotHistogram), 0.0f, fraction, style.FrameRounding); // Default displaying the fraction as percentage string, but user can override it @@ -1360,8 +1360,8 @@ bool ImGui::SplitterBehavior(const ImRect& bb, ImGuiID id, ImGuiAxis axis, float static int IMGUI_CDECL ShrinkWidthItemComparer(const void* lhs, const void* rhs) { - const ImGuiShrinkWidthItem* a = (const ImGuiShrinkWidthItem*)lhs; - const ImGuiShrinkWidthItem* b = (const ImGuiShrinkWidthItem*)rhs; + auto a = (const ImGuiShrinkWidthItem*)lhs; + auto b = (const ImGuiShrinkWidthItem*)rhs; if (int d = (int)(b->Width - a->Width)) return d; return (b->Index - a->Index); @@ -1533,7 +1533,7 @@ void ImGui::EndCombo() // Getter for the old Combo() API: const char*[] static bool Items_ArrayGetter(void* data, int idx, const char** out_text) { - const char* const* items = (const char* const*)data; + auto items = (const char* const*)data; if (out_text) *out_text = items[idx]; return true; @@ -1543,7 +1543,7 @@ static bool Items_ArrayGetter(void* data, int idx, const char** out_text) static bool Items_SingleStringGetter(void* data, int idx, const char** out_text) { // FIXME-OPT: we could pre-compute the indices to fasten this. But only 1 active combo means the waste is limited. - const char* items_separated_by_zeros = (const char*)data; + auto items_separated_by_zeros = (const char*)data; int items_count = 0; const char* p = items_separated_by_zeros; while (*p) @@ -1794,7 +1794,7 @@ bool ImGui::DataTypeApplyOpFromText(const char* buf, const char* initial_value_b int arg1i = 0; if (data_type == ImGuiDataType_S32) { - int* v = (int*)data_ptr; + auto v = (int*)data_ptr; int arg0i = *v; float arg1f = 0.0f; if (op && sscanf(initial_value_buf, format, &arg0i) < 1) @@ -1809,7 +1809,7 @@ bool ImGui::DataTypeApplyOpFromText(const char* buf, const char* initial_value_b { // For floats we have to ignore format with precision (e.g. "%.2f") because sscanf doesn't take them in format = "%f"; - float* v = (float*)data_ptr; + auto v = (float*)data_ptr; float arg0f = *v, arg1f = 0.0f; if (op && sscanf(initial_value_buf, format, &arg0f) < 1) return false; @@ -1823,7 +1823,7 @@ bool ImGui::DataTypeApplyOpFromText(const char* buf, const char* initial_value_b else if (data_type == ImGuiDataType_Double) { format = "%lf"; // scanf differentiate float/double unlike printf which forces everything to double because of ellipsis - double* v = (double*)data_ptr; + auto v = (double*)data_ptr; double arg0f = *v, arg1f = 0.0; if (op && sscanf(initial_value_buf, format, &arg0f) < 1) return false; @@ -3109,7 +3109,7 @@ static ImVec2 InputTextCalcTextSizeW(const ImWchar* text_begin, const ImWchar* t const float line_height = g.FontSize; const float scale = line_height / font->FontSize; - ImVec2 text_size = ImVec2(0,0); + auto text_size = ImVec2(0,0); float line_width = 0.0f; const ImWchar* s = text_begin; @@ -3720,7 +3720,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_ const int ib = state->HasSelection() ? ImMin(state->Stb.select_start, state->Stb.select_end) : 0; const int ie = state->HasSelection() ? ImMax(state->Stb.select_start, state->Stb.select_end) : state->CurLenW; const int clipboard_data_len = ImTextCountUtf8BytesFromStr(state->TextW.Data + ib, state->TextW.Data + ie) + 1; - char* clipboard_data = (char*)IM_ALLOC(clipboard_data_len * sizeof(char)); + auto clipboard_data = (char*)IM_ALLOC(clipboard_data_len * sizeof(char)); ImTextStrToUtf8(clipboard_data, clipboard_data_len, state->TextW.Data + ib, state->TextW.Data + ie); SetClipboardText(clipboard_data); MemFree(clipboard_data); @@ -3739,7 +3739,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_ { // Filter pasted buffer const int clipboard_len = (int)strlen(clipboard); - ImWchar* clipboard_filtered = (ImWchar*)IM_ALLOC((clipboard_len+1) * sizeof(ImWchar)); + auto clipboard_filtered = (ImWchar*)IM_ALLOC((clipboard_len+1) * sizeof(ImWchar)); int clipboard_filtered_len = 0; for (const char* s = clipboard; *s; ) { @@ -4032,7 +4032,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_ } // Draw selection - const ImVec2 draw_scroll = ImVec2(state->ScrollX, 0.0f); + const auto draw_scroll = ImVec2(state->ScrollX, 0.0f); if (render_selection) { const ImWchar* text_selected_begin = text_begin + ImMin(state->Stb.select_start, state->Stb.select_end); @@ -4512,9 +4512,9 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl // Note: the triangle is displayed rotated with triangle_pa pointing to Hue, but most coordinates stays unrotated for logic. float triangle_r = wheel_r_inner - (int)(sv_picker_size * 0.027f); - ImVec2 triangle_pa = ImVec2(triangle_r, 0.0f); // Hue point. - ImVec2 triangle_pb = ImVec2(triangle_r * -0.5f, triangle_r * -0.866025f); // Black point. - ImVec2 triangle_pc = ImVec2(triangle_r * -0.5f, triangle_r * +0.866025f); // White point. + auto triangle_pa = ImVec2(triangle_r, 0.0f); // Hue point. + auto triangle_pb = ImVec2(triangle_r * -0.5f, triangle_r * -0.866025f); // Black point. + auto triangle_pc = ImVec2(triangle_r * -0.5f, triangle_r * +0.866025f); // White point. float H = col[0], S = col[1], V = col[2]; float R = col[0], G = col[1], B = col[2]; @@ -5630,7 +5630,7 @@ bool ImGui::ListBoxHeader(const char* label, const ImVec2& size_arg) // Size default to hold ~7 items. Fractional number of items helps seeing that we can scroll down/up without looking at scrollbar. ImVec2 size = CalcItemSize(size_arg, CalcItemWidth(), GetTextLineHeightWithSpacing() * 7.4f + style.ItemSpacing.y); - ImVec2 frame_size = ImVec2(size.x, ImMax(size.y, label_size.y)); + auto frame_size = ImVec2(size.x, ImMax(size.y, label_size.y)); ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + frame_size); ImRect bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f)); window->DC.LastItemRect = bb; // Forward storage for ListBoxFooter.. dodgy. @@ -5808,7 +5808,7 @@ void ImGui::PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_ge float v0 = values_getter(data, (0 + values_offset) % values_count); float t0 = 0.0f; - ImVec2 tp0 = ImVec2( t0, 1.0f - ImSaturate((v0 - scale_min) * inv_scale) ); // Point in the normalized space of our target rectangle + auto tp0 = ImVec2( t0, 1.0f - ImSaturate((v0 - scale_min) * inv_scale) ); // Point in the normalized space of our target rectangle float histogram_zero_line_t = (scale_min * scale_max < 0.0f) ? (-scale_min * inv_scale) : (scale_min < 0.0f ? 0.0f : 1.0f); // Where does the zero line stands const ImU32 col_base = GetColorU32((plot_type == ImGuiPlotType_Lines) ? ImGuiCol_PlotLines : ImGuiCol_PlotHistogram); @@ -5820,7 +5820,7 @@ void ImGui::PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_ge const int v1_idx = (int)(t0 * item_count + 0.5f); IM_ASSERT(v1_idx >= 0 && v1_idx < values_count); const float v1 = values_getter(data, (v1_idx + values_offset + 1) % values_count); - const ImVec2 tp1 = ImVec2( t1, 1.0f - ImSaturate((v1 - scale_min) * inv_scale) ); + const auto tp1 = ImVec2( t1, 1.0f - ImSaturate((v1 - scale_min) * inv_scale) ); // NB: Draw calls are merged together by the DrawList system. Still, we should render our batch are lower level to save a bit of CPU. ImVec2 pos0 = ImLerp(inner_bb.Min, inner_bb.Max, tp0); @@ -5859,7 +5859,7 @@ struct ImGuiPlotArrayGetterData static float Plot_ArrayGetter(void* data, int idx) { - ImGuiPlotArrayGetterData* plot_data = (ImGuiPlotArrayGetterData*)data; + auto plot_data = (ImGuiPlotArrayGetterData*)data; const float v = *(const float*)(const void*)((const unsigned char*)plot_data->Values + (size_t)idx * plot_data->Stride); return v; } @@ -6350,8 +6350,8 @@ ImGuiTabBar::ImGuiTabBar() static int IMGUI_CDECL TabItemComparerByVisibleOffset(const void* lhs, const void* rhs) { - const ImGuiTabItem* a = (const ImGuiTabItem*)lhs; - const ImGuiTabItem* b = (const ImGuiTabItem*)rhs; + auto a = (const ImGuiTabItem*)lhs; + auto b = (const ImGuiTabItem*)rhs; return (int)(a->Offset - b->Offset); } @@ -6378,7 +6378,7 @@ bool ImGui::BeginTabBar(const char* str_id, ImGuiTabBarFlags flags) ImGuiID id = window->GetID(str_id); ImGuiTabBar* tab_bar = g.TabBars.GetOrAddByKey(id); - ImRect tab_bar_bb = ImRect(window->DC.CursorPos.x, window->DC.CursorPos.y, window->WorkRect.Max.x, window->DC.CursorPos.y + g.FontSize + g.Style.FramePadding.y * 2); + auto tab_bar_bb = ImRect(window->DC.CursorPos.x, window->DC.CursorPos.y, window->WorkRect.Max.x, window->DC.CursorPos.y + g.FontSize + g.Style.FramePadding.y * 2); tab_bar->ID = id; return BeginTabBarEx(tab_bar, tab_bar_bb, flags | ImGuiTabBarFlags_IsFocused); } @@ -7087,7 +7087,7 @@ ImVec2 ImGui::TabItemCalcSize(const char* label, bool has_close_button) { ImGuiContext& g = *GImGui; ImVec2 label_size = CalcTextSize(label, NULL, true); - ImVec2 size = ImVec2(label_size.x + g.Style.FramePadding.x, label_size.y + g.Style.FramePadding.y * 2.0f); + auto size = ImVec2(label_size.x + g.Style.FramePadding.x, label_size.y + g.Style.FramePadding.y * 2.0f); if (has_close_button) size.x += g.Style.FramePadding.x + (g.Style.ItemInnerSpacing.x + g.FontSize); // We use Y intentionally to fit the close button circle. else @@ -7130,7 +7130,7 @@ bool ImGui::TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb, return false; // Render text label (with clipping + alpha gradient) + unsaved marker - const char* TAB_UNSAVED_MARKER = "*"; + auto TAB_UNSAVED_MARKER = "*"; ImRect text_pixel_clip_bb(bb.Min.x + frame_padding.x, bb.Min.y + frame_padding.y, bb.Max.x - frame_padding.x, bb.Max.y); if (flags & ImGuiTabItemFlags_UnsavedDocument) { @@ -7670,7 +7670,7 @@ bool ImGui::Spinner( const char* label, float radius, int thickness, const ImU32 const float a_min = IM_PI * 2.0f * ( (float)start ) / (float)num_segments; const float a_max = IM_PI * 2.0f * ( (float)num_segments - 3 ) / (float)num_segments; - const ImVec2 centre = ImVec2( pos.x + radius, pos.y + radius + style.FramePadding.y ); + const auto centre = ImVec2( pos.x + radius, pos.y + radius + style.FramePadding.y ); for( int i = 0; i < num_segments; i++ ) { const float a = a_min + ( (float)i / (float)num_segments ) * ( a_max - a_min ); diff --git a/imgui/imstb_rectpack.h b/imgui/imstb_rectpack.h index ff2a85df..ac9d5251 100644 --- a/imgui/imstb_rectpack.h +++ b/imgui/imstb_rectpack.h @@ -532,8 +532,8 @@ static stbrp__findresult stbrp__skyline_pack_rectangle(stbrp_context *context, i // [DEAR IMGUI] Added STBRP__CDECL static int STBRP__CDECL rect_height_compare(const void *a, const void *b) { - const stbrp_rect *p = (const stbrp_rect *) a; - const stbrp_rect *q = (const stbrp_rect *) b; + auto p = (const stbrp_rect *) a; + auto q = (const stbrp_rect *) b; if (p->h > q->h) return -1; if (p->h < q->h) @@ -544,8 +544,8 @@ static int STBRP__CDECL rect_height_compare(const void *a, const void *b) // [DEAR IMGUI] Added STBRP__CDECL static int STBRP__CDECL rect_original_order(const void *a, const void *b) { - const stbrp_rect *p = (const stbrp_rect *) a; - const stbrp_rect *q = (const stbrp_rect *) b; + auto p = (const stbrp_rect *) a; + auto q = (const stbrp_rect *) b; return (p->was_packed < q->was_packed) ? -1 : (p->was_packed > q->was_packed); } diff --git a/imgui/imstb_truetype.h b/imgui/imstb_truetype.h index c1cdb180..ca5d4df9 100644 --- a/imgui/imstb_truetype.h +++ b/imgui/imstb_truetype.h @@ -2684,7 +2684,7 @@ static void *stbtt__hheap_alloc(stbtt__hheap *hh, size_t size, void *userdata) } else { if (hh->num_remaining_in_head_chunk == 0) { int count = (size < 32 ? 2000 : size < 128 ? 800 : 100); - stbtt__hheap_chunk *c = (stbtt__hheap_chunk *) STBTT_malloc(sizeof(stbtt__hheap_chunk) + size * count, userdata); + auto c = (stbtt__hheap_chunk *) STBTT_malloc(sizeof(stbtt__hheap_chunk) + size * count, userdata); if (c == NULL) return NULL; c->next = hh->head; @@ -2764,7 +2764,7 @@ static stbtt__active_edge *stbtt__new_active(stbtt__hheap *hh, stbtt__edge *e, i #elif STBTT_RASTERIZER_VERSION == 2 static stbtt__active_edge *stbtt__new_active(stbtt__hheap *hh, stbtt__edge *e, int off_x, float start_point, void *userdata) { - stbtt__active_edge *z = (stbtt__active_edge *) stbtt__hheap_alloc(hh, sizeof(*z), userdata); + auto z = (stbtt__active_edge *) stbtt__hheap_alloc(hh, sizeof(*z), userdata); float dxdy = (e->x1 - e->x0) / (e->y1 - e->y0); STBTT_assert(z != NULL); //STBTT_assert(e->y0 <= start_point); @@ -3796,9 +3796,9 @@ static void stbrp_pack_rects(stbrp_context *con, stbrp_rect *rects, int num_rect STBTT_DEF int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int pw, int ph, int stride_in_bytes, int padding, void *alloc_context) { - stbrp_context *context = (stbrp_context *) STBTT_malloc(sizeof(*context) ,alloc_context); + auto context = (stbrp_context *) STBTT_malloc(sizeof(*context) ,alloc_context); int num_nodes = pw - padding; - stbrp_node *nodes = (stbrp_node *) STBTT_malloc(sizeof(*nodes ) * num_nodes,alloc_context); + auto nodes = (stbrp_node *) STBTT_malloc(sizeof(*nodes ) * num_nodes,alloc_context); if (context == NULL || nodes == NULL) { if (context != NULL) STBTT_free(context, alloc_context); diff --git a/input/command.cpp b/input/command.cpp index 9a373fef..d2925fee 100644 --- a/input/command.cpp +++ b/input/command.cpp @@ -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 command_target target = (command_target)(Recipient & ~0xffff); + const auto target = (command_target)(Recipient & ~0xffff); if (target == command_target::entity) return false; diff --git a/input/keyboardinput.cpp b/input/keyboardinput.cpp index 0279f055..afd4f357 100644 --- a/input/keyboardinput.cpp +++ b/input/keyboardinput.cpp @@ -251,7 +251,7 @@ void keyboard_input::dump_bindings() stream << "none"; } - std::string description = std::get(binding.second); + auto description = std::get(binding.second); if (description.size() > 0) stream << " // " << description << "\r\n"; } diff --git a/input/zmq_input.cpp b/input/zmq_input.cpp index 62fb41ee..3ac98224 100644 --- a/input/zmq_input.cpp +++ b/input/zmq_input.cpp @@ -87,8 +87,8 @@ void zmq_input::poll() std::getline(stream, id1, '/'); std::getline(stream, id2, '/'); - input_type type = input_type::none; - user_command cmd1 = user_command::none, cmd2 = user_command::none; + auto type = input_type::none; + auto cmd1 = user_command::none, cmd2 = user_command::none; auto cmd1_it = nametocommandmap.find(id1); if (cmd1_it != nametocommandmap.end()) diff --git a/launcher/keymapper.cpp b/launcher/keymapper.cpp index 6ec882bd..2bc133ef 100644 --- a/launcher/keymapper.cpp +++ b/launcher/keymapper.cpp @@ -52,7 +52,7 @@ void ui::keymapper_panel::render_contents() ImGui::Text(simulation::Commands_descriptions[static_cast(binding.first)].name.c_str()); // Binding description - std::string description = std::get(binding.second); + auto description = std::get(binding.second); ImGui::SameLine(260); ImGui::Text((description.size() > 0 ? description : "(No description)").c_str()); diff --git a/launcher/launcheruilayer.cpp b/launcher/launcheruilayer.cpp index bf9dddb0..72044fe3 100644 --- a/launcher/launcheruilayer.cpp +++ b/launcher/launcheruilayer.cpp @@ -36,7 +36,7 @@ void launcher_ui::render_() { ImGuiWindowFlags flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove; const float topbar_height = 50 * Global.ui_scale; - const ImVec2 topbar_button_size = ImVec2(150 * Global.ui_scale, topbar_height - 16); + const auto topbar_button_size = ImVec2(150 * Global.ui_scale, topbar_height - 16); ImGui::SetNextWindowPos(ImVec2(0, 0)); ImGui::SetNextWindowSize(ImVec2(Global.window_size.x, topbar_height)); diff --git a/launcher/scenery_list.cpp b/launcher/scenery_list.cpp index 0b49e80f..2df6530e 100644 --- a/launcher/scenery_list.cpp +++ b/launcher/scenery_list.cpp @@ -95,7 +95,7 @@ void ui::scenerylist_panel::open_link(const std::string &link) void ui::scenerylist_panel::draw_scenery_image() { if (!selected_scenery->image_path.empty()) { - scenery_desc *desc = const_cast(selected_scenery); + auto desc = const_cast(selected_scenery); desc->image = GfxRenderer->Fetch_Texture(selected_scenery->image_path, true); desc->image_path.clear(); } @@ -354,7 +354,7 @@ void ui::scenerylist_panel::draw_droptarget(trainset_desc &trainset, int positio payload = ImGui::AcceptDragDropPayload("vehicle_set"); if (payload) { - vehicle_moved *moved = reinterpret_cast(payload->Data); + auto moved = reinterpret_cast(payload->Data); dynamic_desc desc_copy = moved->dynamic; int offset = 0; diff --git a/model/AnimModel.cpp b/model/AnimModel.cpp index ef4f90a8..76dbf114 100644 --- a/model/AnimModel.cpp +++ b/model/AnimModel.cpp @@ -279,8 +279,8 @@ TAnimModel::is_keyword( std::string const &Token ) const { bool TAnimModel::Load(cParser *parser, bool ter) { // rozpoznanie wpisu modelu i ustawienie świateł - std::string name = parser->getToken(); - std::string texture = parser->getToken(false); + auto name = parser->getToken(); + auto texture = parser->getToken(false); replace_slashes( name ); replace_slashes( texture ); if (!Init( name, texture )) diff --git a/model/Model3d.cpp b/model/Model3d.cpp index 5f59558b..e6c7124f 100644 --- a/model/Model3d.cpp +++ b/model/Model3d.cpp @@ -293,7 +293,7 @@ std::pair TSubModel::Load(cParser &parser, bool dynamic) if (parser.expectToken("anim:")) // Ra: ta informacja by się przydała! { // rodzaj animacji - std::string type = parser.getToken(); + auto type = parser.getToken(); if (type != "false") { iFlags |= 0x4000; // jak animacja, to trzeba przechowywać macierz zawsze @@ -341,7 +341,7 @@ std::pair TSubModel::Load(cParser &parser, bool dynamic) } parser.ignoreToken(); // zignorowanie nazwy "SelfIllum:" { - std::string light = parser.getToken(); + auto light = parser.getToken(); if (light == "true") fLight = 2.0; // zawsze świeci else if (light == "false") @@ -407,7 +407,7 @@ std::pair TSubModel::Load(cParser &parser, bool dynamic) if (!parser.expectToken("map:")) Error("Model map parse failure!"); - std::string material = parser.getToken(); + auto material = parser.getToken(); std::replace(material.begin(), material.end(), '\\', '/'); if (material == "none") { // rysowanie podanym kolorem @@ -1179,7 +1179,7 @@ void TSubModel::RaAnimation(glm::mat4 &m, TAnimType a) case TAnimType::at_Billboard: // obrót w pionie do kamery { glm::mat4 mat = glm::make_mat4(OpenGLMatrices.data_array(GL_MODELVIEW)); - float3 gdzie = float3(mat[3][0], mat[3][1], mat[3][2]); // początek układu współrzędnych submodelu względem kamery + auto gdzie = float3(mat[3][0], mat[3][1], mat[3][2]); // początek układu współrzędnych submodelu względem kamery m = glm::mat4(1.0f); m = glm::translate(m, glm::vec3(gdzie.x, gdzie.y, gdzie.z)); // początek układu zostaje bez zmian m = glm::rotate(m, (float)atan2(gdzie.x, gdzie.z), glm::vec3(0.0f, 1.0f, 0.0f)); // jedynie obracamy w pionie o kąt @@ -2338,7 +2338,7 @@ void TSubModel::BinInit(TSubModel *s, float4x4 *m, std::vector *t, bool TSubModel::HasAnyVertexUserData() const { - for (const TSubModel *sm = this; sm; sm = sm->Next) + for (auto sm = this; sm; sm = sm->Next) { if (m_geometry.handle) { @@ -2384,7 +2384,7 @@ TSubModel *TModel3d::AppendChildFromGeometry(const std::string &name, const std: { iFlags |= 0x0200; - TSubModel *sm = new TSubModel(); + auto sm = new TSubModel(); sm->Parent = AddToNamed(parent.c_str(), sm); sm->m_geometry.vertex_count = vertices.size(); sm->m_geometry.index_count = indices.size(); @@ -2415,7 +2415,7 @@ void TModel3d::LoadFromTextFile(std::string const &FileName, bool dynamic) iFlags |= 0x0200; // wczytano z pliku tekstowego (właścicielami tablic są submodle) cParser parser(FileName, cParser::buffer_FILE); // Ra: tu powinno być "models/"... TSubModel *SubModel; - std::string token = parser.getToken(); + auto token = parser.getToken(); while (token != "" || parser.eof()) { std::string parent; diff --git a/model/Texture.cpp b/model/Texture.cpp index c2b134a8..c58f2bdb 100644 --- a/model/Texture.cpp +++ b/model/Texture.cpp @@ -592,7 +592,7 @@ opengl_texture::load_DDS() { // while DDS stores it with top-left origin. we need to flip it. if (Global.dds_upper_origin) { - char *mipmap = (char*)&data[0]; + auto mipmap = (char*)&data[0]; int mapcount = data_mapcount, width = data_width, height = data_height; @@ -771,8 +771,8 @@ opengl_texture::load_TGA() { // rgb or greyscale image, expand to bgra unsigned char buffer[ 4 ] = { 255, 255, 255, 255 }; // alpha channel will be white - unsigned int *datapointer = (unsigned int*)&data[0]; - unsigned int *bufferpointer = (unsigned int*)&buffer[ 0 ]; + auto datapointer = (unsigned int*)&data[0]; + auto bufferpointer = (unsigned int*)&buffer[ 0 ]; int const pixelcount = data_width * data_height; @@ -797,8 +797,8 @@ opengl_texture::load_TGA() { unsigned char buffer[ 4 ] = { 255, 255, 255, 255 }; const int pixelcount = data_width * data_height; - unsigned int *datapointer = (unsigned int *)&data[0]; - unsigned int *bufferpointer = (unsigned int *)&buffer[ 0 ]; + auto datapointer = (unsigned int *)&data[0]; + auto bufferpointer = (unsigned int *)&buffer[ 0 ]; do { unsigned char chunkheader = 0; diff --git a/model/material.cpp b/model/material.cpp index 4101ce62..665bb26f 100644 --- a/model/material.cpp +++ b/model/material.cpp @@ -339,7 +339,7 @@ opengl_material::deserialize_mapping( cParser &Input, int const Priority, bool c else if (key.compare(0, 5, "param") == 0) { key.erase(0, 5); - std::string value = Input.getToken( true, "\n\r\t;" ); + auto value = Input.getToken( true, "\n\r\t;" ); std::istringstream stream(value); glm::vec4 data; stream >> data.r; diff --git a/network/backend/asio.cpp b/network/backend/asio.cpp index 958b084e..972d5e5d 100644 --- a/network/backend/asio.cpp +++ b/network/backend/asio.cpp @@ -148,7 +148,7 @@ network::tcp::server::server(std::shared_ptr buf, asio::io_context void network::tcp::server::accept_conn() { - std::shared_ptr conn = std::make_shared(m_io_ctx); + auto conn = std::make_shared(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)); @@ -182,7 +182,7 @@ void network::tcp::client::connect() if (this->conn) return; - std::shared_ptr conn = std::make_shared(io_ctx, true, resume_frame_counter); + auto conn = std::make_shared(io_ctx, true, resume_frame_counter); conn->set_handler(std::bind(&client::handle_message, this, conn, std::placeholders::_1)); asio::ip::tcp::endpoint endpoint( diff --git a/network/message.cpp b/network/message.cpp index 12609905..eb0d4f54 100644 --- a/network/message.cpp +++ b/network/message.cpp @@ -103,7 +103,7 @@ void network::frame_info::deserialize(std::istream &stream) std::shared_ptr 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 msg; diff --git a/rendering/flip-s3tc.h b/rendering/flip-s3tc.h index a529add4..16c0ab1b 100644 --- a/rendering/flip-s3tc.h +++ b/rendering/flip-s3tc.h @@ -125,7 +125,7 @@ void flip_dxt1_image(void *data, int width, int height) { int x, y; struct dxt1_block temp1, temp2; - struct dxt1_block *blocks = (struct dxt1_block *)data; + auto blocks = (struct dxt1_block *)data; width = (width + 3) / 4; height = (height + 3) / 4; @@ -154,7 +154,7 @@ void flip_dxt23_image(void *data, int width, int height) { int x, y; struct dxt23_block temp1, temp2; - struct dxt23_block *blocks = (struct dxt23_block *)data; + auto blocks = (struct dxt23_block *)data; width = (width + 3) / 4; height = (height + 3) / 4; @@ -183,7 +183,7 @@ void flip_dxt45_image(void *data, int width, int height) { int x, y; struct dxt45_block temp1, temp2; - struct dxt45_block *blocks = (struct dxt45_block *)data; + auto blocks = (struct dxt45_block *)data; width = (width + 3) / 4; height = (height + 3) / 4; diff --git a/rendering/opengl33particles.cpp b/rendering/opengl33particles.cpp index b869012b..a54173e6 100644 --- a/rendering/opengl33particles.cpp +++ b/rendering/opengl33particles.cpp @@ -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(prog); } diff --git a/rendering/opengl33renderer.cpp b/rendering/opengl33renderer.cpp index e0f71d22..bf9c0c73 100644 --- a/rendering/opengl33renderer.cpp +++ b/rendering/opengl33renderer.cpp @@ -549,7 +549,7 @@ std::unique_ptr opengl33_renderer::make_shader(std::string v, std:: { gl::shader vert(v); gl::shader frag(f); - gl::program *prog = new gl::program({vert, frag}); + auto prog = new gl::program({vert, frag}); return std::unique_ptr(prog); } @@ -2145,7 +2145,7 @@ std::shared_ptr opengl33_renderer::Fetch_Shader(const std::string & if (it == m_shaders.end()) { gl::shader fragment("mat_" + name + ".frag"); - gl::program *program = new gl::program({fragment, *m_vertex_shader.get()}); + auto program = new gl::program({fragment, *m_vertex_shader.get()}); m_shaders.insert({name, std::shared_ptr(program)}); } @@ -5314,7 +5314,7 @@ bool opengl33_renderer::Init_caps() WriteLog("Supported extensions:"); for (int i = 0; i < extCount; i++) { - const char *ext = (const char *)glGetStringi(GL_EXTENSIONS, i); + auto ext = (const char *)glGetStringi(GL_EXTENSIONS, i); WriteLog(ext); } WriteLog("--------"); diff --git a/rendering/openglrenderer.cpp b/rendering/openglrenderer.cpp index d159c31a..08016c40 100644 --- a/rendering/openglrenderer.cpp +++ b/rendering/openglrenderer.cpp @@ -4414,7 +4414,7 @@ opengl_renderer::Init_caps() { m_isATI = (gl_vendor.find("ATI") != -1); - char* extensions = (char*)glGetString( GL_EXTENSIONS ); + auto extensions = (char*)glGetString( GL_EXTENSIONS ); if (extensions) WriteLog( "Supported extensions: \n" + std::string(extensions)); diff --git a/rendering/screenshot.cpp b/rendering/screenshot.cpp index 285679b7..f8f888d9 100644 --- a/rendering/screenshot.cpp +++ b/rendering/screenshot.cpp @@ -57,7 +57,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 diff --git a/scene/scenenode.cpp b/scene/scenenode.cpp index 1ba822e1..e9ffd2fe 100644 --- a/scene/scenenode.cpp +++ b/scene/scenenode.cpp @@ -150,7 +150,7 @@ shape_node::import( cParser &Input, scene::node_data const &Nodedata ) { m_data.rangesquared_min = Nodedata.range_min * Nodedata.range_min; m_data.rangesquared_max = Nodedata.range_max >= 0.0 ? Nodedata.range_max * Nodedata.range_max : std::numeric_limits::max(); - std::string token = Input.getToken(); + auto token = Input.getToken(); if( token == "material" ) { // lighting settings token = Input.getToken(); @@ -588,7 +588,7 @@ lines_node::import( cParser &Input, scene::node_data const &Nodedata ) { subtype const nodetype = Nodedata.type == "lines" ? lines : Nodedata.type == "line_strip" ? line_strip : line_loop; std::size_t vertexcount { 0 }; world_vertex vertex, vertex0, vertex1; - std::string token = Input.getToken(); + auto token = Input.getToken(); do { vertex.position.x = std::atof( token.c_str() ); Input.getTokens( 2, false ); diff --git a/scene/scenenodegroups.cpp b/scene/scenenodegroups.cpp index 20ac524b..be98ebad 100644 --- a/scene/scenenodegroups.cpp +++ b/scene/scenenodegroups.cpp @@ -62,7 +62,7 @@ bool node_groups::assign_cross_switch(map::track_switch& sw, std::string &sw_nam if (!sw.action[idx]) return false; - multi_event *multi = dynamic_cast(sw.action[idx]); + auto multi = dynamic_cast(sw.action[idx]); if (!multi) return false; @@ -135,7 +135,7 @@ node_groups::update_map() } if (Global.map_manualswitchcontrol) { - if (TTrack *track = dynamic_cast(node)) { + if (auto track = dynamic_cast(node)) { if (track->eType != tt_Switch) continue; @@ -203,7 +203,7 @@ node_groups::update_map() last_switch_map.erase(sw_name); } } else { - if (TEventLauncher *launcher = dynamic_cast(node)) { + if (auto launcher = dynamic_cast(node)) { if (!launcher || !launcher->Event1 || !launcher->Event2) continue; diff --git a/scripting/pythonscreenviewer.cpp b/scripting/pythonscreenviewer.cpp index fa15e9fa..4d1c8048 100644 --- a/scripting/pythonscreenviewer.cpp +++ b/scripting/pythonscreenviewer.cpp @@ -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); } diff --git a/simulation/simulation.cpp b/simulation/simulation.cpp index a1493f63..3d42cae9 100644 --- a/simulation/simulation.cpp +++ b/simulation/simulation.cpp @@ -232,7 +232,7 @@ void state_manager::process_commands() { continue; // NOTE: because malformed scenario can have vehicle name duplicates we first try to locate vehicle in world, with name search as fallback - TDynamicObject *targetvehicle = std::get( simulation::Region->find_vehicle( commanddata.location, 50, false, false ) ); + auto targetvehicle = std::get( simulation::Region->find_vehicle( commanddata.location, 50, false, false ) ); if( targetvehicle == nullptr || targetvehicle->name() != commanddata.payload ) { targetvehicle = simulation::Vehicles.find( commanddata.payload ); } diff --git a/simulation/simulationstateserializer.cpp b/simulation/simulationstateserializer.cpp index ef7cd7db..7fa6b5a1 100644 --- a/simulation/simulationstateserializer.cpp +++ b/simulation/simulationstateserializer.cpp @@ -47,7 +47,7 @@ state_serializer::deserialize_begin( std::string const &Scenariofile ) { simulation::State.init_scripting_interface(); // NOTE: for the time being import from text format is a given, since we don't have full binary serialization - std::shared_ptr state = + auto state = std::make_shared(Scenariofile, cParser::buffer_FILE, Global.asCurrentSceneryPath, Global.bLoadTraction); // TODO: check first for presence of serialized binary files @@ -128,7 +128,7 @@ state_serializer::deserialize_continue(std::shared_ptr state // deserialize content from the provided input auto timelast { std::chrono::steady_clock::now() }; - std::string token { Input.getToken() }; + auto token { Input.getToken() }; while( false == token.empty() ) { auto lookup = state->functionmap.find( token ); @@ -202,7 +202,7 @@ state_serializer::deserialize_area( cParser &Input, scene::scratch_data &Scratch void state_serializer::deserialize_assignment( cParser &Input, scene::scratch_data &Scratchpad ) { - std::string token { Input.getToken() }; + auto token { Input.getToken() }; while( false == token.empty() && token != "endassignment" ) { // assignment is expected to come as string pairs: language id and the actual assignment enclosed in quotes to form a single token @@ -238,7 +238,7 @@ state_serializer::deserialize_atmo( cParser &Input, scene::scratch_data &Scratch 10.0, 25000.0 ); } - std::string token { Input.getToken() }; + auto token { Input.getToken() }; if( token != "endatmo" ) { // optional overcast parameter Global.Overcast = std::stof( token ); @@ -1131,7 +1131,7 @@ state_serializer::deserialize_sound( cParser &Input, scene::scratch_data &Scratc void state_serializer::skip_until( cParser &Input, std::string const &Token ) { - std::string token { Input.getToken() }; + auto token { Input.getToken() }; while( false == token.empty() && token != Token ) { diff --git a/utilities/uart.cpp b/utilities/uart.cpp index caa644aa..4ab5dca6 100644 --- a/utilities/uart.cpp +++ b/utilities/uart.cpp @@ -72,7 +72,7 @@ void uart_input::find_ports() { status->active_port_index = -1; status->selected_port_index = -1; for (int i=0; ports[i]; i++) { - std::string newport = std::string(sp_get_port_name(ports[i])); + auto newport = std::string(sp_get_port_name(ports[i])); status->available_ports.emplace_back(newport); if(newport == status->port_name) { status->active_port_index = i; diff --git a/utilities/utilities.h b/utilities/utilities.h index bc38b125..d7ab293b 100644 --- a/utilities/utilities.h +++ b/utilities/utilities.h @@ -32,12 +32,12 @@ std::filesystem::path user_config_path(const std::string &filename); // TODO: Shouldn't this be in globals? namespace paths { -inline constexpr const char *scenery = "scenery/"; -inline constexpr const char *textures = "textures/"; -inline constexpr const char *models = "models/"; -inline constexpr const char *dynamic = "dynamic/"; -inline constexpr const char *sounds = "sounds/"; -inline constexpr const char *data = "data/"; +inline constexpr auto scenery = "scenery/"; +inline constexpr auto textures = "textures/"; +inline constexpr auto models = "models/"; +inline constexpr auto dynamic = "dynamic/"; +inline constexpr auto sounds = "sounds/"; +inline constexpr auto data = "data/"; } #define MAKE_ID4(a, b, c, d) (((std::uint32_t)(d) << 24) | ((std::uint32_t)(c) << 16) | ((std::uint32_t)(b) << 8) | (std::uint32_t)(a)) diff --git a/vehicle/AirCoupler.cpp b/vehicle/AirCoupler.cpp index 81253d60..22a5a6bb 100644 --- a/vehicle/AirCoupler.cpp +++ b/vehicle/AirCoupler.cpp @@ -66,7 +66,7 @@ void AirCoupler::Init(std::string const &asName, TModel3d *Model) */ void AirCoupler::Load(cParser *Parser, TModel3d *Model) { - std::string name = Parser->getToken(); + auto name = Parser->getToken(); if(Model) { Init(name, Model); diff --git a/vehicle/Driver.cpp b/vehicle/Driver.cpp index 1552ead7..368264b0 100644 --- a/vehicle/Driver.cpp +++ b/vehicle/Driver.cpp @@ -1797,7 +1797,7 @@ void TController::TableSort() { // we skip last slot and no point in checking if there's only one other entry return; } - TSpeedPos sp_temp = TSpeedPos(); // uzywany do przenoszenia + auto sp_temp = TSpeedPos(); // uzywany do przenoszenia for( int i = 0; i < iLast - 1; ++i ) { // pętla tylko do dwóch pozycji od końca bo ostatniej nie modyfikujemy if (sSpeedTable[i].fDist > sSpeedTable[i + 1].fDist) @@ -4813,7 +4813,7 @@ bool TController::PutCommand( std::string NewCommand, double NewValue1, double N } if (NewCommand == "SetSignal") { - TSignals signal = (TSignals)std::lrint(NewValue1); + auto signal = (TSignals)std::lrint(NewValue1); for (int i = Signal_START; i <= Signal_MAX; i++) iDrivigFlags &= ~(1 << i); diff --git a/vehicle/DynObj.cpp b/vehicle/DynObj.cpp index 184d432a..03eba754 100644 --- a/vehicle/DynObj.cpp +++ b/vehicle/DynObj.cpp @@ -332,7 +332,7 @@ bool TDynamicObject::destination_data::deserialize_mapping( cParser &Input ) { TDynamicObject * TDynamicObject::FirstFind(int &coupler_nr, int cf) { // szukanie skrajnego połączonego pojazdu w pociagu // od strony sprzegu (coupler_nr) obiektu (start) - TDynamicObject *temp = this; + auto temp = this; for (int i = 0; i < 300; i++) // ograniczenie do 300 na wypadek zapętlenia składu { if (!temp) @@ -369,7 +369,7 @@ TDynamicObject * TDynamicObject::FirstFind(int &coupler_nr, int cf) float TDynamicObject::GetEPP() { // szukanie skrajnego połączonego pojazdu w pociagu // od strony sprzegu (coupler_nr) obiektu (start) - TDynamicObject *temp = this; + auto temp = this; int coupler_nr = 0; double eq = 0.0; double am = 0.0; @@ -1603,7 +1603,7 @@ int TDynamicObject::Dettach(int dir) if (ctOwner) { // jeśli pojazd ma przypisany obiekt nadzorujący skład, to póki // są wskaźniki - TDynamicObject *d = this; + auto d = this; while (d) { d->ctOwner = nullptr; // usuwanie właściciela @@ -3356,13 +3356,13 @@ bool TDynamicObject::Update(double dt, double dt1) auto const FzadPN = Fzad - FrED * MoverParameters->MED_FrED_factor; //np = 0; // BUG: likely memory leak, allocation per inner loop, deleted only once outside - // TODO: sort this shit out - bool* PrzekrF = new bool[np]; + // TODO: sort this shit out + auto PrzekrF = new bool[np]; float nPrzekrF = 0; bool test = true; - float* FzED = new float[np]; - float* FzEP = new float[np]; - float* FmaxEP = new float[np]; + auto FzED = new float[np]; + auto FzEP = new float[np]; + auto FmaxEP = new float[np]; // 3. ustaw pojazdom sile hamowania ED // - proporcjonalnie do mozliwosci @@ -3693,7 +3693,7 @@ bool TDynamicObject::Update(double dt, double dt1) if (MoverParameters->Vel != 0) { // McZapkie-050402: krecenie kolami: - glm::dvec3 old_wheels = glm::dvec3(dWheelAngle[0], dWheelAngle[1], dWheelAngle[2]); + auto old_wheels = glm::dvec3(dWheelAngle[0], dWheelAngle[1], dWheelAngle[2]); dWheelAngle[0] += 114.59155902616464175359630962821 * MoverParameters->V * dt1 / MoverParameters->WheelDiameterL; // przednie toczne @@ -4178,7 +4178,7 @@ bool TDynamicObject::Update(double dt, double dt1) void TDynamicObject::pants_up() { - TDynamicObject *d = this; + auto d = this; bool isAnyPantUp = false; while (d) { for (auto &item : d->MoverParameters->Pantographs) @@ -4219,7 +4219,7 @@ glm::dvec3 TDynamicObject::get_future_movement() const void TDynamicObject::move_set(double distance) { - TDynamicObject *d = this; + auto d = this; while( d ) { d->Move( distance * d->DirectionGet() ); d = d->Next(); // pozostałe też @@ -7145,7 +7145,7 @@ void TDynamicObject::RadioStop() && MoverParameters->Radio ) { // jeśli pojazd ma RadioStop i jest on aktywny // HACK cast until math types unification - glm::dvec3 pos = static_cast(vPosition); + auto pos = static_cast(vPosition); Mechanik->PutCommand( "Emergency_brake", 1.0, 1.0, &pos, stopRadio ); // add onscreen notification for human driver // TODO: do it selectively for the 'local' driver once the multiplayer is in diff --git a/vr/openvr_imp.cpp b/vr/openvr_imp.cpp index 088fd5b5..8cdda85f 100644 --- a/vr/openvr_imp.cpp +++ b/vr/openvr_imp.cpp @@ -45,8 +45,7 @@ std::unique_ptr vr_openvr::create_hiddenarea_model(vr_interface::eye_e glm::vec2(0.0f))); } - - std::unique_ptr model = std::make_unique(); + auto model = std::make_unique(); model->AppendChildFromGeometry("__root", "none", vertices, gfx::index_array()); model->Init(); diff --git a/widgets/cameraview_extcam.cpp b/widgets/cameraview_extcam.cpp index 80deddbe..6ee09043 100644 --- a/widgets/cameraview_extcam.cpp +++ b/widgets/cameraview_extcam.cpp @@ -123,8 +123,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; @@ -173,7 +173,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; diff --git a/widgets/map.cpp b/widgets/map.cpp index 379b0311..f2fb6b9e 100644 --- a/widgets/map.cpp +++ b/widgets/map.cpp @@ -16,7 +16,7 @@ ui::map_panel::map_panel() : ui_panel(STR_C("Map"), false) window_flags = ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse; #ifdef WITH_OPENGL_MODERN - opengl33_renderer *gl33 = dynamic_cast(GfxRenderer.get()); + auto gl33 = dynamic_cast(GfxRenderer.get()); if (!gl33) { ErrorLog("map not supported on old renderer"); return; @@ -146,7 +146,7 @@ void ui::map_panel::render_map_texture(glm::mat4 transform, glm::vec2 surface_si scene_ubo->bind_uniform(); #ifdef WITH_OPENGL_MODERN - opengl33_renderer *gl33 = dynamic_cast(GfxRenderer.get()); + auto gl33 = dynamic_cast(GfxRenderer.get()); gl33->Draw_Geometry(m_section_handles.begin(), m_section_handles.end()); diff --git a/widgets/vehiclelist.cpp b/widgets/vehiclelist.cpp index e8ee1e12..92f9edf1 100644 --- a/widgets/vehiclelist.cpp +++ b/widgets/vehiclelist.cpp @@ -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())) { diff --git a/widgets/vehicleparams.cpp b/widgets/vehicleparams.cpp index 51ad7a07..b46fe516 100644 --- a/widgets/vehicleparams.cpp +++ b/widgets/vehicleparams.cpp @@ -24,7 +24,7 @@ void ui::vehicleparams_panel::draw_infobutton(const char *str, ImVec2 pos, const ImGuiStyle &style = ImGui::GetStyle(); ImVec2 text_size = ImGui::CalcTextSize(str); - ImVec2 button_size = ImVec2(text_size.x + style.FramePadding.x * 2.0f, text_size.y + style.FramePadding.y * 2.0f); + auto button_size = ImVec2(text_size.x + style.FramePadding.x * 2.0f, text_size.y + style.FramePadding.y * 2.0f); pos.x = pos.x * window_size.x / 512.0f - button_size.x / 2.0f; pos.y = pos.y * window_size.y / 118.0f - button_size.y / 2.0f; @@ -124,8 +124,8 @@ void ui::vehicleparams_panel::render_contents() glm::mat3 proj = glm::translate(glm::scale(glm::mat3(), 1.0f / viewport.scale), viewport.offset); - glm::vec2 uv0 = glm::vec2(proj * glm::vec3(0.0f, 1.0f, 1.0f)); - glm::vec2 uv1 = glm::vec2(proj * glm::vec3(1.0f, 0.0f, 1.0f)); + auto uv0 = glm::vec2(proj * glm::vec3(0.0f, 1.0f, 1.0f)); + auto uv1 = glm::vec2(proj * glm::vec3(1.0f, 0.0f, 1.0f)); ImVec2 size = ImGui::GetContentRegionAvail(); diff --git a/world/Track.cpp b/world/Track.cpp index 6155116c..39dcb6df 100644 --- a/world/Track.cpp +++ b/world/Track.cpp @@ -1279,7 +1279,7 @@ void TTrack::get_map_future_paths(map_colored_paths &handles) { float distance = Global.map_highlight_distance; TTrack *track = trPrev; - TTrack *visitor = this; + auto visitor = this; while (distance > 0.0f && track && track->iterate_stamp != stamp) { handles.future.push_back(track->extra_map_geometry); diff --git a/world/Traction.cpp b/world/Traction.cpp index ef0c85bd..762ecc07 100644 --- a/world/Traction.cpp +++ b/world/Traction.cpp @@ -138,7 +138,7 @@ TTraction::Load( cParser *parser, glm::dvec3 const &pOrigin ) { >> WireOffset; m_visible = parser->getToken() == "vis"; - std::string token { parser->getToken() }; + auto token { parser->getToken() }; if( token == "parallel" ) { // jawne wskazanie innego przęsła, na które może przestawić się pantograf parser->getTokens(); diff --git a/world/TractionPower.cpp b/world/TractionPower.cpp index 7d816e21..6ceac162 100644 --- a/world/TractionPower.cpp +++ b/world/TractionPower.cpp @@ -46,7 +46,7 @@ bool TTractionPowerSource::Load(cParser *parser) { >> FastFuseRepetition >> SlowFuseTimeOut; - std::string token { parser->getToken() }; + auto token { parser->getToken() }; if( token == "recuperation" ) { Recuperation = true; } diff --git a/world/mtable.h b/world/mtable.h index c58d120f..4f1c538f 100644 --- a/world/mtable.h +++ b/world/mtable.h @@ -18,7 +18,7 @@ namespace Mtable { static int const MaxTTableSize = 100; // można by to robić dynamicznie -static char const *hrsd = "."; +static auto hrsd = "."; // Ra: pozycja zerowa rozkładu chyba nie ma sensu // Ra: numeracja przystanków jest 1..StationCount