1
0
Fork 0

Compare commits

...

6 Commits

Author SHA1 Message Date
Peter Nelson e1544a51ed
Merge 613cc82705 into c3ee5e58a3 2024-05-10 18:41:45 +09:00
merni-ns c3ee5e58a3 Cleanup: Move remaining NPF files into pathfinder directory 2024-05-10 10:38:44 +02:00
merni-ns 798ec4184b Cleanup: Remove unused function InvalidateShipPathCache
This was only used in the callback when changing the ship pathfinder setting.
2024-05-10 10:38:44 +02:00
merni-ns 55a7c59d13 Remove: NPF and pathfinder change settings 2024-05-10 10:38:44 +02:00
translators a5c2543efc Update: Translations from eints
chinese (simplified): 7 changes by WenSimEHRP, 4 changes by ahyangyi
2024-05-10 04:40:29 +00:00
Peter Nelson 613cc82705
Fix #12648: Ensure all uses of std::filesystem::path use native encoding.
std::filesystem::path does not expect UTF-8 strings, so they must be converted to native format first (and back to utf-8 after.)
2024-05-09 18:24:05 +01:00
31 changed files with 52 additions and 1872 deletions

View File

@ -42,7 +42,6 @@ int _debug_misc_level;
int _debug_net_level;
int _debug_sprite_level;
int _debug_oldloader_level;
int _debug_npf_level;
int _debug_yapf_level;
int _debug_fontcache_level;
int _debug_script_level;
@ -68,7 +67,6 @@ static const DebugLevel _debug_levels[] = {
DEBUG_LEVEL(net),
DEBUG_LEVEL(sprite),
DEBUG_LEVEL(oldloader),
DEBUG_LEVEL(npf),
DEBUG_LEVEL(yapf),
DEBUG_LEVEL(fontcache),
DEBUG_LEVEL(script),

View File

@ -44,7 +44,6 @@ extern int _debug_misc_level;
extern int _debug_net_level;
extern int _debug_sprite_level;
extern int _debug_oldloader_level;
extern int _debug_npf_level;
extern int _debug_yapf_level;
extern int _debug_fontcache_level;
extern int _debug_script_level;

View File

@ -489,7 +489,7 @@ bool TarScanner::AddFile(const std::string &filename, size_t, [[maybe_unused]] c
_tar_list[this->subdir][filename] = std::string{};
std::string filename_base = std::filesystem::path(filename).filename().string();
std::string filename_base = FS2OTTD(std::filesystem::path(OTTD2FS(filename)).filename());
SimplifyFileName(filename_base);
TarHeader th;

View File

@ -386,7 +386,7 @@ void ReconsiderGameScriptLanguage()
{
if (_current_data == nullptr) return;
std::string language = _current_language->file.stem().string();
std::string language = FS2OTTD(_current_language->file.stem());
for (auto &p : _current_data->compiled_strings) {
if (p.language == language) {
_current_data->cur_language = &p;

View File

@ -30,7 +30,7 @@
#include "core/random_func.hpp"
#include "object_base.h"
#include "company_func.h"
#include "pathfinder/npf/aystar.h"
#include "pathfinder/aystar.h"
#include "saveload/saveload.h"
#include "framerate_type.h"
#include "landscape_cmd.h"

View File

@ -2130,17 +2130,8 @@ STR_CONFIG_SETTING_AI :Competitors
STR_CONFIG_SETTING_AI_NPC :Computer players
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_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

View File

@ -955,6 +955,7 @@ STR_GAME_OPTIONS_VOLUME :音量
STR_GAME_OPTIONS_SFX_VOLUME :音效
STR_GAME_OPTIONS_MUSIC_VOLUME :音乐
STR_GAME_OPTIONS_VOLUME_MARK :{NUM}%
STR_GAME_OPTIONS_CURRENCY_UNITS_FRAME :{BLACK}货币单位
STR_GAME_OPTIONS_CURRENCY_UNITS_DROPDOWN_TOOLTIP :{BLACK}货币单位选择
@ -1052,6 +1053,7 @@ STR_GAME_OPTIONS_GUI_FONT_SPRITE_TOOLTIP :{BLACK}如果
STR_GAME_OPTIONS_GUI_FONT_AA :字体抗锯齿
STR_GAME_OPTIONS_GUI_FONT_AA_TOOLTIP :{BLACK}勾选此框以对游戏字体应用抗锯齿
STR_GAME_OPTIONS_GUI_SCALE_MARK :{DECIMAL}x
STR_GAME_OPTIONS_PARTICIPATE_SURVEY_FRAME :{BLACK}自动体验调查
STR_GAME_OPTIONS_PARTICIPATE_SURVEY :{BLACK}参与自动体验调查
@ -1080,6 +1082,8 @@ STR_GAME_OPTIONS_BASE_MUSIC :{BLACK}基础
STR_GAME_OPTIONS_BASE_MUSIC_TOOLTIP :{BLACK}选择要使用的基础音乐组
STR_GAME_OPTIONS_BASE_MUSIC_DESCRIPTION_TOOLTIP :{BLACK}有关基础音乐组的附加信息
STR_GAME_OPTIONS_ONLINE_CONTENT :获取内容
STR_GAME_OPTIONS_ONLINE_CONTENT_TOOLTIP :查询并下载最新内容
STR_GAME_OPTIONS_SOCIAL_PLUGINS_NONE :{LTBLUE}(未安装社交平台插件)
@ -1823,6 +1827,9 @@ STR_CONFIG_SETTING_SERVINT_AIRCRAFT_HELPTEXT :如果没有为
STR_CONFIG_SETTING_SERVINT_SHIPS :船只默认保养周期:{STRING}
STR_CONFIG_SETTING_SERVINT_SHIPS_HELPTEXT :如果没有为船只设定保养周期,按照这里设定的默认保养周期执行
###length 3
STR_CONFIG_SETTING_SERVINT_VALUE_DAYS :{COMMA}{NBSP}日
STR_CONFIG_SETTING_SERVINT_VALUE_MINUTES :{COMMA}{NBSP}分
STR_CONFIG_SETTING_SERVINT_VALUE_PERCENTAGE :{COMMA}{NBSP}%
###setting-zero-is-special
STR_CONFIG_SETTING_SERVINT_DISABLED :关闭
@ -2478,6 +2485,7 @@ STR_NETWORK_CLIENT_LIST_PLAYER_NAME_QUERY_CAPTION :你的玩家名
STR_NETWORK_CLIENT_LIST_ADMIN_CLIENT_TOOLTIP :{BLACK}要在此客户端执行的管理命令
STR_NETWORK_CLIENT_LIST_ADMIN_COMPANY_TOOLTIP :{BLACK}要在此公司执行的管理命令
STR_NETWORK_CLIENT_LIST_JOIN_TOOLTIP :{BLACK}加入该公司
STR_NETWORK_CLIENT_LIST_COMPANY_AUTHORIZE_TOOLTIP :{BLACK}授权此客户端加入你的公司
STR_NETWORK_CLIENT_LIST_CHAT_CLIENT_TOOLTIP :{BLACK}给这位玩家发消息
STR_NETWORK_CLIENT_LIST_CHAT_COMPANY_TOOLTIP :{BLACK}给公司中的所有玩家发消息
STR_NETWORK_CLIENT_LIST_CHAT_SPECTATOR_TOOLTIP :{BLACK}给所有旁观者发消息
@ -3469,7 +3477,9 @@ STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT_ROAD_TYPE :道路类型
STR_NEWGRF_INSPECT_QUERY_CAPTION :{WHITE}NewGRF variable 60+x 参数 (十六进制)
# Sprite aligner window
STR_SPRITE_ALIGNER_CAPTION_NO_ACTION :{WHITE}对齐中的 Sprite({STRING}:{NUM})
STR_SPRITE_ALIGNER_CAPTION_ACTIONA :{WHITE}对齐中的 SpriteAction 0xA, {COMMA} ({STRING}:{NUM})
STR_SPRITE_ALIGNER_CAPTION_ACTION5 :{WHITE}对齐中的 SpriteAction 0x5, 类别 {HEX}, {COMMA} ({STRING}:{NUM})
STR_SPRITE_ALIGNER_NEXT_BUTTON :{BLACK}下一个 sprite
STR_SPRITE_ALIGNER_NEXT_TOOLTIP :{BLACK}继续处理下个正常的图形元素,略过任何虚位/重新着色/文字字型相关的图形元素;并且在处理到最后的图形元素后,返回第一个图形元素继续处理。
STR_SPRITE_ALIGNER_GOTO_BUTTON :{BLACK}前往 sprite
@ -3478,6 +3488,7 @@ STR_SPRITE_ALIGNER_PREVIOUS_BUTTON :{BLACK}上一
STR_SPRITE_ALIGNER_PREVIOUS_TOOLTIP :{BLACK}继续处理上一个正常的图形元素,略过任何虚位/重新着色/文字字型相关的图形元素;并且在处理到第一个图形元素后,返回最后的图形元素继续处理。
STR_SPRITE_ALIGNER_SPRITE_TOOLTIP :{BLACK}显示目前选取的 sprite。当 sprite 正在描绘时会忽略其定位。
STR_SPRITE_ALIGNER_MOVE_TOOLTIP :{BLACK}从 X 及 Y 座标方向移动图形元素。如按住 Ctrl 键再点击,可一次移动 8 个单位
STR_SPRITE_ALIGNER_SPRITE :{STRING}:{NUM}
###length 2
STR_SPRITE_ALIGNER_CENTRE_OFFSET :{BLACK}偏移居中

View File

@ -54,7 +54,6 @@ void InitializeObjects();
void InitializeTrees();
void InitializeCompanies();
void InitializeCheats();
void InitializeNPF();
void InitializeOldNames();
/**
@ -149,8 +148,6 @@ void InitializeGame(uint size_x, uint size_y, bool reset_date, bool reset_settin
InitializeIndustries();
InitializeObjects();
InitializeNPF();
InitializeCompanies();
AI::Initialize();
Game::Initialize();

View File

@ -578,7 +578,7 @@ int openttd_main(std::span<char * const> arguments)
if (mgo.opt != nullptr) {
_file_to_saveload.name = mgo.opt;
std::string extension = std::filesystem::path(_file_to_saveload.name).extension().string();
std::string extension = FS2OTTD(std::filesystem::path(OTTD2FS(_file_to_saveload.name)).extension());
auto [ft, _] = FiosGetSavegameListCallback(SLO_LOAD, _file_to_saveload.name, extension);
if (ft == FIOS_TYPE_INVALID) {
std::tie(ft, _) = FiosGetScenarioListCallback(SLO_LOAD, _file_to_saveload.name, extension);
@ -612,7 +612,7 @@ int openttd_main(std::span<char * const> arguments)
return ret;
}
std::string extension = std::filesystem::path(_file_to_saveload.name).extension().string();
std::string extension = FS2OTTD(std::filesystem::path(OTTD2FS(_file_to_saveload.name)).extension());
auto [_, title] = FiosGetSavegameListCallback(SLO_LOAD, mgo.opt, extension);
_load_check_data.Clear();

View File

@ -1,8 +1,11 @@
add_subdirectory(npf)
add_subdirectory(yapf)
add_files(
aystar.h
aystar.cpp
follow_track.hpp
queue.h
queue.cpp
pathfinder_func.h
pathfinder_type.h
water_regions.h

View File

@ -168,7 +168,7 @@ int AyStar::Loop()
if (current == nullptr) return AYSTAR_EMPTY_OPENLIST;
/* Check for end node and if found, return that code */
if (this->EndNodeCheck(this, current) == AYSTAR_FOUND_END_NODE && !CheckIgnoreFirstTile(&current->path)) {
if (this->EndNodeCheck(this, current) == AYSTAR_FOUND_END_NODE && (&current->path)->parent != nullptr) {
if (this->FoundEndNode != nullptr) {
this->FoundEndNode(this, current);
}

View File

@ -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

View File

@ -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 */

View File

@ -11,19 +11,7 @@
#define PATHFINDER_TYPE_H
#include "../tile_type.h"
#include "npf/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;
#include "aystar.h"
/** Length (penalty) of one tile with YAPF */
static const int YAPF_TILE_LENGTH = 100;

View File

@ -12,7 +12,6 @@
#include "command_func.h"
#include "error_func.h"
#include "news_func.h"
#include "pathfinder/npf/npf_func.h"
#include "station_base.h"
#include "company_func.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);
switch (_settings_game.pf.pathfinder_for_roadvehs) {
case VPF_NPF: return NPFRoadVehicleFindNearestDepot(v, max_distance);
case VPF_YAPF: return YapfRoadVehicleFindNearestDepot(v, max_distance);
default: NOT_REACHED();
}
return YapfRoadVehicleFindNearestDepot(v, max_distance);
}
ClosestDepot RoadVehicle::FindClosestDepot()
@ -989,12 +983,8 @@ static Trackdir RoadFindPathToDest(RoadVehicle *v, TileIndex tile, DiagDirection
}
}
switch (_settings_game.pf.pathfinder_for_roadvehs) {
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;
best_track = YapfRoadVehicleChooseTrack(v, tile, enterdir, trackdirs, path_found, v->path);
default: NOT_REACHED();
}
v->HandlePathfindingResult(path_found);
found_best_track:;
@ -1683,12 +1673,7 @@ static void CheckIfRoadVehNeedsService(RoadVehicle *v)
return;
}
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();
}
uint max_penalty = _settings_game.pf.yapf.maximum_go_to_depot_penalty;
FindDepotData rfdd = FindClosestRoadDepot(v, max_penalty);
/* Only go to the depot if it is not too far out of our way. */

View File

@ -1889,25 +1889,6 @@ bool AfterLoadGame()
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)) {

View File

@ -95,13 +95,9 @@ const SaveLoadCompat _settings_sl_compat[] = {
SLC_VAR("vehicle.smoke_amount"),
SLC_NULL(1, SL_MIN_VERSION, SLV_159),
SLC_VAR("pf.roadveh_queue"),
SLC_VAR("pf.new_pathfinding_all"),
SLC_VAR("pf.yapf.ship_use_yapf"),
SLC_VAR("pf.yapf.road_use_yapf"),
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_NULL(1, SL_MIN_VERSION, SLV_87),
SLC_NULL(3, SLV_28, SLV_87),
SLC_NULL(3, SLV_87, SLV_TABLE_CHUNKS),
SLC_VAR("vehicle.never_expire_vehicles"),
SLC_VAR("vehicle.max_trains"),
SLC_VAR("vehicle.max_roadveh"),
@ -183,24 +179,12 @@ const SaveLoadCompat _settings_sl_compat[] = {
SLC_VAR("pf.reserve_paths"),
SLC_VAR("pf.path_backoff_interval"),
SLC_NULL(3, SL_MIN_VERSION, SLV_REMOVE_OPF),
SLC_VAR("pf.npf.npf_max_search_nodes"),
SLC_VAR("pf.npf.npf_rail_firstred_penalty"),
SLC_VAR("pf.npf.npf_rail_firstred_exit_penalty"),
SLC_VAR("pf.npf.npf_rail_lastred_penalty"),
SLC_VAR("pf.npf.npf_rail_station_penalty"),
SLC_VAR("pf.npf.npf_rail_slope_penalty"),
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_NULL(32, SL_MIN_VERSION, SLV_TABLE_CHUNKS),
SLC_NULL(8, SLV_100, SLV_TABLE_CHUNKS),
SLC_NULL(16, SL_MIN_VERSION, SLV_TABLE_CHUNKS),
SLC_NULL(4, SLV_47, SLV_TABLE_CHUNKS),
SLC_NULL(8, SLV_130, SLV_TABLE_CHUNKS),
SLC_NULL(4, SLV_131, SLV_TABLE_CHUNKS),
SLC_VAR("pf.yapf.disable_node_optimization"),
SLC_VAR("pf.yapf.max_search_nodes"),
SLC_VAR("pf.yapf.rail_firstred_twoway_eol"),

View File

@ -2129,12 +2129,9 @@ static SettingsContainer &GetSettingsTree()
SettingsPage *routing = vehicles->Add(new SettingsPage(STR_CONFIG_SETTING_VEHICLES_ROUTING));
{
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("pf.reverse_at_signals"));
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));

View File

@ -555,13 +555,6 @@ static void MaxVehiclesChanged(int32_t)
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.
* @param newval The new string value for this password field.

View File

@ -409,42 +409,11 @@ struct ScriptSettings {
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. */
struct YAPFSettings {
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 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_curve_penalty; ///< penalty for curves
uint32_t road_crossing_penalty; ///< penalty for level crossing
@ -481,11 +450,6 @@ struct YAPFSettings {
/** Settings related to all pathfinders. */
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 forbid_90_deg; ///< forbid trains to make 90 deg turns
@ -497,7 +461,6 @@ struct PathfinderSettings {
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.
NPFSettings npf; ///< pathfinder settings for the new pathfinder
YAPFSettings yapf; ///< pathfinder settings for the yet another pathfinder
};

View File

@ -13,7 +13,6 @@
#include "timetable.h"
#include "news_func.h"
#include "company_func.h"
#include "pathfinder/npf/npf_func.h"
#include "depot_base.h"
#include "station_base.h"
#include "newgrf_engine.h"
@ -210,12 +209,7 @@ static void CheckIfShipNeedsService(Vehicle *v)
return;
}
uint max_distance;
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();
}
uint max_distance = _settings_game.pf.yapf.maximum_go_to_depot_penalty / YAPF_TILE_LENGTH;
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)
{
/* Ask pathfinder for best direction */
bool reverse = false;
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;
return YapfShipCheckReverse(v, trackdir);
}
static bool CheckShipLeaveDepot(Ship *v)
@ -530,11 +518,7 @@ static Track ChooseShipTrack(Ship *v, TileIndex tile, TrackBits tracks)
v->path.clear();
}
switch (_settings_game.pf.pathfinder_for_ships) {
case VPF_NPF: track = NPFShipChooseTrack(v, path_found); break;
case VPF_YAPF: track = YapfShipChooseTrack(v, tile, path_found, v->path); break;
default: NOT_REACHED();
}
track = YapfShipChooseTrack(v, tile, path_found, v->path);
}
v->HandlePathfindingResult(path_found);

