Added custom gamedata file parsing (bug 3644, r=dvander)

This commit is contained in:
Matt Woodrow 2009-02-18 15:08:17 +13:00
parent fddb69e49e
commit 13c1fd09c4

View File

@ -747,6 +747,44 @@ bool CGameConfig::Reparse(char *error, size_t maxlength)
}
}
/* Parse the contents of the 'custom' directory */
g_SourceMod.BuildPath(Path_SM, path, sizeof(path), "gamedata/%s/custom");
IDirectory *customDir = g_LibSys.OpenDirectory(path);
if (!customDir)
{
return true;
}
while (customDir->MoreFiles())
{
if (!customDir->IsEntryFile())
{
customDir->NextEntry();
continue;
}
const char *curFile = customDir->GetEntryName();
/* Only allow .txt files */
int len = strlen(curFile);
if (len > 4 && strcmp(curFile[len-4], ".txt") != 0)
{
customDir->NextEntry();
continue;
}
UTIL_Format(path, sizeof(path), "%s/custom/%s", m_File, curFile);
if (!EnterFile(path, error, maxlength))
{
g_LibSys->CloseDirectory(customDir);
return false;
}
customDir->NextEntry();
}
g_LibSys->CloseDirectory(customDir);
return true;
}