From bdcd9125d299cb59c0d3a49be5b2ce0da0f4195c Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Sun, 14 May 2017 14:47:09 +0100 Subject: [PATCH 1/8] Fixed that thing where missiles like sliding up slopes for some reason. This isn't a 1:1 fix for non-slopes - they still like stepping up over the borders of sloped sectors - but this fixes the most egregrious issue. --- src/p_mobj.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index fb864801..82640abc 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -2363,7 +2363,7 @@ static boolean P_ZMovement(mobj_t *mo) mo->z = mo->floorz; #ifdef ESLOPE - if (mo->standingslope) // You're still on the ground; why are we here? + if (!(mo->flags & MF_MISSILE) && mo->standingslope) // You're still on the ground; why are we here? { mo->momz = 0; return true; From 222807c6f62d73e60c33f1d229f8c7678273b562 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 15 May 2017 14:29:31 +0100 Subject: [PATCH 2/8] Fix R_InitExtraColormaps reporting 6 or more colormaps every time you loaded the game, even though we haven't used C_START/C_END in more than a decade now Note to self: W_ functions are awfully confusing with returning with LUMPERROR or INT16_MAX. Should sort out what's going on there if necessary --- src/r_data.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_data.c b/src/r_data.c index 7bad6bb8..4066ca64 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -944,12 +944,12 @@ static void R_InitExtraColormaps(void) for (cfile = clump = 0; cfile < numwadfiles; cfile++, clump = 0) { startnum = W_CheckNumForNamePwad("C_START", cfile, clump); - if (startnum == LUMPERROR) + if (startnum == INT16_MAX) continue; endnum = W_CheckNumForNamePwad("C_END", cfile, clump); - if (endnum == LUMPERROR) + if (endnum == INT16_MAX) I_Error("R_InitExtraColormaps: C_START without C_END\n"); if (WADFILENUM(startnum) != WADFILENUM(endnum)) From f8482421e5dd1666a61e4901b988a62829b1c2d7 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 15 May 2017 14:38:55 +0100 Subject: [PATCH 3/8] Don't need to use WADFILENUM/LUMPNUM in this function, since W_CheckNumForNamePwad returns just the lump number, not a combined WAD + lump number frankenstein's monster This is just in case someone actually tries to dump in C_START/C_END and "add" colormaps using them, not that they would ever be used currently anyway. --- src/r_data.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/r_data.c b/src/r_data.c index 4066ca64..d19882dd 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -952,15 +952,16 @@ static void R_InitExtraColormaps(void) if (endnum == INT16_MAX) I_Error("R_InitExtraColormaps: C_START without C_END\n"); - if (WADFILENUM(startnum) != WADFILENUM(endnum)) - I_Error("R_InitExtraColormaps: C_START and C_END in different wad files!\n"); + // This shouldn't be possible when you use the Pwad function, silly + //if (WADFILENUM(startnum) != WADFILENUM(endnum)) + //I_Error("R_InitExtraColormaps: C_START and C_END in different wad files!\n"); if (numcolormaplumps >= maxcolormaplumps) maxcolormaplumps *= 2; colormaplumps = Z_Realloc(colormaplumps, sizeof (*colormaplumps) * maxcolormaplumps, PU_STATIC, NULL); - colormaplumps[numcolormaplumps].wadfile = WADFILENUM(startnum); - colormaplumps[numcolormaplumps].firstlump = LUMPNUM(startnum+1); + colormaplumps[numcolormaplumps].wadfile = cfile; + colormaplumps[numcolormaplumps].firstlump = startnum+1; colormaplumps[numcolormaplumps].numlumps = endnum - (startnum + 1); numcolormaplumps++; } From 2aa1215716c28f06a5be7cc3aefc2e7626d22e2c Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Thu, 25 May 2017 15:22:32 +0100 Subject: [PATCH 4/8] Fix a thing where the host adds a WAD and you have too many WADs loaded to add it. --- src/d_netcmd.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 478772ed..0434e7e4 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -3180,10 +3180,15 @@ static void Got_Addfilecmd(UINT8 **cp, INT32 playernum) ncs = findfile(filename,md5sum,true); - if (ncs != FS_FOUND) + if (ncs != FS_FOUND || !P_AddWadFile(filename, NULL)) { Command_ExitGame_f(); - if (ncs == FS_NOTFOUND) + if (ncs == FS_FOUND) + { + CONS_Printf(M_GetText("The server tried to add %s,\nbut you have too many files added.\nRestart the game to clear loaded files\nand play on this server."), filename); + M_StartMessage(va("The server added a file \n(%s)\nbut you have too many files added.\nRestart the game to clear loaded files.\n\nPress ESC\n",filename), NULL, MM_NOTHING); + } + else if (ncs == FS_NOTFOUND) { CONS_Printf(M_GetText("The server tried to add %s,\nbut you don't have this file.\nYou need to find it in order\nto play on this server."), filename); M_StartMessage(va("The server added a file \n(%s)\nthat you do not have.\n\nPress ESC\n",filename), NULL, MM_NOTHING); @@ -3201,7 +3206,6 @@ static void Got_Addfilecmd(UINT8 **cp, INT32 playernum) return; } - P_AddWadFile(filename, NULL); G_SetGameModified(true); } From 5c302d7ffcdce40003016b2fc4cb81a35606c252 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Thu, 25 May 2017 15:34:21 +0100 Subject: [PATCH 5/8] Partial implementation of fix for Got_RequestAddfilecmd (the other half - the limitation on the size of the filesneeded section of the serverinfo packet - will be applied in internal.) --- src/d_netcmd.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 0434e7e4..f4916756 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -3078,6 +3078,7 @@ static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum) filestatus_t ncs = FS_NOTFOUND; UINT8 md5sum[16]; boolean kick = false; + boolean toomany = false; INT32 i; READSTRINGN(*cp, filename, 240); @@ -3104,13 +3105,18 @@ static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum) return; } - ncs = findfile(filename,md5sum,true); + if (numwadfiles >= MAX_WADFILES) // a more comprehensive check in internal; bare minimum of out-of-bounds for public next + toomany = true; + else + ncs = findfile(filename,md5sum,true); - if (ncs != FS_FOUND) + if (ncs != FS_FOUND || toomany) { char message[256]; - if (ncs == FS_NOTFOUND) + if (toomany) + sprintf(message, M_GetText("Too many files loaded to add %s\n"), filename); + else if (ncs == FS_NOTFOUND) sprintf(message, M_GetText("The server doesn't have %s\n"), filename); else if (ncs == FS_MD5SUMBAD) sprintf(message, M_GetText("Checksum mismatch on %s\n"), filename); From 47e171250f88c4d12f4b594213e159d01d592d1b Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Thu, 25 May 2017 16:06:39 +0100 Subject: [PATCH 6/8] * Prevent joining a server if you have too many files loaded to add the remainder. * Made the check in Got_RequestAddfilecmd more comprehensive, since I might as well. Just something to tweak a little later in internal. --- src/d_clisrv.c | 17 ++++++++++++++--- src/d_netcmd.c | 14 +++++++++++++- src/d_netfil.c | 15 +++++++++++++++ 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 939d53de..76b5c95d 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1733,9 +1733,7 @@ static boolean CL_ServerConnectionSearchTicker(boolean viams, tic_t *asksent) { #ifndef NONET INT32 i; -#endif -#ifndef NONET // serverlist is updated by GetPacket function if (serverlistcount > 0) { @@ -1769,7 +1767,20 @@ static boolean CL_ServerConnectionSearchTicker(boolean viams, tic_t *asksent) serverlist[i].info.fileneeded); CONS_Printf(M_GetText("Checking files...\n")); i = CL_CheckFiles(); - if (i == 2) // cannot join for some reason + if (i == 3) // too many files + { + D_QuitNetGame(); + CL_Reset(); + D_StartTitle(); + M_StartMessage(M_GetText( + "You have too many WAD files loaded\n" + "to add ones the server is using.\n" + "Please restart SRB2 before connecting.\n\n" + "Press ESC\n" + ), NULL, MM_NOTHING); + return false; + } + else if (i == 2) // cannot join for some reason { D_QuitNetGame(); CL_Reset(); diff --git a/src/d_netcmd.c b/src/d_netcmd.c index f4916756..d7bbb0aa 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -3080,6 +3080,11 @@ static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum) boolean kick = false; boolean toomany = false; INT32 i; + size_t packetsize = 0; + serverinfo_pak *dummycheck = NULL; + + // Shut the compiler up. + (void)dummycheck; READSTRINGN(*cp, filename, 240); READMEM(*cp, md5sum, 16); @@ -3105,7 +3110,14 @@ static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum) return; } - if (numwadfiles >= MAX_WADFILES) // a more comprehensive check in internal; bare minimum of out-of-bounds for public next + // See W_LoadWadFile in w_wad.c + for (i = 0; i < numwadfiles; i++) + packetsize += nameonlylength(wadfiles[i]->filename) + 22; + + packetsize += nameonlylength(filename) + 22; + + if ((numwadfiles >= MAX_WADFILES) + || (packetsize > sizeof(dummycheck->fileneeded))) toomany = true; else ncs = findfile(filename,md5sum,true); diff --git a/src/d_netfil.c b/src/d_netfil.c index bf4e5987..479fd60d 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -330,6 +330,11 @@ INT32 CL_CheckFiles(void) INT32 i, j; char wadfilename[MAX_WADPATH]; INT32 ret = 1; + size_t packetsize = 0; + serverinfo_pak *dummycheck = NULL; + + // Shut the compiler up. + (void)dummycheck; // if (M_CheckParm("-nofiles")) // return 1; @@ -378,6 +383,10 @@ INT32 CL_CheckFiles(void) return 1; } + // See W_LoadWadFile in w_wad.c + for (i = 0; i < numwadfiles; i++) + packetsize += nameonlylength(wadfiles[i]->filename) + 22; + for (i = 1; i < fileneedednum; i++) { CONS_Debug(DBG_NETPLAY, "searching for '%s' ", fileneeded[i].filename); @@ -397,6 +406,12 @@ INT32 CL_CheckFiles(void) if (fileneeded[i].status != FS_NOTFOUND || !fileneeded[i].important) continue; + packetsize += nameonlylength(fileneeded[i].filename) + 22; + + if ((numwadfiles >= MAX_WADFILES) + || (packetsize > sizeof(dummycheck->fileneeded))) + return 3; + fileneeded[i].status = findfile(fileneeded[i].filename, fileneeded[i].md5sum, true); CONS_Debug(DBG_NETPLAY, "found %d\n", fileneeded[i].status); if (fileneeded[i].status != FS_FOUND) From 437780d503e8cac007d9dcc7a30c410bb08a7365 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 25 May 2017 18:40:48 +0100 Subject: [PATCH 7/8] Add missing break for MT_EGGCAPSULE's switch case in P_SpawnMobj (sorry!) --- src/p_mobj.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/p_mobj.c b/src/p_mobj.c index fb864801..47886ce8 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -7807,6 +7807,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) break; case MT_EGGCAPSULE: mobj->extravalue1 = -1; // timer for how long a player has been at the capsule + break; case MT_REDTEAMRING: mobj->color = skincolor_redteam; break; From db2f8a50bac82d604cf25fcadbb46a439f72256f Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Fri, 26 May 2017 16:16:10 +0100 Subject: [PATCH 8/8] Make sure that the number of files you're trying to add is properly considered! --- src/d_netfil.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/d_netfil.c b/src/d_netfil.c index 479fd60d..70e9ce56 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -331,6 +331,7 @@ INT32 CL_CheckFiles(void) char wadfilename[MAX_WADPATH]; INT32 ret = 1; size_t packetsize = 0; + size_t filestoget = 0; serverinfo_pak *dummycheck = NULL; // Shut the compiler up. @@ -408,10 +409,12 @@ INT32 CL_CheckFiles(void) packetsize += nameonlylength(fileneeded[i].filename) + 22; - if ((numwadfiles >= MAX_WADFILES) + if ((numwadfiles+filestoget >= MAX_WADFILES) || (packetsize > sizeof(dummycheck->fileneeded))) return 3; + filestoget++; + fileneeded[i].status = findfile(fileneeded[i].filename, fileneeded[i].md5sum, true); CONS_Debug(DBG_NETPLAY, "found %d\n", fileneeded[i].status); if (fileneeded[i].status != FS_FOUND)