core/CoreConfig.cpp
changeset 2584 6972eb067f48
parent 2583 d3b2571c378b
parent 2574 d05c7ee81134
child 2752 e19de59cb8e5
     1.1 --- a/core/CoreConfig.cpp	Wed Feb 18 02:19:22 2009 -0600
     1.2 +++ b/core/CoreConfig.cpp	Wed Feb 18 02:30:21 2009 -0600
     1.3 @@ -79,9 +79,7 @@
     1.4  
     1.5  	const char *arg = cmd.Arg(1);
     1.6  
     1.7 -	if (!g_bServerExecd 
     1.8 -		&& arg != NULL 
     1.9 -		&& strcmp(arg, g_ServerCfgFile->GetString()) == 0)
    1.10 +	if (!g_bServerExecd && arg != NULL && strcmp(arg, g_ServerCfgFile->GetString()) == 0)
    1.11  	{
    1.12  		g_bGotTrigger = true;
    1.13  	}
    1.14 @@ -103,8 +101,7 @@
    1.15  
    1.16  void CheckAndFinalizeConfigs()
    1.17  {
    1.18 -	if ((g_bServerExecd || g_ServerCfgFile == NULL) 
    1.19 -		&& g_bGotServerStart)
    1.20 +	if ((g_bServerExecd || g_ServerCfgFile == NULL) && g_bGotServerStart)
    1.21  	{
    1.22  #if SOURCE_ENGINE >= SE_ORANGEBOX
    1.23          g_PendingInternalPush = true;
    1.24 @@ -122,6 +119,14 @@
    1.25  	g_pOnAutoConfigsBuffered = g_Forwards.CreateForward("OnAutoConfigsBuffered", ET_Ignore, 0, NULL);
    1.26  }
    1.27  
    1.28 +CoreConfig::CoreConfig() : m_Strings(512)
    1.29 +{
    1.30 +}
    1.31 +
    1.32 +CoreConfig::~CoreConfig()
    1.33 +{
    1.34 +}
    1.35 +
    1.36  void CoreConfig::OnSourceModShutdown()
    1.37  {
    1.38  	g_RootMenu.RemoveRootConsoleCommand("config", this);
    1.39 @@ -218,6 +223,10 @@
    1.40  	/* Format path to config file */
    1.41  	g_LibSys.PathFormat(filePath, sizeof(filePath), "%s/%s", g_SourceMod.GetGamePath(), corecfg);
    1.42  
    1.43 +	/* Reset cached key values */
    1.44 +	m_KeyValues.clear();
    1.45 +	m_Strings.Reset();
    1.46 +
    1.47  	/* Parse config file */
    1.48  	if ((err=textparsers->ParseFile_SMC(filePath, this, NULL)) != SMCError_Okay)
    1.49  	{
    1.50 @@ -256,9 +265,21 @@
    1.51  		pBase = pBase->m_pGlobalClassNext;
    1.52  	}
    1.53  
    1.54 +	m_KeyValues.replace(option, m_Strings.AddString(value));
    1.55 +
    1.56  	return ConfigResult_Ignore;
    1.57  }
    1.58  
    1.59 +const char *CoreConfig::GetCoreConfigValue(const char *key)
    1.60 +{
    1.61 +	int *pKey = m_KeyValues.retrieve(key);
    1.62 +	if (pKey == NULL)
    1.63 +	{
    1.64 +		return NULL;
    1.65 +	}
    1.66 +	return m_Strings.GetString(*pKey);
    1.67 +}
    1.68 +
    1.69  bool SM_AreConfigsExecuted()
    1.70  {
    1.71  	return g_bConfigsExecd;