1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-21 14:02:59 +01:00

Rename IsValidPathZAndDirection and move to more appropriate place

This commit is contained in:
ζeh Matt
2024-09-30 12:53:12 +03:00
parent fdff60552b
commit bc1f2f62cf
5 changed files with 32 additions and 33 deletions

View File

@@ -183,7 +183,7 @@ bool Staff::CanIgnoreWideFlag(const CoordsXYZ& staffPos, TileElement* path) cons
}
/* test_element is a path */
if (!PathFinding::IsValidPathZAndDirection(test_element, adjacPos.z / kCoordsZStep, adjac_dir))
if (!FootpathIsZAndDirectionValid(test_element, adjacPos.z / kCoordsZStep, adjac_dir))
continue;
/* test_element is a connected path */

View File

@@ -359,7 +359,7 @@ namespace OpenRCT2::PathFinding
continue;
if (nextTileElement->GetType() != TileElementType::Path)
continue;
if (!IsValidPathZAndDirection(nextTileElement, loc.z, chosenDirection))
if (!FootpathIsZAndDirectionValid(nextTileElement, loc.z, chosenDirection))
continue;
if (nextTileElement->AsPath()->IsWide())
return PathSearchResult::Wide;
@@ -453,7 +453,7 @@ namespace OpenRCT2::PathFinding
break;
case TileElementType::Path:
{
if (!IsValidPathZAndDirection(tileElement, loc.z, chosenDirection))
if (!FootpathIsZAndDirectionValid(tileElement, loc.z, chosenDirection))
continue;
if (tileElement->AsPath()->IsWide())
return PathSearchResult::Wide;
@@ -845,7 +845,7 @@ namespace OpenRCT2::PathFinding
* queue path.
* Otherwise, peeps walk on path tiles to get to the goal. */
if (!IsValidPathZAndDirection(tileElement, loc.z, testEdge))
if (!FootpathIsZAndDirectionValid(tileElement, loc.z, testEdge))
continue;
// Path may be sloped, so set z to path base height.
@@ -2134,31 +2134,4 @@ namespace OpenRCT2::PathFinding
return PeepMoveOneTile(direction, peep);
}
bool IsValidPathZAndDirection(TileElement* tileElement, int32_t currentZ, int32_t currentDirection)
{
if (tileElement->AsPath()->IsSloped())
{
int32_t slopeDirection = tileElement->AsPath()->GetSlopeDirection();
if (slopeDirection == currentDirection)
{
if (currentZ != tileElement->BaseHeight)
return false;
}
else
{
slopeDirection = DirectionReverse(slopeDirection);
if (slopeDirection != currentDirection)
return false;
if (currentZ != tileElement->BaseHeight + 2)
return false;
}
}
else
{
if (currentZ != tileElement->BaseHeight)
return false;
}
return true;
}
} // namespace OpenRCT2::PathFinding

View File

@@ -43,6 +43,4 @@ namespace OpenRCT2::PathFinding
int32_t GuestPathFindParkEntranceLeaving(Peep& peep, uint8_t edges);
bool IsValidPathZAndDirection(TileElement* tileElement, int32_t currentZ, int32_t currentDirection);
}; // namespace OpenRCT2::PathFinding

View File

@@ -2328,3 +2328,30 @@ bool PathElement::IsLevelCrossing(const CoordsXY& coords) const
return ride->GetRideTypeDescriptor().HasFlag(RtdFlag::supportsLevelCrossings);
}
bool FootpathIsZAndDirectionValid(TileElement* tileElement, int32_t currentZ, int32_t currentDirection)
{
if (tileElement->AsPath()->IsSloped())
{
int32_t slopeDirection = tileElement->AsPath()->GetSlopeDirection();
if (slopeDirection == currentDirection)
{
if (currentZ != tileElement->BaseHeight)
return false;
}
else
{
slopeDirection = DirectionReverse(slopeDirection);
if (slopeDirection != currentDirection)
return false;
if (currentZ != tileElement->BaseHeight + 2)
return false;
}
}
else
{
if (currentZ != tileElement->BaseHeight)
return false;
}
return true;
}

View File

@@ -186,3 +186,4 @@ const FootpathRailingsObject* GetPathRailingsEntry(ObjectEntryIndex entryIndex);
void FootpathQueueChainReset();
void FootpathQueueChainPush(RideId rideIndex);
bool FootpathIsZAndDirectionValid(TileElement* tileElement, int32_t currentZ, int32_t currentDirection);