W_InitMultipleFiles with one findmultiplefiles call

This speeds up file searching for base resources and pwads by using one
directory traversal. Previously findfile could be called for each wad. And
although subsequent traversals after the first are faster, it's still a waste.
This commit is contained in:
James R 2020-08-22 01:53:22 -07:00
parent 60a4b403dd
commit bb07f12b42

View file

@ -847,16 +847,45 @@ void W_UnloadWadFile(UINT16 num)
*/
INT32 W_InitMultipleFiles(char **filenames, boolean addons)
{
char filenamebufs[MAX_WADFILES][MAX_WADPATH];
filequery_t q[MAX_WADFILES];
int n = 0;
int i;
INT32 rc = 1;
// will be realloced as lumps are added
for (; *filenames; filenames++)
{
if (addons && !W_VerifyNMUSlumps(*filenames))
if (FIL_FileOK(*filenames))
{
q[n].status = FS_FOUND;
q[n].filename = *filenames;
}
else
{
strcpy(filenamebufs[n], *filenames);
q[n].filename = filenamebufs[n];
}
n++;
}
findmultiplefiles(n, q, false, true);
for (i = 0; i < n; ++i)
{
if (q[i].status != FS_FOUND)
{
CONS_Alert(CONS_ERROR, M_GetText("File %s not found.\n"), q[i].filename);
continue;
}
if (addons && !W_VerifyNMUSlumps(q[i].filename))
G_SetGameModified(true, false);
//CONS_Debug(DBG_SETUP, "Loading %s\n", *filenames);
rc &= (W_InitFile(*filenames) != INT16_MAX) ? 1 : 0;
rc &= (W_InitFile(q[i].filename) != INT16_MAX) ? 1 : 0;
}
if (!numwadfiles)