Add comments and direction_reverse function

Add a bit of Javadocs, and introduce helper function for reversing directions because the ^2 trick used elsewhere in the codebase is not immediately obvious exactly what it does.
This commit is contained in:
Richard Fine 2019-01-05 14:28:24 +00:00
parent 613c7e9bf3
commit fd60654238
1 changed files with 18 additions and 0 deletions

View File

@ -129,8 +129,26 @@ struct TileCoordsXYZ
int32_t x = 0, y = 0, z = 0;
};
/**
* Cardinal directions are represented by the Direction type. It has four
* possible values:
* 0 is X-decreasing
* 1 is Y-increasing
* 2 is X-increasing
* 3 is Y-decreasing
* Direction is not used to model up/down, or diagonal directions.
*/
typedef uint8_t Direction;
/**
* Given a direction, return the direction that points the other way,
* on the same axis.
*/
inline Direction direction_reverse(const Direction& dir)
{
return dir ^ 2;
}
struct CoordsXYZD
{
int32_t x, y, z;