Merge branch 'master' into jgrpp

# Conflicts:
#	src/cargopacket.h
#	src/cargotype.h
#	src/station_base.h
#	src/station_cmd.cpp
#	src/timer/timer_game_common.h
#	src/town.h
This commit is contained in:
Jonathan G Rennison
2024-06-13 20:38:38 +01:00
22 changed files with 107 additions and 117 deletions

View File

@@ -29,7 +29,7 @@ open most older savegames or use the content downloading system.
## Windows ## Windows
You need Microsoft Visual Studio 2017 or more recent. You need Microsoft Visual Studio 2022 or more recent.
You can download the free Visual Studio Community Edition from Microsoft at You can download the free Visual Studio Community Edition from Microsoft at
https://visualstudio.microsoft.com/vs/community/. https://visualstudio.microsoft.com/vs/community/.
@@ -65,7 +65,7 @@ To install both the x64 (64bit) and x86 (32bit) variants (though only one is nec
You can open the folder (as a CMake project). CMake will be detected, and you can compile from there. You can open the folder (as a CMake project). CMake will be detected, and you can compile from there.
If libraries are installed but not found, you need to set VCPKG_TARGET_TRIPLET in CMake parameters. If libraries are installed but not found, you need to set VCPKG_TARGET_TRIPLET in CMake parameters.
For Visual Studio 2017 you also need to set CMAKE_TOOLCHAIN_FILE. For Visual Studio 2022 you also need to set CMAKE_TOOLCHAIN_FILE.
(Typical values are shown in the MSVC project file command line example) (Typical values are shown in the MSVC project file command line example)
Alternatively, you can create a MSVC project file via CMake. For this Alternatively, you can create a MSVC project file via CMake. For this
@@ -75,7 +75,7 @@ that comes with vcpkg. After that, you can run something similar to this:
```powershell ```powershell
mkdir build mkdir build
cd build cd build
cmake.exe .. -G"Visual Studio 16 2019" -DCMAKE_TOOLCHAIN_FILE="<location of vcpkg>\vcpkg\scripts\buildsystems\vcpkg.cmake" -DVCPKG_TARGET_TRIPLET="x64-windows-static" cmake.exe .. -G"Visual Studio 17 2022" -DCMAKE_TOOLCHAIN_FILE="<location of vcpkg>\vcpkg\scripts\buildsystems\vcpkg.cmake" -DVCPKG_TARGET_TRIPLET="x64-windows-static"
``` ```
Change `<location of vcpkg>` to where you have installed vcpkg. After this Change `<location of vcpkg>` to where you have installed vcpkg. After this
@@ -83,7 +83,7 @@ in the build folder are MSVC project files. MSVC can rebuild the project
files himself via the `ZERO_CHECK` project. files himself via the `ZERO_CHECK` project.
## All other platforms ## All other platforms
Minimum required version of CMake is 3.9. Minimum required version of CMake is 3.16.
By default this produces a Debug build with assertations enabled. By default this produces a Debug build with assertations enabled.
This is a far slower build than release builds. This is a far slower build than release builds.
@@ -115,9 +115,9 @@ builds.
## Supported compilers ## Supported compilers
Every compiler that is supported by CMake and supports C++17, should be Every compiler that is supported by CMake and supports C++20, should be
able to compile OpenTTD. As the exact list of compilers changes constantly, able to compile OpenTTD. As the exact list of compilers changes constantly,
we refer to the compiler manual to see if it supports C++17, and to CMake we refer to the compiler manual to see if it supports C++20, and to CMake
to see if it supports your compiler. to see if it supports your compiler.
## Compilation of base sets ## Compilation of base sets

View File

@@ -290,10 +290,10 @@ public:
# include "video/video_driver.hpp" # include "video/video_driver.hpp"
class BootstrapEmscripten : public ContentCallback { class BootstrapEmscripten : public ContentCallback {
bool downloading{false}; bool downloading = false;
uint total_files{0}; uint total_files = 0;
uint total_bytes{0}; uint total_bytes = 0;
uint downloaded_bytes{0}; uint downloaded_bytes = 0;
public: public:
BootstrapEmscripten() BootstrapEmscripten()

View File

@@ -1658,7 +1658,7 @@ struct BuildVehicleWindow : BuildVehicleWindowBase {
/* Select the first unshaded engine in the list as default when opening the window */ /* Select the first unshaded engine in the list as default when opening the window */
EngineID engine = INVALID_ENGINE; EngineID engine = INVALID_ENGINE;
auto it = std::find_if(this->eng_list.begin(), this->eng_list.end(), [&](GUIEngineListItem &item){ return (item.flags & EngineDisplayFlags::Shaded) == EngineDisplayFlags::None; }); auto it = std::find_if(this->eng_list.begin(), this->eng_list.end(), [&](GUIEngineListItem &item) { return (item.flags & EngineDisplayFlags::Shaded) == EngineDisplayFlags::None; });
if (it != this->eng_list.end()) engine = it->engine_id; if (it != this->eng_list.end()) engine = it->engine_id;
this->SelectEngine(engine); this->SelectEngine(engine);
} }

View File

@@ -67,21 +67,21 @@ static const uint TOWN_PRODUCTION_DIVISOR = 256;
/** Specification of a cargo type. */ /** Specification of a cargo type. */
struct CargoSpec { struct CargoSpec {
CargoLabel label; ///< Unique label of the cargo type. CargoLabel label; ///< Unique label of the cargo type.
uint8_t bitnum{INVALID_CARGO_BITNUM}; ///< Cargo bit number, is #INVALID_CARGO_BITNUM for a non-used spec. uint8_t bitnum = INVALID_CARGO_BITNUM; ///< Cargo bit number, is #INVALID_CARGO_BITNUM for a non-used spec.
uint8_t legend_colour; uint8_t legend_colour;
uint8_t rating_colour; uint8_t rating_colour;
uint8_t weight; ///< Weight of a single unit of this cargo type in 1/16 ton (62.5 kg). uint8_t weight; ///< Weight of a single unit of this cargo type in 1/16 ton (62.5 kg).
uint16_t multiplier{0x100}; ///< Capacity multiplier for vehicles. (8 fractional bits) uint16_t multiplier = 0x100; ///< Capacity multiplier for vehicles. (8 fractional bits)
uint16_t classes; ///< Classes of this cargo type. @see CargoClass uint16_t classes; ///< Classes of this cargo type. @see CargoClass
int32_t initial_payment; ///< Initial payment rate before inflation is applied. int32_t initial_payment; ///< Initial payment rate before inflation is applied.
uint8_t transit_periods[2]; uint8_t transit_periods[2];
bool is_freight; ///< Cargo type is considered to be freight (affects train freight multiplier). bool is_freight; ///< Cargo type is considered to be freight (affects train freight multiplier).
TownAcceptanceEffect town_acceptance_effect; ///< The effect that delivering this cargo type has on towns. Also affects destination of subsidies. TownAcceptanceEffect town_acceptance_effect; ///< The effect that delivering this cargo type has on towns. Also affects destination of subsidies.
TownProductionEffect town_production_effect{INVALID_TPE}; ///< The effect on town cargo production. TownProductionEffect town_production_effect = INVALID_TPE; ///< The effect on town cargo production.
uint16_t town_production_multiplier{TOWN_PRODUCTION_DIVISOR}; ///< Town production multipler, if commanded by TownProductionEffect. uint16_t town_production_multiplier = TOWN_PRODUCTION_DIVISOR; ///< Town production multipler, if commanded by TownProductionEffect.
uint8_t callback_mask; ///< Bitmask of cargo callbacks that have to be called uint8_t callback_mask; ///< Bitmask of cargo callbacks that have to be called
StringID name; ///< Name of this type of cargo. StringID name; ///< Name of this type of cargo.
StringID name_single; ///< Name of a single entity of this type of cargo. StringID name_single; ///< Name of a single entity of this type of cargo.

View File

@@ -2440,10 +2440,10 @@ DEF_CONSOLE_CMD(ConFont)
IConsolePrint(CC_HELP, " Print out the fonts configuration."); IConsolePrint(CC_HELP, " Print out the fonts configuration.");
IConsolePrint(CC_HELP, " The \"Currently active\" configuration is the one actually in effect (after interface scaling and replacing unavailable fonts)."); IConsolePrint(CC_HELP, " The \"Currently active\" configuration is the one actually in effect (after interface scaling and replacing unavailable fonts).");
IConsolePrint(CC_HELP, " The \"Requested\" configuration is the one requested via console command or config file."); IConsolePrint(CC_HELP, " The \"Requested\" configuration is the one requested via console command or config file.");
IConsolePrint(CC_HELP, "Usage 'font [medium|small|large|mono] [<font name>] [<size>] [aa|noaa]'."); IConsolePrint(CC_HELP, "Usage 'font [medium|small|large|mono] [<font name>] [<size>]'.");
IConsolePrint(CC_HELP, " Change the configuration for a font."); IConsolePrint(CC_HELP, " Change the configuration for a font.");
IConsolePrint(CC_HELP, " Omitting an argument will keep the current value."); IConsolePrint(CC_HELP, " Omitting an argument will keep the current value.");
IConsolePrint(CC_HELP, " Set <font name> to \"\" for the default font. Note that <size> and aa/noaa have no effect if the default font is in use, and fixed defaults are used instead."); IConsolePrint(CC_HELP, " Set <font name> to \"\" for the default font. Note that <size> has no effect if the default font is in use, and fixed defaults are used instead.");
IConsolePrint(CC_HELP, " If the sprite font is enabled in Game Options, it is used instead of the default font."); IConsolePrint(CC_HELP, " If the sprite font is enabled in Game Options, it is used instead of the default font.");
IConsolePrint(CC_HELP, " The <size> is automatically multiplied by the current interface scaling."); IConsolePrint(CC_HELP, " The <size> is automatically multiplied by the current interface scaling.");
return true; return true;
@@ -2461,38 +2461,23 @@ DEF_CONSOLE_CMD(ConFont)
FontCacheSubSetting *setting = GetFontCacheSubSetting(argfs); FontCacheSubSetting *setting = GetFontCacheSubSetting(argfs);
std::string font = setting->font; std::string font = setting->font;
uint size = setting->size; uint size = setting->size;
bool aa = setting->aa; uint v;
uint8_t arg_index = 2; uint8_t arg_index = 2;
/* We may encounter "aa" or "noaa" but it must be the last argument. */ /* For <name> we want a string. */
if (StrEqualsIgnoreCase(argv[arg_index], "aa") || StrEqualsIgnoreCase(argv[arg_index], "noaa")) {
aa = !StrStartsWithIgnoreCase(argv[arg_index++], "no"); if (!GetArgumentInteger(&v, argv[arg_index])) {
if (argc > arg_index) return false; font = argv[arg_index++];
} else {
/* For <name> we want a string. */
uint v;
if (!GetArgumentInteger(&v, argv[arg_index])) {
font = argv[arg_index++];
}
} }
if (argc > arg_index) { if (argc > arg_index) {
/* For <size> we want a number. */ /* For <size> we want a number. */
uint v;
if (GetArgumentInteger(&v, argv[arg_index])) { if (GetArgumentInteger(&v, argv[arg_index])) {
size = v; size = v;
arg_index++; arg_index++;
} }
} }
if (argc > arg_index) { SetFont(argfs, font, size);
/* Last argument must be "aa" or "noaa". */
if (!StrEqualsIgnoreCase(argv[arg_index], "aa") && !StrEqualsIgnoreCase(argv[arg_index], "noaa")) return false;
aa = !StrStartsWithIgnoreCase(argv[arg_index++], "no");
if (argc > arg_index) return false;
}
SetFont(argfs, font, size, aa);
} }
for (FontSize fs = FS_BEGIN; fs < FS_END; fs++) { for (FontSize fs = FS_BEGIN; fs < FS_END; fs++) {
@@ -2504,8 +2489,8 @@ DEF_CONSOLE_CMD(ConFont)
fc = FontCache::Get(fs); fc = FontCache::Get(fs);
} }
IConsolePrint(CC_DEFAULT, "{} font:", FontSizeToName(fs)); IConsolePrint(CC_DEFAULT, "{} font:", FontSizeToName(fs));
IConsolePrint(CC_DEFAULT, "Currently active: \"{}\", size {}, {}", fc->GetFontName(), fc->GetFontSize(), GetFontAAState(fs) ? "aa" : "noaa"); IConsolePrint(CC_DEFAULT, "Currently active: \"{}\", size {}", fc->GetFontName(), fc->GetFontSize());
IConsolePrint(CC_DEFAULT, "Requested: \"{}\", size {}, {}", setting->font, setting->size, setting->aa ? "aa" : "noaa"); IConsolePrint(CC_DEFAULT, "Requested: \"{}\", size {}", setting->font, setting->size);
} }
FontChanged(); FontChanged();

