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;
This commit is contained in:
defacube 2023-10-21 03:20:26 +11:00 committed by GitHub
parent a62f7a63f9
commit 40fe8ef649
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 3 deletions

View File

@ -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;

View File

@ -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.