From 64100065b55f79e76542ba689545c60e6fb0dcef Mon Sep 17 00:00:00 2001 From: Emma Miler Date: Thu, 22 Dec 2022 19:59:10 +0100 Subject: Add script concommands (#373) * Add script concommands * Fix indent * Formatting * Formatting stuff * Changes for review * Fix typo * Forgot to remove the return statement * Formatting --- NorthstarDLL/core/convar/convar.cpp | 40 +++++++++++++++++++++++++++++++++++++ NorthstarDLL/core/convar/convar.h | 2 ++ 2 files changed, 42 insertions(+) (limited to 'NorthstarDLL/core/convar') 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); -- cgit v1.2.3