Added custom gamedata file parsing (bug 3644, r=dvander)
authorMatt Woodrow <pred@alliedmods.net>
Wed Feb 18 15:08:17 2009 +1300 (2009-02-18)
changeset 257830341024c074
parent 2577 2c03ca54c114
child 2579 3db39c149092
Added custom gamedata file parsing (bug 3644, r=dvander)
core/GameConfigs.cpp
     1.1 --- a/core/GameConfigs.cpp	Wed Feb 18 15:03:17 2009 +1300
     1.2 +++ b/core/GameConfigs.cpp	Wed Feb 18 15:08:17 2009 +1300
     1.3 @@ -747,6 +747,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");
     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