aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDLL/shared/keyvalues.cpp
diff options
context:
space:
mode:
authorBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2023-02-12 21:15:00 +0000
committerGitHub <noreply@github.com>2023-02-12 21:15:00 +0000
commit95b41b6f8cc612953eafd7f8b6b40124e1590bc7 (patch)
tree400746bace6855c210e020a5ca93b84c2fdd0dc9 /NorthstarDLL/shared/keyvalues.cpp
parentb61ed18a86ddd2d7ab0e80992859750a49a9c4f6 (diff)
downloadNorthstarLauncher-95b41b6f8cc612953eafd7f8b6b40124e1590bc7.tar.gz
NorthstarLauncher-95b41b6f8cc612953eafd7f8b6b40124e1590bc7.zip
Add `CGlobals` class and `g_pGlobals`, and update code to support (#411)
* add CGlobals class and g_pGlobals, and update scripts to support * don't automatically enable antispeedhack (oops) * add dedicated.cpp * format * bad push oops * reformat again
Diffstat (limited to 'NorthstarDLL/shared/keyvalues.cpp')
-rw-r--r--NorthstarDLL/shared/keyvalues.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/NorthstarDLL/shared/keyvalues.cpp b/NorthstarDLL/shared/keyvalues.cpp
index fe7d6299..25155dde 100644
--- a/NorthstarDLL/shared/keyvalues.cpp
+++ b/NorthstarDLL/shared/keyvalues.cpp
@@ -211,8 +211,15 @@ KeyValues* KeyValues::FindKey(const char* pszKeyName, bool bCreate)
return this;
const char* pSubStr = strchr(pszKeyName, '/');
+ const char* pSearchStr = pszKeyName;
+ if (pSubStr && !*(pSubStr + 1))
+ {
+ // if key name is just '/', then use it as a key directly
+ pSearchStr = pSubStr;
+ pSubStr = nullptr;
+ }
- HKeySymbol iSearchStr = KeyValuesSystem()->m_pVtable->GetSymbolForString(KeyValuesSystem(), pszKeyName, bCreate);
+ HKeySymbol iSearchStr = KeyValuesSystem()->m_pVtable->GetSymbolForString(KeyValuesSystem(), pSearchStr, bCreate);
if (iSearchStr == INVALID_KEY_SYMBOL)
{
// not found, couldn't possibly be in key value list
@@ -222,7 +229,7 @@ KeyValues* KeyValues::FindKey(const char* pszKeyName, bool bCreate)
KeyValues* pLastKVs = nullptr;
KeyValues* pCurrentKVs;
// find the searchStr in the current peer list
- for (pCurrentKVs = m_pSub; pCurrentKVs != NULL; pCurrentKVs = pCurrentKVs->m_pPeer)
+ for (pCurrentKVs = m_pSub; pCurrentKVs != nullptr; pCurrentKVs = pCurrentKVs->m_pPeer)
{
pLastKVs = pCurrentKVs; // record the last item looked at (for if we need to append to the end of the list)
@@ -232,7 +239,7 @@ KeyValues* KeyValues::FindKey(const char* pszKeyName, bool bCreate)
}
if (!pCurrentKVs && m_pChain)
- pCurrentKVs = m_pChain->FindKey(pszKeyName, false);
+ pCurrentKVs = m_pChain->FindKey(pSearchStr, false);
// make sure a key was found
if (!pCurrentKVs)
@@ -240,7 +247,7 @@ KeyValues* KeyValues::FindKey(const char* pszKeyName, bool bCreate)
if (bCreate)
{
// we need to create a new key
- pCurrentKVs = new KeyValues(pszKeyName);
+ pCurrentKVs = new KeyValues(pSearchStr);
// Assert(dat != NULL);
// insert new key at end of list
@@ -249,7 +256,7 @@ KeyValues* KeyValues::FindKey(const char* pszKeyName, bool bCreate)
else
m_pSub = pCurrentKVs;
- pCurrentKVs->m_pPeer = NULL;
+ pCurrentKVs->m_pPeer = nullptr;
// a key graduates to be a submsg as soon as it's m_pSub is set
// this should be the only place m_pSub is set
@@ -257,7 +264,7 @@ KeyValues* KeyValues::FindKey(const char* pszKeyName, bool bCreate)
}
else
{
- return NULL;
+ return nullptr;
}
}