mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r18481) -Codechange: unify the curve pathfinder penalty defaults; 0.01 tile won't make a dent, 3 tiles might be a bit too much
-Feature-ish: make maximum pathfinder penalties for finding depots customisable, also increase it slightly to 20 tiles worth of penalties.
This commit is contained in:
parent
3cfcae07e2
commit
472e5501fa
|
@ -1127,7 +1127,7 @@ static void NPFFillWithOrderData(NPFFindStationOrTileData *fstd, const Vehicle *
|
|||
|
||||
/*** Road vehicles ***/
|
||||
|
||||
FindDepotData NPFRoadVehicleFindNearestDepot(const RoadVehicle *v, int max_distance)
|
||||
FindDepotData NPFRoadVehicleFindNearestDepot(const RoadVehicle *v, int max_penalty)
|
||||
{
|
||||
Trackdir trackdir = v->GetVehicleTrackdir();
|
||||
|
||||
|
@ -1140,7 +1140,7 @@ FindDepotData NPFRoadVehicleFindNearestDepot(const RoadVehicle *v, int max_dista
|
|||
* number by this. It might not be completely what we want, but it will
|
||||
* work for now :-) We can possibly change this when the old pathfinder
|
||||
* is removed. */
|
||||
return FindDepotData(ftd.node.tile, ftd.best_path_dist / NPF_TILE_LENGTH);
|
||||
return FindDepotData(ftd.node.tile, ftd.best_path_dist);
|
||||
}
|
||||
|
||||
Trackdir NPFRoadVehicleChooseTrack(const RoadVehicle *v, TileIndex tile, DiagDirection enterdir, TrackdirBits trackdirs)
|
||||
|
@ -1187,7 +1187,7 @@ Track NPFShipChooseTrack(const Ship *v, TileIndex tile, DiagDirection enterdir,
|
|||
|
||||
/*** Trains ***/
|
||||
|
||||
FindDepotData NPFTrainFindNearestDepot(const Train *v, int max_distance)
|
||||
FindDepotData NPFTrainFindNearestDepot(const Train *v, int max_penalty)
|
||||
{
|
||||
const Train *last = v->Last();
|
||||
Trackdir trackdir = v->GetVehicleTrackdir();
|
||||
|
@ -1202,7 +1202,7 @@ FindDepotData NPFTrainFindNearestDepot(const Train *v, int max_distance)
|
|||
* number by this. It might not be completely what we want, but it will
|
||||
* work for now :-) We can possibly change this when the old pathfinder
|
||||
* is removed. */
|
||||
return FindDepotData(ftd.node.tile, ftd.best_path_dist / NPF_TILE_LENGTH, NPFGetFlag(&ftd.node, NPF_FLAG_REVERSE));
|
||||
return FindDepotData(ftd.node.tile, ftd.best_path_dist, NPFGetFlag(&ftd.node, NPF_FLAG_REVERSE));
|
||||
}
|
||||
|
||||
bool NPFTrainFindNearestSafeTile(const Train *v, TileIndex tile, Trackdir trackdir, bool override_railtype)
|
||||
|
|
|
@ -19,12 +19,12 @@
|
|||
/**
|
||||
* Used when user sends road vehicle to the nearest depot or if road vehicle needs servicing using NPF.
|
||||
* @param v vehicle that needs to go to some depot
|
||||
* @param max_distance max distance (number of track tiles) from the current vehicle position
|
||||
* (used also as optimization - the pathfinder can stop path finding if max_distance
|
||||
* @param max_penalty max distance (in pathfinder penalty) from the current vehicle position
|
||||
* (used also as optimization - the pathfinder can stop path finding if max_penalty
|
||||
* was reached and no depot was seen)
|
||||
* @return the data about the depot
|
||||
*/
|
||||
FindDepotData NPFRoadVehicleFindNearestDepot(const RoadVehicle *v, int max_distance);
|
||||
FindDepotData NPFRoadVehicleFindNearestDepot(const RoadVehicle *v, int max_penalty);
|
||||
|
||||
/**
|
||||
* Finds the best path for given road vehicle using NPF.
|
||||
|
@ -49,12 +49,12 @@ Track NPFShipChooseTrack(const Ship *v, TileIndex tile, DiagDirection enterdir,
|
|||
/**
|
||||
* Used when user sends train to the nearest depot or if train needs servicing using NPF
|
||||
* @param v train that needs to go to some depot
|
||||
* @param max_distance max distance (number of track tiles) from the current train position
|
||||
* (used also as optimization - the pathfinder can stop path finding if max_distance
|
||||
* @param max_penalty max max_penalty (in pathfinder penalty) from the current train position
|
||||
* (used also as optimization - the pathfinder can stop path finding if max_penalty
|
||||
* was reached and no depot was seen)
|
||||
* @return the data about the depot
|
||||
*/
|
||||
FindDepotData NPFTrainFindNearestDepot(const Train *v, int max_distance);
|
||||
FindDepotData NPFTrainFindNearestDepot(const Train *v, int max_penalty);
|
||||
|
||||
/**
|
||||
* Try to extend the reserved path of a train to the nearest safe tile using NPF.
|
||||
|
|
|
@ -43,7 +43,7 @@ static const int YAPF_INFINITE_PENALTY = 1000 * YAPF_TILE_LENGTH;
|
|||
*/
|
||||
struct FindDepotData {
|
||||
TileIndex tile; ///< The tile of the depot
|
||||
uint best_length; ///< The distance towards the depot, or UINT_MAX if not found
|
||||
uint best_length; ///< The distance towards the depot in penalty, or UINT_MAX if not found
|
||||
bool reverse; ///< True if reversing is necessary for the train to get to this depot
|
||||
|
||||
/**
|
||||
|
|
|
@ -52,18 +52,18 @@ Track YapfTrainChooseTrack(const Train *v, TileIndex tile, DiagDirection enterdi
|
|||
/**
|
||||
* Used when user sends road vehicle to the nearest depot or if road vehicle needs servicing using YAPF.
|
||||
* @param v vehicle that needs to go to some depot
|
||||
* @param max_distance max distance (number of track tiles) from the current vehicle position
|
||||
* (used also as optimization - the pathfinder can stop path finding if max_distance
|
||||
* @param max_penalty max distance (in pathfinder penalty) from the current vehicle position
|
||||
* (used also as optimization - the pathfinder can stop path finding if max_penalty
|
||||
* was reached and no depot was seen)
|
||||
* @return the data about the depot
|
||||
*/
|
||||
FindDepotData YapfRoadVehicleFindNearestDepot(const RoadVehicle *v, int max_distance);
|
||||
FindDepotData YapfRoadVehicleFindNearestDepot(const RoadVehicle *v, int max_penalty);
|
||||
|
||||
/**
|
||||
* Used when user sends train to the nearest depot or if train needs servicing using YAPF.
|
||||
* @param v train that needs to go to some depot
|
||||
* @param max_distance max distance (number of track tiles) from the current train position
|
||||
* (used also as optimization - the pathfinder can stop path finding if max_distance
|
||||
* @param max_penalty max distance (int pathfinder penalty) from the current train position
|
||||
* (used also as optimization - the pathfinder can stop path finding if max_penalty
|
||||
* was reached and no depot was seen)
|
||||
* @return the data about the depot
|
||||
*/
|
||||
|
|
|
@ -217,7 +217,7 @@ public:
|
|||
return 't';
|
||||
}
|
||||
|
||||
static bool stFindNearestDepotTwoWay(const Train *v, TileIndex t1, Trackdir td1, TileIndex t2, Trackdir td2, int max_distance, int reverse_penalty, TileIndex *depot_tile, bool *reversed)
|
||||
static bool stFindNearestDepotTwoWay(const Train *v, TileIndex t1, Trackdir td1, TileIndex t2, Trackdir td2, int max_penalty, int reverse_penalty, TileIndex *depot_tile, bool *reversed)
|
||||
{
|
||||
Tpf pf1;
|
||||
/*
|
||||
|
@ -229,15 +229,15 @@ public:
|
|||
* so it will only impact performance when you do not manually set
|
||||
* depot orders and you do not disable automatic servicing.
|
||||
*/
|
||||
if (max_distance != 0) pf1.DisableCache(true);
|
||||
bool result1 = pf1.FindNearestDepotTwoWay(v, t1, td1, t2, td2, max_distance, reverse_penalty, depot_tile, reversed);
|
||||
if (max_penalty != 0) pf1.DisableCache(true);
|
||||
bool result1 = pf1.FindNearestDepotTwoWay(v, t1, td1, t2, td2, max_penalty, reverse_penalty, depot_tile, reversed);
|
||||
|
||||
#if DEBUG_YAPF_CACHE
|
||||
Tpf pf2;
|
||||
TileIndex depot_tile2 = INVALID_TILE;
|
||||
bool reversed2 = false;
|
||||
pf2.DisableCache(true);
|
||||
bool result2 = pf2.FindNearestDepotTwoWay(v, t1, td1, t2, td2, max_distance, reverse_penalty, &depot_tile2, &reversed2);
|
||||
bool result2 = pf2.FindNearestDepotTwoWay(v, t1, td1, t2, td2, max_penalty, reverse_penalty, &depot_tile2, &reversed2);
|
||||
if (result1 != result2 || (result1 && (*depot_tile != depot_tile2 || *reversed != reversed2))) {
|
||||
DEBUG(yapf, 0, "CACHE ERROR: FindNearestDepotTwoWay() = [%s, %s]", result1 ? "T" : "F", result2 ? "T" : "F");
|
||||
DumpState(pf1, pf2);
|
||||
|
@ -247,12 +247,12 @@ public:
|
|||
return result1;
|
||||
}
|
||||
|
||||
FORCEINLINE bool FindNearestDepotTwoWay(const Train *v, TileIndex t1, Trackdir td1, TileIndex t2, Trackdir td2, int max_distance, int reverse_penalty, TileIndex *depot_tile, bool *reversed)
|
||||
FORCEINLINE bool FindNearestDepotTwoWay(const Train *v, TileIndex t1, Trackdir td1, TileIndex t2, Trackdir td2, int max_penalty, int reverse_penalty, TileIndex *depot_tile, bool *reversed)
|
||||
{
|
||||
/* set origin and destination nodes */
|
||||
Yapf().SetOrigin(t1, td1, t2, td2, reverse_penalty, true);
|
||||
Yapf().SetDestination(v);
|
||||
Yapf().SetMaxCost(YAPF_TILE_LENGTH * max_distance);
|
||||
Yapf().SetMaxCost(max_penalty);
|
||||
|
||||
/* find the best path */
|
||||
bool bFound = Yapf().FindPath(v);
|
||||
|
@ -600,7 +600,7 @@ bool YapfTrainCheckReverse(const Train *v)
|
|||
return reverse;
|
||||
}
|
||||
|
||||
FindDepotData YapfTrainFindNearestDepot(const Train *v, int max_distance)
|
||||
FindDepotData YapfTrainFindNearestDepot(const Train *v, int max_penalty)
|
||||
{
|
||||
FindDepotData fdd;
|
||||
|
||||
|
@ -618,8 +618,8 @@ FindDepotData YapfTrainFindNearestDepot(const Train *v, int max_distance)
|
|||
pfnFindNearestDepotTwoWay = &CYapfAnyDepotRail2::stFindNearestDepotTwoWay; // Trackdir, forbid 90-deg
|
||||
}
|
||||
|
||||
bool ret = pfnFindNearestDepotTwoWay(v, origin.tile, origin.trackdir, last_tile, td_rev, max_distance, YAPF_INFINITE_PENALTY, &fdd.tile, &fdd.reverse);
|
||||
fdd.best_length = ret ? max_distance / 2 : UINT_MAX; // some fake distance or NOT_FOUND
|
||||
bool ret = pfnFindNearestDepotTwoWay(v, origin.tile, origin.trackdir, last_tile, td_rev, max_penalty, YAPF_INFINITE_PENALTY, &fdd.tile, &fdd.reverse);
|
||||
fdd.best_length = ret ? max_penalty / 2 : UINT_MAX; // some fake distance or NOT_FOUND
|
||||
return fdd;
|
||||
}
|
||||
|
||||
|
|
|
@ -358,8 +358,8 @@ static FindDepotData FindClosestRoadDepot(const RoadVehicle *v, int max_distance
|
|||
if (IsRoadDepotTile(v->tile)) return FindDepotData(v->tile, 0);
|
||||
|
||||
switch (_settings_game.pf.pathfinder_for_roadvehs) {
|
||||
case VPF_NPF: return NPFRoadVehicleFindNearestDepot(v, max_distance);
|
||||
case VPF_YAPF: return YapfRoadVehicleFindNearestDepot(v, max_distance);
|
||||
case VPF_NPF: return NPFRoadVehicleFindNearestDepot(v, _settings_game.pf.npf.maximum_go_to_depot_penalty);
|
||||
case VPF_YAPF: return YapfRoadVehicleFindNearestDepot(v, _settings_game.pf.yapf.maximum_go_to_depot_penalty);
|
||||
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
|
@ -1608,8 +1608,6 @@ bool RoadVehicle::Tick()
|
|||
|
||||
static void CheckIfRoadVehNeedsService(RoadVehicle *v)
|
||||
{
|
||||
static const uint MAX_ACCEPTABLE_DEPOT_DIST = 16;
|
||||
|
||||
/* If we already got a slot at a stop, use that FIRST, and go to a depot later */
|
||||
if (Company::Get(v->owner)->settings.vehicle.servint_roadveh == 0 || !v->NeedsAutomaticServicing()) return;
|
||||
if (v->IsInDepot()) {
|
||||
|
@ -1617,9 +1615,16 @@ static void CheckIfRoadVehNeedsService(RoadVehicle *v)
|
|||
return;
|
||||
}
|
||||
|
||||
FindDepotData rfdd = FindClosestRoadDepot(v, MAX_ACCEPTABLE_DEPOT_DIST);
|
||||
uint max_penalty;
|
||||
switch (_settings_game.pf.pathfinder_for_roadvehs) {
|
||||
case VPF_NPF: max_penalty = _settings_game.pf.npf.maximum_go_to_depot_penalty; break;
|
||||
case VPF_YAPF: max_penalty = _settings_game.pf.yapf.maximum_go_to_depot_penalty; break;
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
|
||||
FindDepotData rfdd = FindClosestRoadDepot(v, max_penalty);
|
||||
/* Only go to the depot if it is not too far out of our way. */
|
||||
if (rfdd.best_length == UINT_MAX || rfdd.best_length > MAX_ACCEPTABLE_DEPOT_DIST) {
|
||||
if (rfdd.best_length == UINT_MAX || rfdd.best_length > max_penalty) {
|
||||
if (v->current_order.IsType(OT_GOTO_DEPOT)) {
|
||||
/* If we were already heading for a depot but it has
|
||||
* suddenly moved farther away, we continue our normal
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
|
||||
#include "saveload_internal.h"
|
||||
|
||||
extern const uint16 SAVEGAME_VERSION = 130;
|
||||
extern const uint16 SAVEGAME_VERSION = 131;
|
||||
|
||||
SavegameType _savegame_type; ///< type of savegame we are loading
|
||||
|
||||
|
|
|
@ -208,6 +208,7 @@ struct NPFSettings {
|
|||
* of not being perfect anymore.
|
||||
*/
|
||||
uint32 npf_max_search_nodes;
|
||||
uint32 maximum_go_to_depot_penalty; ///< What is the maximum penalty that may be endured for going to a depot
|
||||
|
||||
uint32 npf_rail_firstred_penalty; ///< the penalty for when the first signal is red (and it is not an exit or combo signal)
|
||||
uint32 npf_rail_firstred_exit_penalty; ///< the penalty for when the first signal is red (and it is an exit or combo signal)
|
||||
|
@ -231,6 +232,7 @@ struct NPFSettings {
|
|||
struct YAPFSettings {
|
||||
bool disable_node_optimization; ///< whether to use exit-dir instead of trackdir in node key
|
||||
uint32 max_search_nodes; ///< stop path-finding when this number of nodes visited
|
||||
uint32 maximum_go_to_depot_penalty; ///< What is the maximum penalty that may be endured for going to a depot
|
||||
bool ship_use_yapf; ///< use YAPF for ships
|
||||
bool road_use_yapf; ///< use YAPF for road
|
||||
bool rail_use_yapf; ///< use YAPF for rail
|
||||
|
|
|
@ -126,9 +126,17 @@ static void CheckIfShipNeedsService(Vehicle *v)
|
|||
return;
|
||||
}
|
||||
|
||||
uint max_distance;
|
||||
switch (_settings_game.pf.pathfinder_for_ships) {
|
||||
case VPF_OPF: max_distance = 12; break;
|
||||
case VPF_NPF: max_distance = _settings_game.pf.npf.maximum_go_to_depot_penalty / NPF_TILE_LENGTH; break;
|
||||
case VPF_YAPF: max_distance = _settings_game.pf.yapf.maximum_go_to_depot_penalty / YAPF_TILE_LENGTH; break;
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
|
||||
const Depot *depot = FindClosestShipDepot(v);
|
||||
|
||||
if (depot == NULL || DistanceManhattan(v->tile, depot->xy) > 12) {
|
||||
if (depot == NULL || DistanceManhattan(v->tile, depot->xy) > max_distance) {
|
||||
if (v->current_order.IsType(OT_GOTO_DEPOT)) {
|
||||
v->current_order.MakeDummy();
|
||||
SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
|
||||
|
|
|
@ -464,18 +464,18 @@ const SettingDesc _settings[] = {
|
|||
SDT_VAR(GameSettings, pf.npf.npf_rail_lastred_penalty, SLE_UINT, 0, 0, ( 10 * NPF_TILE_LENGTH), 0, 100000, 0, STR_NULL, NULL),
|
||||
SDT_VAR(GameSettings, pf.npf.npf_rail_station_penalty, SLE_UINT, 0, 0, ( 1 * NPF_TILE_LENGTH), 0, 100000, 0, STR_NULL, NULL),
|
||||
SDT_VAR(GameSettings, pf.npf.npf_rail_slope_penalty, SLE_UINT, 0, 0, ( 1 * NPF_TILE_LENGTH), 0, 100000, 0, STR_NULL, NULL),
|
||||
SDT_VAR(GameSettings, pf.npf.npf_rail_curve_penalty, SLE_UINT, 0, 0, 1, 0, 100000, 0, STR_NULL, NULL),
|
||||
SDT_VAR(GameSettings, pf.npf.npf_rail_curve_penalty, SLE_UINT, 0, 0, ( 1 * NPF_TILE_LENGTH), 0, 100000, 0, STR_NULL, NULL),
|
||||
SDT_VAR(GameSettings, pf.npf.npf_rail_depot_reverse_penalty, SLE_UINT, 0, 0, ( 50 * NPF_TILE_LENGTH), 0, 100000, 0, STR_NULL, NULL),
|
||||
SDT_CONDVAR(GameSettings, pf.npf.npf_rail_pbs_cross_penalty, SLE_UINT,100, SL_MAX_VERSION, 0, 0, ( 3 * NPF_TILE_LENGTH), 0, 100000, 0, STR_NULL, NULL),
|
||||
SDT_CONDVAR(GameSettings, pf.npf.npf_rail_pbs_signal_back_penalty, SLE_UINT,100, SL_MAX_VERSION, 0, 0, ( 15 * NPF_TILE_LENGTH), 0, 100000, 0, STR_NULL, NULL),
|
||||
SDT_VAR(GameSettings, pf.npf.npf_buoy_penalty, SLE_UINT, 0, 0, ( 2 * NPF_TILE_LENGTH), 0, 100000, 0, STR_NULL, NULL),
|
||||
SDT_VAR(GameSettings, pf.npf.npf_water_curve_penalty, SLE_UINT, 0, 0, (NPF_TILE_LENGTH / 4), 0, 100000, 0, STR_NULL, NULL),
|
||||
SDT_VAR(GameSettings, pf.npf.npf_road_curve_penalty, SLE_UINT, 0, 0, 1, 0, 100000, 0, STR_NULL, NULL),
|
||||
SDT_VAR(GameSettings, pf.npf.npf_water_curve_penalty, SLE_UINT, 0, 0, ( 1 * NPF_TILE_LENGTH), 0, 100000, 0, STR_NULL, NULL),
|
||||
SDT_VAR(GameSettings, pf.npf.npf_road_curve_penalty, SLE_UINT, 0, 0, ( 1 * NPF_TILE_LENGTH), 0, 100000, 0, STR_NULL, NULL),
|
||||
SDT_VAR(GameSettings, pf.npf.npf_crossing_penalty, SLE_UINT, 0, 0, ( 3 * NPF_TILE_LENGTH), 0, 100000, 0, STR_NULL, NULL),
|
||||
SDT_CONDVAR(GameSettings, pf.npf.npf_road_drive_through_penalty, SLE_UINT, 47, SL_MAX_VERSION, 0, 0, ( 8 * NPF_TILE_LENGTH), 0, 100000, 0, STR_NULL, NULL),
|
||||
SDT_CONDVAR(GameSettings, pf.npf.npf_road_dt_occupied_penalty, SLE_UINT,130, SL_MAX_VERSION, 0, 0, ( 8 * NPF_TILE_LENGTH), 0, 100000, 0, STR_NULL, NULL),
|
||||
SDT_CONDVAR(GameSettings, pf.npf.npf_road_bay_occupied_penalty, SLE_UINT,130, SL_MAX_VERSION, 0, 0, ( 15 * NPF_TILE_LENGTH), 0, 100000, 0, STR_NULL, NULL),
|
||||
|
||||
SDT_CONDVAR(GameSettings, pf.npf.maximum_go_to_depot_penalty, SLE_UINT,131, SL_MAX_VERSION, 0, 0, ( 20 * NPF_TILE_LENGTH), 0, 1000000, 0, STR_NULL, NULL),
|
||||
|
||||
SDT_CONDBOOL(GameSettings, pf.yapf.disable_node_optimization, 28, SL_MAX_VERSION, 0, 0, false, STR_NULL, NULL),
|
||||
SDT_CONDVAR(GameSettings, pf.yapf.max_search_nodes, SLE_UINT, 28, SL_MAX_VERSION, 0, 0, 10000, 500, 1000000, 0, STR_NULL, NULL),
|
||||
|
@ -486,7 +486,7 @@ const SettingDesc _settings[] = {
|
|||
SDT_CONDVAR(GameSettings, pf.yapf.rail_lastred_exit_penalty, SLE_UINT, 28, SL_MAX_VERSION, 0, 0, 100 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
|
||||
SDT_CONDVAR(GameSettings, pf.yapf.rail_station_penalty, SLE_UINT, 28, SL_MAX_VERSION, 0, 0, 10 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
|
||||
SDT_CONDVAR(GameSettings, pf.yapf.rail_slope_penalty, SLE_UINT, 28, SL_MAX_VERSION, 0, 0, 2 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
|
||||
SDT_CONDVAR(GameSettings, pf.yapf.rail_curve45_penalty, SLE_UINT, 28, SL_MAX_VERSION, 0, 0, 3 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
|
||||
SDT_CONDVAR(GameSettings, pf.yapf.rail_curve45_penalty, SLE_UINT, 28, SL_MAX_VERSION, 0, 0, 1 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
|
||||
SDT_CONDVAR(GameSettings, pf.yapf.rail_curve90_penalty, SLE_UINT, 28, SL_MAX_VERSION, 0, 0, 6 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
|
||||
SDT_CONDVAR(GameSettings, pf.yapf.rail_depot_reverse_penalty, SLE_UINT, 28, SL_MAX_VERSION, 0, 0, 50 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
|
||||
SDT_CONDVAR(GameSettings, pf.yapf.rail_crossing_penalty, SLE_UINT, 28, SL_MAX_VERSION, 0, 0, 3 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
|
||||
|
@ -508,6 +508,7 @@ const SettingDesc _settings[] = {
|
|||
SDT_CONDVAR(GameSettings, pf.yapf.road_stop_penalty, SLE_UINT, 47, SL_MAX_VERSION, 0, 0, 8 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
|
||||
SDT_CONDVAR(GameSettings, pf.yapf.road_stop_occupied_penalty, SLE_UINT,130, SL_MAX_VERSION, 0, 0, 8 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
|
||||
SDT_CONDVAR(GameSettings, pf.yapf.road_stop_bay_occupied_penalty, SLE_UINT,130, SL_MAX_VERSION, 0, 0, 15 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
|
||||
SDT_CONDVAR(GameSettings, pf.yapf.maximum_go_to_depot_penalty, SLE_UINT,131, SL_MAX_VERSION, 0, 0, 20 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
|
||||
|
||||
SDT_CONDVAR(GameSettings, game_creation.land_generator, SLE_UINT8, 30, SL_MAX_VERSION, 0,MS, 1, 0, 1, 0, STR_CONFIG_SETTING_LAND_GENERATOR, NULL),
|
||||
SDT_CONDVAR(GameSettings, game_creation.oil_refinery_limit, SLE_UINT8, 30, SL_MAX_VERSION, 0, 0, 32, 12, 48, 0, STR_CONFIG_SETTING_OIL_REF_EDGE_DISTANCE, NULL),
|
||||
|
|
|
@ -2093,8 +2093,8 @@ static FindDepotData FindClosestTrainDepot(Train *v, int max_distance)
|
|||
if (IsRailDepotTile(origin.tile)) return FindDepotData(origin.tile, 0);
|
||||
|
||||
switch (_settings_game.pf.pathfinder_for_trains) {
|
||||
case VPF_NPF: return NPFTrainFindNearestDepot(v, max_distance);
|
||||
case VPF_YAPF: return YapfTrainFindNearestDepot(v, max_distance);
|
||||
case VPF_NPF: return NPFTrainFindNearestDepot(v, _settings_game.pf.npf.maximum_go_to_depot_penalty);
|
||||
case VPF_YAPF: return YapfTrainFindNearestDepot(v, _settings_game.pf.yapf.maximum_go_to_depot_penalty);
|
||||
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
|
@ -4100,17 +4100,22 @@ bool Train::Tick()
|
|||
|
||||
static void CheckIfTrainNeedsService(Train *v)
|
||||
{
|
||||
static const uint MAX_ACCEPTABLE_DEPOT_DIST = 16;
|
||||
|
||||
if (Company::Get(v->owner)->settings.vehicle.servint_trains == 0 || !v->NeedsAutomaticServicing()) return;
|
||||
if (v->IsInDepot()) {
|
||||
VehicleServiceInDepot(v);
|
||||
return;
|
||||
}
|
||||
|
||||
FindDepotData tfdd = FindClosestTrainDepot(v, MAX_ACCEPTABLE_DEPOT_DIST);
|
||||
uint max_penalty;
|
||||
switch (_settings_game.pf.pathfinder_for_trains) {
|
||||
case VPF_NPF: max_penalty = _settings_game.pf.npf.maximum_go_to_depot_penalty; break;
|
||||
case VPF_YAPF: max_penalty = _settings_game.pf.yapf.maximum_go_to_depot_penalty; break;
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
|
||||
FindDepotData tfdd = FindClosestTrainDepot(v, max_penalty);
|
||||
/* Only go to the depot if it is not too far out of our way. */
|
||||
if (tfdd.best_length == UINT_MAX || tfdd.best_length > MAX_ACCEPTABLE_DEPOT_DIST) {
|
||||
if (tfdd.best_length == UINT_MAX || tfdd.best_length > max_penalty) {
|
||||
if (v->current_order.IsType(OT_GOTO_DEPOT)) {
|
||||
/* If we were already heading for a depot but it has
|
||||
* suddenly moved farther away, we continue our normal
|
||||
|
|
Loading…
Reference in New Issue