From 981b6ac6e54d01cd24a5ac3e14a523fe0c683cbe Mon Sep 17 00:00:00 2001 From: Mefiresu <15063879+Mefiresu@users.noreply.github.com> Date: Sat, 14 Dec 2024 10:54:00 +0100 Subject: [PATCH] Toxomister: Fix cloud not disappearing after being destroyed Player_CheckBadnikBreak() destroys the parent Toxomister entity, we need to keep track of the child cloud before its reference gets lost. More accurate version of #299. Co-authored-by: kapodamy <16857233+kapodamy@users.noreply.github.com> --- SonicMania/Objects/LRZ/Toxomister.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/SonicMania/Objects/LRZ/Toxomister.c b/SonicMania/Objects/LRZ/Toxomister.c index 7dfec7d2..36a73c4f 100644 --- a/SonicMania/Objects/LRZ/Toxomister.c +++ b/SonicMania/Objects/LRZ/Toxomister.c @@ -110,9 +110,10 @@ void Toxomister_CheckPlayerCollisions(void) foreach_active(Player, player) { if (Player_CheckBadnikTouch(player, self, &Toxomister->hitboxBadnik)) { + EntityToxomister *cloud = self->parent; if (Player_CheckBadnikBreak(player, self, true)) { - if (self->parent) - destroyEntity(self->parent); + if (cloud) + destroyEntity(cloud); } } } @@ -123,10 +124,11 @@ void Toxomister_CheckOffScreen(void) RSDK_THIS(Toxomister); if (!RSDK.CheckOnScreen(self, NULL) && !RSDK.CheckPosOnScreen(&self->startPos, &self->updateRange)) { - if (self->parent) + if (self->parent) { destroyEntity(self->parent); + self->parent = NULL; + } - self->parent = NULL; self->position = self->startPos; self->direction = self->startDir;