diff --git a/src/d_netfil.c b/src/d_netfil.c index bf4e59878..a6233f3f1 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -59,6 +59,7 @@ #include "m_menu.h" #include "md5.h" #include "filesrch.h" +#include "d_clisrv.h" #include @@ -103,6 +104,7 @@ INT32 lastfilenum = -1; /** Fills a serverinfo packet with information about wad files loaded. * * \todo Give this function a better name since it is in global scope. + * Used to have size limiting built in - now handled via W_LoadWadFile in w_wad.c * */ UINT8 *PutFileNeeded(void) @@ -111,7 +113,6 @@ UINT8 *PutFileNeeded(void) UINT8 *p = netbuffer->u.serverinfo.fileneeded; char wadfilename[MAX_WADPATH] = ""; UINT8 filestatus; - size_t bytesused = 0; for (i = 0; i < numwadfiles; i++) { @@ -129,12 +130,6 @@ UINT8 *PutFileNeeded(void) else filestatus += (1 << 4); // Will send if requested - bytesused += (nameonlylength(wadfilename) + 22); - - // Don't write too far... - if (bytesused > sizeof(netbuffer->u.serverinfo.fileneeded)) - I_Error("Too many wad files added to host a game. (%s, stopped on %s)\n", sizeu1(bytesused), wadfilename); - WRITEUINT8(p, filestatus); count++; diff --git a/src/w_wad.c b/src/w_wad.c index f51b49d4d..32c2f3e6c 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -319,21 +319,24 @@ UINT16 W_LoadWadFile(const char *filename) // Check if wad files will overflow fileneededbuffer. Only the filename part // is send in the packet; cf. - packetsize = packetsizetally; - - packetsize += nameonlylength(filename); - packetsize += 22; - - if (packetsize > MAXFILENEEDED*sizeof(UINT8)) + // see PutFileNeeded in d_netfil.c + if (!W_VerifyNMUSlumps(filename)) { - CONS_Alert(CONS_ERROR, M_GetText("Maximum wad files reached\n")); - refreshdirmenu |= REFRESHDIR_MAX; - if (handle) - fclose(handle); - return INT16_MAX; - } + packetsize = packetsizetally; - packetsizetally = packetsize; + packetsize += nameonlylength(filename) + 22; + + if (packetsize > MAXFILENEEDED*sizeof(UINT8)) + { + CONS_Alert(CONS_ERROR, M_GetText("Maximum wad files reached\n")); + refreshdirmenu |= REFRESHDIR_MAX; + if (handle) + fclose(handle); + return INT16_MAX; + } + + packetsizetally = packetsize; + } // detect dehacked file with the "soc" extension if (!stricmp(&filename[strlen(filename) - 4], ".soc"))