diff -r d3b2571c378b -r 6972eb067f48 core/CoreConfig.cpp --- a/core/CoreConfig.cpp Wed Feb 18 02:19:22 2009 -0600 +++ b/core/CoreConfig.cpp Wed Feb 18 02:30:21 2009 -0600 @@ -79,9 +79,7 @@ const char *arg = cmd.Arg(1); - if (!g_bServerExecd - && arg != NULL - && strcmp(arg, g_ServerCfgFile->GetString()) == 0) + if (!g_bServerExecd && arg != NULL && strcmp(arg, g_ServerCfgFile->GetString()) == 0) { g_bGotTrigger = true; } @@ -103,8 +101,7 @@ void CheckAndFinalizeConfigs() { - if ((g_bServerExecd || g_ServerCfgFile == NULL) - && g_bGotServerStart) + if ((g_bServerExecd || g_ServerCfgFile == NULL) && g_bGotServerStart) { #if SOURCE_ENGINE >= SE_ORANGEBOX g_PendingInternalPush = true; @@ -122,6 +119,14 @@ g_pOnAutoConfigsBuffered = g_Forwards.CreateForward("OnAutoConfigsBuffered", ET_Ignore, 0, NULL); } +CoreConfig::CoreConfig() : m_Strings(512) +{ +} + +CoreConfig::~CoreConfig() +{ +} + void CoreConfig::OnSourceModShutdown() { g_RootMenu.RemoveRootConsoleCommand("config", this); @@ -218,6 +223,10 @@ /* Format path to config file */ g_LibSys.PathFormat(filePath, sizeof(filePath), "%s/%s", g_SourceMod.GetGamePath(), corecfg); + /* Reset cached key values */ + m_KeyValues.clear(); + m_Strings.Reset(); + /* Parse config file */ if ((err=textparsers->ParseFile_SMC(filePath, this, NULL)) != SMCError_Okay) { @@ -256,9 +265,21 @@ pBase = pBase->m_pGlobalClassNext; } + m_KeyValues.replace(option, m_Strings.AddString(value)); + return ConfigResult_Ignore; } +const char *CoreConfig::GetCoreConfigValue(const char *key) +{ + int *pKey = m_KeyValues.retrieve(key); + if (pKey == NULL) + { + return NULL; + } + return m_Strings.GetString(*pKey); +} + bool SM_AreConfigsExecuted() { return g_bConfigsExecd;