(svn r6159) -Fix: FindClosestTrainDepot hardly ever found a depot with NPF off due to absence of distance-normalization (Rojer)

This commit is contained in:
Darkvater 2006-08-26 21:54:04 +00:00
parent 6540ae18fd
commit 45fa300208
3 changed files with 7 additions and 6 deletions

View File

@ -637,11 +637,6 @@ static const uint16 _is_upwards_slope[15] = {
0, //14 0, //14
}; };
#define DIAG_FACTOR 3
#define STR_FACTOR 2
static uint DistanceMoo(TileIndex t0, TileIndex t1) static uint DistanceMoo(TileIndex t0, TileIndex t1)
{ {
const uint dx = abs(TileX(t0) - TileX(t1)); const uint dx = abs(TileX(t0) - TileX(t1));

View File

@ -5,6 +5,11 @@
#include "direction.h" #include "direction.h"
enum {
STR_FACTOR = 2,
DIAG_FACTOR = 3
};
//#define PF_BENCH // perform simple benchmarks on the train pathfinder (not //#define PF_BENCH // perform simple benchmarks on the train pathfinder (not
//supported on all archs) //supported on all archs)

View File

@ -1847,7 +1847,8 @@ static bool NtpCallbFindDepot(TileIndex tile, TrainFindDepotData *tfdd, int trac
if (IsTileType(tile, MP_RAILWAY) && if (IsTileType(tile, MP_RAILWAY) &&
IsTileOwner(tile, tfdd->owner) && IsTileOwner(tile, tfdd->owner) &&
IsRailDepot(tile)) { IsRailDepot(tile)) {
tfdd->best_length = length; /* approximate number of tiles by dividing by DIAG_FACTOR */
tfdd->best_length = length / DIAG_FACTOR;
tfdd->tile = tile; tfdd->tile = tile;
return true; return true;
} }