From 0717db3f3112da1e4c96b166bb5f79f5f5f6969f Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Mon, 15 Oct 2018 18:41:34 -0400 Subject: [PATCH 1/4] Prevent spectate griefing If the player count dips below what was stored on the start of the last lap, then don't do time over so that someone can't just spectate at the end of a race out of rage. Y'all are assholes :V --- src/doomstat.h | 1 + src/g_game.c | 1 + src/k_kart.c | 1 + src/p_inter.c | 2 +- src/p_saveg.c | 2 ++ src/p_setup.c | 1 + src/p_spec.c | 13 ++++++++++++- 7 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/doomstat.h b/src/doomstat.h index 296c11bfe..1c5e4aa63 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -461,6 +461,7 @@ extern tic_t indirectitemcooldown; extern tic_t spbincoming; extern UINT8 spbplayer; extern tic_t mapreset; +extern UINT8 nospectategrief; extern boolean legitimateexit; extern boolean comebackshowninfo; diff --git a/src/g_game.c b/src/g_game.c index 8d706bbf3..8e7321866 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -267,6 +267,7 @@ tic_t indirectitemcooldown; // Cooldown before any more Shrink, SPB, or any othe tic_t spbincoming; // Timer before SPB hits, can switch targets at this point UINT8 spbplayer; // Player num that used the last SPB tic_t mapreset; // Map reset delay when enough players have joined an empty game +UINT8 nospectategrief; // How many players need to be in-game to eliminate last; for preventing spectate griefing // Client-sided, unsynched variables (NEVER use in anything that needs to be synced with other players) boolean legitimateexit; // Did this client actually finish the match? diff --git a/src/k_kart.c b/src/k_kart.c index 24acd3f27..ba9ee8396 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -31,6 +31,7 @@ // spbincoming is the timer before k_deathsentence is cast on the player in 1st // spbplayer is the last player who fired a SPB // mapreset is set when enough players fill an empty server +// nospectategrief is the players in-game needed to eliminate the person in last //{ SRB2kart Color Code diff --git a/src/p_inter.c b/src/p_inter.c index cd0ed8938..22141bb95 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -2150,7 +2150,7 @@ boolean P_CheckRacers(void) numplayersingame++; } - if (numplayersingame > 1) // if there's more than one player in-game, this is safe to do + if (numplayersingame >= nospectategrief) // prevent spectate griefing { // check if we just got unlucky and there was only one guy who was a problem for (j = i+1; j < MAXPLAYERS; j++) diff --git a/src/p_saveg.c b/src/p_saveg.c index ffcc8789a..a4a5d6391 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -3273,6 +3273,7 @@ static void P_NetArchiveMisc(void) WRITEUINT32(save_p, spbincoming); WRITEUINT8(save_p, spbplayer); WRITEUINT32(save_p, mapreset); + WRITEUINT8(save_p, nospectategrief); // Is it paused? if (paused) @@ -3379,6 +3380,7 @@ static inline boolean P_NetUnArchiveMisc(void) spbincoming = READUINT32(save_p); spbplayer = READUINT8(save_p); mapreset = READUINT32(save_p); + nospectategrief = READUINT8(save_p); // Is it paused? if (READUINT8(save_p) == 0x2f) diff --git a/src/p_setup.c b/src/p_setup.c index 78a597112..4fe721d70 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3027,6 +3027,7 @@ boolean P_SetupLevel(boolean skipprecip) spbincoming = 0; spbplayer = 0; mapreset = 0; + nospectategrief = 0; // clear special respawning que iquehead = iquetail = 0; diff --git a/src/p_spec.c b/src/p_spec.c index 143efd90b..328156605 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4249,12 +4249,23 @@ DoneSection2: S_StartSound(NULL, sfx_s221); } - // //player->starpostangle = player->starposttime = player->starpostnum = 0; //player->starpostx = player->starposty = player->starpostz = 0; // Play the starpost sound for 'consistency' // S_StartSound(player->mo, sfx_strpst); + + // Figure out how many are playing on the last lap, to prevent spectate griefing + if (!nospectategrief && player->laps == (UINT8)(cv_numlaps.value - 1)) + { + UINT8 i; + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i] || players[i].spectator) + continue; + nospectategrief++; + } + } } else if (player->starpostnum) { From 43656e070423558afb8027c4fcfe77e0d5828d34 Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Tue, 16 Oct 2018 12:23:05 -0400 Subject: [PATCH 2/4] == --> >= --- 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 328156605..8d84a1fe5 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4256,7 +4256,7 @@ DoneSection2: // S_StartSound(player->mo, sfx_strpst); // Figure out how many are playing on the last lap, to prevent spectate griefing - if (!nospectategrief && player->laps == (UINT8)(cv_numlaps.value - 1)) + if (!nospectategrief && player->laps >= (UINT8)(cv_numlaps.value - 1)) { UINT8 i; for (i = 0; i < MAXPLAYERS; i++) From 93f5c5c1f0c42b0b32fd2fa6972a89ffba7b7442 Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Tue, 16 Oct 2018 20:56:04 -0400 Subject: [PATCH 3/4] Prevent point grief (Needs tested) --- src/y_inter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/y_inter.c b/src/y_inter.c index 5d7456dd5..fea9a9b40 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -296,9 +296,9 @@ static void Y_CalculateMatchData(UINT8 rankingsmode, void (*comparison)(INT32)) else data.match.pos[data.match.numplayers] = data.match.numplayers+1; - if (!rankingsmode && !(players[i].pflags & PF_TIMEOVER) && (data.match.pos[data.match.numplayers] != numplayersingame)) + if (!rankingsmode && !(players[i].pflags & PF_TIMEOVER) && (data.match.pos[data.match.numplayers] != nospectategrief)) { - data.match.increase[i] = numplayersingame - data.match.pos[data.match.numplayers]; + data.match.increase[i] = nospectategrief - data.match.pos[data.match.numplayers]; players[i].score += data.match.increase[i]; } From 1a698f65bb3427556c742c3e2b89709b99b9ae04 Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Wed, 17 Oct 2018 13:38:31 -0400 Subject: [PATCH 4/4] < --- src/y_inter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/y_inter.c b/src/y_inter.c index fea9a9b40..6a7e305c2 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -296,7 +296,7 @@ static void Y_CalculateMatchData(UINT8 rankingsmode, void (*comparison)(INT32)) else data.match.pos[data.match.numplayers] = data.match.numplayers+1; - if (!rankingsmode && !(players[i].pflags & PF_TIMEOVER) && (data.match.pos[data.match.numplayers] != nospectategrief)) + if (!rankingsmode && !(players[i].pflags & PF_TIMEOVER) && (data.match.pos[data.match.numplayers] < nospectategrief)) { data.match.increase[i] = nospectategrief - data.match.pos[data.match.numplayers]; players[i].score += data.match.increase[i];