K_SetBot: check spectator status on first round of GP

Fixes map warp to Prisons or Sealed Stars, since these
create a 1-round GP.
This commit is contained in:
James R. 2023-09-08 03:24:18 -07:00
parent eff847b216
commit 172c3861f4
3 changed files with 36 additions and 1 deletions

View file

@ -63,6 +63,10 @@ void K_SetBot(UINT8 newplayernum, UINT8 skinnum, UINT8 difficulty, botStyle_e st
players[newplayernum].botvars.style = style;
players[newplayernum].lives = 9;
// The bot may immediately become a spectator AT THE START of a GP.
// For each subsequent round of GP, K_UpdateGrandPrixBots will handle this.
players[newplayernum].spectator = grandprixinfo.gp && grandprixinfo.initalize && K_BotDefaultSpectator();
players[newplayernum].skincolor = skins[skinnum].prefcolor;
sprintf(player_names[newplayernum], "%s", skins[skinnum].realname);
SetPlayerSkinByNum(newplayernum, skinnum);

View file

@ -308,7 +308,7 @@ void K_LoadGrandPrixSaveGame(void)
players[i].botvars.rival = savedata.bots[i].rival;
players[i].score = savedata.bots[i].score;
players[i].spectator = !(gametyperules & GTR_BOTS) || (grandprixinfo.eventmode != GPEVENT_NONE);
players[i].spectator = K_BotDefaultSpectator();
}
}
@ -898,3 +898,25 @@ void K_PlayerFinishGrandPrix(player_t *player)
P_GivePlayerLives(player, player->xtralife);
}
/*--------------------------------------------------
boolean K_BotDefaultSpectator(player_t *player);
See header file for description.
--------------------------------------------------*/
boolean K_BotDefaultSpectator(void)
{
if (!(gametyperules & GTR_BOTS))
{
// This gametype does not support bots.
return true;
}
if (grandprixinfo.eventmode != GPEVENT_NONE)
{
// This is a special round of GP, so bots must spectate.
return true;
}
return false;
}

View file

@ -206,6 +206,15 @@ boolean K_CanChangeRules(boolean allowdemos);
void K_PlayerFinishGrandPrix(player_t *player);
/*--------------------------------------------------
boolean K_BotDefaultSpectator(void)
Check whether bots should spectate this round.
--------------------------------------------------*/
boolean K_BotDefaultSpectator(void);
#ifdef __cplusplus
} // extern "C"
#endif