From ac5ec75838bf575081a440025a45bc8023aae71c Mon Sep 17 00:00:00 2001 From: Roman Fomin Date: Wed, 27 Nov 2024 18:49:21 +0700 Subject: [PATCH] process TRAKINFO in IWADs, introduce process_wad_t flags (#2053) * add PROCESS_ALL --- src/d_main.c | 13 ++++++------- src/w_wad.c | 22 +++++++++++++++------- src/w_wad.h | 11 ++++++++++- 3 files changed, 31 insertions(+), 15 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 61761382..ca8abd4f 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -2260,7 +2260,7 @@ void D_DoomMain(void) if (!M_ParmExists("-nodeh")) { - W_ProcessInWads("DEHACKED", ProcessDehLump, true); + W_ProcessInWads("DEHACKED", ProcessDehLump, PROCESS_IWAD); } // process .deh files specified on the command line with -deh or -bex. @@ -2273,7 +2273,7 @@ void D_DoomMain(void) // killough 10/98: now process all deh in wads if (!M_ParmExists("-nodeh")) { - W_ProcessInWads("DEHACKED", ProcessDehLump, false); + W_ProcessInWads("DEHACKED", ProcessDehLump, PROCESS_PWAD); } // process .deh files from PWADs autoload directories @@ -2281,7 +2281,7 @@ void D_DoomMain(void) PostProcessDeh(); - W_ProcessInWads("BRGHTMPS", R_ParseBrightmaps, false); + W_ProcessInWads("BRGHTMPS", R_ParseBrightmaps, PROCESS_PWAD); // Moved after WAD initialization because we are checking the COMPLVL lump G_ReloadDefaults(false); // killough 3/4/98: set defaults just loaded. @@ -2310,7 +2310,7 @@ void D_DoomMain(void) I_Error("\nThis is not the registered version."); } - W_ProcessInWads("UMAPDEF", U_ParseMapDefInfo, false); + W_ProcessInWads("UMAPDEF", U_ParseMapDefInfo, PROCESS_PWAD); //! // @category mod @@ -2320,8 +2320,7 @@ void D_DoomMain(void) if (!M_ParmExists("-nomapinfo")) { - W_ProcessInWads("UMAPINFO", U_ParseMapInfo, true); - W_ProcessInWads("UMAPINFO", U_ParseMapInfo, false); + W_ProcessInWads("UMAPINFO", U_ParseMapInfo, PROCESS_IWAD | PROCESS_PWAD); } G_ParseCompDatabase(); @@ -2403,7 +2402,7 @@ void D_DoomMain(void) startloadgame = -1; } - W_ProcessInWads("TRAKINFO", S_ParseTrakInfo, false); + W_ProcessInWads("TRAKINFO", S_ParseTrakInfo, PROCESS_IWAD | PROCESS_PWAD); I_Printf(VB_INFO, "M_Init: Init miscellaneous info."); M_Init(); diff --git a/src/w_wad.c b/src/w_wad.c index 425e485e..d415289d 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -583,16 +583,24 @@ int W_LumpLengthWithName(int lump, char *name) // indicated by the third argument, instead of from a file. static void ProcessInWad(int i, const char *name, void (*process)(int lumpnum), - boolean iwad) + process_wad_t flag) { if (i >= 0) { - ProcessInWad(lumpinfo[i].next, name, process, iwad); + ProcessInWad(lumpinfo[i].next, name, process, flag); + + int condition = 0; + if (flag & PROCESS_IWAD) + { + condition |= lumpinfo[i].wad_file == wadfiles[0]; + } + if (flag & PROCESS_PWAD) + { + condition |= lumpinfo[i].wad_file != wadfiles[0]; + } if (!strncasecmp(lumpinfo[i].name, name, 8) - && lumpinfo[i].namespace == ns_global - && (iwad ? lumpinfo[i].wad_file == wadfiles[0] - : lumpinfo[i].wad_file != wadfiles[0])) + && lumpinfo[i].namespace == ns_global && condition) { process(i); } @@ -600,10 +608,10 @@ static void ProcessInWad(int i, const char *name, void (*process)(int lumpnum), } void W_ProcessInWads(const char *name, void (*process)(int lumpnum), - boolean iwad) + process_wad_t flags) { ProcessInWad(lumpinfo[W_LumpNameHash(name) % (unsigned)numlumps].index, - name, process, iwad); + name, process, flags); } void W_Close(void) diff --git a/src/w_wad.h b/src/w_wad.h index 2af4c1f9..3119d757 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -114,8 +114,17 @@ extern const char **wadfiles; boolean W_InitBaseFile(const char *path); void W_AddBaseDir(const char *path); boolean W_AddPath(const char *path); + +typedef enum +{ + PROCESS_PWAD = 0x01, + PROCESS_IWAD = 0x02, + PROCESS_ALL = 0x03 +} process_wad_t; + void W_ProcessInWads(const char *name, void (*process)(int lumpnum), - boolean iwad); + process_wad_t flags); + void W_InitMultipleFiles(void); // killough 4/17/98: if W_CheckNumForName() called with only