summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKUDr <KUDr@openttd.org>2006-06-08 17:31:03 +0000
committerKUDr <KUDr@openttd.org>2006-06-08 17:31:03 +0000
commit7b4c46e388fbb4f67d94d58e171bf052762bacfa (patch)
treed2093663de24fcd49aa10e5113cd3a28d2e39428
parentba86269c6598cf82d4bfe81e923e695d3cead28a (diff)
downloadopenttd-7b4c46e388fbb4f67d94d58e171bf052762bacfa.tar.xz
(svn r5169) - CodeChange: [YAPF] RVs now use YAPF_TILE_LENGTH as base unit and 2 configurable settings (slope and crossing penalties) for cost calculation
-rw-r--r--settings.c3
-rw-r--r--yapf/yapf_road.cpp12
-rw-r--r--yapf/yapf_settings.h2
3 files changed, 11 insertions, 6 deletions
diff --git a/settings.c b/settings.c
index 9f23396b5..919333672 100644
--- a/settings.c
+++ b/settings.c
@@ -1412,6 +1412,9 @@ const SettingDesc _patch_settings[] = {
SDT_CONDVAR (Patches, yapf.rail_longer_platform_per_tile_penalty, SLE_UINT, 28, SL_MAX_VERSION,NS, 0, 0 * YAPF_TILE_LENGTH, 0, 20000, STR_NULL, NULL),
SDT_CONDVAR (Patches, yapf.rail_shorter_platform_penalty, SLE_UINT, 28, SL_MAX_VERSION,NS, 0, 40 * YAPF_TILE_LENGTH, 0, 20000, STR_NULL, NULL),
SDT_CONDVAR (Patches, yapf.rail_shorter_platform_per_tile_penalty, SLE_UINT, 28, SL_MAX_VERSION,NS, 0, 0 * YAPF_TILE_LENGTH, 0, 20000, STR_NULL, NULL),
+ // road vehicles - penalties
+ SDT_CONDVAR (Patches, yapf.road_slope_penalty , SLE_UINT, 28, SL_MAX_VERSION,NS, 0, 2 * YAPF_TILE_LENGTH, 0, 1000000, STR_NULL, NULL),
+ SDT_CONDVAR (Patches, yapf.rail_crossing_penalty , SLE_UINT, 28, SL_MAX_VERSION,NS, 0, 3 * YAPF_TILE_LENGTH, 0, 1000000, STR_NULL, NULL),
SDT_END()
};
diff --git a/yapf/yapf_road.cpp b/yapf/yapf_road.cpp
index e25e57ed0..1f54e5799 100644
--- a/yapf/yapf_road.cpp
+++ b/yapf/yapf_road.cpp
@@ -33,7 +33,7 @@ protected:
if (z2 - z1 > 1) {
/* Slope up */
- return Yapf().PfGetSettings().rail_slope_penalty;
+ return Yapf().PfGetSettings().road_slope_penalty;
}
return 0;
}
@@ -44,12 +44,12 @@ protected:
int cost = 0;
// set base cost
if (IsDiagonalTrackdir(trackdir)) {
- cost += 10;
+ cost += YAPF_TILE_LENGTH;
switch (GetTileType(tile)) {
case MP_STREET:
/* Increase the cost for level crossings */
if (IsLevelCrossing(tile))
- cost += Yapf().PfGetSettings().rail_crossing_penalty;
+ cost += Yapf().PfGetSettings().road_crossing_penalty;
break;
default:
@@ -57,7 +57,7 @@ protected:
}
} else {
// non-diagonal trackdir
- cost = 7;
+ cost = YAPF_TILE_CORNER_LENGTH;
}
return cost;
}
@@ -95,7 +95,7 @@ public:
if (F.m_new_tile == n.m_key.m_tile && new_td == n.m_key.m_td) return false;
// if we skipped some tunnel tiles, add their cost
- segment_cost += 10 * F.m_tiles_skipped;
+ segment_cost += F.m_tiles_skipped * YAPF_TILE_LENGTH;
// add hilly terrain penalty
segment_cost += Yapf().SlopeCost(tile, F.m_new_tile, trackdir);
@@ -206,7 +206,7 @@ public:
int dy = abs(y1 - y2);
int dmin = min(dx, dy);
int dxy = abs(dx - dy);
- int d = dmin * 7 + (dxy - 1) * 5;
+ int d = dmin * YAPF_TILE_CORNER_LENGTH + (dxy - 1) * (YAPF_TILE_LENGTH / 2);
n.m_estimate = n.m_cost + d;
assert(n.m_estimate >= n.m_parent->m_estimate);
return true;
diff --git a/yapf/yapf_settings.h b/yapf/yapf_settings.h
index 3db44547e..aa87ab9d6 100644
--- a/yapf/yapf_settings.h
+++ b/yapf/yapf_settings.h
@@ -36,6 +36,8 @@ YS_DEF_BEGIN
YS_DEF(bool , ship_use_yapf) ///< use YAPF for ships
YS_DEF(bool , road_use_yapf) ///< use YAPF for road
YS_DEF(bool , rail_use_yapf) ///< use YAPF for rail
+ YS_DEF(uint32, road_slope_penalty) ///< penalty for up-hill slope
+ YS_DEF(uint32, road_crossing_penalty) ///< penalty for level crossing
YS_DEF(bool , rail_firstred_twoway_eol) ///< treat first red two-way signal as dead end
YS_DEF(uint32, rail_firstred_penalty) ///< penalty for first red signal
YS_DEF(uint32, rail_firstred_exit_penalty) ///< penalty for first red exit signal