mirror of https://github.com/OpenTTD/OpenTTD
(svn r22801) -Feature: [YAPF] Take canal/ocean speed fraction of ships into account.
parent
c10d415723
commit
45b95ed629
|
@ -133,8 +133,14 @@ public:
|
||||||
c += YAPF_TILE_LENGTH;
|
c += YAPF_TILE_LENGTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Skipped tile cost for aqueducts. */
|
||||||
c += YAPF_TILE_LENGTH * tf->m_tiles_skipped;
|
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 */
|
/* apply it */
|
||||||
n.m_cost = n.m_parent->m_cost + c;
|
n.m_cost = n.m_parent->m_cost + c;
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -13,8 +13,10 @@
|
||||||
#define SHIP_H
|
#define SHIP_H
|
||||||
|
|
||||||
#include "vehicle_base.h"
|
#include "vehicle_base.h"
|
||||||
|
#include "water_map.h"
|
||||||
|
|
||||||
void GetShipSpriteSize(EngineID engine, uint &width, uint &height);
|
void GetShipSpriteSize(EngineID engine, uint &width, uint &height);
|
||||||
|
WaterClass GetEffectiveWaterClass(TileIndex tile);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All ships have this type.
|
* All ships have this type.
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
* @param tile Tile of interest
|
* @param tile Tile of interest
|
||||||
* @return the waterclass to be used by the ship.
|
* @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 (HasTileWaterClass(tile)) return GetWaterClass(tile);
|
||||||
if (IsTileType(tile, MP_TUNNELBRIDGE)) {
|
if (IsTileType(tile, MP_TUNNELBRIDGE)) {
|
||||||
|
|
Loading…
Reference in New Issue