View File

@ -245,7 +245,7 @@ static bool _ValidateSignatureFile(const std::string &filename)
return false;
}
std::string dirname = std::filesystem::path(filename).parent_path().string();
std::string dirname = FS2OTTD(std::filesystem::path(OTTD2FS(filename)).parent_path());
for (auto &signature : signatures["files"]) {
const std::string sig_filename = dirname + PATHSEPCHAR + signature["filename"].get<std::string>();

View File

@ -1904,7 +1904,7 @@ bool ReadLanguagePack(const LanguageMetadata *lang)
{
/* Current language pack */
size_t len = 0;
std::unique_ptr<LanguagePack, LanguagePackDeleter> lang_pack(reinterpret_cast<LanguagePack *>(ReadFileToMem(lang->file.string(), len, 1U << 20).release()));
std::unique_ptr<LanguagePack, LanguagePackDeleter> lang_pack(reinterpret_cast<LanguagePack *>(ReadFileToMem(FS2OTTD(lang->file), len, 1U << 20).release()));
if (!lang_pack) return false;
/* End of read data (+ terminating zero added in ReadFileToMem()) */
@ -1953,7 +1953,7 @@ bool ReadLanguagePack(const LanguageMetadata *lang)
_current_language = lang;
_current_text_dir = (TextDirection)_current_language->text_dir;
_config_language_file = _current_language->file.filename().string();
_config_language_file = FS2OTTD(_current_language->file.filename());
SetCurrentGrfLangID(_current_language->newgrflangid);
#ifdef _WIN32
@ -2079,13 +2079,13 @@ static void FillLanguageList(const std::string &path)
if (dir_entry.path().extension() != ".lng") continue;
LanguageMetadata lmd;
lmd.file = FS2OTTD(dir_entry.path());
lmd.file = dir_entry.path();
/* Check whether the file is of the correct version */
if (!GetLanguageFileHeader(lmd.file.string(), &lmd)) {
Debug(misc, 3, "{} is not a valid language file", lmd.file);
if (!GetLanguageFileHeader(FS2OTTD(lmd.file), &lmd)) {
Debug(misc, 3, "{} is not a valid language file", FS2OTTD(lmd.file));
} else if (GetLanguage(lmd.newgrflangid) != nullptr) {
Debug(misc, 3, "{}'s language ID is already known", lmd.file);
Debug(misc, 3, "{}'s language ID is already known", FS2OTTD(lmd.file));
} else {
_languages.push_back(lmd);
}
@ -2119,7 +2119,7 @@ void InitializeLanguagePacks()
/* We are trying to find a default language. The priority is by
* configuration file, local environment and last, if nothing found,
* English. */
if (_config_language_file == lng.file.filename()) {
if (_config_language_file == FS2OTTD(lng.file.filename())) {
chosen_language = &lng;
break;
}
@ -2139,7 +2139,7 @@ void InitializeLanguagePacks()
chosen_language = (language_fallback != nullptr) ? language_fallback : en_GB_fallback;
}
if (!ReadLanguagePack(chosen_language)) UserError("Can't read language pack '{}'", chosen_language->file);
if (!ReadLanguagePack(chosen_language)) UserError("Can't read language pack '{}'", FS2OTTD(chosen_language->file));
}
/**

View File

@ -258,7 +258,7 @@ void SurveyConfiguration(nlohmann::json &survey)
{
survey["network"] = _networking ? (_network_server ? "server" : "client") : "no";
if (_current_language != nullptr) {
survey["language"]["filename"] = _current_language->file.filename().string();
survey["language"]["filename"] = FS2OTTD(_current_language->file.filename());
survey["language"]["name"] = _current_language->name;
survey["language"]["isocode"] = _current_language->isocode;
}

View File

@ -8,8 +8,6 @@
; and in the savegame PATS chunk.
[pre-amble]
static void InvalidateShipPathCache(int32_t new_value);
static const SettingVariant _pathfinding_settings_table[] = {
[post-amble]
};
@ -52,76 +50,6 @@ var = pf.roadveh_queue
def = true
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]
var = pf.reverse_at_signals
from = SLV_159
@ -169,156 +97,6 @@ min = 1
max = 255
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]
var = pf.yapf.disable_node_optimization
from = SLV_28

View File

@ -12,7 +12,6 @@
#include "articulated_vehicles.h"
#include "command_func.h"
#include "error_func.h"
#include "pathfinder/npf/npf_func.h"
#include "pathfinder/yapf/yapf.hpp"
#include "news_func.h"
#include "company_func.h"
@ -2171,12 +2170,7 @@ static FindDepotData FindClosestTrainDepot(Train *v, int max_distance)
PBSTileInfo origin = FollowTrainReservation(v);
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);
default: NOT_REACHED();
}
return YapfTrainFindNearestDepot(v, max_distance);
}
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)
{
if (final_dest != nullptr) *final_dest = INVALID_TILE;
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();
}
return YapfTrainChooseTrack(v, tile, enterdir, tracks, path_found, do_track_reservation, dest, final_dest);
}
/**
@ -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)
{
switch (_settings_game.pf.pathfinder_for_trains) {
case VPF_NPF: return NPFTrainFindNearestSafeTile(v, tile, td, override_railtype);
case VPF_YAPF: return YapfTrainFindNearestSafeTile(v, tile, td, override_railtype);
default: NOT_REACHED();
}
return YapfTrainFindNearestSafeTile(v, tile, td, override_railtype);
}
/** 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);
switch (_settings_game.pf.pathfinder_for_trains) {
case VPF_NPF: return NPFTrainCheckReverse(v);
case VPF_YAPF: return YapfTrainCheckReverse(v);
default: NOT_REACHED();
}
return YapfTrainCheckReverse(v);
}
/**
@ -4142,12 +4120,7 @@ static void CheckIfTrainNeedsService(Train *v)
return;
}
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();
}
uint max_penalty = _settings_game.pf.yapf.maximum_go_to_depot_penalty;
FindDepotData tfdd = FindClosestTrainDepot(v, max_penalty);
/* Only go to the depot if it is not too far out of our way. */

View File

@ -53,13 +53,6 @@ struct BaseVehicle
static const VehicleID INVALID_VEHICLE = 0xFFFFF; ///< Constant representing a non-existing vehicle.
/** Pathfinding option states */
enum VehiclePathFinders {
// Original PathFinder (OPF) used to be 0
VPF_NPF = 1, ///< New PathFinder
VPF_YAPF = 2, ///< Yet Another PathFinder
};
/** Flags for goto depot commands. */
enum class DepotCommand : uint8_t {
None = 0, ///< No special flags.