summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarkvater <darkvater@openttd.org>2006-08-26 21:54:04 +0000
committerDarkvater <darkvater@openttd.org>2006-08-26 21:54:04 +0000
commit45fa3002088a914fe19ae59f0f4eef77f214e92e (patch)
treeec8cd508fd46492ed27f78bc9edf6ea11d659dd3
parent6540ae18fd4447ecd4f5dd04b35c3e8248da3124 (diff)
downloadopenttd-45fa3002088a914fe19ae59f0f4eef77f214e92e.tar.xz
(svn r6159) -Fix: FindClosestTrainDepot hardly ever found a depot with NPF off due to absence of distance-normalization (Rojer)
-rw-r--r--pathfind.c5
-rw-r--r--pathfind.h5
-rw-r--r--train_cmd.c3
3 files changed, 7 insertions, 6 deletions
diff --git a/pathfind.c b/pathfind.c
index 9a001aac1..e73d3bfa2 100644
--- a/pathfind.c
+++ b/pathfind.c
@@ -637,11 +637,6 @@ static const uint16 _is_upwards_slope[15] = {
0, //14
};
-
-#define DIAG_FACTOR 3
-#define STR_FACTOR 2
-
-
static uint DistanceMoo(TileIndex t0, TileIndex t1)
{
const uint dx = abs(TileX(t0) - TileX(t1));
diff --git a/pathfind.h b/pathfind.h
index 564d83dc2..432d7ea88 100644
--- a/pathfind.h
+++ b/pathfind.h
@@ -5,6 +5,11 @@
#include "direction.h"
+enum {
+ STR_FACTOR = 2,
+ DIAG_FACTOR = 3
+};
+
//#define PF_BENCH // perform simple benchmarks on the train pathfinder (not
//supported on all archs)
diff --git a/train_cmd.c b/train_cmd.c
index 5fe309c98..468bcdba6 100644
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -1847,7 +1847,8 @@ static bool NtpCallbFindDepot(TileIndex tile, TrainFindDepotData *tfdd, int trac
if (IsTileType(tile, MP_RAILWAY) &&
IsTileOwner(tile, tfdd->owner) &&
IsRailDepot(tile)) {
- tfdd->best_length = length;
+ /* approximate number of tiles by dividing by DIAG_FACTOR */
+ tfdd->best_length = length / DIAG_FACTOR;
tfdd->tile = tile;
return true;
}