diff options
author | matthijs <matthijs@openttd.org> | 2005-05-02 22:13:20 +0000 |
---|---|---|
committer | matthijs <matthijs@openttd.org> | 2005-05-02 22:13:20 +0000 |
commit | 2ab5eee78b495ec73049c8446a0ed37ab4ff0920 (patch) | |
tree | d0b9834259f5e0b0d954f2722cf9ab0ce5de1d99 /npf.c | |
parent | d26052c7df0e3ae640f45d72068e3112c2c21477 (diff) | |
download | openttd-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.c')
-rw-r--r-- | npf.c | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -36,6 +36,11 @@ const uint16 _trackdir_reaches_trackdirs[14] = { 0x0520, 0x2A00, 0x2A00, 0x0520, 0x2A00, 0x1009 }; +const uint16 _next_trackdir[14] = { + 0, 1, 3, 2, 5, 4, 0, 0, + 8, 9, 11, 10, 13, 12 +}; + /* Maps a trackdir to all trackdirs that make 90 deg turns with it. */ const uint16 _trackdir_crosses_trackdirs[14] = { 0x0202, 0x0101, 0x3030, 0x3030, 0x0C0C, 0x0C0C, 0, 0, @@ -273,7 +278,13 @@ int32 NPFWaterPathCost(AyStar* as, AyStarNode* current, OpenListNode* parent) { cost = _trackdir_length[trackdir]; /* Should be different for diagonal tracks */ - /* TODO Penalties? */ + if (IsBuoyTile(current->tile) && IsDiagonalTrackdir(current->direction)) + cost += _patches.npf_buoy_penalty; /* A small penalty for going over buoys */ + + if (current->direction != _next_trackdir[parent->path.node.direction]) + cost += _patches.npf_water_curve_penalty; + + /* TODO More penalties? */ return cost; } @@ -385,7 +396,7 @@ int32 NPFRailPathCost(AyStar* as, AyStarNode* current, OpenListNode* parent) { cost += NPFSlopeCost(current); /* Check for turns */ - if (current->direction != parent->path.node.direction) + if (current->direction != _next_trackdir[parent->path.node.direction]) cost += _patches.npf_rail_curve_penalty; //TODO, with realistic acceleration, also the amount of straight track between // curves should be taken into account, as this affects the speed limit. |