From 8dd8203a39bfc0ab622529d4a3404c0ee8a210c5 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Mon, 1 Aug 2022 14:18:40 +0200 Subject: [PATCH] Add missing check to IsDoorClear --- Source/objects.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Source/objects.cpp b/Source/objects.cpp index 1d915c45c..6127f283c 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -1611,16 +1611,17 @@ void ObjectStopAnim(Object &object) /** * @brief Checks if an open door can be closed * - * In order to be able to close a door the space where the closed door would be must be free of bodies, monsters, and items + * In order to be able to close a door the space where the closed door would be must be free of bodies, monsters, players, and items * * @param doorPosition Map tile where the door is in its closed position * @return true if the door is free to be closed, false if anything is blocking it */ -inline bool IsDoorClear(const Point &doorPosition) +inline bool IsDoorClear(const Object &door) { - return dCorpse[doorPosition.x][doorPosition.y] == 0 - && dMonster[doorPosition.x][doorPosition.y] == 0 - && dItem[doorPosition.x][doorPosition.y] == 0; + return dCorpse[door.position.x][door.position.y] == 0 + && dMonster[door.position.x][door.position.y] == 0 + && dItem[door.position.x][door.position.y] == 0 + && dPlayer[door.position.x][door.position.y] == 0; } void UpdateDoor(Object &door) @@ -1633,8 +1634,7 @@ void UpdateDoor(Object &door) door._oMissFlag = true; door._oSelFlag = 2; - bool dok = IsDoorClear(door.position) && dPlayer[door.position.x][door.position.y] == 0; - door._oVar4 = dok ? DOOR_OPEN : DOOR_BLOCKED; + door._oVar4 = IsDoorClear(door) ? DOOR_OPEN : DOOR_BLOCKED; } void UpdateSarcophagus(Object &sarcophagus)