GP bonus round: do not spawn duel mode items TWICE

Level load ordering's a bitch, I explain in the code
comments.
This commit is contained in:
James R 2024-03-07 03:05:44 -08:00
parent c09f55059b
commit d4d2196c73
3 changed files with 12 additions and 10 deletions

View file

@ -125,11 +125,6 @@ void K_TimerReset(void)
g_pointlimit = 0;
}
boolean K_ShouldSpawnDuelItems(void)
{
return (inDuel == true || (grandprixinfo.gp && grandprixinfo.eventmode == GPEVENT_BONUS));
}
static void K_SpawnItemCapsules(void)
{
mapthing_t *mt = mapthings;
@ -281,7 +276,10 @@ void K_TimerInit(void)
timelimitintics = K_TimeLimitForGametype();
g_pointlimit = K_PointLimitForGametype();
if (K_ShouldSpawnDuelItems())
// K_TimerInit is called after all mapthings are spawned,
// so they didn't know if it's supposed to be a duel
// (inDuel is always false before K_TimerInit is called).
if (inDuel)
{
K_SpawnDuelOnlyItems();
}

View file

@ -233,8 +233,6 @@ void K_KartEbrakeVisuals(player_t *p);
void K_HandleDirectionalInfluence(player_t *player);
fixed_t K_DefaultPlayerRadius(player_t *player);
boolean K_ShouldSpawnDuelItems(void);
// sound stuff for lua
void K_PlayAttackTaunt(mobj_t *source);
void K_PlayBoostTaunt(mobj_t *source);

View file

@ -12486,12 +12486,18 @@ static boolean P_AllowMobjSpawn(mapthing_t* mthing, mobjtype_t i)
break;
}
if (!K_ShouldSpawnDuelItems())
// This duel check is tricky.
// At map load, inDuel is always false, because
// K_TimerInit is called afterward. K_TimerInit will then
// spawn all the duel mode objects itself, which ends up
// calling this function again.
// So that's why this check is even here.
if (inDuel == false && (grandprixinfo.gp == false || grandprixinfo.eventmode != GPEVENT_BONUS))
{
if (K_IsDuelItem(i) == true
&& K_DuelItemAlwaysSpawns(mthing) == false)
{
// Only spawns in Duels.
// Only spawns in Duels or GP bonus rounds.
return false;
}
}