* Make wads that don't modify the game not count towards the internal packet size tally in w_wad.c, like they wouldn't in d_netfil.c.

* Now that it's consistent, removed the redundant packet size tally check in d_netfil.c.
This commit is contained in:
toasterbabe 2017-05-24 21:45:03 +01:00
parent 74c4ad4bad
commit c2705b4662
2 changed files with 18 additions and 20 deletions

View File

@ -59,6 +59,7 @@
#include "m_menu.h"
#include "md5.h"
#include "filesrch.h"
#include "d_clisrv.h"
#include <errno.h>
@ -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++;

View File

@ -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"))