From 7b7cbbbf26c39a68a551af7a852c2884bec25aaa Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sat, 1 Oct 2022 22:58:58 -0400 Subject: [PATCH] Fix oddities with duel items not always spawning --- src/k_kart.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ src/k_kart.h | 3 +++ src/p_mobj.c | 28 ++++++++++++---------------- 3 files changed, 64 insertions(+), 16 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 66432ad54..645aee529 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -49,10 +49,53 @@ // battlewanted is an array of the WANTED player nums, -1 for no player in that slot // mapreset is set when enough players fill an empty server +boolean K_IsDuelItem(mobjtype_t type) +{ + switch (type) + { + case MT_DUELBOMB: + case MT_BANANA: + case MT_EGGMANITEM: + case MT_SSMINE: + case MT_LANDMINE: + case MT_HYUDORO_CENTER: + case MT_DROPTARGET: + case MT_POGOSPRING: + return true; + + default: + return false; + } +} + +boolean K_DuelItemAlwaysSpawns(mapthing_t *mt) +{ + return (mt->options & MTF_EXTRA); +} + +static void K_SpawnDuelOnlyItems(void) +{ + mapthing_t *mt = NULL; + size_t i; + + mt = mapthings; + for (i = 0; i < nummapthings; i++, mt++) + { + mobjtype_t type = P_GetMobjtype(mt->type); + + if (K_IsDuelItem(type) == true + && K_DuelItemAlwaysSpawns(mt) == false) + { + P_SpawnMapThing(mt); + } + } +} + void K_TimerReset(void) { starttime = introtime = 3; numbulbs = 1; + inDuel = false; } void K_TimerInit(void) @@ -109,6 +152,12 @@ void K_TimerInit(void) // NOW you can try to spawn in the Battle capsules, if there's not enough players for a match K_BattleInit(); + + if (inDuel == true) + { + K_SpawnDuelOnlyItems(); + } + //CONS_Printf("numbulbs set to %d (%d players, %d spectators) on tic %d\n", numbulbs, numPlayers, numspec, leveltime); } diff --git a/src/k_kart.h b/src/k_kart.h index 7973a236c..a5d2b0185 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -38,6 +38,9 @@ angle_t K_ReflectAngle(angle_t angle, angle_t against, fixed_t maxspeed, fixed_t void K_RegisterKartStuff(void); +boolean K_IsDuelItem(mobjtype_t type); +boolean K_DuelItemAlwaysSpawns(mapthing_t *mt); + void K_TimerReset(void); void K_TimerInit(void); UINT32 K_GetPlayerDontDrawFlag(player_t *player); diff --git a/src/p_mobj.c b/src/p_mobj.c index c3e8795b6..12a484218 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -11755,30 +11755,26 @@ static boolean P_AllowMobjSpawn(mapthing_t* mthing, mobjtype_t i) return false; } break; - case MT_DUELBOMB: - case MT_BANANA: - case MT_EGGMANITEM: - case MT_SSMINE: - case MT_LANDMINE: - case MT_HYUDORO_CENTER: - case MT_DROPTARGET: - case MT_POGOSPRING: - { - // Duel objects. - // Normally only spawn when placed by the map in Duels, - // but can be forced to always spawn with the Extra flag. - if (inDuel == false && !(mthing->options & MTF_EXTRA)) - return false; - } - break; default: break; } + if (inDuel == false) + { + if (K_IsDuelItem(i) == true + && K_DuelItemAlwaysSpawns(mthing) == false) + { + // Only spawns in Duels. + return false; + } + } + // No bosses outside of a combat situation. // (just in case we want boss arenas to do double duty as battle maps) if (!bossinfo.boss && (mobjinfo[i].flags & MF_BOSS)) + { return false; + } if (metalrecording) // Metal Sonic can't use these things. {