mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-27 12:31:54 +00:00
K_RetireBots revamp (resolves #1615)
- All Shuffle Loser code first - Replace all NOCONTESTed CPU per previous behaviour - Fix "0"-prefixed character regression - Instead of tying it to GP specifically, simply don't shuffle bots/players past the final (non-special) round of the Queue
This commit is contained in:
parent
1867079623
commit
4bbaab0381
1 changed files with 108 additions and 91 deletions
|
|
@ -718,99 +718,29 @@ static boolean CompareReplacements(player_t *a, player_t *b)
|
||||||
--------------------------------------------------*/
|
--------------------------------------------------*/
|
||||||
void K_RetireBots(void)
|
void K_RetireBots(void)
|
||||||
{
|
{
|
||||||
const UINT8 defaultbotskin = R_BotDefaultSkin();
|
|
||||||
SINT8 newDifficulty;
|
|
||||||
|
|
||||||
UINT8 usableskins, skincount = (demo.playback ? demo.numskins : numskins);
|
|
||||||
UINT8 grabskins[MAXSKINS+1];
|
|
||||||
|
|
||||||
UINT8 i;
|
UINT8 i;
|
||||||
|
|
||||||
if (grandprixinfo.gp == true
|
if (grandprixinfo.gp == true
|
||||||
&& (grandprixinfo.eventmode != GPEVENT_NONE
|
&& grandprixinfo.eventmode != GPEVENT_NONE)
|
||||||
|| (grandprixinfo.cup != NULL
|
|
||||||
&& roundqueue.size > 0
|
|
||||||
&& roundqueue.roundnum >= grandprixinfo.cup->numlevels)))
|
|
||||||
{
|
{
|
||||||
// No replacement.
|
// Bots can't do anything here, replacement means they never get their spotlight.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init usable bot skins list
|
if (roundqueue.size > 0)
|
||||||
for (usableskins = 0; usableskins < skincount; usableskins++)
|
|
||||||
{
|
{
|
||||||
grabskins[usableskins] = usableskins;
|
// Get the last non-special entry
|
||||||
}
|
i = roundqueue.size;
|
||||||
grabskins[usableskins] = MAXSKINS;
|
while (--i > roundqueue.position)
|
||||||
|
|
||||||
// Exclude player skins
|
|
||||||
for (i = 0; i < MAXPLAYERS; i++)
|
|
||||||
{
|
|
||||||
if (!playeringame[i])
|
|
||||||
continue;
|
|
||||||
if (players[i].spectator)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
grabskins[players[i].skin] = MAXSKINS;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Rearrange usable bot skins list to prevent gaps for randomised selection
|
|
||||||
for (i = 0; i < usableskins; i++)
|
|
||||||
{
|
|
||||||
if (!(grabskins[i] == MAXSKINS || !R_SkinUsable(-1, grabskins[i], true)))
|
|
||||||
continue;
|
|
||||||
while (usableskins > i && (grabskins[usableskins] == MAXSKINS || !R_SkinUsable(-1, grabskins[usableskins], true)))
|
|
||||||
usableskins--;
|
|
||||||
grabskins[i] = grabskins[usableskins];
|
|
||||||
grabskins[usableskins] = MAXSKINS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (grandprixinfo.gp) // Sure, let's let this happen all the time :)
|
|
||||||
{
|
|
||||||
if (grandprixinfo.masterbots == true)
|
|
||||||
{
|
{
|
||||||
newDifficulty = MAXBOTDIFFICULTY;
|
if (!roundqueue.entries[i].rankrestricted)
|
||||||
}
|
break;
|
||||||
else
|
|
||||||
{
|
|
||||||
const UINT8 startingdifficulty = K_BotStartingDifficulty(grandprixinfo.gamespeed);
|
|
||||||
newDifficulty = startingdifficulty - 4;
|
|
||||||
if (roundqueue.size > 0)
|
|
||||||
{
|
|
||||||
newDifficulty += roundqueue.roundnum;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
newDifficulty = cv_kartbot.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newDifficulty > MAXBOTDIFFICULTY)
|
|
||||||
{
|
|
||||||
newDifficulty = MAXBOTDIFFICULTY;
|
|
||||||
}
|
|
||||||
else if (newDifficulty < 1)
|
|
||||||
{
|
|
||||||
newDifficulty = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < MAXPLAYERS; i++)
|
|
||||||
{
|
|
||||||
player_t *bot = NULL;
|
|
||||||
|
|
||||||
if (!playeringame[i] || !players[i].bot || players[i].spectator)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bot = &players[i];
|
if (roundqueue.position >= i)
|
||||||
|
|
||||||
if (bot->pflags & PF_NOCONTEST)
|
|
||||||
{
|
{
|
||||||
// HACK!!!!! two days to end of cleanup period :)
|
// Out of non-special entries, no replacement.
|
||||||
// we do this so that any bot that's been removed doesn't count for K_SetNameForBot conflicts
|
return;
|
||||||
player_names[i][0] = '0';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -861,8 +791,6 @@ void K_RetireBots(void)
|
||||||
std::stable_sort(humans.begin(), humans.end(), CompareReplacements);
|
std::stable_sort(humans.begin(), humans.end(), CompareReplacements);
|
||||||
std::stable_sort(bots.begin(), bots.end(), CompareReplacements);
|
std::stable_sort(bots.begin(), bots.end(), CompareReplacements);
|
||||||
|
|
||||||
boolean did_replacement = false;
|
|
||||||
|
|
||||||
if (G_GametypeHasSpectators() == true && grandprixinfo.gp == false && cv_shuffleloser.value != 0)
|
if (G_GametypeHasSpectators() == true && grandprixinfo.gp == false && cv_shuffleloser.value != 0)
|
||||||
{
|
{
|
||||||
// While joiners and players still exist, insert joiners.
|
// While joiners and players still exist, insert joiners.
|
||||||
|
|
@ -911,24 +839,113 @@ void K_RetireBots(void)
|
||||||
// Add our waiting-to-play spectator to the game.
|
// Add our waiting-to-play spectator to the game.
|
||||||
P_SpectatorJoinGame(joiner);
|
P_SpectatorJoinGame(joiner);
|
||||||
|
|
||||||
did_replacement = true;
|
|
||||||
replacements--;
|
replacements--;
|
||||||
num_joining--;
|
num_joining--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (did_replacement == true)
|
// No need to run any of this code if no bots afoot
|
||||||
|
if (bots.size() == 0)
|
||||||
{
|
{
|
||||||
// No need to run the bot swapping code,
|
|
||||||
// we already replaced the loser.
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace last place bot.
|
// Remove all still-in-contestors
|
||||||
if (bots.size() > 0)
|
bots.erase(std::remove_if(bots.begin(), bots.end(),
|
||||||
{
|
[](player_t *bot) {
|
||||||
player_t *bot = bots.back();
|
return (
|
||||||
|
bot->spectator
|
||||||
|
|| !(bot->pflags & PF_NOCONTEST)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
), bots.end());
|
||||||
|
|
||||||
|
// No need to run any of this code if no *NO-CONTESTORS* afoot
|
||||||
|
if (bots.size() == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Okay, now this is essentially the original contents of K_RetireBots with cpp swag
|
||||||
|
|
||||||
|
const UINT8 defaultbotskin = R_BotDefaultSkin();
|
||||||
|
SINT8 newDifficulty;
|
||||||
|
|
||||||
|
UINT8 usableskins, skincount = (demo.playback ? demo.numskins : numskins);
|
||||||
|
UINT8 grabskins[MAXSKINS+1];
|
||||||
|
|
||||||
|
// Handle adjusting difficulty for new bots
|
||||||
|
{
|
||||||
|
if (grandprixinfo.gp) // Sure, let's let this happen all the time :)
|
||||||
|
{
|
||||||
|
if (grandprixinfo.masterbots == true)
|
||||||
|
{
|
||||||
|
newDifficulty = MAXBOTDIFFICULTY;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const UINT8 startingdifficulty = K_BotStartingDifficulty(grandprixinfo.gamespeed);
|
||||||
|
newDifficulty = startingdifficulty - 4;
|
||||||
|
if (roundqueue.size > 0)
|
||||||
|
{
|
||||||
|
newDifficulty += roundqueue.roundnum;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newDifficulty = cv_kartbot.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newDifficulty > MAXBOTDIFFICULTY)
|
||||||
|
{
|
||||||
|
newDifficulty = MAXBOTDIFFICULTY;
|
||||||
|
}
|
||||||
|
else if (newDifficulty < 1)
|
||||||
|
{
|
||||||
|
newDifficulty = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// HACK!!!!! that survived allll the way since two days to end of cleanup period :)
|
||||||
|
// we do this so that any bot that's been removed doesn't count for K_SetNameForBot conflicts
|
||||||
|
for (player_t *bot : bots)
|
||||||
|
{
|
||||||
|
player_names[(bot-players)][0] = '0';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Init usable bot skins list
|
||||||
|
for (usableskins = 0; usableskins < skincount; usableskins++)
|
||||||
|
{
|
||||||
|
grabskins[usableskins] = usableskins;
|
||||||
|
}
|
||||||
|
grabskins[usableskins] = MAXSKINS;
|
||||||
|
|
||||||
|
// Exclude player skins
|
||||||
|
for (i = 0; i < MAXPLAYERS; i++)
|
||||||
|
{
|
||||||
|
if (!playeringame[i])
|
||||||
|
continue;
|
||||||
|
if (players[i].spectator)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
grabskins[players[i].skin] = MAXSKINS;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rearrange usable bot skins list to prevent gaps for randomised selection
|
||||||
|
for (i = 0; i < usableskins; i++)
|
||||||
|
{
|
||||||
|
if (!(grabskins[i] == MAXSKINS || !R_SkinUsable(-1, grabskins[i], true)))
|
||||||
|
continue;
|
||||||
|
while (usableskins > i && (grabskins[usableskins] == MAXSKINS || !R_SkinUsable(-1, grabskins[usableskins], true)))
|
||||||
|
usableskins--;
|
||||||
|
grabskins[i] = grabskins[usableskins];
|
||||||
|
grabskins[usableskins] = MAXSKINS;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Replace nocontested bots.
|
||||||
|
for (player_t *bot : bots)
|
||||||
|
{
|
||||||
UINT8 skinnum = defaultbotskin;
|
UINT8 skinnum = defaultbotskin;
|
||||||
|
|
||||||
if (usableskins > 0)
|
if (usableskins > 0)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue