MCPcopy Create free account
hub / github.com/OpenDUNE/OpenDUNE / Tile_GetDistance

Function Tile_GetDistance

src/tile.c:39–46  ·  view source on GitHub ↗

* Calculates the distance between the two given tiles. * * @param from The origin. * @param to The destination. * @return The longest distance between the X or Y coordinates, plus half the shortest. */

Source from the content-addressed store, hash-verified

37 * @return The longest distance between the X or Y coordinates, plus half the shortest.
38 */
39uint16 Tile_GetDistance(tile32 from, tile32 to)
40{
41 uint16 distance_x = abs(from.x - to.x);
42 uint16 distance_y = abs(from.y - to.y);
43
44 if (distance_x > distance_y) return distance_x + (distance_y / 2);
45 return distance_y + (distance_x / 2);
46}
47
48/**
49 * Adds two tiles together.

Callers 15

Map_MakeExplosionFunction · 0.85
Map_DeviateAreaFunction · 0.85
Unit_MovementTickFunction · 0.85
Unit_FindClosestRefineryFunction · 0.85
Unit_FindBestTargetUnitFunction · 0.85
Unit_MoveFunction · 0.85
Unit_CreateBulletFunction · 0.85
Tile_GetDistancePackedFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected