Merge branch 'no-spectate-griefing' into 'master'

Prevent spectate griefing

See merge request KartKrew/Kart!43
This commit is contained in:
Sal 2018-10-19 15:50:18 -04:00
commit 4994e9749f
8 changed files with 21 additions and 4 deletions

View file

@ -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;

View file

@ -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?

View file

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

View file

@ -1951,7 +1951,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++)

View file

@ -3287,6 +3287,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)
@ -3393,6 +3394,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)

View file

@ -3026,6 +3026,7 @@ boolean P_SetupLevel(boolean skipprecip)
spbincoming = 0;
spbplayer = 0;
mapreset = 0;
nospectategrief = 0;
// clear special respawning que
iquehead = iquetail = 0;

View file

@ -4229,12 +4229,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)
{

View file

@ -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];
}