From 19e9eedce3e0d89ac056be4d767e9ae3a83ffa49 Mon Sep 17 00:00:00 2001 From: MIDIMan Date: Sun, 19 Jul 2026 16:54:58 -0400 Subject: [PATCH] Fix NiGHTS hoops crashing the game for mid-level netgame joiners --- src/p_inter.c | 16 +++++++++------- src/p_setup.c | 16 +++++++++++----- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/p_inter.c b/src/p_inter.c index 856050959..0cf70f7a0 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -883,18 +883,20 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) break; case MT_HOOPCOLLIDE: // This produces a kind of 'domino effect' with the hoop's pieces. - for (; special->hprev != NULL; special = special->hprev); // Move to the first sprite in the hoop - + for (; special != NULL && special->hprev != NULL; special = special->hprev); // Move to the first sprite in the hoop i = 0; - for (; special->hnext != NULL && special->type == MT_HOOP; special = special->hnext) + for (; special != NULL && special->type == MT_HOOP; special = special->hnext) { - if (!P_MobjWasRemoved(special->target)) + if (!P_MobjWasRemoved(special)) { special->fuse = 11; special->movedir = i; - special->extravalue1 = special->target->extravalue1; - special->extravalue2 = special->target->extravalue2; - special->target->threshold = 4242; + if (!P_MobjWasRemoved(special->target)) + { + special->extravalue1 = special->target->extravalue1; + special->extravalue2 = special->target->extravalue2; + special->target->threshold = 4242; + } } i++; } diff --git a/src/p_setup.c b/src/p_setup.c index affc6b53f..4d7eed838 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -962,7 +962,7 @@ static void P_SpawnEmeraldHunt(void) } } -static void P_SpawnMapThings(void) +static void P_SpawnMapThings(boolean spawnhoops) { size_t i; mapthing_t *mt; @@ -1008,10 +1008,16 @@ static void P_SpawnMapThings(void) // spawn hoops if (mt->type == 1705 || mt->type == 1713) { - // Z for objects Tails 05-26-2002 - mt->z = (INT16)(mtsector->floorheight >> FRACBITS); + // Check for spawnhoops here so the hoops don't spawn ghost variants for players joining a netgame mid-level + // ...It's a long story. + if (spawnhoops) + { + // Z for objects Tails 05-26-2002 + mt->z = (INT16)(mtsector->floorheight >> FRACBITS); + + P_SpawnHoops(mt); + } - P_SpawnHoops(mt); continue; } @@ -3082,7 +3088,7 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) // a shit ton of time loading mobj thinkers. CalculateDoomednumToMobjtype(); - P_SpawnMapThings(); + P_SpawnMapThings(!fromnetsave); P_SpawnEmblems(!fromnetsave);