Custom bridge heads: Initial implementation

This commit is contained in:
Jonathan G Rennison
2017-02-05 18:07:10 +00:00
parent 1f727e9029
commit da177d063f
12 changed files with 433 additions and 106 deletions

View File

@@ -104,7 +104,10 @@ public:
*/
inline bool PfCalcCost(Node &n, const TrackFollower *tf)
{
int segment_cost = 0;
/* this is to handle the case where the starting tile is a junction custom bridge head,
* and we have advanced across the bridge in the initial step */
int segment_cost = tf->m_tiles_skipped * YAPF_TILE_LENGTH;
uint tiles = 0;
/* start at n.m_key.m_tile / n.m_key.m_td and walk to the end of segment */
TileIndex tile = n.m_key.m_tile;
@@ -127,6 +130,11 @@ public:
TrackFollower F(Yapf().GetVehicle());
if (!F.Follow(tile, trackdir)) break;
/* if we skipped some tunnel tiles, add their cost */
/* with custom bridge heads, this cost must be added before checking if the segment has ended */
segment_cost += F.m_tiles_skipped * YAPF_TILE_LENGTH;
tiles += F.m_tiles_skipped + 1;
/* if there are more trackdirs available & reachable, we are at the end of segment */
if (KillFirstBit(F.m_new_td_bits) != TRACKDIR_BIT_NONE) break;
@@ -135,10 +143,6 @@ public:
/* stop if RV is on simple loop with no junctions */
if (F.m_new_tile == n.m_key.m_tile && new_td == n.m_key.m_td) return false;
/* if we skipped some tunnel tiles, add their cost */
segment_cost += F.m_tiles_skipped * YAPF_TILE_LENGTH;
tiles += F.m_tiles_skipped + 1;
/* add hilly terrain penalty */
segment_cost += Yapf().SlopeCost(tile, F.m_new_tile, trackdir);