mirror of https://github.com/OpenTTD/OpenTTD
Change: Add configurable curve penalty for ships.
parent
a69eb5f516
commit
b8a0107ad1
|
@ -169,6 +169,21 @@ protected:
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
inline int CurveCost(Trackdir td1, Trackdir td2)
|
||||||
|
{
|
||||||
|
assert(IsValidTrackdir(td1));
|
||||||
|
assert(IsValidTrackdir(td2));
|
||||||
|
|
||||||
|
if (HasTrackdir(TrackdirCrossesTrackdirs(td1), td2)) {
|
||||||
|
/* 90-deg curve penalty */
|
||||||
|
return Yapf().PfGetSettings().ship_curve90_penalty;
|
||||||
|
} else if (td2 != NextTrackdir(td1)) {
|
||||||
|
/* 45-deg curve penalty */
|
||||||
|
return Yapf().PfGetSettings().ship_curve45_penalty;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by YAPF to calculate the cost from the origin to the given node.
|
* Called by YAPF to calculate the cost from the origin to the given node.
|
||||||
* Calculates only the cost of given node, adds it to the parent node cost
|
* Calculates only the cost of given node, adds it to the parent node cost
|
||||||
|
@ -179,10 +194,7 @@ public:
|
||||||
/* base tile cost depending on distance */
|
/* base tile cost depending on distance */
|
||||||
int c = IsDiagonalTrackdir(n.GetTrackdir()) ? YAPF_TILE_LENGTH : YAPF_TILE_CORNER_LENGTH;
|
int c = IsDiagonalTrackdir(n.GetTrackdir()) ? YAPF_TILE_LENGTH : YAPF_TILE_CORNER_LENGTH;
|
||||||
/* additional penalty for curves */
|
/* additional penalty for curves */
|
||||||
if (n.GetTrackdir() != NextTrackdir(n.m_parent->GetTrackdir())) {
|
c += CurveCost(n.m_parent->GetTrackdir(), n.GetTrackdir());
|
||||||
/* new trackdir does not match the next one when going straight */
|
|
||||||
c += YAPF_TILE_LENGTH;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Skipped tile cost for aqueducts. */
|
/* Skipped tile cost for aqueducts. */
|
||||||
c += YAPF_TILE_LENGTH * tf->m_tiles_skipped;
|
c += YAPF_TILE_LENGTH * tf->m_tiles_skipped;
|
||||||
|
|
|
@ -292,6 +292,7 @@ enum SaveLoadVersion : uint16 {
|
||||||
SLV_SHIPS_STOP_IN_LOCKS, ///< 206 PR#7150 Ship/lock movement changes.
|
SLV_SHIPS_STOP_IN_LOCKS, ///< 206 PR#7150 Ship/lock movement changes.
|
||||||
SLV_FIX_CARGO_MONITOR, ///< 207 PR#7175 v1.9 Cargo monitor data packing fix to support 64 cargotypes.
|
SLV_FIX_CARGO_MONITOR, ///< 207 PR#7175 v1.9 Cargo monitor data packing fix to support 64 cargotypes.
|
||||||
SLV_TOWN_CARGOGEN, ///< 208 PR#6965 New algorithms for town building cargo generation.
|
SLV_TOWN_CARGOGEN, ///< 208 PR#6965 New algorithms for town building cargo generation.
|
||||||
|
SLV_SHIP_CURVE_PENALTY, ///< 209 PR#7289 Configurable ship curve penalties.
|
||||||
|
|
||||||
SL_MAX_VERSION, ///< Highest possible saveload version
|
SL_MAX_VERSION, ///< Highest possible saveload version
|
||||||
};
|
};
|
||||||
|
|
|
@ -418,6 +418,8 @@ struct YAPFSettings {
|
||||||
uint32 rail_longer_platform_per_tile_penalty; ///< penalty for longer station platform than train (per tile)
|
uint32 rail_longer_platform_per_tile_penalty; ///< penalty for longer station platform than train (per tile)
|
||||||
uint32 rail_shorter_platform_penalty; ///< penalty for shorter station platform than train
|
uint32 rail_shorter_platform_penalty; ///< penalty for shorter station platform than train
|
||||||
uint32 rail_shorter_platform_per_tile_penalty; ///< penalty for shorter station platform than train (per tile)
|
uint32 rail_shorter_platform_per_tile_penalty; ///< penalty for shorter station platform than train (per tile)
|
||||||
|
uint32 ship_curve45_penalty; ///< penalty for 45-deg curve for ships
|
||||||
|
uint32 ship_curve90_penalty; ///< penalty for 90-deg curve for ships
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Settings related to all pathfinders. */
|
/** Settings related to all pathfinders. */
|
||||||
|
|
|
@ -2163,6 +2163,26 @@ min = 0
|
||||||
max = 1000000
|
max = 1000000
|
||||||
cat = SC_EXPERT
|
cat = SC_EXPERT
|
||||||
|
|
||||||
|
[SDT_VAR]
|
||||||
|
base = GameSettings
|
||||||
|
var = pf.yapf.ship_curve45_penalty
|
||||||
|
type = SLE_UINT
|
||||||
|
from = SLV_SHIP_CURVE_PENALTY
|
||||||
|
def = 1 * YAPF_TILE_LENGTH
|
||||||
|
min = 0
|
||||||
|
max = 1000000
|
||||||
|
cat = SC_EXPERT
|
||||||
|
|
||||||
|
[SDT_VAR]
|
||||||
|
base = GameSettings
|
||||||
|
var = pf.yapf.ship_curve90_penalty
|
||||||
|
type = SLE_UINT
|
||||||
|
from = SLV_SHIP_CURVE_PENALTY
|
||||||
|
def = 6 * YAPF_TILE_LENGTH
|
||||||
|
min = 0
|
||||||
|
max = 1000000
|
||||||
|
cat = SC_EXPERT
|
||||||
|
|
||||||
##
|
##
|
||||||
[SDT_VAR]
|
[SDT_VAR]
|
||||||
base = GameSettings
|
base = GameSettings
|
||||||
|
|
Loading…
Reference in New Issue