summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatthijs <matthijs@openttd.org>2005-06-16 17:53:40 +0000
committermatthijs <matthijs@openttd.org>2005-06-16 17:53:40 +0000
commit65de40f5476af608239137d9917269a54a7f5d28 (patch)
treeb393c22d92fe82d6de7c2c0eef53d90bfd8e3430
parent9d61f5efe8014bb99376697c87d22e8ab696be09 (diff)
downloadopenttd-65de40f5476af608239137d9917269a54a7f5d28.tar.xz
(svn r2447) * Add: [NPF] Penalty for road vehicles making turns.
-rw-r--r--npf.c6
-rw-r--r--settings.c2
-rw-r--r--variables.h1
3 files changed, 7 insertions, 2 deletions
diff --git a/npf.c b/npf.c
index c3d0f0bef..f8fb7ed0c 100644
--- a/npf.c
+++ b/npf.c
@@ -322,8 +322,10 @@ int32 NPFRoadPathCost(AyStar* as, AyStarNode* current, OpenListNode* parent) {
/* Check for slope */
cost += NPFSlopeCost(current);
- /* Check for turns */
- //TODO
+ /* Check for turns. Road vehicles only really drive diagonal, turns are
+ * represented by non-diagonal tracks */
+ if (!IsDiagonalTrackdir(current->direction))
+ cost += _patches.npf_road_curve_penalty;
NPFMarkTile(tile);
DEBUG(npf, 4)("Calculating G for: (%d, %d). Result: %d", TileX(current->tile), TileY(current->tile), cost);
diff --git a/settings.c b/settings.c
index 0358d0fca..d63662597 100644
--- a/settings.c
+++ b/settings.c
@@ -975,6 +975,8 @@ const SettingDesc patch_settings[] = {
* rail curve penalty, since ships (realisticly) have more trouble with
* making turns */
{"npf_water_curve_penalty", SDT_UINT32, (void*)(NPF_TILE_LENGTH / 4), &_patches.npf_water_curve_penalty, NULL},
+ /* This is the penalty for road, same as for rail. */
+ {"npf_road_curve_penalty", SDT_UINT32, (void*)(1), &_patches.npf_road_curve_penalty, NULL},
{NULL, 0, NULL, NULL, NULL}
};
diff --git a/variables.h b/variables.h
index 80624aaeb..3525783b9 100644
--- a/variables.h
+++ b/variables.h
@@ -215,6 +215,7 @@ typedef struct Patches {
uint32 npf_rail_depot_reverse_penalty; /* The penalty for reversing in depots */
uint32 npf_buoy_penalty; /* The penalty for going over (through) a buoy */
uint32 npf_water_curve_penalty; /* The penalty for curves */
+ uint32 npf_road_curve_penalty; /* The penalty for curves */
bool population_in_label; // Show the population of a town in his label?
} Patches;