Gameconfs now support descriptions to identify games with '!' at the beginning of the string
authorScott Ehlert <ds@alliedmods.net>
Sun Jul 08 09:34:20 2007 +0000 (2007-07-08)
changeset 1064726206725da8
parent 1063 2078b3a13b81
child 1065 11756fc9fb63
Gameconfs now support descriptions to identify games with '!' at the beginning of the string
core/GameConfigs.cpp
core/GameConfigs.h
     1.1 --- a/core/GameConfigs.cpp	Sun Jul 08 05:20:54 2007 +0000
     1.2 +++ b/core/GameConfigs.cpp	Sun Jul 08 09:34:20 2007 +0000
     1.3 @@ -32,7 +32,8 @@
     1.4  
     1.5  GameConfigManager g_GameConfigs;
     1.6  IGameConfig *g_pGameConf = NULL;
     1.7 -char g_mod[255];
     1.8 +char g_Game[256];
     1.9 +char g_GameDesc[256] = {'!', '\0'};
    1.10  
    1.11  #define PSTATE_NONE						0
    1.12  #define PSTATE_GAMES					1
    1.13 @@ -106,10 +107,11 @@
    1.14  		{
    1.15  			if ((strcmp(name, "*") == 0)
    1.16  				|| (strcmp(name, "#default") == 0)
    1.17 -				|| (strcmp(name, g_mod) == 0))
    1.18 +				|| (strcasecmp(name, g_Game) == 0)
    1.19 +				|| (strcasecmp(name, g_GameDesc) == 0))
    1.20  			{
    1.21  				m_ParseState = PSTATE_GAMEDEFS;
    1.22 -				strncopy(m_mod, name, sizeof(m_mod));
    1.23 +				strncopy(m_Game, name, sizeof(m_Game));
    1.24  			} else {
    1.25  				m_IgnoreLevel++;
    1.26  			}
    1.27 @@ -126,7 +128,7 @@
    1.28  				m_ParseState = PSTATE_GAMEDEFS_KEYS;
    1.29  			}
    1.30  			else if ((strcmp(name, "#supported") == 0)
    1.31 -					 && (strcmp(m_mod, "#default") == 0))
    1.32 +					 && (strcmp(m_Game, "#default") == 0))
    1.33  			{
    1.34  				m_ParseState = PSTATE_GAMEDEFS_SUPPORTED;
    1.35  				/* Ignore this section unless we get a game. */
    1.36 @@ -144,8 +146,8 @@
    1.37  		}
    1.38  	case PSTATE_GAMEDEFS_OFFSETS:
    1.39  		{
    1.40 -			m_prop[0] = '\0';
    1.41 -			m_class[0] = '\0';
    1.42 +			m_Prop[0] = '\0';
    1.43 +			m_Class[0] = '\0';
    1.44  			strncopy(m_offset, name, sizeof(m_offset));
    1.45  			m_ParseState = PSTATE_GAMEDEFS_OFFSETS_OFFSET;
    1.46  			break;
    1.47 @@ -185,9 +187,9 @@
    1.48  	{
    1.49  		if (strcmp(key, "class") == 0)
    1.50  		{
    1.51 -			strncopy(m_class, value, sizeof(m_class));
    1.52 +			strncopy(m_Class, value, sizeof(m_Class));
    1.53  		} else if (strcmp(key, "prop") == 0) {
    1.54 -			strncopy(m_prop, value, sizeof(m_prop));
    1.55 +			strncopy(m_Prop, value, sizeof(m_Prop));
    1.56  		} else if (strcmp(key, PLATFORM_NAME) == 0) {
    1.57  			int val = atoi(value);
    1.58  			sm_trie_replace(m_pOffsets, m_offset, (void *)val);
    1.59 @@ -197,7 +199,7 @@
    1.60  		sm_trie_replace(m_pKeys, key, (void *)id);
    1.61  	} else if (m_ParseState == PSTATE_GAMEDEFS_SUPPORTED) {
    1.62  		if (strcmp(key, "game") == 0
    1.63 -			&& strcmp(value, g_mod) == 0)
    1.64 +			&& (strcasecmp(value, g_Game) == 0 || strcasecmp(value, g_GameDesc) == 0))
    1.65  		{
    1.66  			bShouldBeReadingDefault = true;
    1.67  		}
    1.68 @@ -242,10 +244,10 @@
    1.69  	case PSTATE_GAMEDEFS_OFFSETS_OFFSET:
    1.70  		{
    1.71  			/* Parse the offset... */
    1.72 -			if (m_class[0] != '\0'
    1.73 -				&& m_prop[0] != '\0')
    1.74 +			if (m_Class[0] != '\0'
    1.75 +				&& m_Prop[0] != '\0')
    1.76  			{
    1.77 -				SendProp *pProp = g_HL2.FindInSendTable(m_class, m_prop);
    1.78 +				SendProp *pProp = g_HL2.FindInSendTable(m_Class, m_Prop);
    1.79  				if (pProp)
    1.80  				{
    1.81  					int val = pProp->GetOffset();
    1.82 @@ -253,14 +255,14 @@
    1.83  					sm_trie_replace(m_pProps, m_offset, pProp);
    1.84  				} else {
    1.85  					/* Check if it's a non-default game and no offsets exist */
    1.86 -					if (((strcmp(m_mod, "*") != 0) && strcmp(m_mod, "#default") != 0)
    1.87 +					if (((strcmp(m_Game, "*") != 0) && strcmp(m_Game, "#default") != 0)
    1.88  						&& (!sm_trie_retrieve(m_pOffsets, m_offset, NULL)))
    1.89  					{
    1.90  						g_Logger.LogError("[SM] Unable to find property %s.%s (file \"%s\") (mod \"%s\")", 
    1.91 -							m_class,
    1.92 -							m_prop,
    1.93 +							m_Class,
    1.94 +							m_Prop,
    1.95  							m_pFile,
    1.96 -							m_mod);
    1.97 +							m_Game);
    1.98  					}
    1.99  				}
   1.100  			}
   1.101 @@ -491,7 +493,8 @@
   1.102  {
   1.103  	LoadGameConfigFile("core.games", &g_pGameConf, NULL, 0);
   1.104  
   1.105 -	strncopy(g_mod, g_SourceMod.GetGameFolderName(), sizeof(g_mod));
   1.106 +	strncopy(g_Game, g_SourceMod.GetGameFolderName(), sizeof(g_Game));
   1.107 +	strncopy(g_GameDesc + 1, SERVER_CALL(GetGameDescription)(), sizeof(g_GameDesc) - 1);
   1.108  }
   1.109  
   1.110  void GameConfigManager::OnSourceModAllInitialized()
     2.1 --- a/core/GameConfigs.h	Sun Jul 08 05:20:54 2007 +0000
     2.2 +++ b/core/GameConfigs.h	Sun Jul 08 09:34:20 2007 +0000
     2.3 @@ -60,10 +60,10 @@
     2.4  	/* Parse states */
     2.5  	int m_ParseState;
     2.6  	unsigned int m_IgnoreLevel;
     2.7 -	char m_class[64];
     2.8 -	char m_prop[64];
     2.9 +	char m_Class[64];
    2.10 +	char m_Prop[64];
    2.11  	char m_offset[64];
    2.12 -	char m_mod[255];
    2.13 +	char m_Game[256];
    2.14  	bool bShouldBeReadingDefault;
    2.15  };
    2.16