Browse Source

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
pull/2415/head
ephphatha 5 years ago committed by Anders Jenbo
parent
commit
7de18d27cf
  1. 9
      Source/objects.h
  2. 2
      Source/path.cpp

9
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];

2
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;

Loading…
Cancel
Save