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,33 +1203,40 @@ 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?
{
for (i = 0; i < MAXPLAYERS; ++i)
{
if (i == playernum)
continue;
if (!playeringame[i])
continue;
if (players[i].spectator)
continue;
break;
}
players[playernum].roundconditions.switched_skin = true;
if (i != MAXPLAYERS // Someone on your server who isn't you?
&& LUA_HookTeamSwitch(&players[playernum], 0, false, false, false)) // fiiiine, lua can except it
if (
cv_restrictskinchange.value // Skin changes are restricted?
&& G_GametypeHasSpectators() // not a spectator...
&& players[playernum].spectator == false // ...but could be?
)
{
P_DamageMobj(players[playernum].mo, NULL, NULL, 1, DMG_SPECTATOR);
if (players[i].spectator)
for (i = 0; i < MAXPLAYERS; ++i)
{
HU_AddChatText(va("\x82*%s became a spectator.", player_names[playernum]), false);
if (i == playernum)
continue;
if (!playeringame[i])
continue;
if (players[i].spectator)
continue;
break;
}
FinalisePlaystateChange(playernum);
if (i != MAXPLAYERS // Someone on your server who isn't you?
&& LUA_HookTeamSwitch(&players[playernum], 0, false, false, false)) // fiiiine, lua can except it
{
P_DamageMobj(players[playernum].mo, NULL, NULL, 1, DMG_SPECTATOR);
if (players[i].spectator)
{
HU_AddChatText(va("\x82*%s became a spectator.", player_names[playernum]), false);
FinalisePlaystateChange(playernum);
}
}
}
}

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));
memcpy(&roundconditions, &players[player].roundconditions, sizeof (roundconditions));
saveroundconditions = true;
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,