ModSystem: fix unwanted double-nesting when writing status list

The keyvalues file is written incorrectly as we double nest the mod list by calling FindKey on "ModList" with the create parameter set. The constructor of KeyValues already creates the root object called "ModList" in which the list should be stored.

The list is now properly parsed, making the enable/disable feature for individual mods work again.
This commit is contained in:
Kawe Mazidjatari 2024-11-17 21:54:24 +01:00
parent eb374b4328
commit e5b6e3eb6e

View File

@ -135,8 +135,7 @@ void CModSystem::LoadModStatusList(CUtlMap<CUtlString, bool>& enabledList)
//-----------------------------------------------------------------------------
void CModSystem::WriteModStatusList()
{
KeyValues kv = KeyValues("ModList");
KeyValues* pModListKV = kv.FindKey("ModList", true);
KeyValues kv("ModList");
FOR_EACH_VEC(m_ModList, i)
{
@ -146,7 +145,7 @@ void CModSystem::WriteModStatusList()
if (mod->m_iState == eModState::ENABLED)
enabled = true;
pModListKV->SetBool(mod->m_ModID.Get(), enabled);
kv.SetBool(mod->m_ModID.Get(), enabled);
}
CUtlBuffer buf = CUtlBuffer(ssize_t(0), 0, CUtlBuffer::TEXT_BUFFER);