From a07a9e219195d75d0a7cd251dce6faa352430b86 Mon Sep 17 00:00:00 2001 From: toaster Date: Mon, 17 Jul 2023 15:12:18 +0100 Subject: [PATCH] Don't use skincolor unlocks in situations where gamedata is inappropriate - Recieving a different client's XD_NAMEANDCOLOR - Loading profiles on game boot --- src/command.c | 2 +- src/d_netcmd.c | 10 +++++----- src/k_color.c | 6 +++--- src/k_color.h | 5 +++-- src/k_profiles.c | 8 ++++---- src/menus/play-char-select.c | 2 +- 6 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/command.c b/src/command.c index 7184ace42..1a6c74806 100644 --- a/src/command.c +++ b/src/command.c @@ -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) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 823099cf6..e6c36578d 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -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) { diff --git a/src/k_color.c b/src/k_color.c index 9078fc6bc..27d597f87 100644 --- a/src/k_color.c +++ b/src/k_color.c @@ -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; diff --git a/src/k_color.h b/src/k_color.h index b835f9194..a66626f62 100644 --- a/src/k_color.h +++ b/src/k_color.h @@ -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 diff --git a/src/k_profiles.c b/src/k_profiles.c index 63dccc8b7..f0a0a8e89 100644 --- a/src/k_profiles.c +++ b/src/k_profiles.c @@ -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; } diff --git a/src/menus/play-char-select.c b/src/menus/play-char-select.c index 111c24ed8..257f0ad06 100644 --- a/src/menus/play-char-select.c +++ b/src/menus/play-char-select.c @@ -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); }