Check all possible mapcycle paths on newer orangebox games (bug 5719, r=asherkin).
authorNicholas Hastings <skamonkey@gmail.com>
Wed Jul 31 22:57:50 2013 -0400 (2013-07-31)
changeset 39665d8b87f98355
parent 3965 86dedf4462d8
child 3967 ceafb87d38a7
Check all possible mapcycle paths on newer orangebox games (bug 5719, r=asherkin).
core/logic/smn_maplists.cpp
     1.1 --- a/core/logic/smn_maplists.cpp	Wed Jul 31 22:11:15 2013 -0400
     1.2 +++ b/core/logic/smn_maplists.cpp	Wed Jul 31 22:57:50 2013 -0400
     1.3 @@ -127,6 +127,8 @@
     1.4  		SMCError error;
     1.5  		time_t fileTime;
     1.6  		SMCStates states = {0, 0};
     1.7 +		const char *pMapCycleFileName;
     1.8 +		const char *pEngineName;
     1.9  		
    1.10  		fileFound = libsys->FileTime(m_ConfigFile, FileTime_LastChange, &fileTime);
    1.11  
    1.12 @@ -156,11 +158,47 @@
    1.13  
    1.14  		pDefList->bIsPath = true;
    1.15  		smcore.strncopy(pDefList->name, "mapcyclefile", sizeof(pDefList->name));
    1.16 -		g_pSM->BuildPath(Path_Game,
    1.17 -			pDefList->path, 
    1.18 -			sizeof(pDefList->path),
    1.19 -			"%s",
    1.20 -			m_pMapCycleFile ? smcore.GetCvarString(m_pMapCycleFile) : "mapcycle.txt");
    1.21 +
    1.22 +		pMapCycleFileName = m_pMapCycleFile ? smcore.GetCvarString(m_pMapCycleFile) : "mapcycle.txt";
    1.23 +
    1.24 +		pEngineName = smcore.GetSourceEngineName();
    1.25 +
    1.26 +		if (strcmp(pEngineName, "tf2") == 0 || strcmp(pEngineName, "css") == 0
    1.27 +			|| strcmp(pEngineName, "dods") == 0 || strcmp(pEngineName, "hl2dm") == 0)
    1.28 +		{
    1.29 +			// These four games and Source SDK 2013 do a lookup in this order; so shall we.
    1.30 +			g_pSM->BuildPath(Path_Game,
    1.31 +				pDefList->path, 
    1.32 +				sizeof(pDefList->path),
    1.33 +				"cfg/%s",
    1.34 +				pMapCycleFileName);
    1.35 +			
    1.36 +			if (!libsys->PathExists(pDefList->path))
    1.37 +			{
    1.38 +				g_pSM->BuildPath(Path_Game,
    1.39 +					pDefList->path, 
    1.40 +					sizeof(pDefList->path),
    1.41 +					"%s",
    1.42 +					pMapCycleFileName);
    1.43 +
    1.44 +				if (!libsys->PathExists(pDefList->path))
    1.45 +				{
    1.46 +					g_pSM->BuildPath(Path_Game,
    1.47 +						pDefList->path, 
    1.48 +						sizeof(pDefList->path),
    1.49 +						"cfg/mapcycle_default.txt");
    1.50 +				}
    1.51 +			}
    1.52 +		}
    1.53 +		else
    1.54 +		{
    1.55 +			g_pSM->BuildPath(Path_Game,
    1.56 +				pDefList->path, 
    1.57 +				sizeof(pDefList->path),
    1.58 +				"%s",
    1.59 +				pMapCycleFileName);
    1.60 +		}
    1.61 +		
    1.62  		pDefList->last_modified_time = 0;
    1.63  		pDefList->pArray = NULL;
    1.64  		pDefList->serial = 0;