diff --git a/src/openrct2/peep/GuestPathfinding.cpp b/src/openrct2/peep/GuestPathfinding.cpp index 137162ab7c..e957f1a321 100644 --- a/src/openrct2/peep/GuestPathfinding.cpp +++ b/src/openrct2/peep/GuestPathfinding.cpp @@ -602,8 +602,7 @@ static void peep_pathfind_heuristic_search( uint8_t searchResult = PATH_SEARCH_FAILED; bool currentElementIsWide - = (currentTileElement->AsPath()->IsWide() - && !staff_can_ignore_wide_flag(peep, loc.x * 32, loc.y * 32, loc.z, currentTileElement)); + = (currentTileElement->AsPath()->IsWide() && !staff_can_ignore_wide_flag(peep, loc.ToCoordsXYZ(), currentTileElement)); loc += TileDirectionDelta[test_edge]; @@ -737,7 +736,7 @@ static void peep_pathfind_heuristic_search( if (tileElement->AsPath()->IsWide()) { /* Check if staff can ignore this wide flag. */ - if (!staff_can_ignore_wide_flag(peep, loc.x * 32, loc.y * 32, loc.z, tileElement)) + if (!staff_can_ignore_wide_flag(peep, loc.ToCoordsXYZ(), tileElement)) { searchResult = PATH_SEARCH_WIDE; found = true; diff --git a/src/openrct2/peep/Staff.cpp b/src/openrct2/peep/Staff.cpp index 34b903fbec..d71181bf8a 100644 --- a/src/openrct2/peep/Staff.cpp +++ b/src/openrct2/peep/Staff.cpp @@ -202,7 +202,7 @@ bool staff_is_location_on_patrol_edge(Peep* mechanic, const CoordsXY& loc) return onZoneEdge; } -bool staff_can_ignore_wide_flag(Peep* staff, int32_t x, int32_t y, uint8_t z, TileElement* path) +bool staff_can_ignore_wide_flag(Peep* staff, const CoordsXYZ& staffPos, TileElement* path) { /* Wide flags can potentially wall off parts of a staff patrol zone * for the heuristic search. @@ -228,7 +228,7 @@ bool staff_can_ignore_wide_flag(Peep* staff, int32_t x, int32_t y, uint8_t z, Ti if (staff->AssignedPeepType != PEEP_TYPE_STAFF) return false; - if (!staff_is_location_on_patrol_edge(staff, { x, y })) + if (!staff_is_location_on_patrol_edge(staff, staffPos)) { return false; } @@ -240,7 +240,7 @@ bool staff_can_ignore_wide_flag(Peep* staff, int32_t x, int32_t y, uint8_t z, Ti uint8_t widecount = 0; for (Direction adjac_dir : ALL_DIRECTIONS) { - auto adjacPos = CoordsXYZ{ x + CoordsDirectionDelta[adjac_dir].x, y + CoordsDirectionDelta[adjac_dir].y, z }; + auto adjacPos = staffPos + CoordsXYZ{ CoordsDirectionDelta[adjac_dir].x, CoordsDirectionDelta[adjac_dir].y, 0 }; /* Ignore adjacent tiles outside the patrol zone. */ if (!staff->AsStaff()->IsLocationInPatrol(adjacPos)) @@ -264,7 +264,7 @@ bool staff_can_ignore_wide_flag(Peep* staff, int32_t x, int32_t y, uint8_t z, Ti { if (path->AsPath()->GetSlopeDirection() == adjac_dir) { - adjacPos.z = z + 2; + adjacPos.z += PATH_HEIGHT_STEP; } } @@ -282,7 +282,7 @@ bool staff_can_ignore_wide_flag(Peep* staff, int32_t x, int32_t y, uint8_t z, Ti } /* test_element is a path */ - if (!is_valid_path_z_and_direction(test_element, adjacPos.z, adjac_dir)) + if (!is_valid_path_z_and_direction(test_element, adjacPos.z / COORDS_Z_STEP, adjac_dir)) continue; /* test_element is a connected path */ diff --git a/src/openrct2/peep/Staff.h b/src/openrct2/peep/Staff.h index 76ae22b9a6..3826dee4d0 100644 --- a/src/openrct2/peep/Staff.h +++ b/src/openrct2/peep/Staff.h @@ -78,7 +78,7 @@ void staff_set_name(uint16_t spriteIndex, const char* name); bool staff_hire_new_member(STAFF_TYPE staffType, ENTERTAINER_COSTUME entertainerType); void staff_update_greyed_patrol_areas(); bool staff_is_location_on_patrol_edge(Peep* mechanic, const CoordsXY& loc); -bool staff_can_ignore_wide_flag(Peep* mechanic, int32_t x, int32_t y, uint8_t z, TileElement* path); +bool staff_can_ignore_wide_flag(Peep* mechanic, const CoordsXYZ& staffPos, TileElement* path); void staff_reset_stats(); bool staff_is_patrol_area_set_for_type(STAFF_TYPE type, const CoordsXY& coords); void staff_set_patrol_area(int32_t staffIndex, int32_t x, int32_t y, bool value);