diff options
Diffstat (limited to 'src/pathfinder')
-rw-r--r-- | src/pathfinder/yapf/yapf_ship.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/pathfinder/yapf/yapf_ship.cpp b/src/pathfinder/yapf/yapf_ship.cpp index 69f1ce2c5..46b3e9bf7 100644 --- a/src/pathfinder/yapf/yapf_ship.cpp +++ b/src/pathfinder/yapf/yapf_ship.cpp @@ -133,8 +133,14 @@ public: c += YAPF_TILE_LENGTH; } + /* Skipped tile cost for aqueducts. */ c += YAPF_TILE_LENGTH * tf->m_tiles_skipped; + /* Ocean/canal speed penalty. */ + const ShipVehicleInfo *svi = ShipVehInfo(Yapf().GetVehicle()->engine_type); + byte speed_frac = (GetEffectiveWaterClass(n.GetTile()) == WATER_CLASS_SEA) ? svi->ocean_speed_frac : svi->canal_speed_frac; + if (speed_frac > 0) c += YAPF_TILE_LENGTH * (1 + tf->m_tiles_skipped) * speed_frac / (256 - speed_frac); + /* apply it */ n.m_cost = n.m_parent->m_cost + c; return true; |