From 7de18d27cf96f3df240f21dd0f463e36a63fba80 Mon Sep 17 00:00:00 2001 From: ephphatha Date: Sat, 17 Jul 2021 14:28:51 +1000 Subject: [PATCH] Extract door object type test to ObjectStruct method This removes the direct reference to _object_id values in path.cpp, that enum is now only used in objects.h/cpp --- Source/objects.h | 9 +++++++++ Source/path.cpp | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Source/objects.h b/Source/objects.h index 253ec10c5..74f36fd35 100644 --- a/Source/objects.h +++ b/Source/objects.h @@ -121,6 +121,15 @@ struct ObjectStruct { SetMapRange(mapRange); _oVar8 = leverID; } + + /** + * @brief Check if this object is a door + * @return True if the object is one of the door types (see _object_id) + */ + bool IsDoor() const + { + return IsAnyOf(_otype, _object_id::OBJ_L1LDOOR, _object_id::OBJ_L1RDOOR, _object_id::OBJ_L2LDOOR, _object_id::OBJ_L2RDOOR, _object_id::OBJ_L3LDOOR, _object_id::OBJ_L3RDOOR); + } }; extern ObjectStruct Objects[MAXOBJECTS]; diff --git a/Source/path.cpp b/Source/path.cpp index 69476596a..848f34daa 100644 --- a/Source/path.cpp +++ b/Source/path.cpp @@ -78,7 +78,7 @@ bool IsTileWalkable(Point position, bool ignoreDoors) { if (dObject[position.x][position.y] != 0) { int oi = abs(dObject[position.x][position.y]) - 1; - if (ignoreDoors && IsAnyOf(Objects[oi]._otype, OBJ_L1LDOOR, OBJ_L1RDOOR, OBJ_L2LDOOR, OBJ_L2RDOOR, OBJ_L3LDOOR, OBJ_L3RDOOR)) + if (ignoreDoors && Objects[oi].IsDoor()) return true; if (Objects[oi]._oSolidFlag) return false;