Don't use skincolor unlocks in situations where gamedata is inappropriate

- Recieving a different client's XD_NAMEANDCOLOR
- Loading profiles on game boot
This commit is contained in:
toaster 2023-07-17 15:12:18 +01:00
parent c20a76586c
commit a07a9e2191
6 changed files with 17 additions and 16 deletions

View file

@ -917,7 +917,7 @@ static void COM_Help_f(void)
boolean follower = (cvar->PossibleValue == Followercolor_cons_t);
for (i = SKINCOLOR_NONE; i < numskincolors; ++i)
{
if (K_ColorUsable(i, follower) == true)
if (K_ColorUsable(i, follower, true) == true)
{
CONS_Printf(" %-3d : %s\n", i, skincolors[i].name);
if (i == cvar->value)

View file

@ -1497,9 +1497,9 @@ static void SendNameAndColor(const UINT8 n)
UINT16 sendFollowerColor = cv_followercolor[n].value;
// don't allow inaccessible colors
if (sendColor != SKINCOLOR_NONE && K_ColorUsable(sendColor, false) == false)
if (sendColor != SKINCOLOR_NONE && K_ColorUsable(sendColor, false, true) == false)
{
if (player->skincolor && K_ColorUsable(player->skincolor, false) == true)
if (player->skincolor && K_ColorUsable(player->skincolor, false, true) == true)
{
// Use our previous color
CV_StealthSetValue(&cv_playercolor[n], player->skincolor);
@ -1514,7 +1514,7 @@ static void SendNameAndColor(const UINT8 n)
}
// ditto for follower colour:
if (sendFollowerColor != SKINCOLOR_NONE && K_ColorUsable(sendFollowerColor, true) == false)
if (sendFollowerColor != SKINCOLOR_NONE && K_ColorUsable(sendFollowerColor, true, true) == false)
{
CV_StealthSet(&cv_followercolor[n], "Default"); // set it to "Default". I don't care about your stupidity!
sendFollowerColor = cv_followercolor[n].value;
@ -1724,7 +1724,7 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum)
boolean kick = false;
// don't allow inaccessible colors
if (K_ColorUsable(p->skincolor, false) == false)
if (K_ColorUsable(p->skincolor, false, false) == false)
{
kick = true;
}
@ -6829,7 +6829,7 @@ static void Color_OnChange(const UINT8 p)
I_Assert(p < MAXSPLITSCREENPLAYERS);
UINT16 color = cv_playercolor[p].value;
boolean colorisgood = (color == SKINCOLOR_NONE || K_ColorUsable(color, false) == true);
boolean colorisgood = (color == SKINCOLOR_NONE || K_ColorUsable(color, false, true) == true);
if (Playing() && splitscreen < p)
{

View file

@ -217,11 +217,11 @@ void K_GenerateKartColormap(UINT8 *dest_colormap, INT32 skinnum, UINT8 color)
}
/*--------------------------------------------------
boolean K_ColorUsable(skincolornum_t color, boolean follower)
boolean K_ColorUsable(skincolornum_t color, boolean follower, boolean locked)
See header file for description.
--------------------------------------------------*/
boolean K_ColorUsable(skincolornum_t color, boolean follower)
boolean K_ColorUsable(skincolornum_t color, boolean follower, boolean locked)
{
INT32 i = MAXUNLOCKABLES;
@ -237,7 +237,7 @@ boolean K_ColorUsable(skincolornum_t color, boolean follower)
return false;
}
if (demo.playback)
if (demo.playback || !locked)
{
// Simplifies things elsewhere...
return true;

View file

@ -117,7 +117,7 @@ void K_GenerateKartColormap(UINT8 *dest_colormap, INT32 skinnum, UINT8 color);
/*--------------------------------------------------
boolean K_ColorUsable(skincolornum_t color, skin_t *skin, follower_t *follower);
boolean K_ColorUsable(skincolornum_t color, skin_t *skin, follower_t *follower, boolean locked);
Determines whenever or not we meet the unlockable conditions
to use a certain color.
@ -125,12 +125,13 @@ void K_GenerateKartColormap(UINT8 *dest_colormap, INT32 skinnum, UINT8 color);
Input Arguments:-
color - Color we want to use.
follower - Set to include the special follower-only color options.
locked - use local player's unlocks.
Return:-
true if we can use it, otherwise false.
--------------------------------------------------*/
boolean K_ColorUsable(skincolornum_t color, boolean follower);
boolean K_ColorUsable(skincolornum_t color, boolean follower, boolean locked);
#ifdef __cplusplus

View file

@ -373,7 +373,7 @@ void PR_LoadProfiles(void)
; // Valid, even outside the bounds
}
else if (profilesList[i]->color >= numskincolors
|| K_ColorUsable(profilesList[i]->color, false) == false)
|| K_ColorUsable(profilesList[i]->color, false, false) == false)
{
profilesList[i]->color = PROFILEDEFAULTCOLOR;
}
@ -383,13 +383,13 @@ void PR_LoadProfiles(void)
profilesList[i]->followercolor = READUINT16(save.p);
if (profilesList[i]->followercolor == FOLLOWERCOLOR_MATCH
|| profilesList[i]->followercolor == FOLLOWERCOLOR_OPPOSITE)
|| profilesList[i]->followercolor == FOLLOWERCOLOR_OPPOSITE
|| profilesList[i]->followercolor == SKINCOLOR_NONE)
{
; // Valid, even outside the bounds
}
else if (profilesList[i]->followercolor >= numskincolors
|| profilesList[i]->followercolor == SKINCOLOR_NONE
|| K_ColorUsable(profilesList[i]->followercolor, true) == false)
|| K_ColorUsable(profilesList[i]->followercolor, true, false) == false)
{
profilesList[i]->followercolor = PROFILEDEFAULTFOLLOWERCOLOR;
}

View file

@ -150,7 +150,7 @@ static void M_NewPlayerColors(setup_player_t *p)
// Add all unlocked colors
for (i = SKINCOLOR_NONE+1; i < numskincolors; i++)
{
if (K_ColorUsable(i, follower) == true)
if (K_ColorUsable(i, follower, true) == true)
{
M_PushMenuColor(&p->colors, i);
}