mirror of https://github.com/OpenTTD/OpenTTD.git
Compare commits
6 Commits
16c45966c3
...
4feec630a5
Author | SHA1 | Date |
---|---|---|
merni-ns | 4feec630a5 | |
Peter Nelson | bf8de188ec | |
Peter Nelson | 72c55128d2 | |
merni-ns | bd121aa59f | |
merni-ns | d7fd2a9058 | |
merni-ns | 18d054150a |
|
@ -42,7 +42,6 @@ int _debug_misc_level;
|
||||||
int _debug_net_level;
|
int _debug_net_level;
|
||||||
int _debug_sprite_level;
|
int _debug_sprite_level;
|
||||||
int _debug_oldloader_level;
|
int _debug_oldloader_level;
|
||||||
int _debug_npf_level;
|
|
||||||
int _debug_yapf_level;
|
int _debug_yapf_level;
|
||||||
int _debug_fontcache_level;
|
int _debug_fontcache_level;
|
||||||
int _debug_script_level;
|
int _debug_script_level;
|
||||||
|
@ -68,7 +67,6 @@ static const DebugLevel _debug_levels[] = {
|
||||||
DEBUG_LEVEL(net),
|
DEBUG_LEVEL(net),
|
||||||
DEBUG_LEVEL(sprite),
|
DEBUG_LEVEL(sprite),
|
||||||
DEBUG_LEVEL(oldloader),
|
DEBUG_LEVEL(oldloader),
|
||||||
DEBUG_LEVEL(npf),
|
|
||||||
DEBUG_LEVEL(yapf),
|
DEBUG_LEVEL(yapf),
|
||||||
DEBUG_LEVEL(fontcache),
|
DEBUG_LEVEL(fontcache),
|
||||||
DEBUG_LEVEL(script),
|
DEBUG_LEVEL(script),
|
||||||
|
|
|
@ -44,7 +44,6 @@ extern int _debug_misc_level;
|
||||||
extern int _debug_net_level;
|
extern int _debug_net_level;
|
||||||
extern int _debug_sprite_level;
|
extern int _debug_sprite_level;
|
||||||
extern int _debug_oldloader_level;
|
extern int _debug_oldloader_level;
|
||||||
extern int _debug_npf_level;
|
|
||||||
extern int _debug_yapf_level;
|
extern int _debug_yapf_level;
|
||||||
extern int _debug_fontcache_level;
|
extern int _debug_fontcache_level;
|
||||||
extern int _debug_script_level;
|
extern int _debug_script_level;
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
#include "core/random_func.hpp"
|
#include "core/random_func.hpp"
|
||||||
#include "object_base.h"
|
#include "object_base.h"
|
||||||
#include "company_func.h"
|
#include "company_func.h"
|
||||||
#include "pathfinder/npf/aystar.h"
|
#include "pathfinder/aystar.h"
|
||||||
#include "saveload/saveload.h"
|
#include "saveload/saveload.h"
|
||||||
#include "framerate_type.h"
|
#include "framerate_type.h"
|
||||||
#include "landscape_cmd.h"
|
#include "landscape_cmd.h"
|
||||||
|
|
|
@ -2136,17 +2136,8 @@ STR_CONFIG_SETTING_AI :Competitors
|
||||||
STR_CONFIG_SETTING_AI_NPC :Computer players
|
STR_CONFIG_SETTING_AI_NPC :Computer players
|
||||||
STR_CONFIG_SETTING_NETWORK :Network
|
STR_CONFIG_SETTING_NETWORK :Network
|
||||||
|
|
||||||
STR_CONFIG_SETTING_PATHFINDER_FOR_TRAINS :Pathfinder for trains: {STRING2}
|
|
||||||
STR_CONFIG_SETTING_PATHFINDER_FOR_TRAINS_HELPTEXT :Path finder to use for trains
|
|
||||||
STR_CONFIG_SETTING_PATHFINDER_FOR_ROAD_VEHICLES :Pathfinder for road vehicles: {STRING2}
|
|
||||||
STR_CONFIG_SETTING_PATHFINDER_FOR_ROAD_VEHICLES_HELPTEXT :Path finder to use for road vehicles
|
|
||||||
STR_CONFIG_SETTING_PATHFINDER_FOR_SHIPS :Pathfinder for ships: {STRING2}
|
|
||||||
STR_CONFIG_SETTING_PATHFINDER_FOR_SHIPS_HELPTEXT :Path finder to use for ships
|
|
||||||
STR_CONFIG_SETTING_REVERSE_AT_SIGNALS :Automatic reversing at signals: {STRING2}
|
STR_CONFIG_SETTING_REVERSE_AT_SIGNALS :Automatic reversing at signals: {STRING2}
|
||||||
STR_CONFIG_SETTING_REVERSE_AT_SIGNALS_HELPTEXT :Allow trains to reverse on a signal, if they waited there a long time
|
STR_CONFIG_SETTING_REVERSE_AT_SIGNALS_HELPTEXT :Allow trains to reverse on a signal, if they waited there a long time
|
||||||
###length 2
|
|
||||||
STR_CONFIG_SETTING_PATHFINDER_NPF :NPF
|
|
||||||
STR_CONFIG_SETTING_PATHFINDER_YAPF :YAPF {BLUE}(Recommended)
|
|
||||||
|
|
||||||
STR_CONFIG_SETTING_QUERY_CAPTION :{WHITE}Change setting value
|
STR_CONFIG_SETTING_QUERY_CAPTION :{WHITE}Change setting value
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,6 @@ void InitializeObjects();
|
||||||
void InitializeTrees();
|
void InitializeTrees();
|
||||||
void InitializeCompanies();
|
void InitializeCompanies();
|
||||||
void InitializeCheats();
|
void InitializeCheats();
|
||||||
void InitializeNPF();
|
|
||||||
void InitializeOldNames();
|
void InitializeOldNames();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -149,8 +148,6 @@ void InitializeGame(uint size_x, uint size_y, bool reset_date, bool reset_settin
|
||||||
InitializeIndustries();
|
InitializeIndustries();
|
||||||
InitializeObjects();
|
InitializeObjects();
|
||||||
|
|
||||||
InitializeNPF();
|
|
||||||
|
|
||||||
InitializeCompanies();
|
InitializeCompanies();
|
||||||
AI::Initialize();
|
AI::Initialize();
|
||||||
Game::Initialize();
|
Game::Initialize();
|
||||||
|
|
|
@ -4846,7 +4846,6 @@ static ChangeInfoResult RoadStopChangeInfo(uint id, int numinfo, int prop, ByteR
|
||||||
|
|
||||||
uint32_t classid = buf->ReadDWord();
|
uint32_t classid = buf->ReadDWord();
|
||||||
rs->cls_id = RoadStopClass::Allocate(BSWAP32(classid));
|
rs->cls_id = RoadStopClass::Allocate(BSWAP32(classid));
|
||||||
rs->spec_id = id + i;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -308,25 +308,15 @@ bool Convert8bitBooleanCallback(const struct GRFFile *grffile, uint16_t cbid, ui
|
||||||
*/
|
*/
|
||||||
template <size_t Tcnt>
|
template <size_t Tcnt>
|
||||||
struct GRFFilePropsBase {
|
struct GRFFilePropsBase {
|
||||||
GRFFilePropsBase() : local_id(0), grffile(nullptr)
|
uint16_t local_id = 0; ///< id defined by the grf file for this entity
|
||||||
{
|
const struct GRFFile *grffile = nullptr; ///< grf file that introduced this entity
|
||||||
/* The lack of some compilers to provide default constructors complying to the specs
|
std::array<const struct SpriteGroup *, Tcnt> spritegroup{}; ///< pointers to the different sprites of the entity
|
||||||
* requires us to zero the stuff ourself. */
|
|
||||||
memset(spritegroup, 0, sizeof(spritegroup));
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t local_id; ///< id defined by the grf file for this entity
|
|
||||||
const struct GRFFile *grffile; ///< grf file that introduced this entity
|
|
||||||
const struct SpriteGroup *spritegroup[Tcnt]; ///< pointer to the different sprites of the entity
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Data related to the handling of grf files. */
|
/** Data related to the handling of grf files. */
|
||||||
struct GRFFileProps : GRFFilePropsBase<1> {
|
struct GRFFileProps : GRFFilePropsBase<1> {
|
||||||
/** Set all default data constructor for the props. */
|
/** Set all default data constructor for the props. */
|
||||||
GRFFileProps(uint16_t subst_id = 0) :
|
constexpr GRFFileProps(uint16_t subst_id = 0) : subst_id(subst_id), override(subst_id) {}
|
||||||
GRFFilePropsBase<1>(), subst_id(subst_id), override(subst_id)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t subst_id;
|
uint16_t subst_id;
|
||||||
uint16_t override; ///< id of the entity been replaced by
|
uint16_t override; ///< id of the entity been replaced by
|
||||||
|
|
|
@ -53,7 +53,7 @@ const SpriteGroup *GetWagonOverrideSpriteSet(EngineID engine, CargoID cargo, Eng
|
||||||
void SetCustomEngineSprites(EngineID engine, uint8_t cargo, const SpriteGroup *group)
|
void SetCustomEngineSprites(EngineID engine, uint8_t cargo, const SpriteGroup *group)
|
||||||
{
|
{
|
||||||
Engine *e = Engine::Get(engine);
|
Engine *e = Engine::Get(engine);
|
||||||
assert(cargo < lengthof(e->grf_prop.spritegroup));
|
assert(cargo < std::size(e->grf_prop.spritegroup));
|
||||||
|
|
||||||
if (e->grf_prop.spritegroup[cargo] != nullptr) {
|
if (e->grf_prop.spritegroup[cargo] != nullptr) {
|
||||||
GrfMsg(6, "SetCustomEngineSprites: engine {} cargo {} already has group -- replacing", engine, cargo);
|
GrfMsg(6, "SetCustomEngineSprites: engine {} cargo {} already has group -- replacing", engine, cargo);
|
||||||
|
@ -1062,7 +1062,7 @@ VehicleResolverObject::VehicleResolverObject(EngineID engine_type, const Vehicle
|
||||||
if (this->root_spritegroup == nullptr) {
|
if (this->root_spritegroup == nullptr) {
|
||||||
const Engine *e = Engine::Get(engine_type);
|
const Engine *e = Engine::Get(engine_type);
|
||||||
CargoID cargo = v != nullptr ? v->cargo_type : SpriteGroupCargo::SG_PURCHASE;
|
CargoID cargo = v != nullptr ? v->cargo_type : SpriteGroupCargo::SG_PURCHASE;
|
||||||
assert(cargo < lengthof(e->grf_prop.spritegroup));
|
assert(cargo < std::size(e->grf_prop.spritegroup));
|
||||||
this->root_spritegroup = e->grf_prop.spritegroup[cargo] != nullptr ? e->grf_prop.spritegroup[cargo] : e->grf_prop.spritegroup[SpriteGroupCargo::SG_DEFAULT];
|
this->root_spritegroup = e->grf_prop.spritegroup[cargo] != nullptr ? e->grf_prop.spritegroup[cargo] : e->grf_prop.spritegroup[SpriteGroupCargo::SG_DEFAULT];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,6 @@ struct RoadStopSpec {
|
||||||
*/
|
*/
|
||||||
GRFFilePropsBase<NUM_CARGO + 3> grf_prop;
|
GRFFilePropsBase<NUM_CARGO + 3> grf_prop;
|
||||||
RoadStopClassID cls_id; ///< The class to which this spec belongs.
|
RoadStopClassID cls_id; ///< The class to which this spec belongs.
|
||||||
int spec_id; ///< The ID of this spec inside the class.
|
|
||||||
StringID name; ///< Name of this stop
|
StringID name; ///< Name of this stop
|
||||||
|
|
||||||
RoadStopAvailabilityType stop_type = ROADSTOPTYPE_ALL;
|
RoadStopAvailabilityType stop_type = ROADSTOPTYPE_ALL;
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
add_subdirectory(npf)
|
|
||||||
add_subdirectory(yapf)
|
add_subdirectory(yapf)
|
||||||
|
|
||||||
add_files(
|
add_files(
|
||||||
|
aystar.h
|
||||||
|
aystar.cpp
|
||||||
follow_track.hpp
|
follow_track.hpp
|
||||||
|
queue.h
|
||||||
|
queue.cpp
|
||||||
pathfinder_func.h
|
pathfinder_func.h
|
||||||
pathfinder_type.h
|
pathfinder_type.h
|
||||||
water_regions.h
|
water_regions.h
|
||||||
|
|
|
@ -168,7 +168,7 @@ int AyStar::Loop()
|
||||||
if (current == nullptr) return AYSTAR_EMPTY_OPENLIST;
|
if (current == nullptr) return AYSTAR_EMPTY_OPENLIST;
|
||||||
|
|
||||||
/* Check for end node and if found, return that code */
|
/* Check for end node and if found, return that code */
|
||||||
if (this->EndNodeCheck(this, current) == AYSTAR_FOUND_END_NODE && !CheckIgnoreFirstTile(¤t->path)) {
|
if (this->EndNodeCheck(this, current) == AYSTAR_FOUND_END_NODE && (¤t->path)->parent != nullptr) {
|
||||||
if (this->FoundEndNode != nullptr) {
|
if (this->FoundEndNode != nullptr) {
|
||||||
this->FoundEndNode(this, current);
|
this->FoundEndNode(this, current);
|
||||||
}
|
}
|
|
@ -1,8 +0,0 @@
|
||||||
add_files(
|
|
||||||
aystar.cpp
|
|
||||||
aystar.h
|
|
||||||
npf.cpp
|
|
||||||
npf_func.h
|
|
||||||
queue.cpp
|
|
||||||
queue.h
|
|
||||||
)
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,92 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of OpenTTD.
|
|
||||||
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
|
||||||
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @file npf_func.h Functions to access the new pathfinder. */
|
|
||||||
|
|
||||||
#ifndef NPF_FUNC_H
|
|
||||||
#define NPF_FUNC_H
|
|
||||||
|
|
||||||
#include "../../track_type.h"
|
|
||||||
#include "../../direction_type.h"
|
|
||||||
#include "../../vehicle_type.h"
|
|
||||||
#include "../pathfinder_type.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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_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_penalty);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds the best path for given road vehicle using NPF.
|
|
||||||
* @param v the RV that needs to find a path
|
|
||||||
* @param tile the tile to find the path from (should be next tile the RV is about to enter)
|
|
||||||
* @param enterdir diagonal direction which the RV will enter this new tile from
|
|
||||||
* @param path_found [out] Whether a path has been found (true) or has been guessed (false)
|
|
||||||
* @return the best trackdir for next turn or INVALID_TRACKDIR if the path could not be found
|
|
||||||
*/
|
|
||||||
Trackdir NPFRoadVehicleChooseTrack(const RoadVehicle *v, TileIndex tile, DiagDirection enterdir, bool &path_found);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds the best path for given ship using NPF.
|
|
||||||
* @param v the ship that needs to find a path
|
|
||||||
* @param path_found [out] Whether a path has been found (true) or has been guessed (false)
|
|
||||||
* @return the best trackdir for next turn or INVALID_TRACK if the path could not be found
|
|
||||||
*/
|
|
||||||
Track NPFShipChooseTrack(const Ship *v, bool &path_found);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if it is better to reverse the ship before leaving depot using NPF.
|
|
||||||
* @param v the ship leaving the depot
|
|
||||||
* @param trackdir [out] the best of all possible reversed trackdirs
|
|
||||||
* @return true if reversing is better
|
|
||||||
*/
|
|
||||||
bool NPFShipCheckReverse(const Ship *v, Trackdir *trackdir);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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_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_penalty);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Try to extend the reserved path of a train to the nearest safe tile using NPF.
|
|
||||||
*
|
|
||||||
* @param v The train that needs to find a safe tile.
|
|
||||||
* @param tile Last tile of the current reserved path.
|
|
||||||
* @param td Last trackdir of the current reserved path.
|
|
||||||
* @param override_railtype Should all physically compatible railtypes be searched, even if the vehicle can't run on them on its own?
|
|
||||||
* @return True if the path could be extended to a safe tile.
|
|
||||||
*/
|
|
||||||
bool NPFTrainFindNearestSafeTile(const Train *v, TileIndex tile, Trackdir td, bool override_railtype);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if it is better to reverse the train before leaving station using NPF.
|
|
||||||
* @param v the train leaving the station
|
|
||||||
* @return true if reversing is better
|
|
||||||
*/
|
|
||||||
bool NPFTrainCheckReverse(const Train *v);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds the best path for given train using NPF.
|
|
||||||
* @param v the train that needs to find a path
|
|
||||||
* @param path_found [out] Whether a path has been found (true) or has been guessed (false)
|
|
||||||
* @param reserve_track indicates whether YAPF should try to reserve the found path
|
|
||||||
* @param target [out] the target tile of the reservation, free is set to true if path was reserved
|
|
||||||
* @return the best track for next turn
|
|
||||||
*/
|
|
||||||
Track NPFTrainChooseTrack(const Train *v, bool &path_found, bool reserve_track, struct PBSTileInfo *target);
|
|
||||||
|
|
||||||
#endif /* NPF_FUNC_H */
|
|
|
@ -11,19 +11,7 @@
|
||||||
#define PATHFINDER_TYPE_H
|
#define PATHFINDER_TYPE_H
|
||||||
|
|
||||||
#include "../tile_type.h"
|
#include "../tile_type.h"
|
||||||
#include "npf/aystar.h"
|
#include "aystar.h"
|
||||||
|
|
||||||
/** Length (penalty) of one tile with NPF */
|
|
||||||
static const int NPF_TILE_LENGTH = 100;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This penalty is the equivalent of "infinite", which means that paths that
|
|
||||||
* get this penalty will be chosen, but only if there is no other route
|
|
||||||
* without it. Be careful with not applying this penalty too often, or the
|
|
||||||
* total path cost might overflow.
|
|
||||||
*/
|
|
||||||
static const int NPF_INFINITE_PENALTY = 1000 * NPF_TILE_LENGTH;
|
|
||||||
|
|
||||||
|
|
||||||
/** Length (penalty) of one tile with YAPF */
|
/** Length (penalty) of one tile with YAPF */
|
||||||
static const int YAPF_TILE_LENGTH = 100;
|
static const int YAPF_TILE_LENGTH = 100;
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
#include "command_func.h"
|
#include "command_func.h"
|
||||||
#include "error_func.h"
|
#include "error_func.h"
|
||||||
#include "news_func.h"
|
#include "news_func.h"
|
||||||
#include "pathfinder/npf/npf_func.h"
|
|
||||||
#include "station_base.h"
|
#include "station_base.h"
|
||||||
#include "company_func.h"
|
#include "company_func.h"
|
||||||
#include "articulated_vehicles.h"
|
#include "articulated_vehicles.h"
|
||||||
|
@ -342,12 +341,7 @@ static FindDepotData FindClosestRoadDepot(const RoadVehicle *v, int max_distance
|
||||||
{
|
{
|
||||||
if (IsRoadDepotTile(v->tile)) return FindDepotData(v->tile, 0);
|
if (IsRoadDepotTile(v->tile)) return FindDepotData(v->tile, 0);
|
||||||
|
|
||||||
switch (_settings_game.pf.pathfinder_for_roadvehs) {
|
return YapfRoadVehicleFindNearestDepot(v, max_distance);
|
||||||
case VPF_NPF: return NPFRoadVehicleFindNearestDepot(v, max_distance);
|
|
||||||
case VPF_YAPF: return YapfRoadVehicleFindNearestDepot(v, max_distance);
|
|
||||||
|
|
||||||
default: NOT_REACHED();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ClosestDepot RoadVehicle::FindClosestDepot()
|
ClosestDepot RoadVehicle::FindClosestDepot()
|
||||||
|
@ -989,12 +983,8 @@ static Trackdir RoadFindPathToDest(RoadVehicle *v, TileIndex tile, DiagDirection
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (_settings_game.pf.pathfinder_for_roadvehs) {
|
best_track = YapfRoadVehicleChooseTrack(v, tile, enterdir, trackdirs, path_found, v->path);
|
||||||
case VPF_NPF: best_track = NPFRoadVehicleChooseTrack(v, tile, enterdir, path_found); break;
|
|
||||||
case VPF_YAPF: best_track = YapfRoadVehicleChooseTrack(v, tile, enterdir, trackdirs, path_found, v->path); break;
|
|
||||||
|
|
||||||
default: NOT_REACHED();
|
|
||||||
}
|
|
||||||
v->HandlePathfindingResult(path_found);
|
v->HandlePathfindingResult(path_found);
|
||||||
|
|
||||||
found_best_track:;
|
found_best_track:;
|
||||||
|
@ -1683,12 +1673,7 @@ static void CheckIfRoadVehNeedsService(RoadVehicle *v)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint max_penalty;
|
uint max_penalty = _settings_game.pf.yapf.maximum_go_to_depot_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);
|
FindDepotData rfdd = FindClosestRoadDepot(v, max_penalty);
|
||||||
/* Only go to the depot if it is not too far out of our way. */
|
/* Only go to the depot if it is not too far out of our way. */
|
||||||
|
|
|
@ -1889,25 +1889,6 @@ bool AfterLoadGame()
|
||||||
if (!Company::IsValidID(GetTileOwner(t))) FixOwnerOfRailTrack(t);
|
if (!Company::IsValidID(GetTileOwner(t))) FixOwnerOfRailTrack(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert old PF settings to new */
|
|
||||||
if (_settings_game.pf.yapf.rail_use_yapf || IsSavegameVersionBefore(SLV_28)) {
|
|
||||||
_settings_game.pf.pathfinder_for_trains = VPF_YAPF;
|
|
||||||
} else {
|
|
||||||
_settings_game.pf.pathfinder_for_trains = VPF_NPF;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_settings_game.pf.yapf.road_use_yapf || IsSavegameVersionBefore(SLV_28)) {
|
|
||||||
_settings_game.pf.pathfinder_for_roadvehs = VPF_YAPF;
|
|
||||||
} else {
|
|
||||||
_settings_game.pf.pathfinder_for_roadvehs = VPF_NPF;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_settings_game.pf.yapf.ship_use_yapf) {
|
|
||||||
_settings_game.pf.pathfinder_for_ships = VPF_YAPF;
|
|
||||||
} else {
|
|
||||||
_settings_game.pf.pathfinder_for_ships = VPF_NPF;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsSavegameVersionBefore(SLV_88)) {
|
if (IsSavegameVersionBefore(SLV_88)) {
|
||||||
|
|
|
@ -95,13 +95,9 @@ const SaveLoadCompat _settings_sl_compat[] = {
|
||||||
SLC_VAR("vehicle.smoke_amount"),
|
SLC_VAR("vehicle.smoke_amount"),
|
||||||
SLC_NULL(1, SL_MIN_VERSION, SLV_159),
|
SLC_NULL(1, SL_MIN_VERSION, SLV_159),
|
||||||
SLC_VAR("pf.roadveh_queue"),
|
SLC_VAR("pf.roadveh_queue"),
|
||||||
SLC_VAR("pf.new_pathfinding_all"),
|
SLC_NULL(1, SL_MIN_VERSION, SLV_87),
|
||||||
SLC_VAR("pf.yapf.ship_use_yapf"),
|
SLC_NULL(3, SLV_28, SLV_87),
|
||||||
SLC_VAR("pf.yapf.road_use_yapf"),
|
SLC_NULL(3, SLV_87, SLV_TABLE_CHUNKS),
|
||||||
SLC_VAR("pf.yapf.rail_use_yapf"),
|
|
||||||
SLC_VAR("pf.pathfinder_for_trains"),
|
|
||||||
SLC_VAR("pf.pathfinder_for_roadvehs"),
|
|
||||||
SLC_VAR("pf.pathfinder_for_ships"),
|
|
||||||
SLC_VAR("vehicle.never_expire_vehicles"),
|
SLC_VAR("vehicle.never_expire_vehicles"),
|
||||||
SLC_VAR("vehicle.max_trains"),
|
SLC_VAR("vehicle.max_trains"),
|
||||||
SLC_VAR("vehicle.max_roadveh"),
|
SLC_VAR("vehicle.max_roadveh"),
|
||||||
|
@ -183,24 +179,12 @@ const SaveLoadCompat _settings_sl_compat[] = {
|
||||||
SLC_VAR("pf.reserve_paths"),
|
SLC_VAR("pf.reserve_paths"),
|
||||||
SLC_VAR("pf.path_backoff_interval"),
|
SLC_VAR("pf.path_backoff_interval"),
|
||||||
SLC_NULL(3, SL_MIN_VERSION, SLV_REMOVE_OPF),
|
SLC_NULL(3, SL_MIN_VERSION, SLV_REMOVE_OPF),
|
||||||
SLC_VAR("pf.npf.npf_max_search_nodes"),
|
SLC_NULL(32, SL_MIN_VERSION, SLV_TABLE_CHUNKS),
|
||||||
SLC_VAR("pf.npf.npf_rail_firstred_penalty"),
|
SLC_NULL(8, SLV_100, SLV_TABLE_CHUNKS),
|
||||||
SLC_VAR("pf.npf.npf_rail_firstred_exit_penalty"),
|
SLC_NULL(16, SL_MIN_VERSION, SLV_TABLE_CHUNKS),
|
||||||
SLC_VAR("pf.npf.npf_rail_lastred_penalty"),
|
SLC_NULL(4, SLV_47, SLV_TABLE_CHUNKS),
|
||||||
SLC_VAR("pf.npf.npf_rail_station_penalty"),
|
SLC_NULL(8, SLV_130, SLV_TABLE_CHUNKS),
|
||||||
SLC_VAR("pf.npf.npf_rail_slope_penalty"),
|
SLC_NULL(4, SLV_131, SLV_TABLE_CHUNKS),
|
||||||
SLC_VAR("pf.npf.npf_rail_curve_penalty"),
|
|
||||||
SLC_VAR("pf.npf.npf_rail_depot_reverse_penalty"),
|
|
||||||
SLC_VAR("pf.npf.npf_rail_pbs_cross_penalty"),
|
|
||||||
SLC_VAR("pf.npf.npf_rail_pbs_signal_back_penalty"),
|
|
||||||
SLC_VAR("pf.npf.npf_buoy_penalty"),
|
|
||||||
SLC_VAR("pf.npf.npf_water_curve_penalty"),
|
|
||||||
SLC_VAR("pf.npf.npf_road_curve_penalty"),
|
|
||||||
SLC_VAR("pf.npf.npf_crossing_penalty"),
|
|
||||||
SLC_VAR("pf.npf.npf_road_drive_through_penalty"),
|
|
||||||
SLC_VAR("pf.npf.npf_road_dt_occupied_penalty"),
|
|
||||||
SLC_VAR("pf.npf.npf_road_bay_occupied_penalty"),
|
|
||||||
SLC_VAR("pf.npf.maximum_go_to_depot_penalty"),
|
|
||||||
SLC_VAR("pf.yapf.disable_node_optimization"),
|
SLC_VAR("pf.yapf.disable_node_optimization"),
|
||||||
SLC_VAR("pf.yapf.max_search_nodes"),
|
SLC_VAR("pf.yapf.max_search_nodes"),
|
||||||
SLC_VAR("pf.yapf.rail_firstred_twoway_eol"),
|
SLC_VAR("pf.yapf.rail_firstred_twoway_eol"),
|
||||||
|
|
|
@ -2118,12 +2118,9 @@ static SettingsContainer &GetSettingsTree()
|
||||||
SettingsPage *routing = vehicles->Add(new SettingsPage(STR_CONFIG_SETTING_VEHICLES_ROUTING));
|
SettingsPage *routing = vehicles->Add(new SettingsPage(STR_CONFIG_SETTING_VEHICLES_ROUTING));
|
||||||
{
|
{
|
||||||
routing->Add(new SettingEntry("vehicle.road_side"));
|
routing->Add(new SettingEntry("vehicle.road_side"));
|
||||||
routing->Add(new SettingEntry("pf.pathfinder_for_trains"));
|
|
||||||
routing->Add(new SettingEntry("difficulty.line_reverse_mode"));
|
routing->Add(new SettingEntry("difficulty.line_reverse_mode"));
|
||||||
routing->Add(new SettingEntry("pf.reverse_at_signals"));
|
routing->Add(new SettingEntry("pf.reverse_at_signals"));
|
||||||
routing->Add(new SettingEntry("pf.forbid_90_deg"));
|
routing->Add(new SettingEntry("pf.forbid_90_deg"));
|
||||||
routing->Add(new SettingEntry("pf.pathfinder_for_roadvehs"));
|
|
||||||
routing->Add(new SettingEntry("pf.pathfinder_for_ships"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingsPage *orders = vehicles->Add(new SettingsPage(STR_CONFIG_SETTING_VEHICLES_ORDERS));
|
SettingsPage *orders = vehicles->Add(new SettingsPage(STR_CONFIG_SETTING_VEHICLES_ORDERS));
|
||||||
|
|
|
@ -555,13 +555,6 @@ static void MaxVehiclesChanged(int32_t)
|
||||||
MarkWholeScreenDirty();
|
MarkWholeScreenDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void InvalidateShipPathCache(int32_t)
|
|
||||||
{
|
|
||||||
for (Ship *s : Ship::Iterate()) {
|
|
||||||
s->path.clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replace a passwords that are a literal asterisk with an empty string.
|
* Replace a passwords that are a literal asterisk with an empty string.
|
||||||
* @param newval The new string value for this password field.
|
* @param newval The new string value for this password field.
|
||||||
|
|
|
@ -412,42 +412,11 @@ struct ScriptSettings {
|
||||||
uint32_t script_max_memory_megabytes; ///< limit on memory a single script instance may have allocated
|
uint32_t script_max_memory_megabytes; ///< limit on memory a single script instance may have allocated
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Settings related to the new pathfinder. */
|
|
||||||
struct NPFSettings {
|
|
||||||
/**
|
|
||||||
* The maximum amount of search nodes a single NPF run should take. This
|
|
||||||
* limit should make sure performance stays at acceptable levels at the cost
|
|
||||||
* of not being perfect anymore.
|
|
||||||
*/
|
|
||||||
uint32_t npf_max_search_nodes;
|
|
||||||
uint32_t maximum_go_to_depot_penalty; ///< What is the maximum penalty that may be endured for going to a depot
|
|
||||||
|
|
||||||
uint32_t npf_rail_firstred_penalty; ///< the penalty for when the first signal is red (and it is not an exit or combo signal)
|
|
||||||
uint32_t npf_rail_firstred_exit_penalty; ///< the penalty for when the first signal is red (and it is an exit or combo signal)
|
|
||||||
uint32_t npf_rail_lastred_penalty; ///< the penalty for when the last signal is red
|
|
||||||
uint32_t npf_rail_station_penalty; ///< the penalty for station tiles
|
|
||||||
uint32_t npf_rail_slope_penalty; ///< the penalty for sloping upwards
|
|
||||||
uint32_t npf_rail_curve_penalty; ///< the penalty for curves
|
|
||||||
uint32_t npf_rail_depot_reverse_penalty; ///< the penalty for reversing in depots
|
|
||||||
uint32_t npf_rail_pbs_cross_penalty; ///< the penalty for crossing a reserved rail track
|
|
||||||
uint32_t npf_rail_pbs_signal_back_penalty; ///< the penalty for passing a pbs signal from the backside
|
|
||||||
uint32_t npf_buoy_penalty; ///< the penalty for going over (through) a buoy
|
|
||||||
uint32_t npf_water_curve_penalty; ///< the penalty for curves
|
|
||||||
uint32_t npf_road_curve_penalty; ///< the penalty for curves
|
|
||||||
uint32_t npf_crossing_penalty; ///< the penalty for level crossings
|
|
||||||
uint32_t npf_road_drive_through_penalty; ///< the penalty for going through a drive-through road stop
|
|
||||||
uint32_t npf_road_dt_occupied_penalty; ///< the penalty multiplied by the fill percentage of a drive-through road stop
|
|
||||||
uint32_t npf_road_bay_occupied_penalty; ///< the penalty multiplied by the fill percentage of a road bay
|
|
||||||
};
|
|
||||||
|
|
||||||
/** Settings related to the yet another pathfinder. */
|
/** Settings related to the yet another pathfinder. */
|
||||||
struct YAPFSettings {
|
struct YAPFSettings {
|
||||||
bool disable_node_optimization; ///< whether to use exit-dir instead of trackdir in node key
|
bool disable_node_optimization; ///< whether to use exit-dir instead of trackdir in node key
|
||||||
uint32_t max_search_nodes; ///< stop path-finding when this number of nodes visited
|
uint32_t max_search_nodes; ///< stop path-finding when this number of nodes visited
|
||||||
uint32_t maximum_go_to_depot_penalty; ///< What is the maximum penalty that may be endured for going to a depot
|
uint32_t 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
|
|
||||||
uint32_t road_slope_penalty; ///< penalty for up-hill slope
|
uint32_t road_slope_penalty; ///< penalty for up-hill slope
|
||||||
uint32_t road_curve_penalty; ///< penalty for curves
|
uint32_t road_curve_penalty; ///< penalty for curves
|
||||||
uint32_t road_crossing_penalty; ///< penalty for level crossing
|
uint32_t road_crossing_penalty; ///< penalty for level crossing
|
||||||
|
@ -484,11 +453,6 @@ struct YAPFSettings {
|
||||||
|
|
||||||
/** Settings related to all pathfinders. */
|
/** Settings related to all pathfinders. */
|
||||||
struct PathfinderSettings {
|
struct PathfinderSettings {
|
||||||
uint8_t pathfinder_for_trains; ///< the pathfinder to use for trains
|
|
||||||
uint8_t pathfinder_for_roadvehs; ///< the pathfinder to use for roadvehicles
|
|
||||||
uint8_t pathfinder_for_ships; ///< the pathfinder to use for ships
|
|
||||||
bool new_pathfinding_all; ///< use the newest pathfinding algorithm for all
|
|
||||||
|
|
||||||
bool roadveh_queue; ///< buggy road vehicle queueing
|
bool roadveh_queue; ///< buggy road vehicle queueing
|
||||||
bool forbid_90_deg; ///< forbid trains to make 90 deg turns
|
bool forbid_90_deg; ///< forbid trains to make 90 deg turns
|
||||||
|
|
||||||
|
@ -500,7 +464,6 @@ struct PathfinderSettings {
|
||||||
uint8_t wait_for_pbs_path; ///< how long to wait for a path reservation.
|
uint8_t wait_for_pbs_path; ///< how long to wait for a path reservation.
|
||||||
uint8_t path_backoff_interval; ///< ticks between checks for a free path.
|
uint8_t path_backoff_interval; ///< ticks between checks for a free path.
|
||||||
|
|
||||||
NPFSettings npf; ///< pathfinder settings for the new pathfinder
|
|
||||||
YAPFSettings yapf; ///< pathfinder settings for the yet another pathfinder
|
YAPFSettings yapf; ///< pathfinder settings for the yet another pathfinder
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
#include "timetable.h"
|
#include "timetable.h"
|
||||||
#include "news_func.h"
|
#include "news_func.h"
|
||||||
#include "company_func.h"
|
#include "company_func.h"
|
||||||
#include "pathfinder/npf/npf_func.h"
|
|
||||||
#include "depot_base.h"
|
#include "depot_base.h"
|
||||||
#include "station_base.h"
|
#include "station_base.h"
|
||||||
#include "newgrf_engine.h"
|
#include "newgrf_engine.h"
|
||||||
|
@ -210,12 +209,7 @@ static void CheckIfShipNeedsService(Vehicle *v)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint max_distance;
|
uint max_distance = _settings_game.pf.yapf.maximum_go_to_depot_penalty / YAPF_TILE_LENGTH;
|
||||||
switch (_settings_game.pf.pathfinder_for_ships) {
|
|
||||||
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, max_distance);
|
const Depot *depot = FindClosestShipDepot(v, max_distance);
|
||||||
|
|
||||||
|
@ -376,13 +370,7 @@ static Vehicle *EnsureNoMovingShipProc(Vehicle *v, void *)
|
||||||
static bool CheckReverseShip(const Ship *v, Trackdir *trackdir = nullptr)
|
static bool CheckReverseShip(const Ship *v, Trackdir *trackdir = nullptr)
|
||||||
{
|
{
|
||||||
/* Ask pathfinder for best direction */
|
/* Ask pathfinder for best direction */
|
||||||
bool reverse = false;
|
return YapfShipCheckReverse(v, trackdir);
|
||||||
switch (_settings_game.pf.pathfinder_for_ships) {
|
|
||||||
case VPF_NPF: reverse = NPFShipCheckReverse(v, trackdir); break;
|
|
||||||
case VPF_YAPF: reverse = YapfShipCheckReverse(v, trackdir); break;
|
|
||||||
default: NOT_REACHED();
|
|
||||||
}
|
|
||||||
return reverse;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool CheckShipLeaveDepot(Ship *v)
|
static bool CheckShipLeaveDepot(Ship *v)
|
||||||
|
@ -530,11 +518,7 @@ static Track ChooseShipTrack(Ship *v, TileIndex tile, TrackBits tracks)
|
||||||
v->path.clear();
|
v->path.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (_settings_game.pf.pathfinder_for_ships) {
|
track = YapfShipChooseTrack(v, tile, path_found, v->path);
|
||||||
case VPF_NPF: track = NPFShipChooseTrack(v, path_found); break;
|
|
||||||
case VPF_YAPF: track = YapfShipChooseTrack(v, tile, path_found, v->path); break;
|
|
||||||
default: NOT_REACHED();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
v->HandlePathfindingResult(path_found);
|
v->HandlePathfindingResult(path_found);
|
||||||
|
|
|
@ -8,8 +8,6 @@
|
||||||
; and in the savegame PATS chunk.
|
; and in the savegame PATS chunk.
|
||||||
|
|
||||||
[pre-amble]
|
[pre-amble]
|
||||||
static void InvalidateShipPathCache(int32_t new_value);
|
|
||||||
|
|
||||||
static const SettingVariant _pathfinding_settings_table[] = {
|
static const SettingVariant _pathfinding_settings_table[] = {
|
||||||
[post-amble]
|
[post-amble]
|
||||||
};
|
};
|
||||||
|
@ -52,76 +50,6 @@ var = pf.roadveh_queue
|
||||||
def = true
|
def = true
|
||||||
cat = SC_EXPERT
|
cat = SC_EXPERT
|
||||||
|
|
||||||
[SDT_BOOL]
|
|
||||||
var = pf.new_pathfinding_all
|
|
||||||
to = SLV_87
|
|
||||||
def = false
|
|
||||||
cat = SC_EXPERT
|
|
||||||
|
|
||||||
[SDT_BOOL]
|
|
||||||
var = pf.yapf.ship_use_yapf
|
|
||||||
from = SLV_28
|
|
||||||
to = SLV_87
|
|
||||||
def = false
|
|
||||||
cat = SC_EXPERT
|
|
||||||
|
|
||||||
[SDT_BOOL]
|
|
||||||
var = pf.yapf.road_use_yapf
|
|
||||||
from = SLV_28
|
|
||||||
to = SLV_87
|
|
||||||
def = true
|
|
||||||
cat = SC_EXPERT
|
|
||||||
|
|
||||||
[SDT_BOOL]
|
|
||||||
var = pf.yapf.rail_use_yapf
|
|
||||||
from = SLV_28
|
|
||||||
to = SLV_87
|
|
||||||
def = true
|
|
||||||
cat = SC_EXPERT
|
|
||||||
|
|
||||||
[SDT_VAR]
|
|
||||||
var = pf.pathfinder_for_trains
|
|
||||||
type = SLE_UINT8
|
|
||||||
from = SLV_87
|
|
||||||
flags = SF_GUI_DROPDOWN
|
|
||||||
def = 2
|
|
||||||
min = 1
|
|
||||||
max = 2
|
|
||||||
interval = 1
|
|
||||||
str = STR_CONFIG_SETTING_PATHFINDER_FOR_TRAINS
|
|
||||||
strhelp = STR_CONFIG_SETTING_PATHFINDER_FOR_TRAINS_HELPTEXT
|
|
||||||
strval = STR_CONFIG_SETTING_PATHFINDER_NPF
|
|
||||||
cat = SC_EXPERT
|
|
||||||
|
|
||||||
[SDT_VAR]
|
|
||||||
var = pf.pathfinder_for_roadvehs
|
|
||||||
type = SLE_UINT8
|
|
||||||
from = SLV_87
|
|
||||||
flags = SF_GUI_DROPDOWN
|
|
||||||
def = 2
|
|
||||||
min = 1
|
|
||||||
max = 2
|
|
||||||
interval = 1
|
|
||||||
str = STR_CONFIG_SETTING_PATHFINDER_FOR_ROAD_VEHICLES
|
|
||||||
strhelp = STR_CONFIG_SETTING_PATHFINDER_FOR_ROAD_VEHICLES_HELPTEXT
|
|
||||||
strval = STR_CONFIG_SETTING_PATHFINDER_NPF
|
|
||||||
cat = SC_EXPERT
|
|
||||||
|
|
||||||
[SDT_VAR]
|
|
||||||
var = pf.pathfinder_for_ships
|
|
||||||
type = SLE_UINT8
|
|
||||||
from = SLV_87
|
|
||||||
flags = SF_GUI_DROPDOWN
|
|
||||||
def = 2
|
|
||||||
min = 1
|
|
||||||
max = 2
|
|
||||||
interval = 1
|
|
||||||
str = STR_CONFIG_SETTING_PATHFINDER_FOR_SHIPS
|
|
||||||
strhelp = STR_CONFIG_SETTING_PATHFINDER_FOR_SHIPS_HELPTEXT
|
|
||||||
strval = STR_CONFIG_SETTING_PATHFINDER_NPF
|
|
||||||
post_cb = InvalidateShipPathCache
|
|
||||||
cat = SC_EXPERT
|
|
||||||
|
|
||||||
[SDT_BOOL]
|
[SDT_BOOL]
|
||||||
var = pf.reverse_at_signals
|
var = pf.reverse_at_signals
|
||||||
from = SLV_159
|
from = SLV_159
|
||||||
|
@ -169,156 +97,6 @@ min = 1
|
||||||
max = 255
|
max = 255
|
||||||
cat = SC_EXPERT
|
cat = SC_EXPERT
|
||||||
|
|
||||||
[SDT_VAR]
|
|
||||||
var = pf.npf.npf_max_search_nodes
|
|
||||||
type = SLE_UINT
|
|
||||||
def = AYSTAR_DEF_MAX_SEARCH_NODES
|
|
||||||
min = 500
|
|
||||||
max = 100000
|
|
||||||
cat = SC_EXPERT
|
|
||||||
|
|
||||||
[SDT_VAR]
|
|
||||||
var = pf.npf.npf_rail_firstred_penalty
|
|
||||||
type = SLE_UINT
|
|
||||||
def = 10 * NPF_TILE_LENGTH
|
|
||||||
min = 0
|
|
||||||
max = 100000
|
|
||||||
cat = SC_EXPERT
|
|
||||||
|
|
||||||
[SDT_VAR]
|
|
||||||
var = pf.npf.npf_rail_firstred_exit_penalty
|
|
||||||
type = SLE_UINT
|
|
||||||
def = 100 * NPF_TILE_LENGTH
|
|
||||||
min = 0
|
|
||||||
max = 100000
|
|
||||||
cat = SC_EXPERT
|
|
||||||
|
|
||||||
[SDT_VAR]
|
|
||||||
var = pf.npf.npf_rail_lastred_penalty
|
|
||||||
type = SLE_UINT
|
|
||||||
def = 10 * NPF_TILE_LENGTH
|
|
||||||
min = 0
|
|
||||||
max = 100000
|
|
||||||
cat = SC_EXPERT
|
|
||||||
|
|
||||||
[SDT_VAR]
|
|
||||||
var = pf.npf.npf_rail_station_penalty
|
|
||||||
type = SLE_UINT
|
|
||||||
def = 1 * NPF_TILE_LENGTH
|
|
||||||
min = 0
|
|
||||||
max = 100000
|
|
||||||
cat = SC_EXPERT
|
|
||||||
|
|
||||||
[SDT_VAR]
|
|
||||||
var = pf.npf.npf_rail_slope_penalty
|
|
||||||
type = SLE_UINT
|
|
||||||
def = 1 * NPF_TILE_LENGTH
|
|
||||||
min = 0
|
|
||||||
max = 100000
|
|
||||||
cat = SC_EXPERT
|
|
||||||
|
|
||||||
[SDT_VAR]
|
|
||||||
var = pf.npf.npf_rail_curve_penalty
|
|
||||||
type = SLE_UINT
|
|
||||||
def = 1 * NPF_TILE_LENGTH
|
|
||||||
min = 0
|
|
||||||
max = 100000
|
|
||||||
cat = SC_EXPERT
|
|
||||||
|
|
||||||
[SDT_VAR]
|
|
||||||
var = pf.npf.npf_rail_depot_reverse_penalty
|
|
||||||
type = SLE_UINT
|
|
||||||
def = 50 * NPF_TILE_LENGTH
|
|
||||||
min = 0
|
|
||||||
max = 100000
|
|
||||||
cat = SC_EXPERT
|
|
||||||
|
|
||||||
[SDT_VAR]
|
|
||||||
var = pf.npf.npf_rail_pbs_cross_penalty
|
|
||||||
type = SLE_UINT
|
|
||||||
from = SLV_100
|
|
||||||
def = 3 * NPF_TILE_LENGTH
|
|
||||||
min = 0
|
|
||||||
max = 100000
|
|
||||||
cat = SC_EXPERT
|
|
||||||
|
|
||||||
[SDT_VAR]
|
|
||||||
var = pf.npf.npf_rail_pbs_signal_back_penalty
|
|
||||||
type = SLE_UINT
|
|
||||||
from = SLV_100
|
|
||||||
def = 15 * NPF_TILE_LENGTH
|
|
||||||
min = 0
|
|
||||||
max = 100000
|
|
||||||
cat = SC_EXPERT
|
|
||||||
|
|
||||||
[SDT_VAR]
|
|
||||||
var = pf.npf.npf_buoy_penalty
|
|
||||||
type = SLE_UINT
|
|
||||||
def = 2 * NPF_TILE_LENGTH
|
|
||||||
min = 0
|
|
||||||
max = 100000
|
|
||||||
cat = SC_EXPERT
|
|
||||||
|
|
||||||
[SDT_VAR]
|
|
||||||
var = pf.npf.npf_water_curve_penalty
|
|
||||||
type = SLE_UINT
|
|
||||||
def = 1 * NPF_TILE_LENGTH
|
|
||||||
min = 0
|
|
||||||
max = 100000
|
|
||||||
cat = SC_EXPERT
|
|
||||||
|
|
||||||
[SDT_VAR]
|
|
||||||
var = pf.npf.npf_road_curve_penalty
|
|
||||||
type = SLE_UINT
|
|
||||||
def = 1 * NPF_TILE_LENGTH
|
|
||||||
min = 0
|
|
||||||
max = 100000
|
|
||||||
cat = SC_EXPERT
|
|
||||||
|
|
||||||
[SDT_VAR]
|
|
||||||
var = pf.npf.npf_crossing_penalty
|
|
||||||
type = SLE_UINT
|
|
||||||
def = 3 * NPF_TILE_LENGTH
|
|
||||||
min = 0
|
|
||||||
max = 100000
|
|
||||||
cat = SC_EXPERT
|
|
||||||
|
|
||||||
[SDT_VAR]
|
|
||||||
var = pf.npf.npf_road_drive_through_penalty
|
|
||||||
type = SLE_UINT
|
|
||||||
from = SLV_47
|
|
||||||
def = 8 * NPF_TILE_LENGTH
|
|
||||||
min = 0
|
|
||||||
max = 100000
|
|
||||||
cat = SC_EXPERT
|
|
||||||
|
|
||||||
[SDT_VAR]
|
|
||||||
var = pf.npf.npf_road_dt_occupied_penalty
|
|
||||||
type = SLE_UINT
|
|
||||||
from = SLV_130
|
|
||||||
def = 8 * NPF_TILE_LENGTH
|
|
||||||
min = 0
|
|
||||||
max = 100000
|
|
||||||
cat = SC_EXPERT
|
|
||||||
|
|
||||||
[SDT_VAR]
|
|
||||||
var = pf.npf.npf_road_bay_occupied_penalty
|
|
||||||
type = SLE_UINT
|
|
||||||
from = SLV_130
|
|
||||||
def = 15 * NPF_TILE_LENGTH
|
|
||||||
min = 0
|
|
||||||
max = 100000
|
|
||||||
cat = SC_EXPERT
|
|
||||||
|
|
||||||
[SDT_VAR]
|
|
||||||
var = pf.npf.maximum_go_to_depot_penalty
|
|
||||||
type = SLE_UINT
|
|
||||||
from = SLV_131
|
|
||||||
def = 20 * NPF_TILE_LENGTH
|
|
||||||
min = 0
|
|
||||||
max = 1000000
|
|
||||||
cat = SC_EXPERT
|
|
||||||
|
|
||||||
[SDT_BOOL]
|
[SDT_BOOL]
|
||||||
var = pf.yapf.disable_node_optimization
|
var = pf.yapf.disable_node_optimization
|
||||||
from = SLV_28
|
from = SLV_28
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
#include "articulated_vehicles.h"
|
#include "articulated_vehicles.h"
|
||||||
#include "command_func.h"
|
#include "command_func.h"
|
||||||
#include "error_func.h"
|
#include "error_func.h"
|
||||||
#include "pathfinder/npf/npf_func.h"
|
|
||||||
#include "pathfinder/yapf/yapf.hpp"
|
#include "pathfinder/yapf/yapf.hpp"
|
||||||
#include "news_func.h"
|
#include "news_func.h"
|
||||||
#include "company_func.h"
|
#include "company_func.h"
|
||||||
|
@ -2171,12 +2170,7 @@ static FindDepotData FindClosestTrainDepot(Train *v, int max_distance)
|
||||||
PBSTileInfo origin = FollowTrainReservation(v);
|
PBSTileInfo origin = FollowTrainReservation(v);
|
||||||
if (IsRailDepotTile(origin.tile)) return FindDepotData(origin.tile, 0);
|
if (IsRailDepotTile(origin.tile)) return FindDepotData(origin.tile, 0);
|
||||||
|
|
||||||
switch (_settings_game.pf.pathfinder_for_trains) {
|
return YapfTrainFindNearestDepot(v, max_distance);
|
||||||
case VPF_NPF: return NPFTrainFindNearestDepot(v, max_distance);
|
|
||||||
case VPF_YAPF: return YapfTrainFindNearestDepot(v, max_distance);
|
|
||||||
|
|
||||||
default: NOT_REACHED();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ClosestDepot Train::FindClosestDepot()
|
ClosestDepot Train::FindClosestDepot()
|
||||||
|
@ -2473,13 +2467,7 @@ static const uint8_t _initial_tile_subcoord[6][4][3] = {
|
||||||
static Track DoTrainPathfind(const Train *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool &path_found, bool do_track_reservation, PBSTileInfo *dest, TileIndex *final_dest)
|
static Track DoTrainPathfind(const Train *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool &path_found, bool do_track_reservation, PBSTileInfo *dest, TileIndex *final_dest)
|
||||||
{
|
{
|
||||||
if (final_dest != nullptr) *final_dest = INVALID_TILE;
|
if (final_dest != nullptr) *final_dest = INVALID_TILE;
|
||||||
|
return YapfTrainChooseTrack(v, tile, enterdir, tracks, path_found, do_track_reservation, dest, final_dest);
|
||||||
switch (_settings_game.pf.pathfinder_for_trains) {
|
|
||||||
case VPF_NPF: return NPFTrainChooseTrack(v, path_found, do_track_reservation, dest);
|
|
||||||
case VPF_YAPF: return YapfTrainChooseTrack(v, tile, enterdir, tracks, path_found, do_track_reservation, dest, final_dest);
|
|
||||||
|
|
||||||
default: NOT_REACHED();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2581,12 +2569,7 @@ static PBSTileInfo ExtendTrainReservation(const Train *v, TrackBits *new_tracks,
|
||||||
*/
|
*/
|
||||||
static bool TryReserveSafeTrack(const Train *v, TileIndex tile, Trackdir td, bool override_railtype)
|
static bool TryReserveSafeTrack(const Train *v, TileIndex tile, Trackdir td, bool override_railtype)
|
||||||
{
|
{
|
||||||
switch (_settings_game.pf.pathfinder_for_trains) {
|
return YapfTrainFindNearestSafeTile(v, tile, td, override_railtype);
|
||||||
case VPF_NPF: return NPFTrainFindNearestSafeTile(v, tile, td, override_railtype);
|
|
||||||
case VPF_YAPF: return YapfTrainFindNearestSafeTile(v, tile, td, override_railtype);
|
|
||||||
|
|
||||||
default: NOT_REACHED();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This class will save the current order of a vehicle and restore it on destruction. */
|
/** This class will save the current order of a vehicle and restore it on destruction. */
|
||||||
|
@ -2934,12 +2917,7 @@ static bool CheckReverseTrain(const Train *v)
|
||||||
|
|
||||||
assert(v->track != TRACK_BIT_NONE);
|
assert(v->track != TRACK_BIT_NONE);
|
||||||
|
|
||||||
switch (_settings_game.pf.pathfinder_for_trains) {
|
return YapfTrainCheckReverse(v);
|
||||||
case VPF_NPF: return NPFTrainCheckReverse(v);
|
|
||||||
case VPF_YAPF: return YapfTrainCheckReverse(v);
|
|
||||||
|
|
||||||
default: NOT_REACHED();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4142,12 +4120,7 @@ static void CheckIfTrainNeedsService(Train *v)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint max_penalty;
|
uint max_penalty = _settings_game.pf.yapf.maximum_go_to_depot_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);
|
FindDepotData tfdd = FindClosestTrainDepot(v, max_penalty);
|
||||||
/* Only go to the depot if it is not too far out of our way. */
|
/* Only go to the depot if it is not too far out of our way. */
|
||||||
|
|
|
@ -56,7 +56,7 @@ static const VehicleID INVALID_VEHICLE = 0xFFFFF; ///< Constant representing a n
|
||||||
/** Pathfinding option states */
|
/** Pathfinding option states */
|
||||||
enum VehiclePathFinders {
|
enum VehiclePathFinders {
|
||||||
// Original PathFinder (OPF) used to be 0
|
// Original PathFinder (OPF) used to be 0
|
||||||
VPF_NPF = 1, ///< New PathFinder
|
// New PathFinder (NPF) used to be 1
|
||||||
VPF_YAPF = 2, ///< Yet Another PathFinder
|
VPF_YAPF = 2, ///< Yet Another PathFinder
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue