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

Function DirDifference

src/direction_func.h:68–75  ·  view source on GitHub ↗

* Calculate the difference between two directions * * @param d0 The first direction as the base * @param d1 The second direction as the offset from the base * @return The difference how the second direction drifts of the first one. */

Source from the content-addressed store, hash-verified

66 * @return The difference how the second direction drifts of the first one.
67 */
68inline DirDiff DirDifference(Direction d0, Direction d1)
69{
70 assert(IsValidDirection(d0));
71 assert(IsValidDirection(d1));
72 /* Cast to uint so compiler can use bitmask. If the difference is negative
73 * and we used int instead of uint, further "+ 8" would have to be added. */
74 return static_cast<DirDiff>((static_cast<uint>(d0) - static_cast<uint>(d1)) % 8);
75}
76
77/**
78 * Applies two differences together

Callers 8

ShipControllerFunction · 0.85
GetCurveSpeedLimitMethod · 0.85
TrainControllerFunction · 0.85
GetDirectionTowardsFunction · 0.85
AircraftControllerFunction · 0.85
VehicleGetVariableFunction · 0.85

Calls 1

IsValidDirectionFunction · 0.85

Tested by

no test coverage detected