View File

@@ -74,15 +74,15 @@ void UpdateFontHeightCache()
} }
/* Check if a glyph should be rendered with anti-aliasing. */ /* Check if a glyph should be rendered with anti-aliasing. */
bool GetFontAAState(FontSize size, bool check_blitter) bool GetFontAAState()
{ {
/* AA is only supported for 32 bpp */ /* AA is only supported for 32 bpp */
if (check_blitter && BlitterFactory::GetCurrentBlitter()->GetScreenDepth() != 32) return false; if (BlitterFactory::GetCurrentBlitter()->GetScreenDepth() != 32) return false;
return _fcsettings.global_aa || GetFontCacheSubSetting(size)->aa; return _fcsettings.global_aa;
} }
void SetFont(FontSize fontsize, const std::string &font, uint size, bool aa) void SetFont(FontSize fontsize, const std::string &font, uint size)
{ {
FontCacheSubSetting *setting = GetFontCacheSubSetting(fontsize); FontCacheSubSetting *setting = GetFontCacheSubSetting(fontsize);
bool changed = false; bool changed = false;
@@ -97,11 +97,6 @@ void SetFont(FontSize fontsize, const std::string &font, uint size, bool aa)
changed = true; changed = true;
} }
if (setting->aa != aa) {
setting->aa = aa;
changed = true;
}
if (!changed) return; if (!changed) return;
if (fontsize != FS_MONO) { if (fontsize != FS_MONO) {
@@ -216,19 +211,6 @@ void UninitFontCache()
#endif /* WITH_FREETYPE */ #endif /* WITH_FREETYPE */
} }
/**
* Should any of the active fonts be anti-aliased?
* @return True if any of the loaded fonts want anti-aliased drawing.
*/
bool HasAntialiasedFonts()
{
for (FontSize fs = FS_BEGIN; fs < FS_END; fs++) {
if (!FontCache::Get(fs)->IsBuiltInFont() && GetFontAAState(fs, false)) return true;
}
return false;
}
#if !defined(_WIN32) && !defined(__APPLE__) && !defined(WITH_FONTCONFIG) && !defined(WITH_COCOA) #if !defined(_WIN32) && !defined(__APPLE__) && !defined(WITH_FONTCONFIG) && !defined(WITH_COCOA)
bool SetFallbackFont(FontCacheSettings *, const std::string &, int, MissingGlyphSearcher *) { return false; } bool SetFallbackFont(FontCacheSettings *, const std::string &, int, MissingGlyphSearcher *) { return false; }

