From c31a706dbd98a340c9f0a1eba581540ee8af237f Mon Sep 17 00:00:00 2001 From: MysterD Date: Mon, 21 Mar 2022 12:31:37 -0700 Subject: [PATCH] Fixed crash in dist_between_objects() --- src/game/object_helpers.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/game/object_helpers.c b/src/game/object_helpers.c index 58da148a..7146b365 100644 --- a/src/game/object_helpers.c +++ b/src/game/object_helpers.c @@ -321,6 +321,7 @@ void obj_set_held_state(struct Object *obj, const BehaviorScript *heldBehavior) } f32 lateral_dist_between_objects(struct Object *obj1, struct Object *obj2) { + if (obj1 == NULL || obj2 == NULL) { return 0; } f32 dx = obj1->oPosX - obj2->oPosX; f32 dz = obj1->oPosZ - obj2->oPosZ; @@ -328,6 +329,7 @@ f32 lateral_dist_between_objects(struct Object *obj1, struct Object *obj2) { } f32 dist_between_objects(struct Object *obj1, struct Object *obj2) { + if (obj1 == NULL || obj2 == NULL) { return 0; } f32 dx = obj1->oPosX - obj2->oPosX; f32 dy = obj1->oPosY - obj2->oPosY; f32 dz = obj1->oPosZ - obj2->oPosZ; @@ -336,6 +338,7 @@ f32 dist_between_objects(struct Object *obj1, struct Object *obj2) { } f32 dist_between_object_and_point(struct Object *obj, f32 pointX, f32 pointY, f32 pointZ) { + if (obj == NULL) { return 0; } f32 dx = (f32)obj->oPosX - pointX; f32 dy = (f32)obj->oPosY - pointY; f32 dz = (f32)obj->oPosZ - pointZ;