Forbid character-based unlocks if you switched your skin in a context where it didn't auto-spectate you (more robust stop for #1231)

This commit is contained in:
toaster 2024-04-01 18:03:00 +01:00
parent 4f37a3f183
commit b818a7d776
3 changed files with 35 additions and 21 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

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