View File

@@ -211,7 +211,6 @@ inline bool GetDrawGlyphShadow(FontSize size)
struct FontCacheSubSetting { struct FontCacheSubSetting {
std::string font; ///< The name of the font, or path to the font. std::string font; ///< The name of the font, or path to the font.
uint size; ///< The (requested) size of the font. uint size; ///< The (requested) size of the font.
bool aa; ///< Whether to do anti aliasing or not.
const void *os_handle = nullptr; ///< Optional native OS font info. Only valid during font search. const void *os_handle = nullptr; ///< Optional native OS font info. Only valid during font search.
}; };
@@ -246,9 +245,8 @@ inline FontCacheSubSetting *GetFontCacheSubSetting(FontSize fs)
void InitFontCache(bool monospace); void InitFontCache(bool monospace);
void UninitFontCache(); void UninitFontCache();
bool HasAntialiasedFonts();
bool GetFontAAState(FontSize size, bool check_blitter = true); bool GetFontAAState();
void SetFont(FontSize fontsize, const std::string &font, uint size, bool aa); void SetFont(FontSize fontsize, const std::string &font, uint size);
#endif /* FONTCACHE_H */ #endif /* FONTCACHE_H */

View File

@@ -91,7 +91,7 @@ void TrueTypeFontCache::SetGlyphPtr(GlyphID key, const GlyphEntry *glyph, bool d
bool TrueTypeFontCache::GetDrawGlyphShadow() bool TrueTypeFontCache::GetDrawGlyphShadow()
{ {
return this->fs == FS_NORMAL && GetFontAAState(FS_NORMAL); return this->fs == FS_NORMAL && GetFontAAState();
} }
uint TrueTypeFontCache::GetGlyphWidth(GlyphID key) uint TrueTypeFontCache::GetGlyphWidth(GlyphID key)
@@ -162,7 +162,7 @@ const Sprite *TrueTypeFontCache::GetGlyph(GlyphID key)
} }
} }
return this->InternalGetGlyph(key, GetFontAAState(this->fs)); return this->InternalGetGlyph(key, GetFontAAState());
} }
const void *TrueTypeFontCache::GetFontTable(uint32_t tag, size_t &length) const void *TrueTypeFontCache::GetFontTable(uint32_t tag, size_t &length)

