Added custom gamedata file parsing (bug 3644, r=dvander)
This commit is contained in:
parent
fddb69e49e
commit
13c1fd09c4
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user