diff options
author | Emma Miler <emma.pi@protonmail.com> | 2022-12-22 19:59:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-22 19:59:10 +0100 |
commit | 64100065b55f79e76542ba689545c60e6fb0dcef (patch) | |
tree | 396bfeb9eacdd6d8070dee89de16c6c216ac6b10 /NorthstarDLL/core/convar | |
parent | 7cdf27e6dfcf61329317e641e6625599cda3f5b0 (diff) | |
download | NorthstarLauncher-64100065b55f79e76542ba689545c60e6fb0dcef.tar.gz NorthstarLauncher-64100065b55f79e76542ba689545c60e6fb0dcef.zip |
Add script concommands (#373)
* Add script concommands
* Fix indent
* Formatting
* Formatting stuff
* Changes for review
* Fix typo
* Forgot to remove the return statement
* Formatting
Diffstat (limited to 'NorthstarDLL/core/convar')
-rw-r--r-- | NorthstarDLL/core/convar/convar.cpp | 40 | ||||
-rw-r--r-- | NorthstarDLL/core/convar/convar.h | 2 |
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); |