From 2caf268f1c11f7d4e436f8d3fd1b6f3f59fa30d8 Mon Sep 17 00:00:00 2001 From: LHoG <1476261+lhog@users.noreply.github.com> Date: Sun, 1 Dec 2024 18:07:24 +0100 Subject: [PATCH] Report content_error(s) during CGame::Load() with a MsgBox() --- rts/Game/Game.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/rts/Game/Game.cpp b/rts/Game/Game.cpp index 67fe957241..f94251eace 100644 --- a/rts/Game/Game.cpp +++ b/rts/Game/Game.cpp @@ -125,6 +125,7 @@ #include "System/Log/ILog.h" #include "System/Platform/Misc.h" #include "System/Platform/Watchdog.h" +#include "System/Platform/errorhandler.h" #include "System/Sound/ISound.h" #include "System/Sound/ISoundChannels.h" #include "System/Sync/DumpState.h" @@ -361,6 +362,8 @@ void CGame::Load(const std::string& mapFileName) ZoneScoped; + std::vector contentErrors; + auto& globalQuit = gu->globalQuit; bool forcedQuit = false; @@ -377,6 +380,7 @@ void CGame::Load(const std::string& mapFileName) LoadDefs(defsParser); Watchdog::ClearTimer(WDT_LOAD); } catch (const content_error& e) { + contentErrors.emplace_back(e.what()); LOG_L(L_ERROR, "[Game::%s][1] forced quit with exception \"%s\"", __func__, e.what()); defsParser = &nullDefsParser; @@ -395,6 +399,7 @@ void CGame::Load(const std::string& mapFileName) PreLoadRendering(); Watchdog::ClearTimer(WDT_LOAD); } catch (const content_error& e) { + contentErrors.emplace_back(e.what()); LOG_L(L_ERROR, "[Game::%s][2] forced quit with exception \"%s\"", __func__, e.what()); forcedQuit = true; } @@ -407,6 +412,7 @@ void CGame::Load(const std::string& mapFileName) PostLoadRendering(); Watchdog::ClearTimer(WDT_LOAD); } catch (const content_error& e) { + contentErrors.emplace_back(e.what()); LOG_L(L_ERROR, "[Game::%s][3] forced quit with exception \"%s\"", __func__, e.what()); forcedQuit = true; } @@ -417,6 +423,7 @@ void CGame::Load(const std::string& mapFileName) LoadInterface(); Watchdog::ClearTimer(WDT_LOAD); } catch (const content_error& e) { + contentErrors.emplace_back(e.what()); LOG_L(L_ERROR, "[Game::%s][4] forced quit with exception \"%s\"", __func__, e.what()); forcedQuit = true; } @@ -429,6 +436,7 @@ void CGame::Load(const std::string& mapFileName) LoadFinalize(); Watchdog::ClearTimer(WDT_LOAD); } catch (const content_error& e) { + contentErrors.emplace_back(e.what()); LOG_L(L_ERROR, "[Game::%s][5] forced quit with exception \"%s\"", __func__, e.what()); forcedQuit = true; } @@ -441,6 +449,7 @@ void CGame::Load(const std::string& mapFileName) LoadLua(saveFileHandler != nullptr, false); Watchdog::ClearTimer(WDT_LOAD); } catch (const content_error& e) { + contentErrors.emplace_back(e.what()); LOG_L(L_ERROR, "[Game::%s][6] forced quit with exception \"%s\"", __func__, e.what()); forcedQuit = true; } @@ -487,6 +496,7 @@ void CGame::Load(const std::string& mapFileName) CLIENT_NETLOG(gu->myPlayerNum, LOG_LEVEL_INFO, msgBuf); } } catch (const content_error& e) { + contentErrors.emplace_back(e.what()); LOG_L(L_ERROR, "[Game::%s][7] forced quit with exception \"%s\"", __func__, e.what()); forcedQuit = true; } @@ -498,6 +508,7 @@ void CGame::Load(const std::string& mapFileName) LoadSkirmishAIs(); Watchdog::ClearTimer(WDT_LOAD); } catch (const content_error& e) { + contentErrors.emplace_back(e.what()); LOG_L(L_ERROR, "[Game::%s][8] forced quit with exception \"%s\"", __func__, e.what()); forcedQuit = true; } @@ -509,6 +520,9 @@ void CGame::Load(const std::string& mapFileName) if (forcedQuit) spring::exitCode = spring::EXIT_CODE_NOLOAD; + if (!contentErrors.empty()) + ErrorMessageBox(fmt::format("Errors:\n{}", fmt::join(contentErrors, "\n")).c_str(), "Recoil: caught content_error(s)", MBF_OK | MBF_EXCL); + loadDone = true; globalQuit = globalQuit | forcedQuit; }