From 8bb41b787b9cc7d00864594de664e2eedef0a7fa Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 5 Oct 2023 18:12:32 +0100 Subject: [PATCH] Fix SECRET_SKIN locks preventing Rivals from showing up Previously, there was a permanent exception for Eggrobo (the default bot skin). Now that exception is generalised for the specific skin the bot is being assigned, which we assume is intentful and correct. In addition, the randomclass PR_BOTS now controls K_RetireBots as well, matching the other two random calls done for bot skins. --- src/d_clisrv.c | 4 ++-- src/g_demo.c | 2 +- src/k_bot.cpp | 2 +- src/k_grandprix.c | 4 +++- src/r_skins.c | 8 ++++---- src/r_skins.h | 2 +- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 0a2cbf53d..e21da3b4d 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -917,7 +917,7 @@ static boolean CL_SendJoin(void) for (; i < MAXSPLITSCREENPLAYERS; i++) strncpy(netbuffer->u.clientcfg.names[i], va("Player %c", 'A' + i), MAXPLAYERNAME); - memcpy(&netbuffer->u.clientcfg.availabilities, R_GetSkinAvailabilities(false, false), MAXAVAILABILITY*sizeof(UINT8)); + memcpy(&netbuffer->u.clientcfg.availabilities, R_GetSkinAvailabilities(false, -1), MAXAVAILABILITY*sizeof(UINT8)); // Don't leak old signatures from prior sessions. memset(&netbuffer->u.clientcfg.challengeResponse, 0, sizeof(((clientconfig_pak *)0)->challengeResponse)); @@ -4332,7 +4332,7 @@ boolean SV_SpawnServer(void) // strictly speaking, i'm not convinced the following is necessary // but I'm not confident enough to remove it entirely in case it breaks something { - UINT8 *availabilitiesbuffer = R_GetSkinAvailabilities(false, false); + UINT8 *availabilitiesbuffer = R_GetSkinAvailabilities(false, -1); SINT8 node = 0; for (; node < MAXNETNODES; node++) result |= SV_AddWaitingPlayers(node, availabilitiesbuffer, diff --git a/src/g_demo.c b/src/g_demo.c index 95f5a0ac3..2e23d698d 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -2236,7 +2236,7 @@ static void G_SaveDemoSkins(UINT8 **pp) { char skin[16]; UINT8 i; - UINT8 *availabilitiesbuffer = R_GetSkinAvailabilities(true, false); + UINT8 *availabilitiesbuffer = R_GetSkinAvailabilities(true, -1); WRITEUINT8((*pp), numskins); for (i = 0; i < numskins; i++) diff --git a/src/k_bot.cpp b/src/k_bot.cpp index 440a646d0..5ab7d74e9 100644 --- a/src/k_bot.cpp +++ b/src/k_bot.cpp @@ -59,7 +59,7 @@ void K_SetBot(UINT8 newplayernum, UINT8 skinnum, UINT8 difficulty, botStyle_e st playernode[newplayernum] = servernode; // this will permit unlocks - memcpy(&players[newplayernum].availabilities, R_GetSkinAvailabilities(false, true), MAXAVAILABILITY*sizeof(UINT8)); + memcpy(&players[newplayernum].availabilities, R_GetSkinAvailabilities(false, skinnum), MAXAVAILABILITY*sizeof(UINT8)); players[newplayernum].splitscreenindex = 0; players[newplayernum].bot = true; diff --git a/src/k_grandprix.c b/src/k_grandprix.c index f6520ef7a..9f2ed102f 100644 --- a/src/k_grandprix.c +++ b/src/k_grandprix.c @@ -714,11 +714,13 @@ void K_RetireBots(void) if (usableskins > 0) { - UINT8 index = P_RandomKey(PR_RULESCRAMBLE, usableskins); + UINT8 index = P_RandomKey(PR_BOTS, usableskins); skinnum = grabskins[index]; grabskins[index] = grabskins[--usableskins]; } + memcpy(&bot->availabilities, R_GetSkinAvailabilities(false, skinnum), MAXAVAILABILITY*sizeof(UINT8)); + bot->botvars.difficulty = newDifficulty; bot->botvars.diffincrease = 0; diff --git a/src/r_skins.c b/src/r_skins.c index 30c4fa487..0ae7cd9a9 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -185,13 +185,13 @@ void R_InitSkins(void) M_UpdateConditionSetsPending(); } -UINT8 *R_GetSkinAvailabilities(boolean demolock, boolean forbots) +UINT8 *R_GetSkinAvailabilities(boolean demolock, INT32 botforcecharacter) { UINT16 i; UINT8 shif, byte; INT32 skinid; static UINT8 responsebuffer[MAXAVAILABILITY]; - UINT8 defaultbotskin = R_BotDefaultSkin(); + const boolean forbots = (botforcecharacter != -1); memset(&responsebuffer, 0, sizeof(responsebuffer)); @@ -206,7 +206,7 @@ UINT8 *R_GetSkinAvailabilities(boolean demolock, boolean forbots) continue; if ((forbots - ? (M_CheckNetUnlockByID(i) || skinid == defaultbotskin) // Assert the host's lock. + ? (M_CheckNetUnlockByID(i) || skinid == botforcecharacter) // Assert the host's lock. : gamedata->unlocked[i]) // Assert the local lock. != true && !demolock) continue; @@ -451,7 +451,7 @@ void SetPlayerSkinByNum(INT32 playernum, INT32 skinnum) if (P_IsLocalPlayer(player)) CONS_Alert(CONS_WARNING, M_GetText("Requested skin %d not found\n"), skinnum); - else if(server || IsPlayerAdmin(consoleplayer)) + else if (server || IsPlayerAdmin(consoleplayer)) CONS_Alert(CONS_WARNING, "Player %d (%s) skin %d not found\n", playernum, player_names[playernum], skinnum); SetSkin(player, GetPlayerDefaultSkin(playernum)); // not found put the eggman skin diff --git a/src/r_skins.h b/src/r_skins.h index 9a1c45ce6..89f1c2b91 100644 --- a/src/r_skins.h +++ b/src/r_skins.h @@ -113,7 +113,7 @@ void R_PatchSkins(UINT16 wadnum, boolean mainfile); // Access INT32 R_SkinAvailable(const char *name); boolean R_SkinUsable(INT32 playernum, INT32 skinnum, boolean demoskins); -UINT8 *R_GetSkinAvailabilities(boolean demolock, boolean forbots); +UINT8 *R_GetSkinAvailabilities(boolean demolock, INT32 botforcecharacter); // Setting void SetPlayerSkin(INT32 playernum,const char *skinname);