Skip to content

Commit

Permalink
Bug fixes. Added 'костыль' for save settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
UnrealKaraulov committed Dec 9, 2024
1 parent 8958a41 commit b91b542
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 52 deletions.
11 changes: 2 additions & 9 deletions src/bsp/Bsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
{
Expand Down Expand Up @@ -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);
Expand Down
33 changes: 3 additions & 30 deletions src/editor/Gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 0 additions & 8 deletions src/editor/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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)
Expand Down
9 changes: 4 additions & 5 deletions src/editor/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,19 +281,18 @@ 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)
{
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
Expand All @@ -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)
Expand Down

0 comments on commit b91b542

Please sign in to comment.