MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / DistanceSquare

Function DistanceSquare

src/map.cpp:186–191  ·  view source on GitHub ↗

* Gets the 'Square' distance between the two given tiles. * The 'Square' distance is the square of the shortest (straight line) * distance between the two tiles. * Also known as Euclidean- or L2-Norm squared. * @param t0 the start tile * @param t1 the end tile * @return the distance */

Source from the content-addressed store, hash-verified

184 * @return the distance
185 */
186uint DistanceSquare(TileIndex t0, TileIndex t1)
187{
188 const int dx = TileX(t0) - TileX(t1);
189 const int dy = TileY(t0) - TileY(t1);
190 return dx * dx + dy * dy;
191}
192
193
194/**

Callers 15

GetOrderDistanceFunction · 0.85
FindClosestShipDepotFunction · 0.85
MakeWetlandsFunction · 0.85
CmdBuildBridgeFunction · 0.85
CmdBuildTunnelFunction · 0.85
GetVariableMethod · 0.85
FindNearestHangarFunction · 0.85
AircraftEventHandlerFunction · 0.85
GetVariableMethod · 0.85
PlaceTreeGroupAroundTileFunction · 0.85
GetVariableMethod · 0.85
GetTownRadiusGroupFunction · 0.85

Calls 2

TileXFunction · 0.85
TileYFunction · 0.85

Tested by

no test coverage detected