Skip to content

Commit

Permalink
Toxomister: Fix cloud not disappearing after being destroyed
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Mefiresu and kapodamy committed Dec 14, 2024
1 parent 952056c commit 981b6ac
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions SonicMania/Objects/LRZ/Toxomister.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand All @@ -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;

Expand Down

0 comments on commit 981b6ac

Please sign in to comment.