From 37a74cbd9444feece5894925196101f2410fec1c Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Sun, 28 Jan 2018 19:57:38 -0500 Subject: [PATCH] Double-check legitimacy on match completion --- src/doomstat.h | 1 + src/g_game.c | 19 ++++++++++++++----- src/p_user.c | 7 +++++++ 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/doomstat.h b/src/doomstat.h index 7c1367ed..a74e470b 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -445,6 +445,7 @@ extern boolean franticitems; extern boolean mirrormode; extern boolean comeback; extern tic_t curlap, bestlap; +extern boolean legitimateexit; extern tic_t hidetime; diff --git a/src/g_game.c b/src/g_game.c index 81e18197..7a022e5c 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -244,6 +244,8 @@ UINT8 gamespeed; // Game's current speed (or difficulty, or cc, or etc); 0-2 for boolean mirrormode; // Mirror Mode currently enabled? boolean franticitems; // Frantic items currently enabled? boolean comeback; // Battle Mode's karma comeback is on/off + +boolean legitimateexit; // Did this client actually finish the match? Calculated locally tic_t curlap; // Current lap time, calculated locally tic_t bestlap; // Best lap time, locally @@ -2264,14 +2266,19 @@ static inline void G_PlayerFinishLevel(INT32 player) V_SetPaletteLump(GetPalette()); // Reset the palette // SRB2kart: Increment the "matches played" counter. - if (player == consoleplayer && ((!modifiedgame || savemoddata) && !demoplayback)) // SRB2kart: Yes, let stuff unlock stuff in MP + if (player == consoleplayer) { - matchesplayed++; - if (M_UpdateUnlockablesAndExtraEmblems()) + if (legitimateexit && ((!modifiedgame || savemoddata) && !demoplayback)) { - S_StartSound(NULL, sfx_ncitem); - G_SaveGameData(); // only save if unlocked something + matchesplayed++; + if (M_UpdateUnlockablesAndExtraEmblems()) + { + S_StartSound(NULL, sfx_ncitem); + G_SaveGameData(); // only save if unlocked something + } } + + legitimateexit = false; } } @@ -3892,6 +3899,8 @@ void G_InitNew(UINT8 pultmode, const char *mapname, boolean resetplayer, boolean if (netgame || multiplayer) // Nice try, haxor. ultimatemode = false; + legitimateexit = false; // SRB2Kart + if (!demoplayback && !netgame) // Netgame sets random seed elsewhere, demo playback sets seed just before us! P_SetRandSeed(M_RandomizedSeed()); // Use a more "Random" random seed diff --git a/src/p_user.c b/src/p_user.c index d434a6bf..978ee1b9 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1645,6 +1645,13 @@ void P_DoPlayerExit(player_t *player) if (player->exiting) return; + if ((player == &players[consoleplayer] + || (splitscreen && player == &players[secondarydisplayplayer]) + || (splitscreen > 1 && player == &players[thirddisplayplayer]) + || (splitscreen > 2 && player == &players[fourthdisplayplayer])) + && (!player->spectator && ((!modifiedgame || savemoddata) && !demoplayback))) + legitimateexit = true; + if (gametype == GT_RACE || gametype == GT_COMPETITION) // If in Race Mode, allow { // SRB2kart 120217