aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFourthVolt <87427011+EM4Volts@users.noreply.github.com>2024-08-09 20:28:26 +0200
committerGitHub <noreply@github.com>2024-08-09 20:28:26 +0200
commita28c1cb10cc805907d22b656ccc300b39b720a88 (patch)
treeecb286535a958852cb2758902ddb596b877db466
parenta176b707faa24547e1f00a1a7dcdeb92811d7fe7 (diff)
downloadNorthstarLauncher-1.27.2.tar.gz
NorthstarLauncher-1.27.2.zip
Fix postload crash from missing `rpak.json` (#762)v1.27.2-rc2v1.27.2
Missing `rpak.json` would previously crash the game due to faulty boolean logic in the `if` statement. This change ensures that a missing `rpak.json` is handled gracefully.
-rw-r--r--primedev/mods/modmanager.cpp26
1 files changed, 17 insertions, 9 deletions
diff --git a/primedev/mods/modmanager.cpp b/primedev/mods/modmanager.cpp
index 68f9bd0f..45eddd3e 100644
--- a/primedev/mods/modmanager.cpp
+++ b/primedev/mods/modmanager.cpp
@@ -866,16 +866,24 @@ void ModManager::LoadMods()
if (fs::is_regular_file(file) && file.path().extension() == ".rpak")
{
std::string pakName(file.path().filename().string());
-
ModRpakEntry& modPak = mod.Rpaks.emplace_back();
- modPak.m_bAutoLoad =
- !bUseRpakJson || (dRpakJson.HasMember("Preload") && dRpakJson["Preload"].IsObject() &&
- dRpakJson["Preload"].HasMember(pakName) && dRpakJson["Preload"][pakName].IsTrue());
-
- // postload things
- if (!bUseRpakJson ||
- (dRpakJson.HasMember("Postload") && dRpakJson["Postload"].IsObject() && dRpakJson["Postload"].HasMember(pakName)))
- modPak.m_sLoadAfterPak = dRpakJson["Postload"][pakName].GetString();
+
+ if (!bUseRpakJson)
+ {
+ spdlog::warn("Mod {} contains rpaks without valid rpak.json, rpaks might not be loaded", mod.Name);
+ }
+ else
+ {
+ modPak.m_bAutoLoad =
+ (dRpakJson.HasMember("Preload") && dRpakJson["Preload"].IsObject() && dRpakJson["Preload"].HasMember(pakName) &&
+ dRpakJson["Preload"][pakName].IsTrue());
+
+ // postload things
+ if (dRpakJson.HasMember("Postload") && dRpakJson["Postload"].IsObject() && dRpakJson["Postload"].HasMember(pakName))
+ {
+ modPak.m_sLoadAfterPak = dRpakJson["Postload"][pakName].GetString();
+ }
+ }
modPak.m_sPakName = pakName;