core/GameConfigs.cpp
changeset 2584 6972eb067f48
parent 2583 d3b2571c378b
parent 2582 81a9781157c7
child 2628 541e48653064
     1.1 --- a/core/GameConfigs.cpp	Wed Feb 18 02:19:22 2009 -0600
     1.2 +++ b/core/GameConfigs.cpp	Wed Feb 18 02:30:21 2009 -0600
     1.3 @@ -749,6 +749,44 @@
     1.4  		}
     1.5  	}
     1.6  
     1.7 +	/* Parse the contents of the 'custom' directory */
     1.8 +	g_SourceMod.BuildPath(Path_SM, path, sizeof(path), "gamedata/%s/custom", m_File);
     1.9 +	IDirectory *customDir = g_LibSys.OpenDirectory(path);
    1.10 +
    1.11 +	if (!customDir)
    1.12 +	{
    1.13 +		return true;
    1.14 +	}
    1.15 +
    1.16 +	while (customDir->MoreFiles())
    1.17 +	{
    1.18 +		if (!customDir->IsEntryFile())
    1.19 +		{
    1.20 +			customDir->NextEntry();
    1.21 +			continue;
    1.22 +		}
    1.23 +		
    1.24 +		const char *curFile = customDir->GetEntryName();
    1.25 +
    1.26 +		/* Only allow .txt files */
    1.27 +		int len = strlen(curFile);
    1.28 +		if (len > 4 && strcmp(&curFile[len-4], ".txt") != 0)
    1.29 +		{
    1.30 +			customDir->NextEntry();
    1.31 +			continue;	
    1.32 +		}
    1.33 +
    1.34 +		UTIL_Format(path, sizeof(path), "%s/custom/%s", m_File, curFile);
    1.35 +		if (!EnterFile(path, error, maxlength))
    1.36 +		{
    1.37 +			g_LibSys.CloseDirectory(customDir);
    1.38 +			return false;
    1.39 +		}
    1.40 +
    1.41 +		customDir->NextEntry();
    1.42 +	}
    1.43 +
    1.44 +	g_LibSys.CloseDirectory(customDir);
    1.45  	return true;
    1.46  }
    1.47  
    1.48 @@ -764,15 +802,11 @@
    1.49  	bShouldBeReadingDefault = true;
    1.50  	m_ParseState = PSTATE_NONE;
    1.51  
    1.52 -	g_GameConfigs.AcquireLock();
    1.53 -
    1.54  	if ((err=textparsers->ParseSMCFile(m_CurFile, this, &state, error, maxlength))
    1.55  		!= SMCError_Okay)
    1.56  	{
    1.57  		const char *msg;
    1.58  
    1.59 -		g_GameConfigs.ReleaseLock();
    1.60 -
    1.61  		msg = textparsers->GetSMCErrorString(err);
    1.62  
    1.63  		g_Logger.LogError("[SM] Error parsing gameconfig file \"%s\":", m_CurFile);
    1.64 @@ -793,8 +827,6 @@
    1.65  		return false;
    1.66  	}
    1.67  
    1.68 -	g_GameConfigs.ReleaseLock();
    1.69 -
    1.70  	return true;
    1.71  }
    1.72  
    1.73 @@ -862,8 +894,6 @@
    1.74  
    1.75  void GameConfigManager::OnSourceModStartup(bool late)
    1.76  {
    1.77 -	m_FileLock = g_pThreader->MakeMutex();
    1.78 -
    1.79  	LoadGameConfigFile("core.games", &g_pGameConf, NULL, 0);
    1.80  
    1.81  	strncopy(g_Game, g_SourceMod.GetGameFolderName(), sizeof(g_Game));
    1.82 @@ -898,7 +928,6 @@
    1.83  void GameConfigManager::OnSourceModAllShutdown()
    1.84  {
    1.85  	CloseGameConfigFile(g_pGameConf);
    1.86 -	m_FileLock->DestroyThis();
    1.87  }
    1.88  
    1.89  bool GameConfigManager::LoadGameConfigFile(const char *file, IGameConfig **_pConfig, char *error, size_t maxlength)
    1.90 @@ -993,10 +1022,8 @@
    1.91  
    1.92  void GameConfigManager::AcquireLock()
    1.93  {
    1.94 -	m_FileLock->Lock();
    1.95  }
    1.96  
    1.97  void GameConfigManager::ReleaseLock()
    1.98  {
    1.99 -	m_FileLock->Unlock();
   1.100  }