diff options
author | michi_cc <michi_cc@openttd.org> | 2011-08-21 14:13:22 +0000 |
---|---|---|
committer | michi_cc <michi_cc@openttd.org> | 2011-08-21 14:13:22 +0000 |
commit | 45b95ed62950678b677c555cec558b009e0b8d3e (patch) | |
tree | 15fb97a4babf447c25b84d5afe67b938e57722a8 /src/pathfinder | |
parent | c10d4157233109aab8794d2455481d45bd44b019 (diff) | |
download | openttd-45b95ed62950678b677c555cec558b009e0b8d3e.tar.xz |
(svn r22801) -Feature: [YAPF] Take canal/ocean speed fraction of ships into account.
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; |