diff --git a/src/d_netcmd.c b/src/d_netcmd.c index d6fc5bdfa8616f8e41acf1aa435ce7b0d194fef1..f96b036ae192e365ac9f4177db071c0130b4fe90 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -3322,7 +3322,7 @@ static void Command_Addfile(void) break; ++p; - // check total packet size and no of files currently loaded + // check no of files currently loaded // See W_LoadWadFile in w_wad.c if (numwadfiles >= MAX_WADFILES) { @@ -3400,7 +3400,6 @@ static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum) return; } - // See W_LoadWadFile in w_wad.c if (numwadfiles >= MAX_WADFILES) toomany = true; else @@ -3483,7 +3482,13 @@ static void Command_ListWADS_f(void) { INT32 i = numwadfiles; char *tempname; - CONS_Printf(M_GetText("There are %d/%d wads loaded:\n"),numwadfiles,MAX_WADFILES); + +#ifdef ENFORCE_WAD_LIMIT + CONS_Printf(M_GetText("There are %d/%d files loaded:\n"),numwadfiles,MAX_WADFILES); +#else + CONS_Printf(M_GetText("There are %d files loaded:\n"),numwadfiles); +#endif + for (i--; i >= 0; i--) { nameonly(tempname = va("%s", wadfiles[i]->filename)); diff --git a/src/doomdef.h b/src/doomdef.h index 52abc95972cf4a2ed4b57c1dc939654d84f32906..11bf27ab0b5511fc337416499dbef7435241c6fd 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -151,6 +151,9 @@ extern char logfilename[1024]; // Comment or uncomment this as necessary. #define USE_PATCH_DTA +// Enforce a limit of loaded WAD files. +//#define ENFORCE_WAD_LIMIT + // Use .kart extension addons //#define USE_KART diff --git a/src/m_menu.c b/src/m_menu.c index b3c0f1c767f8c00b82496bba9de3b7c3ddab7aa5..148473378f789e3937e25675b173b450cc3ea274 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6307,6 +6307,7 @@ static void M_Addons(INT32 choice) M_SetupNextMenu(&MISC_AddonsDef); } +#ifdef ENFORCE_WAD_LIMIT #define width 4 #define vpadding 27 #define h (BASEVIDHEIGHT-(2*vpadding)) @@ -6354,6 +6355,7 @@ static void M_DrawTemperature(INT32 x, fixed_t t) #undef vpadding #undef h #undef NUMCOLOURS +#endif static char *M_AddonsHeaderPath(void) { @@ -6447,6 +6449,7 @@ static void M_DrawAddons(void) V_DrawCenteredString(BASEVIDWIDTH/2, 5, 0, LOCATIONSTRING1); // (recommendedflags == V_SKYMAP ? LOCATIONSTRING2 : LOCATIONSTRING1) +#ifdef ENFORCE_WAD_LIMIT if (numwadfiles <= mainwads+1) y = 0; else if (numwadfiles >= MAX_WADFILES) @@ -6459,6 +6462,7 @@ static void M_DrawAddons(void) } M_DrawTemperature(BASEVIDWIDTH - 19 - 5, y); +#endif // DRAW MENU x = currentMenu->x; diff --git a/src/w_wad.c b/src/w_wad.c index 14bdad9e3e13d3ede3734062eb0bd47fa6a07248..695b392cda63a7497d55026abf39bd87c3b8157e 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -734,9 +734,8 @@ UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup) refreshdirname = NULL; //CONS_Debug(DBG_SETUP, "Loading %s\n", filename); - // - // check if limit of active wadfiles - // + + // Check if the game reached the limit of active wadfiles. if (numwadfiles >= MAX_WADFILES) { CONS_Alert(CONS_ERROR, M_GetText("Maximum wad files reached\n")); @@ -900,7 +899,7 @@ void W_InitMultipleFiles(addfilelist_t *list) */ static boolean TestValidLump(UINT16 wad, UINT16 lump) { - I_Assert(wad < MAX_WADFILES); + I_Assert(wad < numwadfiles); if (!wadfiles[wad]) // make sure the wad file exists return false; diff --git a/src/w_wad.h b/src/w_wad.h index 88929c187e85e444db67a9b6bd040aef7df693f0..bd7809b8bfe56b525c7a2cfe663167b587e1ba9a 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -96,9 +96,15 @@ virtlump_t* vres_Find(const virtres_t*, const char*); // DYNAMIC WAD LOADING // ========================================================================= +// Maximum of files that can be loaded +// (there is a max of simultaneous open files anyway) +#ifdef ENFORCE_WAD_LIMIT +#define MAX_WADFILES 2048 // This cannot be any higher than UINT16_MAX. +#else +#define MAX_WADFILES UINT16_MAX +#endif + #define MAX_WADPATH 512 -#define MAX_WADFILES 2048 // Maximum of files that can be loaded -// (there is a max of simultaneous open files anyway, and this should be plenty) #define lumpcache_t void * @@ -127,7 +133,7 @@ typedef struct wadfile_s boolean important; // also network - !W_VerifyNMUSlumps } wadfile_t; -#define WADFILENUM(lumpnum) (UINT16)((lumpnum)>>16) // wad flumpnum>>16) // wad file number in upper word +#define WADFILENUM(lumpnum) (UINT16)((lumpnum)>>16) // wad file number in upper word #define LUMPNUM(lumpnum) (UINT16)((lumpnum)&0xFFFF) // lump number for this pwad extern UINT16 numwadfiles;