From 40fe8ef649b7130da2bef19a21f17ae0eb23659a Mon Sep 17 00:00:00 2001 From: defacube <85292886+yoyeet961@users.noreply.github.com> Date: Sat, 21 Oct 2023 03:20:26 +1100 Subject: [PATCH] Fix Ukiki and Koopa the Quick crashing the game (#481) * Fix KTQ Crash * Fix Ukiki Crash * Just mark ukiki for deletion instead * Add a return; --- src/game/behaviors/koopa.inc.c | 9 +++++++-- src/game/behaviors/ukiki.inc.c | 8 +++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/game/behaviors/koopa.inc.c b/src/game/behaviors/koopa.inc.c index 273ce5f1..5e48e746 100644 --- a/src/game/behaviors/koopa.inc.c +++ b/src/game/behaviors/koopa.inc.c @@ -1,4 +1,3 @@ - /** * Behavior for bhvKoopa and bhvKoopaRaceEndpoint. * bhvKoopa includes normal, unshelled, tiny, and Koopa the Quick. @@ -116,7 +115,13 @@ void bhv_koopa_init(void) { if (o->oKoopaMovementType >= KOOPA_BP_KOOPA_THE_QUICK_BASE) { // koopa the quick - o->parentObj = cur_obj_nearest_object_with_behavior(bhvKoopaRaceEndpoint); + if (cur_obj_nearest_object_with_behavior(bhvKoopaRaceEndpoint) != NULL) { + o->parentObj = cur_obj_nearest_object_with_behavior(bhvKoopaRaceEndpoint); + } + else { + obj_mark_for_deletion(o); + return; + } struct SyncObject* so = sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); if (so) { so->on_received_post = bhv_koopa_the_quick_on_received_post; diff --git a/src/game/behaviors/ukiki.inc.c b/src/game/behaviors/ukiki.inc.c index d425dacb..265e07e0 100644 --- a/src/game/behaviors/ukiki.inc.c +++ b/src/game/behaviors/ukiki.inc.c @@ -365,7 +365,13 @@ void ukiki_act_go_to_cage(void) { struct Object* obj; f32 latDistToCage = 0.0f; s16 yawToCage = 0; - obj = cur_obj_nearest_object_with_behavior(bhvUkikiCageChild); + if (cur_obj_nearest_object_with_behavior(bhvUkikiCageChild) != NULL) { + obj = cur_obj_nearest_object_with_behavior(bhvUkikiCageChild); + } + else { + obj_mark_for_deletion(o); + return; + } // Ultimately is checking the cage, as it points to the parent // of a dummy child object of the cage.