aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/modmanager.cpp
diff options
context:
space:
mode:
authorBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2022-05-10 01:51:16 +0100
committerBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2022-05-10 01:51:16 +0100
commit5644c1aaabb9487ef2a4c3e5110c8a21bf7b6a59 (patch)
treea2b03490a14234f35b0087fc3f31681da7a7b168 /NorthstarDedicatedTest/modmanager.cpp
parent4f29baf18ca6ec7abe87724682c95f1ab3a26808 (diff)
downloadNorthstarLauncher-5644c1aaabb9487ef2a4c3e5110c8a21bf7b6a59.tar.gz
NorthstarLauncher-5644c1aaabb9487ef2a4c3e5110c8a21bf7b6a59.zip
allow parsing of convar flags from string
Diffstat (limited to 'NorthstarDedicatedTest/modmanager.cpp')
-rw-r--r--NorthstarDedicatedTest/modmanager.cpp52
1 files changed, 48 insertions, 4 deletions
diff --git a/NorthstarDedicatedTest/modmanager.cpp b/NorthstarDedicatedTest/modmanager.cpp
index e2773f5a..7aaf5846 100644
--- a/NorthstarDedicatedTest/modmanager.cpp
+++ b/NorthstarDedicatedTest/modmanager.cpp
@@ -107,11 +107,55 @@ Mod::Mod(fs::path modDir, char* jsonBuf)
else
convar->HelpString = "";
- // todo: could possibly parse FCVAR names here instead, would be easier
+ convar->Flags = FCVAR_NONE;
+
if (convarObj.HasMember("Flags"))
- convar->Flags = convarObj["Flags"].GetInt();
- else
- convar->Flags = FCVAR_NONE;
+ {
+ // read raw integer flags
+ if (convarObj["Flags"].IsInt())
+ convar->Flags = convarObj["Flags"].GetInt();
+ else if (convarObj["Flags"].IsString())
+ {
+ // parse cvar flags from string
+ // example string: ARCHIVE_PLAYERPROFILE | GAMEDLL
+
+ std::string sFlags = convarObj["Flags"].GetString();
+ sFlags += '|'; // add additional | so we register the last flag
+ std::string sCurrentFlag;
+
+ for (int i = 0; i < sFlags.length(); i++)
+ {
+ if (isspace(sFlags[i]))
+ continue;
+
+ // if we encounter a |, add current string as a flag
+ if (sFlags[i] == '|')
+ {
+ bool bHasFlags = false;
+ int iCurrentFlags;
+
+ for (auto& flagPair : g_PrintCommandFlags)
+ {
+ if (!sCurrentFlag.compare(flagPair.second))
+ {
+ iCurrentFlags = flagPair.first;
+ bHasFlags = true;
+ break;
+ }
+ }
+
+ if (bHasFlags)
+ convar->Flags |= iCurrentFlags;
+ else
+ spdlog::warn("Mod ConVar {} has unknown flag {}", convar->Name, sCurrentFlag);
+
+ sCurrentFlag = "";
+ }
+ else
+ sCurrentFlag += sFlags[i];
+ }
+ }
+ }
ConVars.push_back(convar);
}