Fix obj_can_hear_obj implementation

This commit is contained in:
Alexander Batalov 2022-10-05 14:38:19 +03:00
parent db57fe6a5e
commit 8a5c3bc97b
1 changed files with 4 additions and 3 deletions

View File

@ -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)) {