diff options
-rw-r--r-- | src/pathfinder/yapf/yapf_ship.cpp | 6 | ||||
-rw-r--r-- | src/ship.h | 2 | ||||
-rw-r--r-- | src/ship_cmd.cpp | 2 |
3 files changed, 9 insertions, 1 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; diff --git a/src/ship.h b/src/ship.h index 3a7e21d58..b40697087 100644 --- a/src/ship.h +++ b/src/ship.h @@ -13,8 +13,10 @@ #define SHIP_H #include "vehicle_base.h" +#include "water_map.h" void GetShipSpriteSize(EngineID engine, uint &width, uint &height); +WaterClass GetEffectiveWaterClass(TileIndex tile); /** * All ships have this type. diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp index 222d48994..f38a83c25 100644 --- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -41,7 +41,7 @@ * @param tile Tile of interest * @return the waterclass to be used by the ship. */ -static WaterClass GetEffectiveWaterClass(TileIndex tile) +WaterClass GetEffectiveWaterClass(TileIndex tile) { if (HasTileWaterClass(tile)) return GetWaterClass(tile); if (IsTileType(tile, MP_TUNNELBRIDGE)) { |