Merge branch 'netids-break-again-fuck-this' into 'next'

Fix net ids broken AGAIN (closes #310)

Closes #310

See merge request STJr/SRB2!1166
This commit is contained in:
James R 2020-10-01 23:13:05 -04:00
commit 304e4bb1f9
4 changed files with 24 additions and 22 deletions

View file

@ -1201,7 +1201,7 @@ static consvar_t *CV_FindNetVar(UINT16 netid)
{
consvar_t *cvar;
if (netid >= consvar_number_of_netids)
if (netid > consvar_number_of_netids)
return NULL;
for (cvar = consvar_vars; cvar; cvar = cvar->next)

View file

@ -99,6 +99,7 @@ UINT8 window_notinfocus = false;
// DEMO LOOP
//
static char *startupwadfiles[MAX_WADFILES];
static char *startuppwads[MAX_WADFILES];
boolean devparm = false; // started game with -devparm
@ -977,12 +978,12 @@ void D_StartTitle(void)
//
// D_AddFile
//
static void D_AddFile(const char *file)
static void D_AddFile(char **list, const char *file)
{
size_t pnumwadfiles;
char *newfile;
for (pnumwadfiles = 0; startupwadfiles[pnumwadfiles]; pnumwadfiles++)
for (pnumwadfiles = 0; list[pnumwadfiles]; pnumwadfiles++)
;
newfile = malloc(strlen(file) + 1);
@ -992,16 +993,16 @@ static void D_AddFile(const char *file)
}
strcpy(newfile, file);
startupwadfiles[pnumwadfiles] = newfile;
list[pnumwadfiles] = newfile;
}
static inline void D_CleanFile(void)
static inline void D_CleanFile(char **list)
{
size_t pnumwadfiles;
for (pnumwadfiles = 0; startupwadfiles[pnumwadfiles]; pnumwadfiles++)
for (pnumwadfiles = 0; list[pnumwadfiles]; pnumwadfiles++)
{
free(startupwadfiles[pnumwadfiles]);
startupwadfiles[pnumwadfiles] = NULL;
free(list[pnumwadfiles]);
list[pnumwadfiles] = NULL;
}
}
@ -1086,7 +1087,7 @@ static void IdentifyVersion(void)
// Load the IWAD
if (srb2wad != NULL && FIL_ReadFileOK(srb2wad))
D_AddFile(srb2wad);
D_AddFile(startupwadfiles, srb2wad);
else
I_Error("srb2.pk3 not found! Expected in %s, ss file: %s\n", srb2waddir, srb2wad);
@ -1097,14 +1098,14 @@ static void IdentifyVersion(void)
// checking in D_SRB2Main
// Add the maps
D_AddFile(va(pandf,srb2waddir,"zones.pk3"));
D_AddFile(startupwadfiles, va(pandf,srb2waddir,"zones.pk3"));
// Add the players
D_AddFile(va(pandf,srb2waddir, "player.dta"));
D_AddFile(startupwadfiles, va(pandf,srb2waddir, "player.dta"));
#ifdef USE_PATCH_DTA
// Add our crappy patches to fix our bugs
D_AddFile(va(pandf,srb2waddir,"patch.pk3"));
D_AddFile(startupwadfiles, va(pandf,srb2waddir,"patch.pk3"));
#endif
#if !defined (HAVE_SDL) || defined (HAVE_MIXER)
@ -1114,7 +1115,7 @@ static void IdentifyVersion(void)
const char *musicpath = va(pandf,srb2waddir,str);\
int ms = W_VerifyNMUSlumps(musicpath); \
if (ms == 1) \
D_AddFile(musicpath); \
D_AddFile(startupwadfiles, musicpath); \
else if (ms == 0) \
I_Error("File "str" has been modified with non-music/sound lumps"); \
}
@ -1304,7 +1305,7 @@ void D_SRB2Main(void)
{
if (!W_VerifyNMUSlumps(s))
G_SetGameModified(true);
D_AddFile(s);
D_AddFile(startuppwads, s);
}
}
}
@ -1345,8 +1346,8 @@ void D_SRB2Main(void)
// load wad, including the main wad file
CONS_Printf("W_InitMultipleFiles(): Adding IWAD and main PWADs.\n");
W_InitMultipleFiles(startupwadfiles, mainwads);
D_CleanFile();
W_InitMultipleFiles(startupwadfiles);
D_CleanFile(startupwadfiles);
#ifndef DEVELOP // md5s last updated 22/02/20 (ddmmyy)
@ -1395,6 +1396,10 @@ void D_SRB2Main(void)
I_RegisterSysCommands();
CONS_Printf("W_InitMultipleFiles(): Adding extra PWADs.\n");
W_InitMultipleFiles(startuppwads);
D_CleanFile(startuppwads);
//--------------------------------------------------------- CONFIG.CFG
M_FirstLoadConfig(); // WARNING : this do a "COM_BufExecute()"

View file

@ -887,16 +887,13 @@ UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup)
*
* \param filenames A null-terminated list of files to use.
*/
void W_InitMultipleFiles(char **filenames, UINT16 mainfiles)
void W_InitMultipleFiles(char **filenames)
{
// open all the files, load headers, and count lumps
numwadfiles = 0;
// will be realloced as lumps are added
for (; *filenames; filenames++)
{
//CONS_Debug(DBG_SETUP, "Loading %s\n", *filenames);
W_InitFile(*filenames, numwadfiles < mainfiles, true);
W_InitFile(*filenames, numwadfiles < mainwads, true);
}
}

View file

@ -150,7 +150,7 @@ FILE *W_OpenWadFile(const char **filename, boolean useerrors);
UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup);
// W_InitMultipleFiles exits if a file was not found, but not if all is okay.
void W_InitMultipleFiles(char **filenames, UINT16 mainfiles);
void W_InitMultipleFiles(char **filenames);
const char *W_CheckNameForNumPwad(UINT16 wad, UINT16 lump);
const char *W_CheckNameForNum(lumpnum_t lumpnum);