Skip to content

Commit

Permalink
Report content_error(s) during CGame::Load() with a MsgBox()
Browse files Browse the repository at this point in the history
  • Loading branch information
lhog committed Dec 1, 2024
1 parent 35c914e commit 2caf268
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions rts/Game/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -361,6 +362,8 @@ void CGame::Load(const std::string& mapFileName)

ZoneScoped;

std::vector<std::string> contentErrors;

auto& globalQuit = gu->globalQuit;
bool forcedQuit = false;

Expand All @@ -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;
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down

0 comments on commit 2caf268

Please sign in to comment.