Bot skin selection fixes

- The case where entries on the end of the `grabskins` list were invalid
- Double ++ for botskinlistpos meant any successful skin-rival placement also guaranteed an Eggrobo (default skin)
This commit is contained in:
toaster 2022-10-12 12:52:08 +01:00
parent 99705faea6
commit df467a4a32

View file

@ -133,7 +133,7 @@ void K_InitGrandPrixBots(void)
UINT8 competitors[MAXSPLITSCREENPLAYERS];
UINT8 usableskins;
UINT8 grabskins[MAXSKINS];
UINT8 grabskins[MAXSKINS+1];
UINT8 botskinlist[MAXPLAYERS];
UINT8 botskinlistpos = 0;
@ -149,6 +149,7 @@ void K_InitGrandPrixBots(void)
{
grabskins[usableskins] = usableskins;
}
grabskins[usableskins] = MAXSKINS;
#if MAXPLAYERS != 16
I_Error("GP bot difficulty levels need rebalanced for the new player count!\n");
@ -221,7 +222,6 @@ void K_InitGrandPrixBots(void)
{
botskinlist[botskinlistpos++] = (UINT8)rivalnum;
grabskins[(UINT8)rivalnum] = MAXSKINS;
botskinlistpos++;
}
}
}
@ -230,9 +230,14 @@ void K_InitGrandPrixBots(void)
// Rearrange usable bot skins list to prevent gaps for randomised selection
for (i = 0; i < usableskins; i++)
{
if (grabskins[i] != MAXSKINS /*&& !K_SkinLocked(usableskins)*/)
if (!(grabskins[i] == MAXSKINS /*|| K_SkinLocked(grabskins[i])*/))
continue;
grabskins[i] = grabskins[--usableskins];
while (usableskins > i && (grabskins[usableskins] == MAXSKINS /*|| K_SkinLocked(grabskins[i])*/))
{
usableskins--;
}
grabskins[i] = grabskins[usableskins];
grabskins[usableskins] = MAXSKINS;
}
// Pad the remaining list with random skins if we need to
@ -508,7 +513,7 @@ void K_RetireBots(void)
SINT8 newDifficulty;
UINT8 usableskins;
UINT8 grabskins[MAXSKINS];
UINT8 grabskins[MAXSKINS+1];
UINT8 i;
@ -523,6 +528,7 @@ void K_RetireBots(void)
{
grabskins[usableskins] = usableskins;
}
grabskins[usableskins] = MAXSKINS;
// Exclude player skins
for (i = 0; i < MAXPLAYERS; i++)
@ -538,9 +544,12 @@ void K_RetireBots(void)
// Rearrange usable bot skins list to prevent gaps for randomised selection
for (i = 0; i < usableskins; i++)
{
if (grabskins[i] != MAXSKINS /*&& !K_SkinLocked(usableskins)*/)
if (!(grabskins[i] == MAXSKINS /*|| K_SkinLocked(grabskins[i])*/))
continue;
grabskins[i] = grabskins[--usableskins];
while (usableskins > i && (grabskins[usableskins] == MAXSKINS /*|| K_SkinLocked(grabskins[i])*/))
usableskins--;
grabskins[i] = grabskins[usableskins];
grabskins[usableskins] = MAXSKINS;
}
if (!grandprixinfo.gp) // Sure, let's let this happen all the time :)