summaryrefslogtreecommitdiff
path: root/npf.h
diff options
context:
space:
mode:
authormatthijs <matthijs@openttd.org>2005-05-02 22:13:20 +0000
committermatthijs <matthijs@openttd.org>2005-05-02 22:13:20 +0000
commit2ab5eee78b495ec73049c8446a0ed37ab4ff0920 (patch)
treed0b9834259f5e0b0d954f2722cf9ab0ce5de1d99 /npf.h
parentd26052c7df0e3ae640f45d72068e3112c2c21477 (diff)
downloadopenttd-2ab5eee78b495ec73049c8446a0ed37ab4ff0920.tar.xz
(svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
Buoys will now try to get within 3 tiles of a buoy instead of a the actual buoy tile. This gets ships to got past buoys in a realistic (IMO) way instead of barging right through them. - Fix: [NPF] Trains get curves penalties sometimes even when the track is straight. - Add: [NPF] Ships get a penalty for going over buoys now, so they will try to go around. - Add: [NPF] Ships get a penalty for curves too, yay for straight lines. - Add: TrackdirToTrack(), TrackToTrackdir(), IsDiagonalTrack() and IsDiagonalTrackdir() helper functions. - Add: IsBuoy() and IsBuoyTile() helper functions. - Codechange: Rearranged part of the control flow of ShipController(), removing a goto.
Diffstat (limited to 'npf.h')
-rw-r--r--npf.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/npf.h b/npf.h
index 338f7e100..1b6eabf45 100644
--- a/npf.h
+++ b/npf.h
@@ -118,6 +118,11 @@ const byte _signal_against_trackdir[14];
const uint16 _trackdir_reaches_trackdirs[14];
/**
+ * Maps a trackdir to the trackdir that you will end up on if you go straight
+ * ahead. This will be the same trackdir for diagonal trackdirs, but a
+ * different (alternating) one for straight trackdirs */
+const uint16 _next_trackdir[14];
+/**
* Maps a trackdir to all trackdirs that make 90 deg turns with it.
*/
const uint16 _trackdir_crosses_trackdirs[14];
@@ -161,6 +166,23 @@ const byte _reverse_dir[4];
*/
const byte _reverse_trackdir[14];
+/* Returns the Track that a given Trackdir represents */
+static inline byte TrackdirToTrack(byte trackdir) { return trackdir & 0x7; }
+
+/* Returns a Trackdir for the given Track. Since every Track corresponds to
+ * two Trackdirs, we choose the one which points between N and SE.
+ * Note that the actual implementation is quite futile, but this might change
+ * in the future.
+ */
+static inline byte TrackToTrackdir(byte track) { return track; }
+
+/* Checks if a given Track is diagonal */
+static inline bool IsDiagonalTrack(byte track) { return track == 0x0 || track == 0x1; }
+
+/* Checks if a given Trackdir is diagonal. */
+static inline bool IsDiagonalTrackdir(byte trackdir) { return IsDiagonalTrack(TrackdirToTrack(trackdir)); }
+
+
#define REVERSE_TRACKDIR(trackdir) (trackdir ^ 0x8)
#endif // NPF_H