mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2025-04-15 06:40:51 +00:00
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:
parent
60a4b403dd
commit
bb07f12b42
1 changed files with 31 additions and 2 deletions
33
src/w_wad.c
33
src/w_wad.c
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue