diff options
author | tron <tron@openttd.org> | 2006-03-08 07:48:56 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2006-03-08 07:48:56 +0000 |
commit | ecabf8a5f0b39626efef5c720f302a3169c8cdab (patch) | |
tree | f7e5f43e03b4cc5ea6f80ee95a7e5827601efcbf /direction.h | |
parent | fbe939b31f8c7ea4e6e47d6d903625dd25c5e856 (diff) | |
download | openttd-ecabf8a5f0b39626efef5c720f302a3169c8cdab.tar.xz |
(svn r3784) Add a type and functions to handle direction changes
Diffstat (limited to 'direction.h')
-rw-r--r-- | direction.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/direction.h b/direction.h index e29fb3c49..4aed8bea3 100644 --- a/direction.h +++ b/direction.h @@ -23,6 +23,32 @@ static inline Direction ReverseDir(Direction d) } +typedef enum DirDiff { + DIRDIFF_SAME = 0, + DIRDIFF_45RIGHT = 1, + DIRDIFF_90RIGHT = 2, + DIRDIFF_REVERSE = 4, + DIRDIFF_90LEFT = 6, + DIRDIFF_45LEFT = 7 +} DirDiff; + +static inline DirDiff DirDifference(Direction d0, Direction d1) +{ + return (DirDiff)(d0 + 8 - d1) % 8; +} + +static inline DirDiff ChangeDirDiff(DirDiff d, DirDiff delta) +{ + return (DirDiff)((d + delta) % 8); +} + + +static inline Direction ChangeDir(Direction d, DirDiff delta) +{ + return (Direction)((d + delta) % 8); +} + + /* Direction commonly used as the direction of entering and leaving tiles, 4-way */ typedef enum DiagDirection { DIAGDIR_NE = 0, /* Northeast, upper right on your monitor */ |