View File

@@ -115,6 +115,10 @@ static void _GenerateWorld()
IncreaseGeneratingWorldProgress(GWP_MAP_INIT); IncreaseGeneratingWorldProgress(GWP_MAP_INIT);
/* Must start economy early because of the costs. */ /* Must start economy early because of the costs. */
StartupEconomy(); StartupEconomy();
if (!CheckTownRoadTypes()) {
HandleGeneratingWorldAbortion();
return;
}
bool landscape_generated = false; bool landscape_generated = false;

View File

@@ -151,7 +151,7 @@ void ICURun::Shape(UChar *buff, size_t buff_length)
{ {
auto hbfont = hb_ft_font_create_referenced(*(static_cast<const FT_Face *>(font->fc->GetOSHandle()))); auto hbfont = hb_ft_font_create_referenced(*(static_cast<const FT_Face *>(font->fc->GetOSHandle())));
/* Match the flags with how we render the glyphs. */ /* Match the flags with how we render the glyphs. */
hb_ft_font_set_load_flags(hbfont, GetFontAAState(this->font->fc->GetSize()) ? FT_LOAD_TARGET_NORMAL : FT_LOAD_TARGET_MONO); hb_ft_font_set_load_flags(hbfont, GetFontAAState() ? FT_LOAD_TARGET_NORMAL : FT_LOAD_TARGET_MONO);
/* ICU buffer is in UTF-16. */ /* ICU buffer is in UTF-16. */
auto hbbuf = hb_buffer_create(); auto hbbuf = hb_buffer_create();

View File

@@ -325,7 +325,7 @@ static bool SwitchNewGRFBlitter()
if (c->palette & GRFP_BLT_32BPP) depth_wanted_by_grf = 32; if (c->palette & GRFP_BLT_32BPP) depth_wanted_by_grf = 32;
} }
/* We need a 32bpp blitter for font anti-alias. */ /* We need a 32bpp blitter for font anti-alias. */
if (HasAntialiasedFonts()) depth_wanted_by_grf = 32; if (GetFontAAState()) depth_wanted_by_grf = 32;
/* Search the best blitter. */ /* Search the best blitter. */
static const struct { static const struct {

View File

@@ -446,7 +446,7 @@ STR_SETTINGS_MENU_CONFIG_SETTINGS_TREE :Configurações
STR_SETTINGS_MENU_AI_SETTINGS :Configurações de IA STR_SETTINGS_MENU_AI_SETTINGS :Configurações de IA
STR_SETTINGS_MENU_GAMESCRIPT_SETTINGS :Configurações de Script de Jogo STR_SETTINGS_MENU_GAMESCRIPT_SETTINGS :Configurações de Script de Jogo
STR_SETTINGS_MENU_NEWGRF_SETTINGS :Configurações de NewGRF STR_SETTINGS_MENU_NEWGRF_SETTINGS :Configurações de NewGRF
STR_SETTINGS_MENU_SANDBOX_OPTIONS :Opções de trapaças STR_SETTINGS_MENU_SANDBOX_OPTIONS :Opções da sandbox
STR_SETTINGS_MENU_TRANSPARENCY_OPTIONS :Opções de transparência STR_SETTINGS_MENU_TRANSPARENCY_OPTIONS :Opções de transparência
STR_SETTINGS_MENU_TOWN_NAMES_DISPLAYED :Mostrar nomes de localidades STR_SETTINGS_MENU_TOWN_NAMES_DISPLAYED :Mostrar nomes de localidades
STR_SETTINGS_MENU_STATION_NAMES_DISPLAYED :Mostrar nomes de estações STR_SETTINGS_MENU_STATION_NAMES_DISPLAYED :Mostrar nomes de estações
@@ -2242,7 +2242,7 @@ STR_HELP_WINDOW_BUGTRACKER :{BLACK}Relatar
STR_HELP_WINDOW_COMMUNITY :{BLACK}Comunidade STR_HELP_WINDOW_COMMUNITY :{BLACK}Comunidade
# Cheat window # Cheat window
STR_CHEATS :{WHITE}Trapaças STR_CHEATS :{WHITE}Opções da Sandbox
STR_CHEAT_MONEY :{LTBLUE}Aumentar dinheiro em {CURRENCY_LONG} STR_CHEAT_MONEY :{LTBLUE}Aumentar dinheiro em {CURRENCY_LONG}
STR_CHEAT_CHANGE_COMPANY :{LTBLUE}Jogando como empresa: {ORANGE}{COMMA} STR_CHEAT_CHANGE_COMPANY :{LTBLUE}Jogando como empresa: {ORANGE}{COMMA}
STR_CHEAT_EXTRA_DYNAMITE :{LTBLUE}Escavadeira mágica (remove indústrias, objetos estáticos): {ORANGE}{STRING} STR_CHEAT_EXTRA_DYNAMITE :{LTBLUE}Escavadeira mágica (remove indústrias, objetos estáticos): {ORANGE}{STRING}

View File

@@ -5286,6 +5286,11 @@ STR_ERROR_NO_VEHICLES_AVAILABLE_AT_ALL_EXPLANATION :{WHITE}Change y
STR_ERROR_NO_VEHICLES_AVAILABLE_YET :{WHITE}No vehicles are available yet STR_ERROR_NO_VEHICLES_AVAILABLE_YET :{WHITE}No vehicles are available yet
STR_ERROR_NO_VEHICLES_AVAILABLE_YET_EXPLANATION :{WHITE}Start a new game after {DATE_SHORT} or use a NewGRF that provides early vehicles STR_ERROR_NO_VEHICLES_AVAILABLE_YET_EXPLANATION :{WHITE}Start a new game after {DATE_SHORT} or use a NewGRF that provides early vehicles
STR_ERROR_NO_TOWN_ROADTYPES_AVAILABLE_AT_ALL :{WHITE}No town-buildable road types are available
STR_ERROR_NO_TOWN_ROADTYPES_AVAILABLE_AT_ALL_EXPLANATION :{WHITE}Change your NewGRF configuration
STR_ERROR_NO_TOWN_ROADTYPES_AVAILABLE_YET :{WHITE}No town-buildable road types are available yet
STR_ERROR_NO_TOWN_ROADTYPES_AVAILABLE_YET_EXPLANATION :{WHITE}Start a new game after {DATE_SHORT} or use a NewGRF that provides early town-buildable road types
# Specific vehicle errors # Specific vehicle errors
STR_ERROR_CAN_T_MAKE_TRAIN_PASS_SIGNAL :{WHITE}Can't make train pass signal at danger... STR_ERROR_CAN_T_MAKE_TRAIN_PASS_SIGNAL :{WHITE}Can't make train pass signal at danger...
STR_ERROR_CAN_T_REVERSE_DIRECTION_TRAIN :{WHITE}Can't reverse direction of train... STR_ERROR_CAN_T_REVERSE_DIRECTION_TRAIN :{WHITE}Can't reverse direction of train...

View File

@@ -137,7 +137,7 @@ struct TemporaryStorageArray {
StorageType storage{}; ///< Memory for the storage array StorageType storage{}; ///< Memory for the storage array
StorageInitType init{}; ///< Storage has been assigned, if this equals 'init_key'. StorageInitType init{}; ///< Storage has been assigned, if this equals 'init_key'.
uint16_t init_key{1}; ///< Magic key to 'init'. uint16_t init_key = 1; ///< Magic key to 'init'.
/** /**
* Stores some value at a given position. * Stores some value at a given position.

View File

@@ -27,7 +27,7 @@ static std::vector<StringID> _grf_townname_names;
GRFTownName *GetGRFTownName(uint32_t grfid) GRFTownName *GetGRFTownName(uint32_t grfid)
{ {
auto found = std::find_if(std::begin(_grf_townnames), std::end(_grf_townnames), [&grfid](const GRFTownName &t){ return t.grfid == grfid; }); auto found = std::find_if(std::begin(_grf_townnames), std::end(_grf_townnames), [&grfid](const GRFTownName &t) { return t.grfid == grfid; });
if (found != std::end(_grf_townnames)) return &*found; if (found != std::end(_grf_townnames)) return &*found;
return nullptr; return nullptr;
} }
@@ -44,7 +44,7 @@ GRFTownName *AddGRFTownName(uint32_t grfid)
void DelGRFTownName(uint32_t grfid) void DelGRFTownName(uint32_t grfid)
{ {
_grf_townnames.erase(std::find_if(std::begin(_grf_townnames), std::end(_grf_townnames), [&grfid](const GRFTownName &t){ return t.grfid == grfid; })); _grf_townnames.erase(std::find_if(std::begin(_grf_townnames), std::end(_grf_townnames), [&grfid](const GRFTownName &t) { return t.grfid == grfid; }));
} }
static void RandomPart(StringBuilder builder, const GRFTownName *t, uint32_t seed, uint8_t id) static void RandomPart(StringBuilder builder, const GRFTownName *t, uint32_t seed, uint8_t id)

View File

@@ -2759,7 +2759,7 @@ static void SetDefaultRailGui()
case 0: { case 0: {
/* Use first available type */ /* Use first available type */
std::vector<RailType>::const_iterator it = std::find_if(_sorted_railtypes.begin(), _sorted_railtypes.end(), std::vector<RailType>::const_iterator it = std::find_if(_sorted_railtypes.begin(), _sorted_railtypes.end(),
[](RailType r){ return HasRailTypeAvail(_local_company, r); }); [](RailType r) { return HasRailTypeAvail(_local_company, r); });
rt = it != _sorted_railtypes.end() ? *it : RAILTYPE_BEGIN; rt = it != _sorted_railtypes.end() ? *it : RAILTYPE_BEGIN;
break; break;
} }

View File

@@ -1144,7 +1144,7 @@ CommandCost CheckFlatLandRoadStop(TileArea tile_area, const RoadStopSpec *spec,
return ClearTile_Station(cur_tile, DC_AUTO); // Get error message. return ClearTile_Station(cur_tile, DC_AUTO); // Get error message.
} }
/* Drive-through station in the wrong direction. */ /* Drive-through station in the wrong direction. */
if (is_drive_through && IsDriveThroughStopTile(cur_tile) && DiagDirToAxis(GetRoadStopDir(cur_tile)) != axis){ if (is_drive_through && IsDriveThroughStopTile(cur_tile) && DiagDirToAxis(GetRoadStopDir(cur_tile)) != axis) {
return_cmd_error(STR_ERROR_DRIVE_THROUGH_DIRECTION); return_cmd_error(STR_ERROR_DRIVE_THROUGH_DIRECTION);
} }
StationID st = GetStationIndex(cur_tile); StationID st = GetStationIndex(cur_tile);

