Double-check legitimacy on match completion

This commit is contained in:
TehRealSalt 2018-01-28 19:57:38 -05:00
parent e27a60847e
commit 37a74cbd94
3 changed files with 22 additions and 5 deletions

View file

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

View file

@ -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,7 +2266,9 @@ 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)
{
if (legitimateexit && ((!modifiedgame || savemoddata) && !demoplayback))
{
matchesplayed++;
if (M_UpdateUnlockablesAndExtraEmblems())
@ -2273,6 +2277,9 @@ static inline void G_PlayerFinishLevel(INT32 player)
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

View file

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