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.
This commit is contained in:
toaster 2023-10-05 18:12:32 +01:00
parent b937b1a7bc
commit 8bb41b787b
6 changed files with 12 additions and 10 deletions

View file

@ -917,7 +917,7 @@ static boolean CL_SendJoin(void)
for (; i < MAXSPLITSCREENPLAYERS; i++) for (; i < MAXSPLITSCREENPLAYERS; i++)
strncpy(netbuffer->u.clientcfg.names[i], va("Player %c", 'A' + i), MAXPLAYERNAME); 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. // Don't leak old signatures from prior sessions.
memset(&netbuffer->u.clientcfg.challengeResponse, 0, sizeof(((clientconfig_pak *)0)->challengeResponse)); 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 // 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 // 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; SINT8 node = 0;
for (; node < MAXNETNODES; node++) for (; node < MAXNETNODES; node++)
result |= SV_AddWaitingPlayers(node, availabilitiesbuffer, result |= SV_AddWaitingPlayers(node, availabilitiesbuffer,

View file

@ -2236,7 +2236,7 @@ static void G_SaveDemoSkins(UINT8 **pp)
{ {
char skin[16]; char skin[16];
UINT8 i; UINT8 i;
UINT8 *availabilitiesbuffer = R_GetSkinAvailabilities(true, false); UINT8 *availabilitiesbuffer = R_GetSkinAvailabilities(true, -1);
WRITEUINT8((*pp), numskins); WRITEUINT8((*pp), numskins);
for (i = 0; i < numskins; i++) for (i = 0; i < numskins; i++)

View file

@ -59,7 +59,7 @@ void K_SetBot(UINT8 newplayernum, UINT8 skinnum, UINT8 difficulty, botStyle_e st
playernode[newplayernum] = servernode; playernode[newplayernum] = servernode;
// this will permit unlocks // 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].splitscreenindex = 0;
players[newplayernum].bot = true; players[newplayernum].bot = true;

View file

@ -714,11 +714,13 @@ void K_RetireBots(void)
if (usableskins > 0) if (usableskins > 0)
{ {
UINT8 index = P_RandomKey(PR_RULESCRAMBLE, usableskins); UINT8 index = P_RandomKey(PR_BOTS, usableskins);
skinnum = grabskins[index]; skinnum = grabskins[index];
grabskins[index] = grabskins[--usableskins]; grabskins[index] = grabskins[--usableskins];
} }
memcpy(&bot->availabilities, R_GetSkinAvailabilities(false, skinnum), MAXAVAILABILITY*sizeof(UINT8));
bot->botvars.difficulty = newDifficulty; bot->botvars.difficulty = newDifficulty;
bot->botvars.diffincrease = 0; bot->botvars.diffincrease = 0;

View file

@ -185,13 +185,13 @@ void R_InitSkins(void)
M_UpdateConditionSetsPending(); M_UpdateConditionSetsPending();
} }
UINT8 *R_GetSkinAvailabilities(boolean demolock, boolean forbots) UINT8 *R_GetSkinAvailabilities(boolean demolock, INT32 botforcecharacter)
{ {
UINT16 i; UINT16 i;
UINT8 shif, byte; UINT8 shif, byte;
INT32 skinid; INT32 skinid;
static UINT8 responsebuffer[MAXAVAILABILITY]; static UINT8 responsebuffer[MAXAVAILABILITY];
UINT8 defaultbotskin = R_BotDefaultSkin(); const boolean forbots = (botforcecharacter != -1);
memset(&responsebuffer, 0, sizeof(responsebuffer)); memset(&responsebuffer, 0, sizeof(responsebuffer));
@ -206,7 +206,7 @@ UINT8 *R_GetSkinAvailabilities(boolean demolock, boolean forbots)
continue; continue;
if ((forbots 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. : gamedata->unlocked[i]) // Assert the local lock.
!= true && !demolock) != true && !demolock)
continue; continue;
@ -451,7 +451,7 @@ void SetPlayerSkinByNum(INT32 playernum, INT32 skinnum)
if (P_IsLocalPlayer(player)) if (P_IsLocalPlayer(player))
CONS_Alert(CONS_WARNING, M_GetText("Requested skin %d not found\n"), skinnum); 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); 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 SetSkin(player, GetPlayerDefaultSkin(playernum)); // not found put the eggman skin

View file

@ -113,7 +113,7 @@ void R_PatchSkins(UINT16 wadnum, boolean mainfile);
// Access // Access
INT32 R_SkinAvailable(const char *name); INT32 R_SkinAvailable(const char *name);
boolean R_SkinUsable(INT32 playernum, INT32 skinnum, boolean demoskins); boolean R_SkinUsable(INT32 playernum, INT32 skinnum, boolean demoskins);
UINT8 *R_GetSkinAvailabilities(boolean demolock, boolean forbots); UINT8 *R_GetSkinAvailabilities(boolean demolock, INT32 botforcecharacter);
// Setting // Setting
void SetPlayerSkin(INT32 playernum,const char *skinname); void SetPlayerSkin(INT32 playernum,const char *skinname);