Merge branch 'challenge-reskin' into 'master'

Halt skin-switching Challenge cheese (resolves #1231)

Closes #1231

See merge request KartKrew/Kart!2206
This commit is contained in:
James R. 2024-04-02 00:39:23 +00:00
commit 96948258d2
4 changed files with 42 additions and 24 deletions

View file

@ -1203,11 +1203,17 @@ static void Got_NameAndColor(const UINT8 **cp, INT32 playernum)
// The following is a miniature subset of Got_Teamchange.
if ((gamestate == GS_LEVEL) // In a level?
&& (cv_restrictskinchange.value) // Skin changes are restricted?
&& (G_GametypeHasSpectators() && players[playernum].spectator == false) // not a spectator but could be?
&& (players[playernum].jointime > 1) // permit on join
&& (leveltime > introtime) // permit during intro turnaround
&& (players[playernum].skin != oldskin)) // a skin change actually happened?
{
players[playernum].roundconditions.switched_skin = true;
if (
cv_restrictskinchange.value // Skin changes are restricted?
&& G_GametypeHasSpectators() // not a spectator...
&& players[playernum].spectator == false // ...but could be?
)
{
for (i = 0; i < MAXPLAYERS; ++i)
{
@ -1234,6 +1240,7 @@ static void Got_NameAndColor(const UINT8 **cp, INT32 playernum)
}
}
}
}
// set follower colour:
// Don't bother doing garbage and kicking if we receive None,

View file

@ -464,6 +464,9 @@ struct roundconditions_t
// 32 triggers, one bit each, for map execution
UINT32 unlocktriggers;
// Forbidding skin-based unlocks if you changed your skin
boolean switched_skin;
};
// player_t struct for all skybox variables

View file

@ -2267,6 +2267,8 @@ void G_PlayerReborn(INT32 player, boolean betweenmaps)
rings = 5;
}
saveroundconditions = false;
if (betweenmaps || leveltime < introtime)
{
K_StopRoulette(&itemRoulette);
@ -2288,7 +2290,6 @@ void G_PlayerReborn(INT32 player, boolean betweenmaps)
lastsafecheatcheck = 0;
bigwaypointgap = 0;
saveroundconditions = false;
tallyactive = false;
}
else
@ -2328,8 +2329,11 @@ void G_PlayerReborn(INT32 player, boolean betweenmaps)
pflags |= (players[player].pflags & (PF_STASIS|PF_ELIMINATED|PF_NOCONTEST|PF_FAULT|PF_LOSTLIFE));
if (spectator == false)
{
memcpy(&roundconditions, &players[player].roundconditions, sizeof (roundconditions));
saveroundconditions = true;
}
lastsafelap = players[player].lastsafelap;
lastsafecheatcheck = players[player].lastsafecheatcheck;

View file

@ -1649,9 +1649,13 @@ boolean M_CheckCondition(condition_t *cn, player_t *player)
case UCRP_ISMAP:
return (gamemap == cn->requirement+1);
case UCRP_ISCHARACTER:
return (player->skin == cn->requirement);
return (
player->roundconditions.switched_skin == false
&& player->skin == cn->requirement
);
case UCRP_ISENGINECLASS:
return (player->skin < numskins
return (player->roundconditions.switched_skin == false
&& player->skin < numskins
&& R_GetEngineClass(
skins[player->skin].kartspeed,
skins[player->skin].kartweight,