MCPcopy Create free account
hub / github.com/diasurgical/DevilutionX / GetPathDirection

Function GetPathDirection

Source/engine/path.cpp:215–219  ·  view source on GitHub ↗

* Returns a number representing the direction from a starting tile to a neighbouring tile. * * Used in the pathfinding code, each step direction is assigned a number like this: * dx * -1 0 1 * +----- * -1|5 1 6 * dy 0|2 0 3 * 1|8 4 7 */

Source from the content-addressed store, hash-verified

213 * 1|8 4 7
214 */
215int8_t GetPathDirection(Point startPosition, Point destinationPosition)
216{
217 constexpr int8_t PathDirections[9] = { 5, 1, 6, 2, 0, 3, 8, 4, 7 };
218 return PathDirections[3 * (destinationPosition.y - startPosition.y) + 4 + destinationPosition.x - startPosition.x];
219}
220
221/**
222 * @brief heuristic, estimated cost from startPosition to destinationPosition.

Callers 2

FindPathFunction · 0.85
path_solid_piecesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected