From 01c48c88d02e265c5972c381f5fcb819c4aff8e6 Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Mon, 15 Oct 2018 18:41:34 -0400 Subject: [PATCH] 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 296c11bf..1c5e4aa6 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 8d706bbf..8e732186 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 24acd3f2..ba9ee839 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 cd0ed893..22141bb9 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 ffcc8789..a4a5d639 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 78a59711..4fe721d7 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 143efd90..32815660 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) {