From d2d88a919b9aa29a16d11b125febe0c0de199a35 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Thu, 26 Jan 2017 12:47:47 +0000 Subject: [PATCH 01/52] * Allowing for changing skins on command line startup again. * Fixing an inconsistency with being able to change skin colours when you shouldn't be able to, much like the previous skin change issue that was fixed. --- src/d_netcmd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index f61c80cb..8f6c45b3 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -4102,7 +4102,8 @@ static void Skin_OnChange(void) if (!Playing()) return; // do whatever you want - if (!(cv_debug || devparm) && !(multiplayer || netgame)) // In single player. + if (!(cv_debug || devparm) && !(multiplayer || netgame) // In single player. + && (gamestate != GS_WAITINGPLAYERS)) // allows command line -warp x +skin y { CV_StealthSet(&cv_skin, skins[players[consoleplayer].skin].name); return; @@ -4145,8 +4146,7 @@ static void Color_OnChange(void) if (!Playing()) return; // do whatever you want - if (!(cv_debug || devparm) && !(multiplayer || netgame) // In single player. - && (gamestate == GS_LEVEL || gamestate == GS_INTERMISSION || gamestate == GS_CONTINUING)) + if (!(cv_debug || devparm) && !(multiplayer || netgame)) // In single player. { CV_StealthSet(&cv_skin, skins[players[consoleplayer].skin].name); return; From 659a62db887fb323fb5111330327e47b959a9e47 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 3 Feb 2017 18:47:20 +0000 Subject: [PATCH 02/52] Make sure rocks spawned by the rock spawners despawn when they're on the floor and not moving --- src/p_mobj.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/p_mobj.c b/src/p_mobj.c index b9412ee7..5d4defb4 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -6648,6 +6648,17 @@ void P_MobjThinker(mobj_t *mobj) } else switch (mobj->type) { + case MT_FALLINGROCK: + // Despawn rocks here in case zmovement code can't do so (blame slopes) + if (!mobj->momx && !mobj->momy && !mobj->momz + && ((mobj->z <= mobj->floorz && !(mobj->eflags & MFE_VERTICALFLIP)) + || (mobj->z + mobj->height >= mobj->ceilingz && mobj->eflags & MFE_VERTICALFLIP))) + { + P_RemoveMobj(mobj); + return; + } + P_MobjCheckWater(mobj); + break; case MT_EMERALDSPAWN: if (mobj->threshold) { From 9a2b7b2091a462e4eeed1ad7f957738e628ff4b2 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 3 Feb 2017 20:13:16 +0000 Subject: [PATCH 03/52] Better plan, use ?: for deciding between floorz/ceiling checks based on gravity --- src/p_mobj.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 5d4defb4..fb864801 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -6651,8 +6651,9 @@ void P_MobjThinker(mobj_t *mobj) case MT_FALLINGROCK: // Despawn rocks here in case zmovement code can't do so (blame slopes) if (!mobj->momx && !mobj->momy && !mobj->momz - && ((mobj->z <= mobj->floorz && !(mobj->eflags & MFE_VERTICALFLIP)) - || (mobj->z + mobj->height >= mobj->ceilingz && mobj->eflags & MFE_VERTICALFLIP))) + && ((mobj->eflags & MFE_VERTICALFLIP) ? + mobj->z + mobj->height >= mobj->ceilingz + : mobj->z <= mobj->floorz)) { P_RemoveMobj(mobj); return; From f9b41898a9730f755ce29edf5843d4366a11b0f4 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 5 Feb 2017 22:04:29 +0000 Subject: [PATCH 04/52] Don't allow skipping stats in record attack/nights attack --- src/g_game.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index 84db9013..7499fe7a 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2888,7 +2888,7 @@ static void G_DoCompleted(void) if (nextmap < NUMMAPS && !mapheaderinfo[nextmap]) P_AllocMapHeader(nextmap); - if (skipstats) + if (skipstats && !modeattacking) // Don't skip stats if we're in record attack G_AfterIntermission(); else { From 8a421a05d9e9365d5bbfac54459794a497a2c4d5 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 10 Feb 2017 20:31:58 +0000 Subject: [PATCH 05/52] admin bans with custom ban messages should now be recognised by the server properly --- src/d_clisrv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index f47f6637..1b23ce95 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2696,7 +2696,7 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum) // If a verified admin banned someone, the server needs to know about it. // If the playernum isn't zero (the server) then the server needs to record the ban. - if (server && playernum && msg == KICK_MSG_BANNED) + if (server && playernum && (msg == KICK_MSG_BANNED || msg == KICK_MSG_CUSTOM_BAN)) { if (I_Ban && !I_Ban(playernode[(INT32)pnum])) { From 84727f42058ee95126878fffe442b1a211df8ac5 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 16 Feb 2017 21:55:17 +0000 Subject: [PATCH 06/52] Created W_OpenWadFile for opening WAD files with the path correction code. This is used by Command_Addfile in the MD5 calculation code, so that it can search subfolders properly and allow addfile in netgames to treat them the same way as in SP --- src/d_netcmd.c | 16 ++++----- src/w_wad.c | 88 +++++++++++++++++++++++++++----------------------- src/w_wad.h | 2 ++ 3 files changed, 56 insertions(+), 50 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index f61c80cb..09f6795e 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2967,6 +2967,7 @@ static void Command_Addfile(void) XBOXSTATIC char buf[256]; char *buf_p = buf; INT32 i; + int musiconly; // W_VerifyNMUSlumps isn't boolean if (COM_Argc() != 2) { @@ -2981,7 +2982,9 @@ static void Command_Addfile(void) if (!isprint(fn[i]) || fn[i] == ';') return; - if (!W_VerifyNMUSlumps(fn)) + musiconly = W_VerifyNMUSlumps(fn); + + if (!musiconly) { // ... But only so long as they contain nothing more then music and sprites. if (netgame && !(server || adminplayer == consoleplayer)) @@ -2993,7 +2996,7 @@ static void Command_Addfile(void) } // Add file on your client directly if it is trivial, or you aren't in a netgame. - if (!(netgame || multiplayer) || W_VerifyNMUSlumps(fn)) + if (!(netgame || multiplayer) || musiconly) { P_AddWadFile(fn, NULL); return; @@ -3013,9 +3016,7 @@ static void Command_Addfile(void) #else FILE *fhandle; - fhandle = fopen(fn, "rb"); - - if (fhandle) + if ((fhandle = W_OpenWadFile(&fn, true)) != NULL) { tic_t t = I_GetTime(); CONS_Debug(DBG_SETUP, "Making MD5 for %s\n",fn); @@ -3023,11 +3024,8 @@ static void Command_Addfile(void) CONS_Debug(DBG_SETUP, "MD5 calc for %s took %f second\n", fn, (float)(I_GetTime() - t)/TICRATE); fclose(fhandle); } - else - { - CONS_Printf(M_GetText("File %s not found.\n"), fn); + else // file not found return; - } #endif WRITEMEM(buf_p, md5sum, 16); } diff --git a/src/w_wad.c b/src/w_wad.c index e4cb9305..3a828559 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -133,6 +133,47 @@ void W_Shutdown(void) static char filenamebuf[MAX_WADPATH]; +// W_OpenWadFile +// Helper function for opening the WAD file. +// Returns the FILE * handle for the file, or NULL if not found or could not be opened +// If "useerrors" is true then print errors in the console, else just don't bother +// "filename" may be modified to have the correct path the actual file is located in, if necessary +FILE *W_OpenWadFile(const char **filename, boolean useerrors) +{ + FILE *handle; + + strncpy(filenamebuf, *filename, MAX_WADPATH); + filenamebuf[MAX_WADPATH - 1] = '\0'; + *filename = filenamebuf; + + // open wad file + if ((handle = fopen(*filename, "rb")) == NULL) + { + // If we failed to load the file with the path as specified by + // the user, strip the directories and search for the file. + nameonly(filenamebuf); + + // If findfile finds the file, the full path will be returned + // in filenamebuf == *filename. + if (findfile(filenamebuf, NULL, true)) + { + if ((handle = fopen(*filename, "rb")) == NULL) + { + if (useerrors) + CONS_Alert(CONS_ERROR, M_GetText("Can't open %s\n"), *filename); + return NULL; + } + } + else + { + if (useerrors) + CONS_Alert(CONS_ERROR, M_GetText("File %s not found.\n"), *filename); + return NULL; + } + } + return handle; +} + // search for all DEHACKED lump in all wads and load it static inline void W_LoadDehackedLumps(UINT16 wadnum) { @@ -234,7 +275,6 @@ static void W_InvalidateLumpnumCache(void) memset(lumpnumcache, 0, sizeof (lumpnumcache)); } - // Allocate a wadfile, setup the lumpinfo (directory) and // lumpcache, add the wadfile to the current active wadfiles // @@ -271,33 +311,9 @@ UINT16 W_LoadWadFile(const char *filename) return INT16_MAX; } - strncpy(filenamebuf, filename, MAX_WADPATH); - filenamebuf[MAX_WADPATH - 1] = '\0'; - filename = filenamebuf; - // open wad file - if ((handle = fopen(filename, "rb")) == NULL) - { - // If we failed to load the file with the path as specified by - // the user, strip the directories and search for the file. - nameonly(filenamebuf); - - // If findfile finds the file, the full path will be returned - // in filenamebuf == filename. - if (findfile(filenamebuf, NULL, true)) - { - if ((handle = fopen(filename, "rb")) == NULL) - { - CONS_Alert(CONS_ERROR, M_GetText("Can't open %s\n"), filename); - return INT16_MAX; - } - } - else - { - CONS_Alert(CONS_ERROR, M_GetText("File %s not found.\n"), filename); - return INT16_MAX; - } - } + if ((handle = W_OpenWadFile(&filename, true)) == NULL) + return INT16_MAX; // Check if wad files will overflow fileneededbuffer. Only the filename part // is send in the packet; cf. @@ -1115,21 +1131,11 @@ static int W_VerifyFile(const char *filename, lumpchecklist_t *checklist, size_t i, j; int goodfile = false; - if (!checklist) I_Error("No checklist for %s\n", filename); - strlcpy(filenamebuf, filename, MAX_WADPATH); - filename = filenamebuf; + if (!checklist) + I_Error("No checklist for %s\n", filename); // open wad file - if ((handle = fopen(filename, "rb")) == NULL) - { - nameonly(filenamebuf); // leave full path here - if (findfile(filenamebuf, NULL, true)) - { - if ((handle = fopen(filename, "rb")) == NULL) - return -1; - } - else - return -1; - } + if ((handle = W_OpenWadFile(&filename, false)) == NULL) + return -1; // detect dehacked file with the "soc" extension if (stricmp(&filename[strlen(filename) - 4], ".soc") != 0 diff --git a/src/w_wad.h b/src/w_wad.h index b03e376b..f7ea64a5 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -82,6 +82,8 @@ extern wadfile_t *wadfiles[MAX_WADFILES]; void W_Shutdown(void); +// Opens a WAD file. Returns the FILE * handle for the file, or NULL if not found or could not be opened +FILE *W_OpenWadFile(const char **filename, boolean useerrors); // Load and add a wadfile to the active wad files, returns numbers of lumps, INT16_MAX on error UINT16 W_LoadWadFile(const char *filename); #ifdef DELFILE From 7424df8180e4f7e69a79200e244bea7c902eaf92 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 20 Feb 2017 19:58:29 +0000 Subject: [PATCH 07/52] Make sure I_Ban and Ban_Add are only used by the server Also make sure the server actually uses Ban_Add if an admin banned someone --- src/d_clisrv.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 1b23ce95..41c3ac34 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2531,7 +2531,7 @@ static void Command_Ban(void) return; else WRITEUINT8(p, pn); - if (I_Ban && !I_Ban(node)) + if (server && I_Ban && !I_Ban(node)) // only the server is allowed to do this right now { CONS_Alert(CONS_WARNING, M_GetText("Too many bans! Geez, that's a lot of people you're excluding...\n")); WRITEUINT8(p, KICK_MSG_GO_AWAY); @@ -2539,7 +2539,8 @@ static void Command_Ban(void) } else { - Ban_Add(COM_Argv(2)); + if (server) // only the server is allowed to do this right now + Ban_Add(COM_Argv(2)); if (COM_Argc() == 2) { @@ -2699,9 +2700,9 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum) if (server && playernum && (msg == KICK_MSG_BANNED || msg == KICK_MSG_CUSTOM_BAN)) { if (I_Ban && !I_Ban(playernode[(INT32)pnum])) - { CONS_Alert(CONS_WARNING, M_GetText("Too many bans! Geez, that's a lot of people you're excluding...\n")); - } + else + Ban_Add(reason); } switch (msg) From 6efb15c6e8a9c48e2f0c739ecf166bf43558943a Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 20 Feb 2017 21:36:05 +0000 Subject: [PATCH 08/52] Fix Ban_Add usage for NONET --- src/d_clisrv.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 41c3ac34..939d53de 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2701,8 +2701,10 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum) { if (I_Ban && !I_Ban(playernode[(INT32)pnum])) CONS_Alert(CONS_WARNING, M_GetText("Too many bans! Geez, that's a lot of people you're excluding...\n")); +#ifndef NONET else Ban_Add(reason); +#endif } switch (msg) From b837d5b23d51b1674738106112e91dedbe9f6324 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 2 Mar 2017 14:25:46 +0000 Subject: [PATCH 09/52] Fix teamchange/teamchange2 to block changing FROM spectator rather than changing TO spectator This way they're consistent with Got_Teamchange, which is the cause of the "illegal team change" desyncs --- src/d_netcmd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index f61c80cb..2afadcc2 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2116,7 +2116,7 @@ static void Command_Teamchange_f(void) return; } - if (!cv_allowteamchange.value && !NetPacket.packet.newteam) // allow swapping to spectator even in locked teams. + if (!cv_allowteamchange.value && NetPacket.packet.newteam) // allow swapping to spectator even in locked teams. { CONS_Alert(CONS_NOTICE, M_GetText("The server is not allowing team changes at the moment.\n")); return; @@ -2213,7 +2213,7 @@ static void Command_Teamchange2_f(void) return; } - if (!cv_allowteamchange.value && !NetPacket.packet.newteam) // allow swapping to spectator even in locked teams. + if (!cv_allowteamchange.value && NetPacket.packet.newteam) // allow swapping to spectator even in locked teams. { CONS_Alert(CONS_NOTICE, M_GetText("The server is not allowing team changes at the moment.\n")); return; From c43b41815fede02f64420aac4f65f11c98e170e5 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 2 Mar 2017 14:28:52 +0000 Subject: [PATCH 10/52] Make "Enter Game" option use the big blue window notice if you cannot switch teams, instead of falling back on changeteam's own console notice --- src/m_menu.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/m_menu.c b/src/m_menu.c index d7b4d908..45b3d7e5 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -3849,6 +3849,7 @@ static void M_ChangeLevel(INT32 choice) static void M_ConfirmSpectate(INT32 choice) { (void)choice; + // We allow switching to spectator even if team changing is not allowed M_ClearMenus(true); COM_ImmedExecute("changeteam spectator"); } @@ -3856,6 +3857,11 @@ static void M_ConfirmSpectate(INT32 choice) static void M_ConfirmEnterGame(INT32 choice) { (void)choice; + if (!cv_allowteamchange.value) + { + M_StartMessage(M_GetText("The server is not allowing\nteam changes at this time.\nPress a key.\n"), NULL, MM_NOTHING); + return; + } M_ClearMenus(true); COM_ImmedExecute("changeteam playing"); } From 48777e60ed8a13aaa397279b683979f9dd462a1f Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Wed, 29 Mar 2017 21:27:44 +0100 Subject: [PATCH 11/52] check i not add, silly --- src/m_misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_misc.c b/src/m_misc.c index cfe73d88..d88643ec 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -585,7 +585,7 @@ static const char *Newsnapshotfile(const char *pathname, const char *ext) i += add * result; - if (add < 0 || add > 9999) + if (i < 0 || i > 9999) return NULL; } From bf29b5c6d188dfe25e0d6c5b614b254d1502ca5b Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 1 Apr 2017 20:16:48 +0100 Subject: [PATCH 12/52] Print warning message in console if line->next is NULL --- src/p_spec.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index 3d83561a..a699cbc2 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3039,7 +3039,10 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) case 443: // Calls a named Lua function #ifdef HAVE_BLUA - LUAh_LinedefExecute(line, mo, callsec); + if (line->text) + LUAh_LinedefExecute(line, mo, callsec); + else + CONS_Alert(CONS_WARNING, "Linedef %d is missing the hook name of the Lua function to call! (This should be given in the front texture fields)\n", line-lines); #else CONS_Alert(CONS_ERROR, "The map is trying to run a Lua script, but this exe was not compiled with Lua support!\n"); #endif From 4fa188cf01c6c9aceed293237d5532b6abe641d3 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Sat, 1 Apr 2017 17:22:24 -0400 Subject: [PATCH 13/52] build: fix 64-bit builds --- src/p_spec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index a699cbc2..48c0f58b 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3042,7 +3042,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) if (line->text) LUAh_LinedefExecute(line, mo, callsec); else - CONS_Alert(CONS_WARNING, "Linedef %d is missing the hook name of the Lua function to call! (This should be given in the front texture fields)\n", line-lines); + CONS_Alert(CONS_WARNING, "Linedef %s is missing the hook name of the Lua function to call! (This should be given in the front texture fields)\n", sizeu1(line-lines)); #else CONS_Alert(CONS_ERROR, "The map is trying to run a Lua script, but this exe was not compiled with Lua support!\n"); #endif From 5e4f960f3aa7ce9b095ad953a02720adbd800bb7 Mon Sep 17 00:00:00 2001 From: Inuyasha Date: Wed, 12 Apr 2017 15:34:13 -0700 Subject: [PATCH 14/52] fixed drawfill to be more consistent w/ other functions doesn't draw off of the sides, and doesn't ignore snapping or widths for reasons that don't make sense (for instance: the green bar in MI's test script showed *above* the blue one in non-green resolutions in 2.1.17) --- src/v_video.c | 103 +++++++++++++++++++++++++------------------------- 1 file changed, 52 insertions(+), 51 deletions(-) diff --git a/src/v_video.c b/src/v_video.c index 1fb10fb5..eafd5c84 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -758,79 +758,80 @@ void V_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c) { UINT8 *dest; const UINT8 *deststop; - INT32 u, v, dupx, dupy; + + if (rendermode == render_none) + return; #ifdef HWRENDER - if (rendermode != render_soft && rendermode != render_none) + if (rendermode != render_soft && !con_startup) { HWR_DrawFill(x, y, w, h, c); return; } #endif - dupx = vid.dupx; - dupy = vid.dupy; - - if (!screens[0]) - return; - - if (c & V_NOSCALESTART) - { - dest = screens[0] + y*vid.width + x; - deststop = screens[0] + vid.rowbytes * vid.height; - } - else + if (!(c & V_NOSCALESTART)) { + INT32 dupx = vid.dupx, dupy = vid.dupy; + if (x == 0 && y == 0 && w == BASEVIDWIDTH && h == BASEVIDHEIGHT) { // Clear the entire screen, from dest to deststop. Yes, this really works. memset(screens[0], (UINT8)(c&255), vid.width * vid.height * vid.bpp); return; } - dest = screens[0] + y*dupy*vid.width + x*dupx; - deststop = screens[0] + vid.rowbytes * vid.height; + x *= dupx; + y *= dupy; + w *= dupx; + h *= dupy; - if (w == BASEVIDWIDTH) - w = vid.width; - else - w *= dupx; - if (h == BASEVIDHEIGHT) - h = vid.height; - else - h *= dupy; - - if (x && y && x + w < vid.width && y + h < vid.height) + // Center it if necessary + if (vid.width != BASEVIDWIDTH * dupx) { - // Center it if necessary - if (vid.width != BASEVIDWIDTH * dupx) - { - // dupx adjustments pretend that screen width is BASEVIDWIDTH * dupx, - // so center this imaginary screen - if (c & V_SNAPTORIGHT) - dest += (vid.width - (BASEVIDWIDTH * dupx)); - else if (!(c & V_SNAPTOLEFT)) - dest += (vid.width - (BASEVIDWIDTH * dupx)) / 2; - } - if (vid.height != BASEVIDHEIGHT * dupy) - { - // same thing here - if (c & V_SNAPTOBOTTOM) - dest += (vid.height - (BASEVIDHEIGHT * dupy)) * vid.width; - else if (!(c & V_SNAPTOTOP)) - dest += (vid.height - (BASEVIDHEIGHT * dupy)) * vid.width / 2; - } + // dupx adjustments pretend that screen width is BASEVIDWIDTH * dupx, + // so center this imaginary screen + if (c & V_SNAPTORIGHT) + x += (vid.width - (BASEVIDWIDTH * dupx)); + else if (!(c & V_SNAPTOLEFT)) + x += (vid.width - (BASEVIDWIDTH * dupx)) / 2; + } + if (vid.height != BASEVIDHEIGHT * dupy) + { + // same thing here + if (c & V_SNAPTOBOTTOM) + y += (vid.height - (BASEVIDHEIGHT * dupy)); + else if (!(c & V_SNAPTOTOP)) + y += (vid.height - (BASEVIDHEIGHT * dupy)) / 2; } } + if (x >= vid.width || y >= vid.height) + return; // off the screen + if (x < 0) + { + w += x; + x = 0; + } + if (y < 0) + { + h += y; + y = 0; + } + + if (w <= 0 || h <= 0) + return; // zero width/height wouldn't draw anything + if (x + w > vid.width) + w = vid.width - x; + if (y + h > vid.height) + h = vid.height - y; + + dest = screens[0] + y*vid.width + x; + deststop = screens[0] + vid.rowbytes * vid.height; + c &= 255; - for (v = 0; v < h; v++, dest += vid.width) - for (u = 0; u < w; u++) - { - if (dest > deststop) - return; - dest[u] = (UINT8)c; - } + for (;(--h >= 0) && dest <= deststop; dest += vid.width) + memset(dest, (UINT8)(c&255), w * vid.bpp); } // From 7f7c7c58ab0f365d9923c1929ae5d1e3e8aced9d Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 24 Apr 2017 17:41:50 +0100 Subject: [PATCH 15/52] Use less-than, not less-than-or-equals, since deststop is off-screen --- src/v_video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/v_video.c b/src/v_video.c index eafd5c84..64bb3214 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -830,7 +830,7 @@ void V_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c) c &= 255; - for (;(--h >= 0) && dest <= deststop; dest += vid.width) + for (;(--h >= 0) && dest < deststop; dest += vid.width) memset(dest, (UINT8)(c&255), w * vid.bpp); } From 19ca1698d8ac9cd1503d5d735ccdd22f155d2265 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 30 Apr 2017 20:33:36 +0100 Subject: [PATCH 16/52] Combine all /objs/*/.gitignore files into /objs/.gitignore, make sure depend.ped is also ignored --- objs/.gitignore | 8 ++++++++ objs/DC/SDL/Debug/.gitignore | 1 - objs/DC/SDL/Release/.gitignore | 1 - objs/Linux/SDL/Debug/.gitignore | 2 -- objs/Linux/SDL/Release/.gitignore | 2 -- objs/Linux64/SDL/Debug/.gitignore | 2 -- objs/Linux64/SDL/Release/.gitignore | 2 -- objs/Mingw/Debug/.gitignore | 3 --- objs/Mingw/Release/.gitignore | 3 --- objs/Mingw/SDL/Debug/.gitignore | 3 --- objs/Mingw/SDL/Release/.gitignore | 3 --- objs/Mingw64/Debug/.gitignore | 3 --- objs/Mingw64/Release/.gitignore | 3 --- objs/Mingw64/SDL/Debug/.gitignore | 3 --- objs/Mingw64/SDL/Release/.gitignore | 3 --- objs/PS3/SDL/Debug/.gitignore | 2 -- objs/PS3/SDL/Release/.gitignore | 2 -- objs/PSP/SDL/Release/.gitignore | 1 - objs/SDL/Release/.gitignore | 1 - objs/VC/.gitignore | 0 objs/VC9/.gitignore | 2 -- objs/Wii/SDL/Debug/.gitignore | 2 -- objs/Wii/SDL/Release/.gitignore | 2 -- objs/WinCE/SDL/Release/.gitignore | 1 - objs/djgppdos/Debug/.gitignore | 1 - objs/djgppdos/Release/.gitignore | 1 - objs/nds/Debug/.gitignore | 2 -- objs/nds/Release/.gitignore | 2 -- 28 files changed, 8 insertions(+), 53 deletions(-) create mode 100644 objs/.gitignore delete mode 100644 objs/DC/SDL/Debug/.gitignore delete mode 100644 objs/DC/SDL/Release/.gitignore delete mode 100644 objs/Linux/SDL/Debug/.gitignore delete mode 100644 objs/Linux/SDL/Release/.gitignore delete mode 100644 objs/Linux64/SDL/Debug/.gitignore delete mode 100644 objs/Linux64/SDL/Release/.gitignore delete mode 100644 objs/Mingw/Debug/.gitignore delete mode 100644 objs/Mingw/Release/.gitignore delete mode 100644 objs/Mingw/SDL/Debug/.gitignore delete mode 100644 objs/Mingw/SDL/Release/.gitignore delete mode 100644 objs/Mingw64/Debug/.gitignore delete mode 100644 objs/Mingw64/Release/.gitignore delete mode 100644 objs/Mingw64/SDL/Debug/.gitignore delete mode 100644 objs/Mingw64/SDL/Release/.gitignore delete mode 100644 objs/PS3/SDL/Debug/.gitignore delete mode 100644 objs/PS3/SDL/Release/.gitignore delete mode 100644 objs/PSP/SDL/Release/.gitignore delete mode 100644 objs/SDL/Release/.gitignore delete mode 100644 objs/VC/.gitignore delete mode 100644 objs/VC9/.gitignore delete mode 100644 objs/Wii/SDL/Debug/.gitignore delete mode 100644 objs/Wii/SDL/Release/.gitignore delete mode 100644 objs/WinCE/SDL/Release/.gitignore delete mode 100644 objs/djgppdos/Debug/.gitignore delete mode 100644 objs/djgppdos/Release/.gitignore delete mode 100644 objs/nds/Debug/.gitignore delete mode 100644 objs/nds/Release/.gitignore diff --git a/objs/.gitignore b/objs/.gitignore new file mode 100644 index 00000000..35ecd6de --- /dev/null +++ b/objs/.gitignore @@ -0,0 +1,8 @@ +#All folders +SRB2.res +depend.dep +depend.ped +*.o +#VC9 folder only +/VC9/Win32 +/VC9/x64 diff --git a/objs/DC/SDL/Debug/.gitignore b/objs/DC/SDL/Debug/.gitignore deleted file mode 100644 index 867fcb4e..00000000 --- a/objs/DC/SDL/Debug/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/depend.dep diff --git a/objs/DC/SDL/Release/.gitignore b/objs/DC/SDL/Release/.gitignore deleted file mode 100644 index 867fcb4e..00000000 --- a/objs/DC/SDL/Release/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/depend.dep diff --git a/objs/Linux/SDL/Debug/.gitignore b/objs/Linux/SDL/Debug/.gitignore deleted file mode 100644 index 8f6d0bdc..00000000 --- a/objs/Linux/SDL/Debug/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/depend.dep -/*.o diff --git a/objs/Linux/SDL/Release/.gitignore b/objs/Linux/SDL/Release/.gitignore deleted file mode 100644 index 8f6d0bdc..00000000 --- a/objs/Linux/SDL/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/depend.dep -/*.o diff --git a/objs/Linux64/SDL/Debug/.gitignore b/objs/Linux64/SDL/Debug/.gitignore deleted file mode 100644 index 8f6d0bdc..00000000 --- a/objs/Linux64/SDL/Debug/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/depend.dep -/*.o diff --git a/objs/Linux64/SDL/Release/.gitignore b/objs/Linux64/SDL/Release/.gitignore deleted file mode 100644 index 8f6d0bdc..00000000 --- a/objs/Linux64/SDL/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/depend.dep -/*.o diff --git a/objs/Mingw/Debug/.gitignore b/objs/Mingw/Debug/.gitignore deleted file mode 100644 index da4b3e91..00000000 --- a/objs/Mingw/Debug/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/SRB2.res -/depend.dep -/*.o diff --git a/objs/Mingw/Release/.gitignore b/objs/Mingw/Release/.gitignore deleted file mode 100644 index da4b3e91..00000000 --- a/objs/Mingw/Release/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/SRB2.res -/depend.dep -/*.o diff --git a/objs/Mingw/SDL/Debug/.gitignore b/objs/Mingw/SDL/Debug/.gitignore deleted file mode 100644 index da4b3e91..00000000 --- a/objs/Mingw/SDL/Debug/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/SRB2.res -/depend.dep -/*.o diff --git a/objs/Mingw/SDL/Release/.gitignore b/objs/Mingw/SDL/Release/.gitignore deleted file mode 100644 index da4b3e91..00000000 --- a/objs/Mingw/SDL/Release/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/SRB2.res -/depend.dep -/*.o diff --git a/objs/Mingw64/Debug/.gitignore b/objs/Mingw64/Debug/.gitignore deleted file mode 100644 index da4b3e91..00000000 --- a/objs/Mingw64/Debug/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/SRB2.res -/depend.dep -/*.o diff --git a/objs/Mingw64/Release/.gitignore b/objs/Mingw64/Release/.gitignore deleted file mode 100644 index da4b3e91..00000000 --- a/objs/Mingw64/Release/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/SRB2.res -/depend.dep -/*.o diff --git a/objs/Mingw64/SDL/Debug/.gitignore b/objs/Mingw64/SDL/Debug/.gitignore deleted file mode 100644 index da4b3e91..00000000 --- a/objs/Mingw64/SDL/Debug/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/SRB2.res -/depend.dep -/*.o diff --git a/objs/Mingw64/SDL/Release/.gitignore b/objs/Mingw64/SDL/Release/.gitignore deleted file mode 100644 index da4b3e91..00000000 --- a/objs/Mingw64/SDL/Release/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/SRB2.res -/depend.dep -/*.o diff --git a/objs/PS3/SDL/Debug/.gitignore b/objs/PS3/SDL/Debug/.gitignore deleted file mode 100644 index 8f6d0bdc..00000000 --- a/objs/PS3/SDL/Debug/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/depend.dep -/*.o diff --git a/objs/PS3/SDL/Release/.gitignore b/objs/PS3/SDL/Release/.gitignore deleted file mode 100644 index 8f6d0bdc..00000000 --- a/objs/PS3/SDL/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/depend.dep -/*.o diff --git a/objs/PSP/SDL/Release/.gitignore b/objs/PSP/SDL/Release/.gitignore deleted file mode 100644 index 867fcb4e..00000000 --- a/objs/PSP/SDL/Release/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/depend.dep diff --git a/objs/SDL/Release/.gitignore b/objs/SDL/Release/.gitignore deleted file mode 100644 index 4a262f94..00000000 --- a/objs/SDL/Release/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/depend.ped diff --git a/objs/VC/.gitignore b/objs/VC/.gitignore deleted file mode 100644 index e69de29b..00000000 diff --git a/objs/VC9/.gitignore b/objs/VC9/.gitignore deleted file mode 100644 index 205fe45d..00000000 --- a/objs/VC9/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/Win32 -/x64 diff --git a/objs/Wii/SDL/Debug/.gitignore b/objs/Wii/SDL/Debug/.gitignore deleted file mode 100644 index 8f6d0bdc..00000000 --- a/objs/Wii/SDL/Debug/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/depend.dep -/*.o diff --git a/objs/Wii/SDL/Release/.gitignore b/objs/Wii/SDL/Release/.gitignore deleted file mode 100644 index 8f6d0bdc..00000000 --- a/objs/Wii/SDL/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/depend.dep -/*.o diff --git a/objs/WinCE/SDL/Release/.gitignore b/objs/WinCE/SDL/Release/.gitignore deleted file mode 100644 index 867fcb4e..00000000 --- a/objs/WinCE/SDL/Release/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/depend.dep diff --git a/objs/djgppdos/Debug/.gitignore b/objs/djgppdos/Debug/.gitignore deleted file mode 100644 index 867fcb4e..00000000 --- a/objs/djgppdos/Debug/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/depend.dep diff --git a/objs/djgppdos/Release/.gitignore b/objs/djgppdos/Release/.gitignore deleted file mode 100644 index 867fcb4e..00000000 --- a/objs/djgppdos/Release/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/depend.dep diff --git a/objs/nds/Debug/.gitignore b/objs/nds/Debug/.gitignore deleted file mode 100644 index 8f6d0bdc..00000000 --- a/objs/nds/Debug/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/depend.dep -/*.o diff --git a/objs/nds/Release/.gitignore b/objs/nds/Release/.gitignore deleted file mode 100644 index 8f6d0bdc..00000000 --- a/objs/nds/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/depend.dep -/*.o From d7a216e1927784112142a220ea812976c6b75136 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 30 Apr 2017 20:42:24 +0100 Subject: [PATCH 17/52] Ignore all *.exe files and *.mo files (such as en.mo) in all bin/Mingw folders --- bin/Mingw/Debug/.gitignore | 6 +++--- bin/Mingw/Release/.gitignore | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/Mingw/Debug/.gitignore b/bin/Mingw/Debug/.gitignore index e431dca5..834f313e 100644 --- a/bin/Mingw/Debug/.gitignore +++ b/bin/Mingw/Debug/.gitignore @@ -1,3 +1,3 @@ -/srb2sdl.exe -/srb2win.exe -/r_opengl.dll +*.exe +*.mo +r_opengl.dll diff --git a/bin/Mingw/Release/.gitignore b/bin/Mingw/Release/.gitignore index e431dca5..834f313e 100644 --- a/bin/Mingw/Release/.gitignore +++ b/bin/Mingw/Release/.gitignore @@ -1,3 +1,3 @@ -/srb2sdl.exe -/srb2win.exe -/r_opengl.dll +*.exe +*.mo +r_opengl.dll From 41130465b4e3f77aab4f88bbf1ee88b923eda2d6 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 7 May 2017 22:21:17 +0100 Subject: [PATCH 18/52] Use NF instead of normal P_SetMobjState to prevent endless looping --- src/p_enemy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index a8a6bb6b..649c7883 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -1102,7 +1102,7 @@ void A_JetJawChomp(mobj_t *actor) if (!actor->target || !(actor->target->flags & MF_SHOOTABLE) || actor->target->health <= 0 || !P_CheckSight(actor, actor->target)) { - P_SetMobjState(actor, actor->info->spawnstate); + P_SetMobjStateNF(actor, actor->info->spawnstate); return; } From 1745966aa62876f2951914f0e034324898fd7f19 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 8 May 2017 15:54:17 +0100 Subject: [PATCH 19/52] Re-add all the folders present in objs before my .gitignore changes, by adding .gitignore files again to keep them from disappearing --- objs/DC/SDL/Debug/.gitignore | 2 ++ objs/DC/SDL/Release/.gitignore | 2 ++ objs/Linux/SDL/Debug/.gitignore | 2 ++ objs/Linux/SDL/Release/.gitignore | 2 ++ objs/Linux64/SDL/Debug/.gitignore | 2 ++ objs/Linux64/SDL/Release/.gitignore | 2 ++ objs/Mingw/Debug/.gitignore | 2 ++ objs/Mingw/Release/.gitignore | 2 ++ objs/Mingw/SDL/Debug/.gitignore | 2 ++ objs/Mingw/SDL/Release/.gitignore | 2 ++ objs/Mingw64/Debug/.gitignore | 2 ++ objs/Mingw64/Release/.gitignore | 2 ++ objs/Mingw64/SDL/Debug/.gitignore | 2 ++ objs/Mingw64/SDL/Release/.gitignore | 2 ++ objs/PS3/SDL/Debug/.gitignore | 2 ++ objs/PS3/SDL/Release/.gitignore | 2 ++ objs/PSP/SDL/Release/.gitignore | 2 ++ objs/SDL/Release/.gitignore | 2 ++ objs/VC/.gitignore | 2 ++ objs/VC9/.gitignore | 2 ++ objs/Wii/SDL/Debug/.gitignore | 2 ++ objs/Wii/SDL/Release/.gitignore | 2 ++ objs/WinCE/SDL/Release/.gitignore | 2 ++ objs/djgppdos/Debug/.gitignore | 2 ++ objs/djgppdos/Release/.gitignore | 2 ++ objs/nds/Debug/.gitignore | 2 ++ objs/nds/Release/.gitignore | 2 ++ 27 files changed, 54 insertions(+) create mode 100644 objs/DC/SDL/Debug/.gitignore create mode 100644 objs/DC/SDL/Release/.gitignore create mode 100644 objs/Linux/SDL/Debug/.gitignore create mode 100644 objs/Linux/SDL/Release/.gitignore create mode 100644 objs/Linux64/SDL/Debug/.gitignore create mode 100644 objs/Linux64/SDL/Release/.gitignore create mode 100644 objs/Mingw/Debug/.gitignore create mode 100644 objs/Mingw/Release/.gitignore create mode 100644 objs/Mingw/SDL/Debug/.gitignore create mode 100644 objs/Mingw/SDL/Release/.gitignore create mode 100644 objs/Mingw64/Debug/.gitignore create mode 100644 objs/Mingw64/Release/.gitignore create mode 100644 objs/Mingw64/SDL/Debug/.gitignore create mode 100644 objs/Mingw64/SDL/Release/.gitignore create mode 100644 objs/PS3/SDL/Debug/.gitignore create mode 100644 objs/PS3/SDL/Release/.gitignore create mode 100644 objs/PSP/SDL/Release/.gitignore create mode 100644 objs/SDL/Release/.gitignore create mode 100644 objs/VC/.gitignore create mode 100644 objs/VC9/.gitignore create mode 100644 objs/Wii/SDL/Debug/.gitignore create mode 100644 objs/Wii/SDL/Release/.gitignore create mode 100644 objs/WinCE/SDL/Release/.gitignore create mode 100644 objs/djgppdos/Debug/.gitignore create mode 100644 objs/djgppdos/Release/.gitignore create mode 100644 objs/nds/Debug/.gitignore create mode 100644 objs/nds/Release/.gitignore diff --git a/objs/DC/SDL/Debug/.gitignore b/objs/DC/SDL/Debug/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/objs/DC/SDL/Debug/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/objs/DC/SDL/Release/.gitignore b/objs/DC/SDL/Release/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/objs/DC/SDL/Release/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/objs/Linux/SDL/Debug/.gitignore b/objs/Linux/SDL/Debug/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/objs/Linux/SDL/Debug/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/objs/Linux/SDL/Release/.gitignore b/objs/Linux/SDL/Release/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/objs/Linux/SDL/Release/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/objs/Linux64/SDL/Debug/.gitignore b/objs/Linux64/SDL/Debug/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/objs/Linux64/SDL/Debug/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/objs/Linux64/SDL/Release/.gitignore b/objs/Linux64/SDL/Release/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/objs/Linux64/SDL/Release/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/objs/Mingw/Debug/.gitignore b/objs/Mingw/Debug/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/objs/Mingw/Debug/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/objs/Mingw/Release/.gitignore b/objs/Mingw/Release/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/objs/Mingw/Release/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/objs/Mingw/SDL/Debug/.gitignore b/objs/Mingw/SDL/Debug/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/objs/Mingw/SDL/Debug/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/objs/Mingw/SDL/Release/.gitignore b/objs/Mingw/SDL/Release/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/objs/Mingw/SDL/Release/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/objs/Mingw64/Debug/.gitignore b/objs/Mingw64/Debug/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/objs/Mingw64/Debug/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/objs/Mingw64/Release/.gitignore b/objs/Mingw64/Release/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/objs/Mingw64/Release/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/objs/Mingw64/SDL/Debug/.gitignore b/objs/Mingw64/SDL/Debug/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/objs/Mingw64/SDL/Debug/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/objs/Mingw64/SDL/Release/.gitignore b/objs/Mingw64/SDL/Release/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/objs/Mingw64/SDL/Release/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/objs/PS3/SDL/Debug/.gitignore b/objs/PS3/SDL/Debug/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/objs/PS3/SDL/Debug/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/objs/PS3/SDL/Release/.gitignore b/objs/PS3/SDL/Release/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/objs/PS3/SDL/Release/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/objs/PSP/SDL/Release/.gitignore b/objs/PSP/SDL/Release/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/objs/PSP/SDL/Release/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/objs/SDL/Release/.gitignore b/objs/SDL/Release/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/objs/SDL/Release/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/objs/VC/.gitignore b/objs/VC/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/objs/VC/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/objs/VC9/.gitignore b/objs/VC9/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/objs/VC9/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/objs/Wii/SDL/Debug/.gitignore b/objs/Wii/SDL/Debug/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/objs/Wii/SDL/Debug/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/objs/Wii/SDL/Release/.gitignore b/objs/Wii/SDL/Release/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/objs/Wii/SDL/Release/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/objs/WinCE/SDL/Release/.gitignore b/objs/WinCE/SDL/Release/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/objs/WinCE/SDL/Release/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/objs/djgppdos/Debug/.gitignore b/objs/djgppdos/Debug/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/objs/djgppdos/Debug/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/objs/djgppdos/Release/.gitignore b/objs/djgppdos/Release/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/objs/djgppdos/Release/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/objs/nds/Debug/.gitignore b/objs/nds/Debug/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/objs/nds/Debug/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/objs/nds/Release/.gitignore b/objs/nds/Release/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/objs/nds/Release/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing From 8582406dd2f27d7e9e7c810cca15993b09a41f36 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 9 May 2017 19:57:21 +0100 Subject: [PATCH 20/52] prevent invalid nodes from crashing Net_CloseConnection, print a warning and return instead --- src/d_net.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/d_net.c b/src/d_net.c index 7f16c302..98fe71ab 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -716,6 +716,12 @@ void Net_CloseConnection(INT32 node) if (!node) return; + if (node >= MAXNETNODES) // prevent invalid nodes from crashing the game + { + CONS_Alert(CONS_WARNING, M_GetText("Net_CloseConnection: invalid node %d detected!\n"), node); + return; + } + nodes[node].flags |= NF_CLOSE; // try to Send ack back (two army problem) From 96c63bf95b66061d84e8b71ed1679a8180a3c477 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 9 May 2017 20:02:42 +0100 Subject: [PATCH 21/52] Whoops forgot this bit too --- src/d_net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_net.c b/src/d_net.c index 98fe71ab..70cdc5f1 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -716,7 +716,7 @@ void Net_CloseConnection(INT32 node) if (!node) return; - if (node >= MAXNETNODES) // prevent invalid nodes from crashing the game + if (node < 0 || node >= MAXNETNODES) // prevent invalid nodes from crashing the game { CONS_Alert(CONS_WARNING, M_GetText("Net_CloseConnection: invalid node %d detected!\n"), node); return; From b8ffeeb59f4a7022b6ebbb8e2762deb21f5df6e2 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 12 May 2017 16:06:27 +0100 Subject: [PATCH 22/52] Update version number to v2.1.18 Don't worry, I remembered to update MODVERSION as well this time :) --- CMakeLists.txt | 2 +- appveyor.yml | 2 +- src/doomdef.h | 8 ++++---- src/sdl/macosx/Srb2mac.xcodeproj/project.pbxproj | 4 ++-- src/sdl12/macosx/Srb2mac.xcodeproj/project.pbxproj | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 31597f39..23b768a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.0) project(SRB2 - VERSION 2.1.17 + VERSION 2.1.18 LANGUAGES C) if(${PROJECT_SOURCE_DIR} MATCHES ${PROJECT_BINARY_DIR}) diff --git a/appveyor.yml b/appveyor.yml index b0544a90..76e1261f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -version: 2.1.17.{branch}-{build} +version: 2.1.18.{branch}-{build} os: MinGW environment: diff --git a/src/doomdef.h b/src/doomdef.h index 99e54c07..428972cc 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -150,9 +150,9 @@ extern FILE *logstream; // we use comprevision and compbranch instead. #else #define VERSION 201 // Game version -#define SUBVERSION 17 // more precise version number -#define VERSIONSTRING "v2.1.17" -#define VERSIONSTRINGW L"v2.1.17" +#define SUBVERSION 18 // more precise version number +#define VERSIONSTRING "v2.1.18" +#define VERSIONSTRINGW L"v2.1.18" // Hey! If you change this, add 1 to the MODVERSION below! // Otherwise we can't force updates! #endif @@ -214,7 +214,7 @@ extern FILE *logstream; // it's only for detection of the version the player is using so the MS can alert them of an update. // Only set it higher, not lower, obviously. // Note that we use this to help keep internal testing in check; this is why v2.1.0 is not version "1". -#define MODVERSION 22 +#define MODVERSION 23 // ========================================================================= diff --git a/src/sdl/macosx/Srb2mac.xcodeproj/project.pbxproj b/src/sdl/macosx/Srb2mac.xcodeproj/project.pbxproj index 32ae88c0..fbf9bacb 100644 --- a/src/sdl/macosx/Srb2mac.xcodeproj/project.pbxproj +++ b/src/sdl/macosx/Srb2mac.xcodeproj/project.pbxproj @@ -1214,7 +1214,7 @@ C01FCF4B08A954540054247B /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 2.1.17; + CURRENT_PROJECT_VERSION = 2.1.18; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", NORMALSRB2, @@ -1226,7 +1226,7 @@ C01FCF4C08A954540054247B /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 2.1.17; + CURRENT_PROJECT_VERSION = 2.1.18; GCC_ENABLE_FIX_AND_CONTINUE = NO; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_PREPROCESSOR_DEFINITIONS = ( diff --git a/src/sdl12/macosx/Srb2mac.xcodeproj/project.pbxproj b/src/sdl12/macosx/Srb2mac.xcodeproj/project.pbxproj index 13e78f31..98a760c7 100644 --- a/src/sdl12/macosx/Srb2mac.xcodeproj/project.pbxproj +++ b/src/sdl12/macosx/Srb2mac.xcodeproj/project.pbxproj @@ -1214,7 +1214,7 @@ C01FCF4B08A954540054247B /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 2.1.17; + CURRENT_PROJECT_VERSION = 2.1.18; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", NORMALSRB2, @@ -1226,7 +1226,7 @@ C01FCF4C08A954540054247B /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 2.1.17; + CURRENT_PROJECT_VERSION = 2.1.18; GCC_ENABLE_FIX_AND_CONTINUE = NO; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_PREPROCESSOR_DEFINITIONS = ( From 377fc814479f768558114960c5bc8557195b1f01 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Sat, 13 May 2017 12:07:37 -0400 Subject: [PATCH 23/52] Appveyor: disable deployment --- appveyor.yml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 76e1261f..75f3b3ab 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -63,21 +63,21 @@ after_build: test: off -deploy: - - provider: FTP - protocol: ftps - host: - secure: NsLJEPIBvmwCOj8Tg8RoRQ== - username: - secure: ejxi5mvk7oLYu7QtbYojajEPigMy0mokaKhuEVuDZcA= - password: - secure: Hbn6Uy3lT0YZ88yFJ3aW4w== - folder: appveyor - application: - active_mode: false - on: - branch: master - appveyor_repo_tag: true +#deploy: +# - provider: FTP +# protocol: ftps +# host: +# secure: NsLJEPIBvmwCOj8Tg8RoRQ== +# username: +# secure: ejxi5mvk7oLYu7QtbYojajEPigMy0mokaKhuEVuDZcA= +# password: +# secure: Hbn6Uy3lT0YZ88yFJ3aW4w== +# folder: appveyor +# application: +# active_mode: false +# on: +# branch: master +# appveyor_repo_tag: true on_finish: From 7d4146870a8b7dd1484af3c8650a2f8979dc79f4 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Sat, 13 May 2017 12:13:47 -0400 Subject: [PATCH 24/52] Appveyor: keep a stable name version of the archive --- appveyor.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index 75f3b3ab..c1f6894e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -58,8 +58,11 @@ after_build: - cmd: git rev-parse --short %APPVEYOR_REPO_COMMIT%>%TMP%/gitshort.txt - cmd: set /P GITSHORT=<%TMP%/gitshort.txt - set BUILD_ARCHIVE=%APPVEYOR_REPO_BRANCH%-%GITSHORT%-%CONFIGURATION%.7z +- set BUILDSARCHIVE=%APPVEYOR_REPO_BRANCH%-%CONFIGURATION%.7z - cmd: 7z a %BUILD_ARCHIVE% bin\Mingw\Release -xr!.gitignore - appveyor PushArtifact %BUILD_ARCHIVE% +- cmd: copy %BUILD_ARCHIVE% %BUILDSARCHIVE% +- appveyor PushArtifact %BUILDSARCHIVE% test: off From 093800cb06be63040368adbf4579af0738ae97a5 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 15 May 2017 15:24:40 +0100 Subject: [PATCH 25/52] I_FinishUpdate: OglSdlFinishUpdate should never run for render_soft, even if screens[0] somehow is NULL --- src/sdl/i_video.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index aa572e6e..73bbe8ac 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -931,7 +931,7 @@ void I_FinishUpdate(void) if (cv_ticrate.value) SCR_DisplayTicRate(); - if (render_soft == rendermode && screens[0]) + if (rendermode == render_soft && screens[0]) { SDL_Rect rect; @@ -958,7 +958,7 @@ void I_FinishUpdate(void) } #ifdef HWRENDER - else + else if (rendermode == render_opengl) { OglSdlFinishUpdate(cv_vidwait.value); } From d1bbd1261e7f3b3dbdbbe9951ae007fa120d0df0 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 15 May 2017 15:36:51 +0100 Subject: [PATCH 26/52] VID_SetMode: SDLSetMode should use vid.width/vid.height, not windowedModes[modeNum]. If modenum was < 0 or >= MAXWINMODES, that would make windowedModes[modeNum] be out of bounds and possibly crash the game. --- src/sdl/i_video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 73bbe8ac..43a293ae 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1188,7 +1188,7 @@ INT32 VID_SetMode(INT32 modeNum) } Impl_SetWindowName("SRB2 "VERSIONSTRING); - SDLSetMode(windowedModes[modeNum][0], windowedModes[modeNum][1], USE_FULLSCREEN); + SDLSetMode(vid.width, vid.height, USE_FULLSCREEN); if (render_soft == rendermode) { From 4979ab6b8ec0de1e684ff87a00978b0fab87df51 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 15 May 2017 15:43:31 +0100 Subject: [PATCH 27/52] Not really important or anything, but checking render_soft == rendermode rather than rendermode == render_soft always bugged me. And it's not consistent with the rest of the source code (or at least most of it) anyway. --- src/sdl/i_video.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 43a293ae..2df4d527 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -899,7 +899,7 @@ static inline boolean I_SkipFrame(void) { static boolean skip = false; - if (render_soft != rendermode) + if (rendermode != render_soft) return false; skip = !skip; @@ -1190,7 +1190,7 @@ INT32 VID_SetMode(INT32 modeNum) SDLSetMode(vid.width, vid.height, USE_FULLSCREEN); - if (render_soft == rendermode) + if (rendermode == render_soft) { if (bufSurface) { @@ -1483,7 +1483,7 @@ void I_ShutdownGraphics(void) rendermode = render_none; if (icoSurface) SDL_FreeSurface(icoSurface); icoSurface = NULL; - if (render_soft == oldrendermode) + if (oldrendermode == render_soft) { if (vidSurface) SDL_FreeSurface(vidSurface); vidSurface = NULL; From a340f2c8edec7c9e2e84f5aef4372f2423923c5c Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 15 May 2017 16:19:28 +0100 Subject: [PATCH 28/52] Impl_CreateWindow: re-use "flags" for SDL_RENDERER_* flags, remove unnecessary curly braces --- src/sdl/i_video.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 2df4d527..5602ed04 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1209,30 +1209,20 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen) int flags = 0; if (rendermode == render_none) // dedicated - { return SDL_TRUE; // Monster Iestyn -- not sure if it really matters what we return here tbh - } if (window != NULL) - { return SDL_FALSE; - } if (fullscreen) - { flags |= SDL_WINDOW_FULLSCREEN_DESKTOP; - } if (borderlesswindow) - { flags |= SDL_WINDOW_BORDERLESS; - } #ifdef HWRENDER if (rendermode == render_opengl) - { flags |= SDL_WINDOW_OPENGL; - } #endif // Create a window @@ -1261,7 +1251,13 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen) #endif if (rendermode == render_soft) { - renderer = SDL_CreateRenderer(window, -1, (usesdl2soft ? SDL_RENDERER_SOFTWARE : 0) | (cv_vidwait.value && !usesdl2soft ? SDL_RENDERER_PRESENTVSYNC : 0)); + flags = 0; // Use this to set SDL_RENDERER_* flags now + if (usesdl2soft) + flags |= SDL_RENDERER_SOFTWARE; + else if (cv_vidwait.value) + flags |= SDL_RENDERER_PRESENTVSYNC; + + renderer = SDL_CreateRenderer(window, -1, flags); if (renderer == NULL) { CONS_Printf(M_GetText("Couldn't create rendering context: %s\n"), SDL_GetError()); From 87085f2475ff5b699a1f95221b73e2e7fc81f5f6 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 15 May 2017 16:35:32 +0100 Subject: [PATCH 29/52] SDLSetMode: merge wasfullscreen/windowed mode code into one block --- src/sdl/i_video.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 5602ed04..ec9b901c 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -181,15 +181,13 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen) wasfullscreen = SDL_TRUE; SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP); } - else if (wasfullscreen) - { - wasfullscreen = SDL_FALSE; - SDL_SetWindowFullscreen(window, 0); - SDL_SetWindowSize(window, width, height); - SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED_DISPLAY(1), SDL_WINDOWPOS_CENTERED_DISPLAY(1)); - } - else + else // windowed mode { + if (wasfullscreen) + { + wasfullscreen = SDL_FALSE; + SDL_SetWindowFullscreen(window, 0); + } // Reposition window only in windowed mode SDL_SetWindowSize(window, width, height); SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED_DISPLAY(1), SDL_WINDOWPOS_CENTERED_DISPLAY(1)); From 17a06dd6c4875f562bbb33ddb6ddb0fa37d8428b Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 15 May 2017 18:39:59 +0100 Subject: [PATCH 30/52] I_GetConsoleEvents: Split KEY_EVENT code into a function of its own, like with I_GetEvent's event types One benefit of this is that event_t data need only be created if KEY_EVENT is found, since the other event types never do anything anyway --- src/sdl/i_system.c | 112 ++++++++++++++++++++++++--------------------- 1 file changed, 60 insertions(+), 52 deletions(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 71ee3f79..f72a9857 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -590,70 +590,78 @@ static BOOL I_ReadyConsole(HANDLE ci) static boolean entering_con_command = false; +static void Impl_HandleKeyboardConsoleEvent(KEY_EVENT_RECORD evt, HANDLE co) +{ + event_t event; + CONSOLE_SCREEN_BUFFER_INFO CSBI; + DWORD t; + + memset(&event,0x00,sizeof (event)); + + if (evt.bKeyDown) + { + event.type = ev_console; + entering_con_command = true; + switch (evt.wVirtualKeyCode) + { + case VK_ESCAPE: + case VK_TAB: + event.data1 = KEY_NULL; + break; + case VK_SHIFT: + event.data1 = KEY_LSHIFT; + break; + case VK_RETURN: + entering_con_command = false; + // Fall through. + default: + event.data1 = MapVirtualKey(evt.wVirtualKeyCode,2); // convert in to char + } + if (co != INVALID_HANDLE_VALUE && GetFileType(co) == FILE_TYPE_CHAR && GetConsoleMode(co, &t)) + { + if (event.data1 && event.data1 != KEY_LSHIFT && event.data1 != KEY_RSHIFT) + { +#ifdef _UNICODE + WriteConsole(co, &evt.uChar.UnicodeChar, 1, &t, NULL); +#else + WriteConsole(co, &evt.uChar.AsciiChar, 1 , &t, NULL); +#endif + } + if (evt.wVirtualKeyCode == VK_BACK + && GetConsoleScreenBufferInfo(co,&CSBI)) + { + WriteConsoleOutputCharacterA(co, " ",1, CSBI.dwCursorPosition, &t); + } + } + } + else + { + event.type = ev_keyup; + switch (evt.wVirtualKeyCode) + { + case VK_SHIFT: + event.data1 = KEY_LSHIFT; + break; + default: + break; + } + } + if (event.data1) D_PostEvent(&event); +} + void I_GetConsoleEvents(void) { - event_t ev = {0,0,0,0}; HANDLE ci = GetStdHandle(STD_INPUT_HANDLE); HANDLE co = GetStdHandle(STD_OUTPUT_HANDLE); - CONSOLE_SCREEN_BUFFER_INFO CSBI; INPUT_RECORD input; DWORD t; while (I_ReadyConsole(ci) && ReadConsoleInput(ci, &input, 1, &t) && t) { - memset(&ev,0x00,sizeof (ev)); switch (input.EventType) { case KEY_EVENT: - if (input.Event.KeyEvent.bKeyDown) - { - ev.type = ev_console; - entering_con_command = true; - switch (input.Event.KeyEvent.wVirtualKeyCode) - { - case VK_ESCAPE: - case VK_TAB: - ev.data1 = KEY_NULL; - break; - case VK_SHIFT: - ev.data1 = KEY_LSHIFT; - break; - case VK_RETURN: - entering_con_command = false; - // Fall through. - default: - ev.data1 = MapVirtualKey(input.Event.KeyEvent.wVirtualKeyCode,2); // convert in to char - } - if (co != INVALID_HANDLE_VALUE && GetFileType(co) == FILE_TYPE_CHAR && GetConsoleMode(co, &t)) - { - if (ev.data1 && ev.data1 != KEY_LSHIFT && ev.data1 != KEY_RSHIFT) - { -#ifdef _UNICODE - WriteConsole(co, &input.Event.KeyEvent.uChar.UnicodeChar, 1, &t, NULL); -#else - WriteConsole(co, &input.Event.KeyEvent.uChar.AsciiChar, 1 , &t, NULL); -#endif - } - if (input.Event.KeyEvent.wVirtualKeyCode == VK_BACK - && GetConsoleScreenBufferInfo(co,&CSBI)) - { - WriteConsoleOutputCharacterA(co, " ",1, CSBI.dwCursorPosition, &t); - } - } - } - else - { - ev.type = ev_keyup; - switch (input.Event.KeyEvent.wVirtualKeyCode) - { - case VK_SHIFT: - ev.data1 = KEY_LSHIFT; - break; - default: - break; - } - } - if (ev.data1) D_PostEvent(&ev); + Impl_HandleKeyboardConsoleEvent(input.Event.KeyEvent, co); break; case MOUSE_EVENT: case WINDOW_BUFFER_SIZE_EVENT: From 5a1fc6098ed84aa82bc73afa2640840d17a0845f Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 19 May 2017 11:25:28 +0100 Subject: [PATCH 31/52] Attempts to prevent stupid stuff from happening --- src/d_clisrv.c | 7 ++++++- src/d_net.c | 9 ++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 939d53de..87e51b44 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3936,6 +3936,9 @@ FILESTAMP while (HGetPacket()) { + if (doomcom->remotenode == -1) // ...this should have been ignored already + continue; // might come from PT_NODETIMEOUT somehow though + node = (SINT8)doomcom->remotenode; if (netbuffer->packettype == PT_CLIENTJOIN && server) @@ -3968,8 +3971,10 @@ FILESTAMP if (netbuffer->packettype == PT_PLAYERINFO) continue; // We do nothing with PLAYERINFO, that's for the MS browser. + if (node < 0 || node >= MAXNETNODES) // THIS SHOULDN'T EVEN BE POSSIBLE + ; //CONS_Printf("Received packet from node %d!\n", (int)node); // Packet received from someone already playing - if (nodeingame[node]) + else if (nodeingame[node]) HandlePacketFromPlayer(node); // Packet received from someone not playing else diff --git a/src/d_net.c b/src/d_net.c index 70cdc5f1..68720f5e 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -711,6 +711,10 @@ void Net_CloseConnection(INT32 node) #else INT32 i; boolean forceclose = (node & FORCECLOSE) != 0; + + if (node == -1) + return; // nope, just ignore it + node &= ~FORCECLOSE; if (!node) @@ -718,7 +722,7 @@ void Net_CloseConnection(INT32 node) if (node < 0 || node >= MAXNETNODES) // prevent invalid nodes from crashing the game { - CONS_Alert(CONS_WARNING, M_GetText("Net_CloseConnection: invalid node %d detected!\n"), node); + //CONS_Alert(CONS_WARNING, M_GetText("Net_CloseConnection: invalid node %d detected!\n"), node); return; } @@ -1128,6 +1132,9 @@ boolean HGetPacket(void) doomcom->remotenode = 0; rebound_tail = (rebound_tail+1) % MAXREBOUND; + + if (doomcom->remotenode == -1) // wait hang on what? + return true; // there might still be packets from others though, so don't return false #ifdef DEBUGFILE if (debugfile) DebugPrintpacket("GETLOCAL"); From 1078a642dfee676cf87fcb023d9b8889477ae959 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 19 May 2017 11:52:50 +0100 Subject: [PATCH 32/52] Loop through rebound packets until you found a good one or ran out of them --- src/d_net.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/d_net.c b/src/d_net.c index 68720f5e..8f11f60f 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -1124,22 +1124,27 @@ boolean HGetPacket(void) // Get a packet from self if (rebound_tail != rebound_head) { - M_Memcpy(netbuffer, &reboundstore[rebound_tail], reboundsize[rebound_tail]); - doomcom->datalength = reboundsize[rebound_tail]; - if (netbuffer->packettype == PT_NODETIMEOUT) - doomcom->remotenode = netbuffer->u.textcmd[0]; - else - doomcom->remotenode = 0; + while (true) // loop until we found a valid packet, or we ran out of packets + { // provided MAXREBOUND is not all that large this shouldn't take too long + if (rebound_tail == rebound_head) + break; // just give up, none of them were any good somehow + M_Memcpy(netbuffer, &reboundstore[rebound_tail], reboundsize[rebound_tail]); + doomcom->datalength = reboundsize[rebound_tail]; + if (netbuffer->packettype == PT_NODETIMEOUT) + doomcom->remotenode = netbuffer->u.textcmd[0]; + else + doomcom->remotenode = 0; - rebound_tail = (rebound_tail+1) % MAXREBOUND; + rebound_tail = (rebound_tail+1) % MAXREBOUND; - if (doomcom->remotenode == -1) // wait hang on what? - return true; // there might still be packets from others though, so don't return false + if (doomcom->remotenode == -1) // wait hang on what? + continue; // ignore it, look for the next packet #ifdef DEBUGFILE - if (debugfile) - DebugPrintpacket("GETLOCAL"); + if (debugfile) + DebugPrintpacket("GETLOCAL"); #endif - return true; + return true; + } } if (!netgame) From 284e539c66817d2448781a29024818d1c620a29c Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 19 May 2017 16:31:23 +0100 Subject: [PATCH 33/52] Don't bail out in Y_StartIntermission in dedicated mode, this causes the game not to add on score bonuses for players from the server's view of things! --- src/y_inter.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/y_inter.c b/src/y_inter.c index b2e1cdf9..2fd37ff3 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -965,7 +965,8 @@ void Y_StartIntermission(void) } // We couldn't display the intermission even if we wanted to. - if (dedicated) return; + // But we still need to give the players their score bonuses, dummy. + //if (dedicated) return; // This should always exist, but just in case... if(!mapheaderinfo[prevmap]) From 5aeb4b591949399676d0e5e3e358e539115f0e43 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 20 May 2017 21:29:05 +0100 Subject: [PATCH 34/52] Revert "Loop through rebound packets until you found a good one or ran out of them" On second thought, this was probably unnecessary anyway. This reverts commit 1078a642dfee676cf87fcb023d9b8889477ae959. --- src/d_net.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/src/d_net.c b/src/d_net.c index 8f11f60f..68720f5e 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -1124,27 +1124,22 @@ boolean HGetPacket(void) // Get a packet from self if (rebound_tail != rebound_head) { - while (true) // loop until we found a valid packet, or we ran out of packets - { // provided MAXREBOUND is not all that large this shouldn't take too long - if (rebound_tail == rebound_head) - break; // just give up, none of them were any good somehow - M_Memcpy(netbuffer, &reboundstore[rebound_tail], reboundsize[rebound_tail]); - doomcom->datalength = reboundsize[rebound_tail]; - if (netbuffer->packettype == PT_NODETIMEOUT) - doomcom->remotenode = netbuffer->u.textcmd[0]; - else - doomcom->remotenode = 0; + M_Memcpy(netbuffer, &reboundstore[rebound_tail], reboundsize[rebound_tail]); + doomcom->datalength = reboundsize[rebound_tail]; + if (netbuffer->packettype == PT_NODETIMEOUT) + doomcom->remotenode = netbuffer->u.textcmd[0]; + else + doomcom->remotenode = 0; - rebound_tail = (rebound_tail+1) % MAXREBOUND; + rebound_tail = (rebound_tail+1) % MAXREBOUND; - if (doomcom->remotenode == -1) // wait hang on what? - continue; // ignore it, look for the next packet + if (doomcom->remotenode == -1) // wait hang on what? + return true; // there might still be packets from others though, so don't return false #ifdef DEBUGFILE - if (debugfile) - DebugPrintpacket("GETLOCAL"); + if (debugfile) + DebugPrintpacket("GETLOCAL"); #endif - return true; - } + return true; } if (!netgame) From 247ed56e1790caa0a69f9f1027dfcb0d0fb5b8e8 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 22 May 2017 16:44:50 +0100 Subject: [PATCH 35/52] Don't allow nonsense PT_ASKINFOVIAMS packets, nor any at all if offline --- src/d_clisrv.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 87e51b44..09843023 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3405,13 +3405,23 @@ static void HandlePacketFromAwayNode(SINT8 node) switch (netbuffer->packettype) { case PT_ASKINFOVIAMS: + if (ms_RoomId < 0) // ignore if we're not actually on the MS right now + { + Net_CloseConnection(node); // and yes, close connection + break; + } if (server && serverrunning) { INT32 clientnode = I_NetMakeNode(netbuffer->u.msaskinfo.clientaddr); - SV_SendServerInfo(clientnode, (tic_t)LONG(netbuffer->u.msaskinfo.time)); - SV_SendPlayerInfo(clientnode); // Send extra info - Net_CloseConnection(clientnode); - // Don't close connection to MS. + if (clientnode != -1) + { + SV_SendServerInfo(clientnode, (tic_t)LONG(netbuffer->u.msaskinfo.time)); + SV_SendPlayerInfo(clientnode); // Send extra info + Net_CloseConnection(clientnode); + // Don't close connection to MS... + } + else + Net_CloseConnection(node); // ...unless the IP address is not valid } break; From 28444c12dd6d57ae43d08186a40dd5b5e8b43019 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 22 May 2017 16:54:39 +0100 Subject: [PATCH 36/52] Some more things I overlooked in this fix --- src/d_clisrv.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 09843023..17f0b774 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3405,14 +3405,16 @@ static void HandlePacketFromAwayNode(SINT8 node) switch (netbuffer->packettype) { case PT_ASKINFOVIAMS: - if (ms_RoomId < 0) // ignore if we're not actually on the MS right now - { - Net_CloseConnection(node); // and yes, close connection - break; - } + if (server && serverrunning) { - INT32 clientnode = I_NetMakeNode(netbuffer->u.msaskinfo.clientaddr); + INT32 clientnode; + if (ms_RoomId < 0) // ignore if we're not actually on the MS right now + { + Net_CloseConnection(node); // and yes, close connection + return; + } + clientnode = I_NetMakeNode(netbuffer->u.msaskinfo.clientaddr); if (clientnode != -1) { SV_SendServerInfo(clientnode, (tic_t)LONG(netbuffer->u.msaskinfo.time)); @@ -3423,6 +3425,8 @@ static void HandlePacketFromAwayNode(SINT8 node) else Net_CloseConnection(node); // ...unless the IP address is not valid } + else + Net_CloseConnection(node); // you're not supposed to get it, so ignore it break; case PT_ASKINFO: From 3784d765e493d7820f7dd37b5d4c3c66ef7a3f8a Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 22 May 2017 20:47:38 +0100 Subject: [PATCH 37/52] Remove extra whitespace I added --- src/d_clisrv.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 17f0b774..36b03be6 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3405,7 +3405,6 @@ static void HandlePacketFromAwayNode(SINT8 node) switch (netbuffer->packettype) { case PT_ASKINFOVIAMS: - if (server && serverrunning) { INT32 clientnode; From c70839334e180869279c84f5d40360afdcc43bdc Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 22 May 2017 22:17:51 +0100 Subject: [PATCH 38/52] Added a bunch of missing checks to prevent non-server players from sending other non-server players stuff --- src/d_clisrv.c | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 36b03be6..c6b8bbd6 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3433,8 +3433,8 @@ static void HandlePacketFromAwayNode(SINT8 node) { SV_SendServerInfo(node, (tic_t)LONG(netbuffer->u.askinfo.time)); SV_SendPlayerInfo(node); // Send extra info - Net_CloseConnection(node); } + Net_CloseConnection(node); break; case PT_SERVERREFUSE: // Negative response of client join request @@ -3443,6 +3443,11 @@ static void HandlePacketFromAwayNode(SINT8 node) Net_CloseConnection(node); break; } + if (node != servernode) // nope you're not the server + { + Net_CloseConnection(node); + break; + } if (cl_mode == CL_WAITJOINRESPONSE) { // Save the reason so it can be displayed after quitting the netgame @@ -3474,6 +3479,11 @@ static void HandlePacketFromAwayNode(SINT8 node) Net_CloseConnection(node); break; } + if (node != servernode) // nope you're not the server + { + Net_CloseConnection(node); + break; + } /// \note how would this happen? and is it doing the right thing if it does? if (cl_mode != CL_WAITJOINRESPONSE) break; @@ -3537,11 +3547,20 @@ static void HandlePacketFromAwayNode(SINT8 node) Net_CloseConnection(node); break; } - else - Got_Filetxpak(); + if (node != servernode) // nope you're not the server + { + Net_CloseConnection(node); + break; + } + Got_Filetxpak(); break; case PT_REQUESTFILE: + if (node != servernode) // nope you're not the server + { + Net_CloseConnection(node); + break; + } if (server) Got_RequestFilePak(node); break; @@ -3926,6 +3945,21 @@ FILESTAMP case PT_SERVERCFG: break; case PT_FILEFRAGMENT: + // Only accept PT_FILEFRAGMENT from the server. + if (node != servernode) + { + CONS_Alert(CONS_WARNING, M_GetText("%s received from non-host %d\n"), "PT_FILEFRAGMENT", node); + + if (server) + { + XBOXSTATIC UINT8 buf[2]; + buf[0] = (UINT8)node; + buf[1] = KICK_MSG_CON_FAIL; + SendNetXCmd(XD_KICK, &buf, 2); + } + + break; + } if (client) Got_Filetxpak(); break; From fdfd6e1c0bbce1c7c584a906a7b51f7907eba5bb Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 22 May 2017 22:20:08 +0100 Subject: [PATCH 39/52] Whoops don't do that for PT_REQUESTFILE --- src/d_clisrv.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index c6b8bbd6..76262461 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3556,11 +3556,6 @@ static void HandlePacketFromAwayNode(SINT8 node) break; case PT_REQUESTFILE: - if (node != servernode) // nope you're not the server - { - Net_CloseConnection(node); - break; - } if (server) Got_RequestFilePak(node); break; From 9e3bdc5ee229c061db3550eda3c4cf1c7e4a35fb Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 23 May 2017 16:13:42 +0100 Subject: [PATCH 40/52] Prevent bad PT_TEXTCMD/PT_TEXTCMD2 textcmd[0] sizes? --- src/d_clisrv.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 76262461..4700fcb8 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3737,6 +3737,15 @@ FILESTAMP tic_t tic = maketic; UINT8 *textcmd; + // ignore if the textcmd size var is actually larger than it should be + if (BASEPACKETSIZE + netbuffer->u.textcmd[0] > (size_t)doomcom->datalength) + { + DEBFILE(va("GetPacket: Bad Textcmd packet size! (expected %d, actual %d)\n", + BASEPACKETSIZE + netbuffer->u.textcmd[0], doomcom->datalength)); + Net_UnAcknowledgePacket(node); + break; + } + // check if tic that we are making isn't too large else we cannot send it :( // doomcom->numslots+1 "+1" since doomcom->numslots can change within this time and sent time j = software_MAXPACKETLENGTH From ff1cc07a1d20989c0271dc8c875a4d3b248aea94 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 23 May 2017 16:29:09 +0100 Subject: [PATCH 41/52] Implemented toaster's suggestion to make a macro here --- src/d_clisrv.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 4700fcb8..246642b9 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3402,6 +3402,14 @@ static void HandlePacketFromAwayNode(SINT8 node) if (node != servernode) DEBFILE(va("Received packet from unknown host %d\n", node)); +// macro for packets that should only be sent by the server +// if it is NOT from the server, bail out and close the connection! +#define SERVERONLY \ + if (node != servernode) \ + { \ + Net_CloseConnection(node); \ + break; \ + } switch (netbuffer->packettype) { case PT_ASKINFOVIAMS: @@ -3443,11 +3451,7 @@ static void HandlePacketFromAwayNode(SINT8 node) Net_CloseConnection(node); break; } - if (node != servernode) // nope you're not the server - { - Net_CloseConnection(node); - break; - } + SERVERONLY if (cl_mode == CL_WAITJOINRESPONSE) { // Save the reason so it can be displayed after quitting the netgame @@ -3479,11 +3483,7 @@ static void HandlePacketFromAwayNode(SINT8 node) Net_CloseConnection(node); break; } - if (node != servernode) // nope you're not the server - { - Net_CloseConnection(node); - break; - } + SERVERONLY /// \note how would this happen? and is it doing the right thing if it does? if (cl_mode != CL_WAITJOINRESPONSE) break; @@ -3547,11 +3547,7 @@ static void HandlePacketFromAwayNode(SINT8 node) Net_CloseConnection(node); break; } - if (node != servernode) // nope you're not the server - { - Net_CloseConnection(node); - break; - } + SERVERONLY Got_Filetxpak(); break; @@ -3580,6 +3576,7 @@ static void HandlePacketFromAwayNode(SINT8 node) break; // Ignore it } +#undef SERVERONLY } /** Handles a packet received from a node that is in game From 0b0b738a6f8af4ceb95c05de44f42da11b550408 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 23 May 2017 16:34:56 +0100 Subject: [PATCH 42/52] Don't allow non-servers to receive PT_RESYNCHGET --- src/d_clisrv.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 246642b9..186c25e6 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3609,6 +3609,8 @@ FILESTAMP { // -------------------------------------------- SERVER RECEIVE ---------- case PT_RESYNCHGET: + if (client) + break; SV_AcknowledgeResynchAck(netconsole, netbuffer->u.resynchgot); break; case PT_CLIENTCMD: From 7147e0fcafcdf89f65bb2e909e94ea575cdbc3d9 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 23 May 2017 17:35:32 +0100 Subject: [PATCH 43/52] Improve previous PT_TEXTCMD/PT_TEXTCMD2 check, add another one to ignore zero size textcmds! --- src/d_clisrv.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 186c25e6..a42fcf1d 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3736,11 +3736,23 @@ FILESTAMP tic_t tic = maketic; UINT8 *textcmd; - // ignore if the textcmd size var is actually larger than it should be - if (BASEPACKETSIZE + netbuffer->u.textcmd[0] > (size_t)doomcom->datalength) + // ignore if the textcmd has a reported size of zero + // this shouldn't be sent at all + if (!netbuffer->u.textcmd[0]) { - DEBFILE(va("GetPacket: Bad Textcmd packet size! (expected %d, actual %d)\n", - BASEPACKETSIZE + netbuffer->u.textcmd[0], doomcom->datalength)); + DEBFILE(va("GetPacket: Textcmd with size 0 detected! (node %u, player %d)\n", + node, netconsole)); + Net_UnAcknowledgePacket(node); + break; + } + + // ignore if the textcmd size var is actually larger than it should be + // BASEPACKETSIZE + 1 (for size) + textcmd[0] should == datalength + if (netbuffer->u.textcmd[0] > (size_t)doomcom->datalength-BASEPACKETSIZE-1) + { + DEBFILE(va("GetPacket: Bad Textcmd packet size! (expected %d, actual %d, node %u, player %d)\n", + netbuffer->u.textcmd[0], (size_t)doomcom->datalength-BASEPACKETSIZE-1, + node, netconsole)); Net_UnAcknowledgePacket(node); break; } From c92aaa74a41e3ad2477b564eaa9bfe086b518450 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 23 May 2017 18:46:34 +0100 Subject: [PATCH 44/52] I think PT_CLIENT2MIS was meant to do this too, probably --- src/d_clisrv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index a42fcf1d..27fcd067 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3677,7 +3677,8 @@ FILESTAMP } // Splitscreen cmd - if (netbuffer->packettype == PT_CLIENT2CMD && nodetoplayer2[node] >= 0) + if ((netbuffer->packettype == PT_CLIENT2CMD || netbuffer->packettype == PT_CLIENT2MIS) + && nodetoplayer2[node] >= 0) G_MoveTiccmd(&netcmds[maketic%BACKUPTICS][(UINT8)nodetoplayer2[node]], &netbuffer->u.client2pak.cmd2, 1); From 58236af6f73f535f5071d5fca84457b993239f5d Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 25 May 2017 16:55:59 +0100 Subject: [PATCH 45/52] Tweak to D_MapChange: if you failed to start a server, DON'T send a map change command --- src/d_netcmd.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 478772ed..f2354931 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1569,8 +1569,13 @@ void D_MapChange(INT32 mapnum, INT32 newgametype, boolean pultmode, boolean rese mapchangepending = 0; // spawn the server if needed // reset players if there is a new one - if (!(adminplayer == consoleplayer) && SV_SpawnServer()) - buf[0] &= ~(1<<1); + if (!(adminplayer == consoleplayer)) + { + if (SV_SpawnServer()) + buf[0] &= ~(1<<1); + if (!Playing()) // you failed to start a server somehow, so cancel the map change + return; + } // Kick bot from special stages if (botskin) From a23e9bc32b6357f5e366246dada0aa55c34c235b Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 25 May 2017 18:10:20 +0100 Subject: [PATCH 46/52] Fix size_t printing --- src/d_clisrv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 27fcd067..c095d38a 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3751,8 +3751,8 @@ FILESTAMP // BASEPACKETSIZE + 1 (for size) + textcmd[0] should == datalength if (netbuffer->u.textcmd[0] > (size_t)doomcom->datalength-BASEPACKETSIZE-1) { - DEBFILE(va("GetPacket: Bad Textcmd packet size! (expected %d, actual %d, node %u, player %d)\n", - netbuffer->u.textcmd[0], (size_t)doomcom->datalength-BASEPACKETSIZE-1, + DEBFILE(va("GetPacket: Bad Textcmd packet size! (expected %d, actual %s, node %u, player %d)\n", + netbuffer->u.textcmd[0], sizeu1((size_t)doomcom->datalength-BASEPACKETSIZE-1), node, netconsole)); Net_UnAcknowledgePacket(node); break; From aecc97ded33bbfd7e8e62aca333398a14b3c06d5 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 26 May 2017 13:39:54 +0100 Subject: [PATCH 47/52] PT_REQUESTFILE checking: * if you sent it to a client rather than the server, game over, your connection is closed * if files that don't exist or are too large are requested are listed, game over, your connection is closed (they should have been checked on YOUR side beforehand, silly) * if the server has downloading disabled anyway, ...yeah, you get the idea Don't worry, I made sure Got_RequestFilePak cleaned up the full file request list for the node in case of failure --- src/d_clisrv.c | 7 +++++- src/d_netfil.c | 64 +++++++++++++++++++++++++++++++++++++++++++++----- src/d_netfil.h | 2 +- 3 files changed, 65 insertions(+), 8 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index c095d38a..2fc895c2 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3553,7 +3553,12 @@ static void HandlePacketFromAwayNode(SINT8 node) case PT_REQUESTFILE: if (server) - Got_RequestFilePak(node); + { + if (!cv_downloading.value || !Got_RequestFilePak(node)) + Net_CloseConnection(node); // close connection if one of the requested files could not be sent, or you disabled downloading anyway + } + else + Net_CloseConnection(node); // nope break; case PT_NODETIMEOUT: diff --git a/src/d_netfil.c b/src/d_netfil.c index bf4e5987..777814ce 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -62,7 +62,9 @@ #include -static void SV_SendFile(INT32 node, const char *filename, UINT8 fileid); +// Prototypes +static boolean SV_SendFile(INT32 node, const char *filename, UINT8 fileid); +static void SV_RemoveFileSendList(INT32 node); // Sender structure typedef struct filetx_s @@ -303,7 +305,8 @@ boolean CL_SendRequestFile(void) } // get request filepak and put it on the send queue -void Got_RequestFilePak(INT32 node) +// returns false if a requested file was not found or cannot be sent +boolean Got_RequestFilePak(INT32 node) { char wad[MAX_WADPATH+1]; UINT8 *p = netbuffer->u.textcmd; @@ -314,8 +317,13 @@ void Got_RequestFilePak(INT32 node) if (id == 0xFF) break; READSTRINGN(p, wad, MAX_WADPATH); - SV_SendFile(node, wad, id); + if (!SV_SendFile(node, wad, id)) + { + SV_RemoveFileSendList(node); + return false; // don't read the rest of the files + } } + return true; // no problems with any files } /** Checks if the files needed aren't already loaded or on the disk @@ -480,7 +488,7 @@ static INT32 filestosend = 0; * \sa SV_SendRam * */ -static void SV_SendFile(INT32 node, const char *filename, UINT8 fileid) +static boolean SV_SendFile(INT32 node, const char *filename, UINT8 fileid) { filetx_t **q; // A pointer to the "next" field of the last file in the list filetx_t *p; // The new file request @@ -537,7 +545,7 @@ static void SV_SendFile(INT32 node, const char *filename, UINT8 fileid) free(p->id.filename); free(p); *q = NULL; - return; + return false; // cancel the rest of the requests } // Handle huge file requests (i.e. bigger than cv_maxsend.value KB) @@ -549,7 +557,7 @@ static void SV_SendFile(INT32 node, const char *filename, UINT8 fileid) free(p->id.filename); free(p); *q = NULL; - return; + return false; // cancel the rest of the requests } DEBFILE(va("Sending file %s (id=%d) to %d\n", filename, fileid, node)); @@ -557,6 +565,7 @@ static void SV_SendFile(INT32 node, const char *filename, UINT8 fileid) p->fileid = fileid; p->next = NULL; // End of list filestosend++; + return true; } /** Adds a memory block to the file list for a node @@ -598,6 +607,49 @@ void SV_SendRam(INT32 node, void *data, size_t size, freemethod_t freemethod, UI filestosend++; } +/** Removes all file requests for a node + * This is needed only if a PT_REQUESTFILE's content gave you something that shouldn't be there + * + * \param node The destination + * \sa Got_RequestFilePak + * + */ +static void SV_RemoveFileSendList(INT32 node) +{ + filetx_t *p = transfer[node].txlist; + + if (p == NULL) + return; // ...well, that was easy + + while (p) + { + // Free the file request according to the freemethod parameter used with SV_SendFile/Ram + switch (p->ram) + { + case SF_FILE: // It's a file, close it and free its filename + if (cv_noticedownload.value) + CONS_Printf("Cancelling file transfer for node %d\n", node); + if (transfer[node].currentfile) + fclose(transfer[node].currentfile); + free(p->id.filename); + break; + case SF_Z_RAM: // It's a memory block allocated with Z_Alloc or the likes, use Z_Free + Z_Free(p->id.ram); + break; + case SF_RAM: // It's a memory block allocated with malloc, use free + free(p->id.ram); + case SF_NOFREERAM: // Nothing to free + break; + } + // Remove the file request from the list + transfer[node].txlist = p->next; + free(p); + // Indicate that the transmission is over (if for some reason it had started) + transfer[node].currentfile = NULL; + filestosend--; + } +} + /** Stops sending a file for a node, and removes the file request from the list, * either because the file has been fully sent or because the node was disconnected * diff --git a/src/d_netfil.h b/src/d_netfil.h index c9085a5b..b9b7b2f2 100644 --- a/src/d_netfil.h +++ b/src/d_netfil.h @@ -69,7 +69,7 @@ boolean SV_SendingFile(INT32 node); boolean CL_CheckDownloadable(void); boolean CL_SendRequestFile(void); -void Got_RequestFilePak(INT32 node); +boolean Got_RequestFilePak(INT32 node); void SV_AbortSendFiles(INT32 node); void CloseNetFile(void); From 7979f84e258769cf230610a6cd7b4c0161479ba4 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 26 May 2017 13:58:34 +0100 Subject: [PATCH 48/52] whoops --- src/d_netfil.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/d_netfil.c b/src/d_netfil.c index 777814ce..8704e05c 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -644,6 +644,7 @@ static void SV_RemoveFileSendList(INT32 node) // Remove the file request from the list transfer[node].txlist = p->next; free(p); + p = transfer[node].txlist; // Indicate that the transmission is over (if for some reason it had started) transfer[node].currentfile = NULL; filestosend--; From 569af9f4c13b3124c7821689b612762d727274eb Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 26 May 2017 14:19:18 +0100 Subject: [PATCH 49/52] I am dumb, SV_AbortSendFiles already does what SV_RemoveFileSendList was made to do --- src/d_netfil.c | 47 +---------------------------------------------- 1 file changed, 1 insertion(+), 46 deletions(-) diff --git a/src/d_netfil.c b/src/d_netfil.c index 8704e05c..84e16aa1 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -64,7 +64,6 @@ // Prototypes static boolean SV_SendFile(INT32 node, const char *filename, UINT8 fileid); -static void SV_RemoveFileSendList(INT32 node); // Sender structure typedef struct filetx_s @@ -319,7 +318,7 @@ boolean Got_RequestFilePak(INT32 node) READSTRINGN(p, wad, MAX_WADPATH); if (!SV_SendFile(node, wad, id)) { - SV_RemoveFileSendList(node); + SV_AbortSendFiles(node); return false; // don't read the rest of the files } } @@ -607,50 +606,6 @@ void SV_SendRam(INT32 node, void *data, size_t size, freemethod_t freemethod, UI filestosend++; } -/** Removes all file requests for a node - * This is needed only if a PT_REQUESTFILE's content gave you something that shouldn't be there - * - * \param node The destination - * \sa Got_RequestFilePak - * - */ -static void SV_RemoveFileSendList(INT32 node) -{ - filetx_t *p = transfer[node].txlist; - - if (p == NULL) - return; // ...well, that was easy - - while (p) - { - // Free the file request according to the freemethod parameter used with SV_SendFile/Ram - switch (p->ram) - { - case SF_FILE: // It's a file, close it and free its filename - if (cv_noticedownload.value) - CONS_Printf("Cancelling file transfer for node %d\n", node); - if (transfer[node].currentfile) - fclose(transfer[node].currentfile); - free(p->id.filename); - break; - case SF_Z_RAM: // It's a memory block allocated with Z_Alloc or the likes, use Z_Free - Z_Free(p->id.ram); - break; - case SF_RAM: // It's a memory block allocated with malloc, use free - free(p->id.ram); - case SF_NOFREERAM: // Nothing to free - break; - } - // Remove the file request from the list - transfer[node].txlist = p->next; - free(p); - p = transfer[node].txlist; - // Indicate that the transmission is over (if for some reason it had started) - transfer[node].currentfile = NULL; - filestosend--; - } -} - /** Stops sending a file for a node, and removes the file request from the list, * either because the file has been fully sent or because the node was disconnected * From e09270276ef445a36dae97b147c023b345f63eed Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 26 May 2017 14:38:59 +0100 Subject: [PATCH 50/52] Display node's IP when printing the "sending file to node n" message, if noticedownload is turned on --- src/d_netfil.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_netfil.c b/src/d_netfil.c index 84e16aa1..2c463c0b 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -495,7 +495,7 @@ static boolean SV_SendFile(INT32 node, const char *filename, UINT8 fileid) char wadfilename[MAX_WADPATH]; if (cv_noticedownload.value) - CONS_Printf("Sending file \"%s\" to node %d\n", filename, node); + CONS_Printf("Sending file \"%s\" to node %d (%s)\n", filename, node, I_GetNodeAddress(node)); // Find the last file in the list and set a pointer to its "next" field q = &transfer[node].txlist; From ab5835cd3b325b748a1b514bd6a825264779b982 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 26 May 2017 15:26:00 +0100 Subject: [PATCH 51/52] Remove cruft from my initial days of fumbling with this branch textcmd[0] for PT_NODETIMEOUT can't hold anything < 0 anyway, and you'd probably have to really try to get >= MAXNETNODES --- src/d_clisrv.c | 7 +------ src/d_net.c | 2 -- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 2fc895c2..89418dde 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4004,9 +4004,6 @@ FILESTAMP while (HGetPacket()) { - if (doomcom->remotenode == -1) // ...this should have been ignored already - continue; // might come from PT_NODETIMEOUT somehow though - node = (SINT8)doomcom->remotenode; if (netbuffer->packettype == PT_CLIENTJOIN && server) @@ -4039,10 +4036,8 @@ FILESTAMP if (netbuffer->packettype == PT_PLAYERINFO) continue; // We do nothing with PLAYERINFO, that's for the MS browser. - if (node < 0 || node >= MAXNETNODES) // THIS SHOULDN'T EVEN BE POSSIBLE - ; //CONS_Printf("Received packet from node %d!\n", (int)node); // Packet received from someone already playing - else if (nodeingame[node]) + if (nodeingame[node]) HandlePacketFromPlayer(node); // Packet received from someone not playing else diff --git a/src/d_net.c b/src/d_net.c index 68720f5e..b6914f81 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -1133,8 +1133,6 @@ boolean HGetPacket(void) rebound_tail = (rebound_tail+1) % MAXREBOUND; - if (doomcom->remotenode == -1) // wait hang on what? - return true; // there might still be packets from others though, so don't return false #ifdef DEBUGFILE if (debugfile) DebugPrintpacket("GETLOCAL"); From 4d1af86431b9b7d4f90b314811df7825ac467fe8 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 26 May 2017 15:30:26 +0100 Subject: [PATCH 52/52] Cleanup part 2, make ye old 2.1.18 warning a debugfile only message, and make the node == -1 have its own debugfile only message too Also get rid of a stray newline --- src/d_net.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/d_net.c b/src/d_net.c index b6914f81..50b6c8cf 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -713,7 +713,10 @@ void Net_CloseConnection(INT32 node) boolean forceclose = (node & FORCECLOSE) != 0; if (node == -1) + { + DEBFILE(M_GetText("Net_CloseConnection: node -1 detected!\n")); return; // nope, just ignore it + } node &= ~FORCECLOSE; @@ -722,7 +725,7 @@ void Net_CloseConnection(INT32 node) if (node < 0 || node >= MAXNETNODES) // prevent invalid nodes from crashing the game { - //CONS_Alert(CONS_WARNING, M_GetText("Net_CloseConnection: invalid node %d detected!\n"), node); + DEBFILE(va(M_GetText("Net_CloseConnection: invalid node %d detected!\n"), node)); return; } @@ -1132,7 +1135,6 @@ boolean HGetPacket(void) doomcom->remotenode = 0; rebound_tail = (rebound_tail+1) % MAXREBOUND; - #ifdef DEBUGFILE if (debugfile) DebugPrintpacket("GETLOCAL");