Make staff_can_ignore_wide_flag use CoordsXYZ

This commit is contained in:
Tulio Leao 2020-06-21 22:25:22 -03:00
parent caeed92cf0
commit abcb50ff96
3 changed files with 8 additions and 9 deletions

View File

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

View File

@ -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 */

View File

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