mirror of https://github.com/OpenTTD/OpenTTD
Compare commits
8 Commits
734c056fd3
...
644d57449e
Author | SHA1 | Date |
---|---|---|
Peter Nelson | 644d57449e | |
merni-ns | c3ee5e58a3 | |
merni-ns | 798ec4184b | |
merni-ns | 55a7c59d13 | |
translators | a5c2543efc | |
Peter Nelson | 9be9bb0b6b | |
Peter Nelson | eb79f691db | |
Peter Nelson | 79cd8cc2c9 |
|
@ -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),
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -139,50 +139,57 @@ void SetFont(FontSize fontsize, const std::string &font, uint size)
|
|||
|
||||
#ifdef WITH_FREETYPE
|
||||
extern void LoadFreeTypeFont(FontSize fs);
|
||||
extern void LoadFreeTypeFont(FontSize fs, const std::string &file_name, uint size);
|
||||
extern void UninitFreeType();
|
||||
#elif defined(_WIN32)
|
||||
extern void LoadWin32Font(FontSize fs);
|
||||
extern void LoadWin32Font(FontSize fs, const std::string &file_name, uint size);
|
||||
#elif defined(WITH_COCOA)
|
||||
extern void LoadCoreTextFont(FontSize fs);
|
||||
extern void LoadCoreTextFont(FontSize fs, const std::string &file_name, uint size);
|
||||
#endif
|
||||
|
||||
static void TryLoadDefaultTrueTypeFont([[maybe_unused]] FontSize fs)
|
||||
{
|
||||
#if defined(WITH_FREETYPE) || defined(_WIN32) || defined(WITH_COCOA)
|
||||
std::string font_name{};
|
||||
/**
|
||||
* Get name of default font file for a given font size.
|
||||
* @param fs Font size.
|
||||
* @return Name of default font file.
|
||||
*/
|
||||
static std::string GetDefaultTruetypeFont(FontSize fs)
|
||||
{
|
||||
switch (fs) {
|
||||
case FS_NORMAL:
|
||||
font_name = "OpenTTD-Sans.ttf";
|
||||
break;
|
||||
case FS_SMALL:
|
||||
font_name = "OpenTTD-Small.ttf";
|
||||
break;
|
||||
case FS_LARGE:
|
||||
font_name = "OpenTTD-Serif.ttf";
|
||||
break;
|
||||
case FS_MONO:
|
||||
font_name = "OpenTTD-Mono.ttf";
|
||||
break;
|
||||
|
||||
case FS_NORMAL: return "OpenTTD-Sans.ttf";
|
||||
case FS_SMALL: return "OpenTTD-Small.ttf";
|
||||
case FS_LARGE: return "OpenTTD-Serif.ttf";
|
||||
case FS_MONO: return "OpenTTD-Mono.ttf";
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
|
||||
/* Find font file. */
|
||||
std::string full_font = FioFindFullPath(BASESET_DIR, font_name);
|
||||
if (!full_font.empty()) {
|
||||
int size = FontCache::GetDefaultFontHeight(fs);
|
||||
#ifdef WITH_FREETYPE
|
||||
LoadFreeTypeFont(fs, full_font, size);
|
||||
#elif defined(_WIN32)
|
||||
LoadWin32Font(fs, full_font, size);
|
||||
#elif defined(WITH_COCOA)
|
||||
LoadCoreTextFont(fs, full_font, size);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif /* defined(WITH_FREETYPE) || defined(_WIN32) || defined(WITH_COCOA) */
|
||||
|
||||
/**
|
||||
* Get path of default font file for a given font size.
|
||||
* @param fs Font size.
|
||||
* @return Full path of default font file.
|
||||
*/
|
||||
static std::string GetDefaultTruetypeFontFile([[maybe_unused]] FontSize fs)
|
||||
{
|
||||
#if defined(WITH_FREETYPE) || defined(_WIN32) || defined(WITH_COCOA)
|
||||
/* Find font file. */
|
||||
return FioFindFullPath(BASESET_DIR, GetDefaultTruetypeFont(fs));
|
||||
#else
|
||||
return {};
|
||||
#endif /* defined(WITH_FREETYPE) || defined(_WIN32) || defined(WITH_COCOA) */
|
||||
}
|
||||
|
||||
/**
|
||||
* Get font to use for a given font size.
|
||||
* @param fs Font size.
|
||||
* @return If configured, the font name to use, or the path of the default TrueType font if sprites are not preferred.
|
||||
*/
|
||||
std::string GetFontCacheFontName(FontSize fs)
|
||||
{
|
||||
const FontCacheSubSetting *settings = GetFontCacheSubSetting(fs);
|
||||
if (!settings->font.empty()) return settings->font;
|
||||
if (_fcsettings.prefer_sprite) return {};
|
||||
return GetDefaultTruetypeFontFile(fs);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -199,17 +206,13 @@ void InitFontCache(bool monospace)
|
|||
FontCache *fc = FontCache::Get(fs);
|
||||
if (fc->HasParent()) delete fc;
|
||||
|
||||
if (!_fcsettings.prefer_sprite && GetFontCacheSubSetting(fs)->font.empty()) {
|
||||
TryLoadDefaultTrueTypeFont(fs);
|
||||
} else {
|
||||
#ifdef WITH_FREETYPE
|
||||
LoadFreeTypeFont(fs);
|
||||
LoadFreeTypeFont(fs);
|
||||
#elif defined(_WIN32)
|
||||
LoadWin32Font(fs);
|
||||
LoadWin32Font(fs);
|
||||
#elif defined(WITH_COCOA)
|
||||
LoadCoreTextFont(fs);
|
||||
LoadCoreTextFont(fs);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -239,6 +239,7 @@ inline FontCacheSubSetting *GetFontCacheSubSetting(FontSize fs)
|
|||
}
|
||||
}
|
||||
|
||||
std::string GetFontCacheFontName(FontSize fs);
|
||||
void InitFontCache(bool monospace);
|
||||
void UninitFontCache();
|
||||
|
||||
|
|
|
@ -162,7 +162,8 @@ void LoadFreeTypeFont(FontSize fs)
|
|||
{
|
||||
FontCacheSubSetting *settings = GetFontCacheSubSetting(fs);
|
||||
|
||||
if (settings->font.empty()) return;
|
||||
std::string font = GetFontCacheFontName(fs);
|
||||
if (font.empty()) return;
|
||||
|
||||
if (_library == nullptr) {
|
||||
if (FT_Init_FreeType(&_library) != FT_Err_Ok) {
|
||||
|
@ -173,7 +174,7 @@ void LoadFreeTypeFont(FontSize fs)
|
|||
Debug(fontcache, 2, "Initialized");
|
||||
}
|
||||
|
||||
const char *font_name = settings->font.c_str();
|
||||
const char *font_name = font.c_str();
|
||||
FT_Face face = nullptr;
|
||||
|
||||
/* If font is an absolute path to a ttf, try loading that first. */
|
||||
|
@ -202,34 +203,6 @@ void LoadFreeTypeFont(FontSize fs)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a TrueType font from a file.
|
||||
* @param fs The font size to load.
|
||||
* @param file_name Path to the font file.
|
||||
* @param size Requested font size.
|
||||
*/
|
||||
void LoadFreeTypeFont(FontSize fs, const std::string &file_name, uint size)
|
||||
{
|
||||
if (_library == nullptr) {
|
||||
if (FT_Init_FreeType(&_library) != FT_Err_Ok) {
|
||||
ShowInfo("Unable to initialize FreeType, using sprite fonts instead");
|
||||
return;
|
||||
}
|
||||
|
||||
Debug(fontcache, 2, "Initialized");
|
||||
}
|
||||
|
||||
FT_Face face = nullptr;
|
||||
int32_t index = 0;
|
||||
FT_Error error = FT_New_Face(_library, file_name.c_str(), index, &face);
|
||||
if (error == FT_Err_Ok) {
|
||||
LoadFont(fs, face, file_name.c_str(), size);
|
||||
} else {
|
||||
FT_Done_Face(face);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Free everything that was allocated for this font cache.
|
||||
*/
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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}对齐中的 Sprite:Action 0xA, {COMMA} ({STRING}:{NUM})
|
||||
STR_SPRITE_ALIGNER_CAPTION_ACTION5 :{WHITE}对齐中的 Sprite:Action 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}偏移居中
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -341,7 +341,8 @@ void LoadCoreTextFont(FontSize fs)
|
|||
{
|
||||
FontCacheSubSetting *settings = GetFontCacheSubSetting(fs);
|
||||
|
||||
if (settings->font.empty()) return;
|
||||
std::string font = GetFontCacheFontName(fs);
|
||||
if (font.empty()) return;
|
||||
|
||||
CFAutoRelease<CTFontDescriptorRef> font_ref;
|
||||
|
||||
|
@ -352,12 +353,12 @@ void LoadCoreTextFont(FontSize fs)
|
|||
|
||||
if (!font_ref && MacOSVersionIsAtLeast(10, 6, 0)) {
|
||||
/* Might be a font file name, try load it. */
|
||||
font_ref.reset(LoadFontFromFile(settings->font));
|
||||
if (!font_ref) ShowInfo("Unable to load file '{}' for {} font, using default OS font selection instead", settings->font, FontSizeToName(fs));
|
||||
font_ref.reset(LoadFontFromFile(font));
|
||||
if (!font_ref) ShowInfo("Unable to load file '{}' for {} font, using default OS font selection instead", font, FontSizeToName(fs));
|
||||
}
|
||||
|
||||
if (!font_ref) {
|
||||
CFAutoRelease<CFStringRef> name(CFStringCreateWithCString(kCFAllocatorDefault, settings->font.c_str(), kCFStringEncodingUTF8));
|
||||
CFAutoRelease<CFStringRef> name(CFStringCreateWithCString(kCFAllocatorDefault, font.c_str(), kCFStringEncodingUTF8));
|
||||
|
||||
/* Simply creating the font using CTFontCreateWithNameAndSize will *always* return
|
||||
* something, no matter the name. As such, we can't use it to check for existence.
|
||||
|
@ -375,23 +376,9 @@ void LoadCoreTextFont(FontSize fs)
|
|||
}
|
||||
|
||||
if (!font_ref) {
|
||||
ShowInfo("Unable to use '{}' for {} font, using sprite font instead", settings->font, FontSizeToName(fs));
|
||||
ShowInfo("Unable to use '{}' for {} font, using sprite font instead", font, FontSizeToName(fs));
|
||||
return;
|
||||
}
|
||||
|
||||
new CoreTextFontCache(fs, std::move(font_ref), settings->size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a TrueType font from a file.
|
||||
* @param fs The font size to load.
|
||||
* @param file_name Path to the font file.
|
||||
* @param size Requested font size.
|
||||
*/
|
||||
void LoadCoreTextFont(FontSize fs, const std::string &file_name, uint size)
|
||||
{
|
||||
CFAutoRelease<CTFontDescriptorRef> font_ref{LoadFontFromFile(file_name)};
|
||||
if (font_ref) {
|
||||
new CoreTextFontCache(fs, std::move(font_ref), size);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,5 @@ public:
|
|||
};
|
||||
|
||||
void LoadCoreTextFont(FontSize fs);
|
||||
void LoadCoreTextFont(FontSize fs, const std::string &file_name, uint size);
|
||||
|
||||
#endif /* FONT_OSX_H */
|
||||
|
|
|
@ -370,9 +370,10 @@ void LoadWin32Font(FontSize fs)
|
|||
{
|
||||
FontCacheSubSetting *settings = GetFontCacheSubSetting(fs);
|
||||
|
||||
if (settings->font.empty()) return;
|
||||
std::string font = GetFontCacheFontName(fs);
|
||||
if (font.empty()) return;
|
||||
|
||||
const char *font_name = settings->font.c_str();
|
||||
const char *font_name = font.c_str();
|
||||
LOGFONT logfont;
|
||||
MemSetT(&logfont, 0);
|
||||
logfont.lfPitchAndFamily = fs == FS_MONO ? FIXED_PITCH : VARIABLE_PITCH;
|
||||
|
@ -384,8 +385,8 @@ void LoadWin32Font(FontSize fs)
|
|||
logfont = *(const LOGFONT *)settings->os_handle;
|
||||
} else if (strchr(font_name, '.') != nullptr) {
|
||||
/* Might be a font file name, try load it. */
|
||||
if (!TryLoadFontFromFile(settings->font, logfont)) {
|
||||
ShowInfo("Unable to load file '{}' for {} font, using default windows font selection instead", font_name, FontSizeToName(fs));
|
||||
if (!TryLoadFontFromFile(font, logfont)) {
|
||||
ShowInfo("Unable to load file '{}' for {} font, using default windows font selection instead", font, FontSizeToName(fs));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -396,23 +397,3 @@ void LoadWin32Font(FontSize fs)
|
|||
|
||||
LoadWin32Font(fs, logfont, settings->size, font_name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a TrueType font from a file.
|
||||
* @param fs The font size to load.
|
||||
* @param file_name Path to the font file.
|
||||
* @param size Requested font size.
|
||||
*/
|
||||
void LoadWin32Font(FontSize fs, const std::string &file_name, uint size)
|
||||
{
|
||||
LOGFONT logfont;
|
||||
MemSetT(&logfont, 0);
|
||||
logfont.lfPitchAndFamily = fs == FS_MONO ? FIXED_PITCH : VARIABLE_PITCH;
|
||||
logfont.lfCharSet = DEFAULT_CHARSET;
|
||||
logfont.lfOutPrecision = OUT_OUTLINE_PRECIS;
|
||||
logfont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
|
||||
|
||||
if (TryLoadFontFromFile(file_name, logfont)) {
|
||||
LoadWin32Font(fs, logfont, size, file_name.c_str());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,6 +41,5 @@ public:
|
|||
};
|
||||
|
||||
void LoadWin32Font(FontSize fs);
|
||||
void LoadWin32Font(FontSize fs, const std::string &file_name, uint size);
|
||||
|
||||
#endif /* FONT_WIN32_H */
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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(¤t->path)) {
|
||||
if (this->EndNodeCheck(this, current) == AYSTAR_FOUND_END_NODE && (¤t->path)->parent != nullptr) {
|
||||
if (this->FoundEndNode != nullptr) {
|
||||
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
|
||||
|
||||
#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;
|
||||
|
|
|
@ -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. */
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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"),
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
};
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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. */
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue