From 8a5c3bc97b66e576e9fba4302e3d1f8c303d655c Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Wed, 5 Oct 2022 14:38:19 +0300 Subject: [PATCH] Fix obj_can_hear_obj implementation --- src/interpreter_extra.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/interpreter_extra.cc b/src/interpreter_extra.cc index b9970d7..ed35b0f 100644 --- a/src/interpreter_extra.cc +++ b/src/interpreter_extra.cc @@ -2622,9 +2622,10 @@ static void opObjectCanHearObject(Program* program) bool canHear = false; - // FIXME: This is clearly an error. If any of the object is NULL - // dereferencing will crash the game. - if (object2 == NULL || object1 == NULL) { + // SFALL: Fix broken implementation. + // CE: In Sfall this fix is available under "ObjCanHearObjFix" switch and + // it's not enabled by default. Probably needs testing. + if (object2 != nullptr && object1 != nullptr) { if (object2->elevation == object1->elevation) { if (object2->tile != -1 && object1->tile != -1) { if (isWithinPerception(object2, object1)) {