From 04fe5de985ecbf0c11a6398a28d4eddd34fc063d Mon Sep 17 00:00:00 2001 From: wolfy852 Date: Sat, 16 Feb 2019 08:16:56 -0600 Subject: [PATCH 1/6] Incomplete: Split files added with -file into their own array Compiles with no errors but the game errors on launch. With no files added, it gives "W_InitMultipleFiles: no files found". With files loaded via -file it gives "W_GetNumForName: PLAYPAL not found!" --- src/d_main.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 28f89f4f..125c8f1e 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -111,6 +111,7 @@ UINT8 window_notinfocus = false; //static INT32 demosequence; static const char *pagename = "MAP1PIC"; static char *startupwadfiles[MAX_WADFILES]; +static char *startuppwads[MAX_WADFILES]; boolean devparm = false; // started game with -devparm @@ -824,12 +825,12 @@ void D_StartTitle(void) // // D_AddFile // -static void D_AddFile(const char *file) +static void D_AddFile(const char *file, char **filearray) { size_t pnumwadfiles; char *newfile; - for (pnumwadfiles = 0; startupwadfiles[pnumwadfiles]; pnumwadfiles++) + for (pnumwadfiles = 0; filearray[pnumwadfiles]; pnumwadfiles++) ; newfile = malloc(strlen(file) + 1); @@ -839,16 +840,16 @@ static void D_AddFile(const char *file) } strcpy(newfile, file); - startupwadfiles[pnumwadfiles] = newfile; + filearray[pnumwadfiles] = newfile; } -static inline void D_CleanFile(void) +static inline void D_CleanFile(char **filearray) { size_t pnumwadfiles; - for (pnumwadfiles = 0; startupwadfiles[pnumwadfiles]; pnumwadfiles++) + for (pnumwadfiles = 0; filearray[pnumwadfiles]; pnumwadfiles++) { - free(startupwadfiles[pnumwadfiles]); - startupwadfiles[pnumwadfiles] = NULL; + free(filearray[pnumwadfiles]); + filearray[pnumwadfiles] = NULL; } } @@ -908,9 +909,9 @@ static void IdentifyVersion(void) // Load the IWAD if (srb2wad2 != NULL && FIL_ReadFileOK(srb2wad2)) - D_AddFile(srb2wad2); + D_AddFile(srb2wad2, startupwadfiles); else if (srb2wad1 != NULL && FIL_ReadFileOK(srb2wad1)) - D_AddFile(srb2wad1); + D_AddFile(srb2wad1, startupwadfiles); else I_Error("SRB2.SRB/SRB2.WAD not found! Expected in %s, ss files: %s or %s\n", srb2waddir, srb2wad1, srb2wad2); @@ -927,12 +928,12 @@ static void IdentifyVersion(void) D_AddFile(va(pandf,srb2waddir,"patch.dta")); #endif - D_AddFile(va(pandf,srb2waddir,"gfx.kart")); - D_AddFile(va(pandf,srb2waddir,"textures.kart")); - D_AddFile(va(pandf,srb2waddir,"chars.kart")); - D_AddFile(va(pandf,srb2waddir,"maps.kart")); + D_AddFile(va(pandf,srb2waddir,"gfx.kart"), startupwadfiles); + D_AddFile(va(pandf,srb2waddir,"textures.kart"), startupwadfiles); + D_AddFile(va(pandf,srb2waddir,"chars.kart"), startupwadfiles); + D_AddFile(va(pandf,srb2waddir,"maps.kart"), startupwadfiles); #ifdef USE_PATCH_KART - D_AddFile(va(pandf,srb2waddir,"patch.kart")); + D_AddFile(va(pandf,srb2waddir,"patch.kart"), startupwadfiles); #endif #if !defined (HAVE_SDL) || defined (HAVE_MIXER) @@ -941,7 +942,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(musicpath, startupwadfiles); \ else if (ms == 0) \ I_Error("File "str" has been modified with non-music/sound lumps"); \ } @@ -1163,7 +1164,7 @@ void D_SRB2Main(void) { if (!W_VerifyNMUSlumps(s)) G_SetGameModified(true, false); - D_AddFile(s); + D_AddFile(s, startuppwads); } } } @@ -1220,7 +1221,7 @@ void D_SRB2Main(void) #else I_Error("A WAD file was not found or not valid.\nCheck the log to see which ones.\n"); #endif - D_CleanFile(); + D_CleanFile(startupwadfiles); mainwads = 0; @@ -1254,6 +1255,10 @@ void D_SRB2Main(void) mainwadstally = packetsizetally; + if (!W_InitMultipleFiles(startuppwads)) + CONS_Error("A PWAD file was not found or not valid.\nCheck the log to see which ones.\n"); + D_CleanFile(startuppwads); + cht_Init(); //---------------------------------------------------- READY SCREEN From f34ed24132bcf3cc3424b74065b9a8a68083d85e Mon Sep 17 00:00:00 2001 From: wolfy852 Date: Tue, 19 Feb 2019 22:20:18 -0600 Subject: [PATCH 2/6] Correct an oversight --- src/w_wad.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/w_wad.c b/src/w_wad.c index 29e1ba22..dc45d869 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -860,7 +860,8 @@ INT32 W_InitMultipleFiles(char **filenames) INT32 rc = 1; // open all the files, load headers, and count lumps - numwadfiles = 0; + if (!numwadfiles) + numwadfiles = 0; // will be realloced as lumps are added for (; *filenames; filenames++) From 84755ec171d25ae7688e412b12d34123fa407274 Mon Sep 17 00:00:00 2001 From: wolfy852 Date: Wed, 20 Feb 2019 19:04:18 -0600 Subject: [PATCH 3/6] Handle things in a more sensible way --- src/w_wad.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/w_wad.c b/src/w_wad.c index dc45d869..5ae67aa8 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -106,7 +106,7 @@ static UINT16 lumpnumcacheindex = 0; //=========================================================================== // GLOBALS //=========================================================================== -UINT16 numwadfiles; // number of active wadfiles +UINT16 numwadfiles = 0; // number of active wadfiles wadfile_t *wadfiles[MAX_WADFILES]; // 0 to numwadfiles-1 are valid // W_Shutdown @@ -859,10 +859,6 @@ INT32 W_InitMultipleFiles(char **filenames) { INT32 rc = 1; - // open all the files, load headers, and count lumps - if (!numwadfiles) - numwadfiles = 0; - // will be realloced as lumps are added for (; *filenames; filenames++) { From b955f4f66d7f5f1345d85dad22f70ffe8888eeb3 Mon Sep 17 00:00:00 2001 From: wolfy852 Date: Sun, 10 Mar 2019 18:55:55 -0500 Subject: [PATCH 4/6] Attempt to fix replaced maps not marking the game as modified What this ACTUALLY does is mark the game as modified by default. --- src/d_main.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 2 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 125c8f1e..c87c59f7 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1007,9 +1007,12 @@ static inline void D_MakeTitleString(char *s) // void D_SRB2Main(void) { - INT32 p; + INT32 p, i; char srb2[82]; // srb2 title banner char title[82]; + lumpinfo_t *lumpinfo; + UINT16 wadnum; + char *name; INT32 pstartmap = 1; boolean autostart = false; @@ -1235,7 +1238,7 @@ void D_SRB2Main(void) mainwads++; W_VerifyFileMD5(mainwads, ASSET_HASH_GFX_KART); // gfx.kart mainwads++; W_VerifyFileMD5(mainwads, ASSET_HASH_TEXTURES_KART); // textures.kart mainwads++; W_VerifyFileMD5(mainwads, ASSET_HASH_CHARS_KART); // chars.kart - mainwads++; W_VerifyFileMD5(mainwads, ASSET_HASH_MAPS_KART); // maps.kart + mainwads++; W_VerifyFileMD5(mainwads, ASSET_HASH_MAPS_KART); // maps.kart -- 4 - If you touch this, make sure to touch up the majormods stuff below. #ifdef USE_PATCH_KART mainwads++; W_VerifyFileMD5(mainwads, ASSET_HASH_PATCH_KART); // patch.kart #endif @@ -1255,10 +1258,69 @@ void D_SRB2Main(void) mainwadstally = packetsizetally; + // + // search for maps + // + for (wadnum = 4; wadnum < 6; wadnum++) // fucking arbitrary numbers + { + lumpinfo = wadfiles[wadnum]->lumpinfo; + for (i = 0; i < wadfiles[wadnum]->numlumps; i++, lumpinfo++) + { + name = lumpinfo->name; + + if (name[0] == 'M' && name[1] == 'A' && name[2] == 'P') // Ignore the headers + { + INT16 num; + if (name[5] != '\0') + continue; + num = (INT16)M_MapNumber(name[3], name[4]); + + // we want to record whether this map exists. if it doesn't have a header, we can assume it's not relephant + if (num <= NUMMAPS && mapheaderinfo[num - 1]) + { + mapheaderinfo[num - 1]->menuflags |= LF2_EXISTSHACK; + } + + CONS_Printf("%s\n", name); + //mapsadded = true; + } + } + } + if (!W_InitMultipleFiles(startuppwads)) CONS_Error("A PWAD file was not found or not valid.\nCheck the log to see which ones.\n"); D_CleanFile(startuppwads); + // + // search for maps... again. + // + for (wadnum = mainwads; wadnum < numwadfiles; wadnum++) + { + lumpinfo = wadfiles[wadnum]->lumpinfo; + for (i = 0; i < wadfiles[wadnum]->numlumps; i++, lumpinfo++) + { + name = lumpinfo->name; + + if (name[0] == 'M' && name[1] == 'A' && name[2] == 'P') // Ignore the headers + { + INT16 num; + if (name[5] != '\0') + continue; + num = (INT16)M_MapNumber(name[3], name[4]); + + // we want to record whether this map exists. if it doesn't have a header, we can assume it's not relephant + if (num <= NUMMAPS && mapheaderinfo[num - 1]) + { + if (mapheaderinfo[num - 1]->menuflags & LF2_EXISTSHACK) + G_SetGameModified(multiplayer, true); // oops, double-defined - no record attack privileges for you + mapheaderinfo[num - 1]->menuflags |= LF2_EXISTSHACK; + } + + CONS_Printf("%s\n", name); + } + } + } + cht_Init(); //---------------------------------------------------- READY SCREEN From fae8833ff4db9540092ba91a23a9444d04dbadac Mon Sep 17 00:00:00 2001 From: wolfy852 Date: Sun, 10 Mar 2019 19:27:45 -0500 Subject: [PATCH 5/6] Fix the game getting flagged as modified by default As a result, majormods trips for Lua and map replacements now, but modifiedgame isn't set for minor addons... --- src/d_main.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index c87c59f7..31320267 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1280,9 +1280,6 @@ void D_SRB2Main(void) { mapheaderinfo[num - 1]->menuflags |= LF2_EXISTSHACK; } - - CONS_Printf("%s\n", name); - //mapsadded = true; } } } @@ -1294,7 +1291,7 @@ void D_SRB2Main(void) // // search for maps... again. // - for (wadnum = mainwads; wadnum < numwadfiles; wadnum++) + for (wadnum = mainwads+1; wadnum < numwadfiles; wadnum++) { lumpinfo = wadfiles[wadnum]->lumpinfo; for (i = 0; i < wadfiles[wadnum]->numlumps; i++, lumpinfo++) From 66c9d9aa838b1b80dbceedc3b2b43c520112ad15 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sun, 10 Mar 2019 19:44:31 -0500 Subject: [PATCH 6/6] Move modified check on -file addons later in startup --- src/d_main.c | 8 ++------ src/w_wad.c | 5 ++++- src/w_wad.h | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 31320267..ba67eee9 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1164,11 +1164,7 @@ void D_SRB2Main(void) const char *s = M_GetNextParm(); if (s) // Check for NULL? - { - if (!W_VerifyNMUSlumps(s)) - G_SetGameModified(true, false); D_AddFile(s, startuppwads); - } } } } @@ -1218,7 +1214,7 @@ void D_SRB2Main(void) // load wad, including the main wad file CONS_Printf("W_InitMultipleFiles(): Adding IWAD and main PWADs.\n"); - if (!W_InitMultipleFiles(startupwadfiles)) + if (!W_InitMultipleFiles(startupwadfiles, false)) #ifdef _DEBUG CONS_Error("A WAD file was not found or not valid.\nCheck the log to see which ones.\n"); #else @@ -1284,7 +1280,7 @@ void D_SRB2Main(void) } } - if (!W_InitMultipleFiles(startuppwads)) + if (!W_InitMultipleFiles(startuppwads, true)) CONS_Error("A PWAD file was not found or not valid.\nCheck the log to see which ones.\n"); D_CleanFile(startuppwads); diff --git a/src/w_wad.c b/src/w_wad.c index 5ae67aa8..15e4177e 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -855,13 +855,16 @@ void W_UnloadWadFile(UINT16 num) * \return 1 if all files were loaded, 0 if at least one was missing or * invalid. */ -INT32 W_InitMultipleFiles(char **filenames) +INT32 W_InitMultipleFiles(char **filenames, boolean addons) { INT32 rc = 1; // will be realloced as lumps are added for (; *filenames; filenames++) { + if (addons && !W_VerifyNMUSlumps(*filenames)) + G_SetGameModified(true, false); + //CONS_Debug(DBG_SETUP, "Loading %s\n", *filenames); rc &= (W_InitFile(*filenames) != INT16_MAX) ? 1 : 0; } diff --git a/src/w_wad.h b/src/w_wad.h index e2e17740..762d3708 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -133,7 +133,7 @@ void W_UnloadWadFile(UINT16 num); // 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); +INT32 W_InitMultipleFiles(char **filenames, boolean addons); const char *W_CheckNameForNumPwad(UINT16 wad, UINT16 lump); const char *W_CheckNameForNum(lumpnum_t lumpnum);