View File

@@ -247,30 +247,6 @@ def = 0
min = 0 min = 0
max = 72 max = 72
[SDTG_BOOL]
ifdef = HAS_TRUETYPE_FONT
name = ""small_aa""
var = _fcsettings.small.aa
def = false
[SDTG_BOOL]
ifdef = HAS_TRUETYPE_FONT
name = ""medium_aa""
var = _fcsettings.medium.aa
def = false
[SDTG_BOOL]
ifdef = HAS_TRUETYPE_FONT
name = ""large_aa""
var = _fcsettings.large.aa
def = false
[SDTG_BOOL]
ifdef = HAS_TRUETYPE_FONT
name = ""mono_aa""
var = _fcsettings.mono.aa
def = false
[SDTG_BOOL] [SDTG_BOOL]
ifdef = HAS_TRUETYPE_FONT ifdef = HAS_TRUETYPE_FONT
name = ""global_aa"" name = ""global_aa""

View File

@@ -56,10 +56,10 @@ protected:
void ConstructWindow(); void ConstructWindow();
struct Line { struct Line {
int top{0}; ///< Top scroll position in visual lines. int top = 0; ///< Top scroll position in visual lines.
int bottom{0}; ///< Bottom scroll position in visual lines. int bottom = 0; ///< Bottom scroll position in visual lines.
std::string text{}; ///< Contents of the line. std::string text{}; ///< Contents of the line.
TextColour colour{TC_WHITE}; ///< Colour to render text line in. TextColour colour = TC_WHITE; ///< Colour to render text line in.
Line(int top, std::string_view text) : top(top), bottom(top + 1), text(text) {} Line(int top, std::string_view text) : top(top), bottom(top + 1), text(text) {}
Line() {} Line() {}
@@ -85,8 +85,8 @@ protected:
std::vector<Hyperlink> links; ///< Clickable links in lines. std::vector<Hyperlink> links; ///< Clickable links in lines.
std::vector<Hyperlink> link_anchors; ///< Anchor names of headings that can be linked to. std::vector<Hyperlink> link_anchors; ///< Anchor names of headings that can be linked to.
std::vector<HistoryEntry> history; ///< Browsing history in this window. std::vector<HistoryEntry> history; ///< Browsing history in this window.
size_t history_pos{0}; ///< Position in browsing history (for forward movement). size_t history_pos = 0; ///< Position in browsing history (for forward movement).
bool trusted{false}; ///< Whether the content is trusted (read: not from content like NewGRFs, etc). bool trusted = false; ///< Whether the content is trusted (read: not from content like NewGRFs, etc).
void LoadText(std::string_view buf); void LoadText(std::string_view buf);
void FindHyperlinksInMarkdown(Line &line, size_t line_index); void FindHyperlinksInMarkdown(Line &line, size_t line_index);
@@ -109,8 +109,8 @@ protected:
void NavigateHistory(int delta); void NavigateHistory(int delta);
private: private:
uint search_iterator{0}; ///< Iterator for the font check search. uint search_iterator = 0; ///< Iterator for the font check search.
uint max_length{0}; ///< Maximum length of unwrapped text line. uint max_length = 0; ///< Maximum length of unwrapped text line.
uint ReflowContent(); uint ReflowContent();
uint GetContentHeight(); uint GetContentHeight();

View File

@@ -446,7 +446,7 @@ static int *HeightMapMakeHistogram(Height h_min, [[maybe_unused]] Height h_max,
int *hist = hist_buf - h_min; int *hist = hist_buf - h_min;
/* Count the heights and fill the histogram */ /* Count the heights and fill the histogram */
for (const Height &h : _height_map.h){ for (const Height &h : _height_map.h) {
assert(h >= h_min); assert(h >= h_min);
assert(h <= h_max); assert(h <= h_max);
hist[h]++; hist[h]++;

View File

@@ -382,6 +382,7 @@ inline uint16_t TownTicksToGameTicks(uint16_t ticks)
RoadType GetTownRoadType(); RoadType GetTownRoadType();
bool CheckTownRoadTypes();
bool MayTownModifyRoad(TileIndex tile); bool MayTownModifyRoad(TileIndex tile);
#endif /* TOWN_H */ #endif /* TOWN_H */

View File

@@ -1088,6 +1088,45 @@ bool MayTownModifyRoad(TileIndex tile)
return true; return true;
} }
/**
* Get the calendar date of the earliest town-buildable road type.
* @return introduction date of earliest road type, or INT32_MAX if none available.
*/
static CalTime::Date GetTownRoadTypeFirstIntroductionDate()
{
const RoadTypeInfo *best = nullptr;
for (RoadType rt = ROADTYPE_BEGIN; rt != ROADTYPE_END; rt++) {
if (RoadTypeIsTram(rt)) continue;
const RoadTypeInfo *rti = GetRoadTypeInfo(rt);
if (rti->label == 0) continue; // Unused road type.
if (!HasBit(rti->flags, ROTF_TOWN_BUILD)) continue; // Town can't build this road type.
if (best != nullptr && rti->introduction_date >= best->introduction_date) continue;
best = rti;
}
if (best == nullptr) return INT32_MAX;
return best->introduction_date;
}
/**
* Check if towns are able to build road.
* @return true iff the towns are currently able to build road.
*/
bool CheckTownRoadTypes()
{
auto min_date = GetTownRoadTypeFirstIntroductionDate();
if (min_date <= CalTime::CurDate()) return true;
if (min_date < INT32_MAX) {
SetDParam(0, min_date);
ShowErrorMessage(STR_ERROR_NO_TOWN_ROADTYPES_AVAILABLE_YET, STR_ERROR_NO_TOWN_ROADTYPES_AVAILABLE_YET_EXPLANATION, WL_CRITICAL);
} else {
ShowErrorMessage(STR_ERROR_NO_TOWN_ROADTYPES_AVAILABLE_AT_ALL, STR_ERROR_NO_TOWN_ROADTYPES_AVAILABLE_AT_ALL_EXPLANATION, WL_CRITICAL);
}
return false;
}
/** /**
* Check for parallel road inside a given distance. * Check for parallel road inside a given distance.
* Assuming a road from (tile - TileOffsByDiagDir(dir)) to tile, * Assuming a road from (tile - TileOffsByDiagDir(dir)) to tile,