aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDLL/core
diff options
context:
space:
mode:
Diffstat (limited to 'NorthstarDLL/core')
-rw-r--r--NorthstarDLL/core/convar/convar.cpp40
-rw-r--r--NorthstarDLL/core/convar/convar.h2
2 files changed, 42 insertions, 0 deletions
diff --git a/NorthstarDLL/core/convar/convar.cpp b/NorthstarDLL/core/convar/convar.cpp
index 5ff0e4c1..11411c0a 100644
--- a/NorthstarDLL/core/convar/convar.cpp
+++ b/NorthstarDLL/core/convar/convar.cpp
@@ -488,3 +488,43 @@ bool ConVar::ClampValue(float& flValue)
return false;
}
+
+int ParseConVarFlagsString(std::string modName, std::string sFlags)
+{
+ 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)
+ return iCurrentFlags;
+ else
+ spdlog::warn("Mod ConCommand {} has unknown flag {}", modName, sCurrentFlag);
+
+ sCurrentFlag = "";
+ }
+ else
+ {
+ sCurrentFlag += sFlags[i];
+ }
+ }
+}
diff --git a/NorthstarDLL/core/convar/convar.h b/NorthstarDLL/core/convar/convar.h
index edc6ac97..4b00e25f 100644
--- a/NorthstarDLL/core/convar/convar.h
+++ b/NorthstarDLL/core/convar/convar.h
@@ -190,3 +190,5 @@ class ConVar
void* m_pMalloc {}; // 0x0070
char m_pPad80[10] {}; // 0x0080
}; // Size: 0x0080
+
+int ParseConVarFlagsString(std::string modName, std::string flags);