diff options
author | tron <tron@openttd.org> | 2006-03-08 07:50:26 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2006-03-08 07:50:26 +0000 |
commit | 8b447de24c0f65dabb9fc9ea710f6f567303f40f (patch) | |
tree | 80753acfadc66487bbe8f4eb0b58ae0b8508149d | |
parent | ecabf8a5f0b39626efef5c720f302a3169c8cdab (diff) | |
download | openttd-8b447de24c0f65dabb9fc9ea710f6f567303f40f.tar.xz |
(svn r3785) Replace some if-magic to determine the turning direction for road vehicles with the new DirDiff stuff
-rw-r--r-- | roadveh_cmd.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/roadveh_cmd.c b/roadveh_cmd.c index 64be9610a..7a97722ce 100644 --- a/roadveh_cmd.c +++ b/roadveh_cmd.c @@ -852,15 +852,11 @@ static Direction RoadVehGetSlidingDirection(const Vehicle* v, int x, int y) { Direction b = RoadVehGetNewDirection(v, x, y); Direction d = v->direction; + DirDiff delta; if (b == d) return d; - d = (d + 1) & 7; - if (b == d) return d; - d = (d - 2) & 7; - if (b == d) return d; - if (b == ((d - 1) & 7)) return d; - if (b == ((d - 2) & 7)) return d; - return (d + 2) & 7; + delta = (DirDifference(d, b) > DIRDIFF_REVERSE ? DIRDIFF_45LEFT : DIRDIFF_45RIGHT); + return ChangeDir(d, delta); } typedef struct OvertakeData { |