From b91b542f741a9d8ebdcc1d6164c3e75f1f430ffb Mon Sep 17 00:00:00 2001 From: Unreal Karaulov Date: Mon, 9 Dec 2024 14:13:53 +0300 Subject: [PATCH] =?UTF-8?q?Bug=20fixes.=20Added=20'=D0=BA=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D1=8B=D0=BB=D1=8C'=20for=20save=20settings.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bsp/Bsp.cpp | 11 ++--------- src/editor/Gui.cpp | 33 +++------------------------------ src/editor/Renderer.cpp | 8 -------- src/editor/Settings.cpp | 9 ++++----- 4 files changed, 9 insertions(+), 52 deletions(-) diff --git a/src/bsp/Bsp.cpp b/src/bsp/Bsp.cpp index 9a60f228..c4de6330 100644 --- a/src/bsp/Bsp.cpp +++ b/src/bsp/Bsp.cpp @@ -12444,7 +12444,7 @@ void Bsp::ExportToMapWIP(const std::string& path, bool selected, bool merge_face bool findSomethingMerge = false; - int mergeStages = 3; + int mergeStages = 2; for (int stage = 0; stage < mergeStages; stage++) { @@ -12491,17 +12491,10 @@ void Bsp::ExportToMapWIP(const std::string& path, bool selected, bool merge_face { connected_edges++; findSomethingMerge = true; - if (stage != 0) - { - if (connected_edges == 2) - break; - } } } - if (connected_edges > 0) - - if (connected_edges == 2 || (findSomethingMerge && stage == 2)) + if (stage == 0 || findSomethingMerge) { Winding wind1(brush.wind); Winding wind2(brush2.wind); diff --git a/src/editor/Gui.cpp b/src/editor/Gui.cpp index 23d96968..107a44ef 100644 --- a/src/editor/Gui.cpp +++ b/src/editor/Gui.cpp @@ -3994,34 +3994,7 @@ void Gui::drawMenuBar() ImGui::Separator(); if (ImGui::MenuItem(get_localized_string(LANG_0555).c_str(), NULL)) { - g_settings.saveSettings(); - if (fileSize(g_settings_path) == 0) - { - g_settings.saveSettings(); - glfwTerminate(); - -#ifdef MINGW - std::set_terminate(NULL); - std::terminate(); -#else - std::quick_exit(0); -#endif - } - g_settings.saveSettings(); - if (fileSize(g_settings_path) == 0) - { - print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0359)); - } - else - { - glfwTerminate(); -#ifdef MINGW - std::set_terminate(NULL); - std::terminate(); -#else - std::quick_exit(0); -#endif - } + g_app->is_closing = true; } ImGui::EndMenu(); } @@ -9930,12 +9903,12 @@ void Gui::drawSettings() ImGui::End(); - if ((oldShowSettings && !showSettingsWidget) || apply_settings_pressed || g_app->is_closing) + if ((oldShowSettings && !showSettingsWidget) || apply_settings_pressed ) { g_settings.selected_lang = langForSelect; g_settings.palette_name = palForSelect; set_localize_lang(g_settings.selected_lang); - g_settings.saveSettings(); + if (!app->reloading) { app->reloading = true; diff --git a/src/editor/Renderer.cpp b/src/editor/Renderer.cpp index 8795eb95..2bcedba0 100644 --- a/src/editor/Renderer.cpp +++ b/src/editor/Renderer.cpp @@ -165,7 +165,6 @@ void window_focus_callback(GLFWwindow* window, int focused) void window_close_callback(GLFWwindow* window) { - g_settings.saveSettings(); g_app->is_closing = true; } @@ -374,15 +373,8 @@ Renderer::Renderer() Renderer::~Renderer() { - g_settings.saveSettings(); print_log(get_localized_string(LANG_0901)); glfwTerminate(); -#ifdef MINGW - std::set_terminate(NULL); - std::terminate(); -#else - std::quick_exit(0); -#endif } void Renderer::updateWindowTitle(double _curTime) diff --git a/src/editor/Settings.cpp b/src/editor/Settings.cpp index 70774bb4..b830795e 100644 --- a/src/editor/Settings.cpp +++ b/src/editor/Settings.cpp @@ -281,11 +281,11 @@ void Settings::loadSettings() int errorLine = settings_ini->ParseError(); if (errorLine < 0) { - throw std::exception("Error parse! Can't open file bspguy.ini!"); + throw std::runtime_error("Error parse! Can't open file bspguy.ini!"); } else if (errorLine > 0) { - throw std::exception(("Error parse ini at line:" + std::to_string(errorLine)).c_str()); + throw std::runtime_error(("Error parse ini at line:" + std::to_string(errorLine)).c_str()); } } catch (std::runtime_error& runtime) @@ -293,7 +293,6 @@ void Settings::loadSettings() print_log(PRINT_RED | PRINT_INTENSITY, "Settings parse from {} fatal error: {}\n", g_settings_path, runtime.what()); delete settings_ini; settings_ini = NULL; - saveSettings(g_settings_path); } } else @@ -305,11 +304,11 @@ void Settings::loadSettings() int errorLine = settings_ini->ParseError(); if (errorLine < 0) { - throw std::exception("Error parse! Can't open file bspguy.ini!"); + throw std::runtime_error("Error parse! Can't open file bspguy.ini!"); } else if (errorLine > 0) { - throw std::exception(("Error parse ini at line:" + std::to_string(errorLine)).c_str()); + throw std::runtime_error(("Error parse ini at line:" + std::to_string(errorLine)).c_str()); } } catch (std::runtime_error& runtime)