pass our file counts to W_InitMultipleFiles

smol opzimiation, skips some ptr deref
This commit is contained in:
Alug committed 2025-11-01 20:49:03 +01:00
1 parent c8ae4a89d9
commit 7c1f17bb8d
3 files changed
+17 -15

No files matched your search

+9 -8
View File
@@ -1046,7 +1046,7 @@ void D_StartTitle(void)
//
// D_AddFile
//
static void D_AddFile(const char *file, char **filearray, size_t count)
static void D_AddFile(const char *file, char **filearray, size_t index)
{
char *newfile;
@@ -1057,14 +1057,14 @@ static void D_AddFile(const char *file, char **filearray, size_t count)
}
strcpy(newfile, file);
filearray[count] = newfile;
filearray[index] = newfile;
}
static void D_CleanFile(char **filearray, size_t count)
static void D_CleanFile(char **filearray, size_t index)
{
size_t i;
for (i = 0; i < count; i++)
for (i = 0; i < index; i++)
{
free(filearray[i]);
filearray[i] = NULL;
@@ -1358,7 +1358,7 @@ static void IdentifyVersion(void)
musicpath = va(pandf, srb2waddir, str);\
handle = W_OpenWadFile(&musicpath, false); \
if (handle) \
{\
{ \
int ms = W_VerifyNMUSlumps(musicpath, handle, false); \
fclose(handle); \
if (ms == 0) \
@@ -1843,7 +1843,8 @@ void D_SRB2Main(void)
// load wad, including the main wad file
CONS_Printf("W_InitMultipleFiles(): Adding IWAD and main PWADs.\n");
W_InitMultipleFiles(startupiwadfiles, false);
W_InitMultipleFiles(startupiwadfiles, startupiwadcount, false);
//mainwads = startupiwadcount - musicwads;
D_CleanFile(startupiwadfiles, startupiwadcount);
startupiwadcount = 0;
mainwads = 0;
@@ -1884,10 +1885,10 @@ void D_SRB2Main(void)
D_CheckMaps(false);
W_InitMultipleFiles(startuppwads, true);
W_InitMultipleFiles(startuppwads, startuppwadcount, true);
// Only search for pwad maps if we actually have a pwad added
if (startuppwads[0] != NULL)
if (startuppwadcount > 0)
{
D_CheckMaps(true);
}
+7 -6
View File
@@ -971,24 +971,25 @@ UINT16 W_InitFile(const char *filename, boolean local, boolean startup)
* \return 1 if all files were loaded, 0 if at least one was missing or
* invalid.
*/
INT32 W_InitMultipleFiles(char **filenames, boolean addons)
INT32 W_InitMultipleFiles(char **filenames, size_t count, boolean addons)
{
INT32 rc = 1;
INT32 overallrc = 1;
size_t i;
(void)addons;
// will be realloced as lumps are added
for (; *filenames; filenames++)
for (i = 0; i < count; i++)
{
const char *filename = filenames[i];
// Previously, W_VerifyNMUSlumps was called to mark game modified
// for addons... but W_InitFile already does exactly that!
//CONS_Debug(DBG_SETUP, "Loading %s\n", *filenames);
rc = W_InitFile(*filenames, false, true);
rc = W_InitFile(filename, false, true);
if (rc == INT16_MAX)
CONS_Printf(M_GetText("Errors occurred while loading %s; not added.\n"), *filenames);
CONS_Printf(M_GetText("Errors occurred while loading %s; not added.\n"), filename);
overallrc &= (rc != INT16_MAX) ? 1 : 0;
}
+1 -1
View File
@@ -167,7 +167,7 @@ UINT16 W_InitFile(const char *filename, boolean local, boolean startup);
// W_InitMultipleFiles returns 1 if all is okay, 0 otherwise,
// so that it stops with a message if a file was not found, but not if all is okay.
INT32 W_InitMultipleFiles(char **filenames, boolean addons);
INT32 W_InitMultipleFiles(char **filenames, size_t count, boolean addons);
// Used for autoload. Uses P_AddWadFileLocal instead of W_InitFiles.
INT32 W_AddAutoloadedLocalFiles(char **filenames);