From 727392e0b3e30a42c70a60841fa21352be859819 Mon Sep 17 00:00:00 2001 From: ladysadie <144490006+ladysadie@users.noreply.github.com> Date: Mon, 15 Apr 2024 12:44:33 -0700 Subject: [PATCH 1/6] Codechange: Remove per font AA settings. (#12413) OpenTTD will use the global AA font setting for all fonts from now on. --- src/console_cmds.cpp | 35 ++++++++-------------------- src/fontcache.cpp | 26 ++++----------------- src/fontcache.h | 6 ++--- src/fontcache/truetypefontcache.cpp | 4 ++-- src/gfx_layout_icu.cpp | 2 +- src/gfxinit.cpp | 2 +- src/table/settings/misc_settings.ini | 24 ------------------- 7 files changed, 20 insertions(+), 79 deletions(-) diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index 1a7460ce43..62a8e18c6d 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -2181,10 +2181,10 @@ DEF_CONSOLE_CMD(ConFont) 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 \"Requested\" configuration is the one requested via console command or config file."); - IConsolePrint(CC_HELP, "Usage 'font [medium|small|large|mono] [] [] [aa|noaa]'."); + IConsolePrint(CC_HELP, "Usage 'font [medium|small|large|mono] [] []'."); IConsolePrint(CC_HELP, " Change the configuration for a font."); IConsolePrint(CC_HELP, " Omitting an argument will keep the current value."); - IConsolePrint(CC_HELP, " Set to \"\" for the default font. Note that and aa/noaa have no effect if the default font is in use, and fixed defaults are used instead."); + IConsolePrint(CC_HELP, " Set to \"\" for the default font. Note that 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, " The is automatically multiplied by the current interface scaling."); return true; @@ -2202,38 +2202,23 @@ DEF_CONSOLE_CMD(ConFont) FontCacheSubSetting *setting = GetFontCacheSubSetting(argfs); std::string font = setting->font; uint size = setting->size; - bool aa = setting->aa; - + uint v; uint8_t arg_index = 2; - /* We may encounter "aa" or "noaa" but it must be the last argument. */ - if (StrEqualsIgnoreCase(argv[arg_index], "aa") || StrEqualsIgnoreCase(argv[arg_index], "noaa")) { - aa = !StrStartsWithIgnoreCase(argv[arg_index++], "no"); - if (argc > arg_index) return false; - } else { - /* For we want a string. */ - uint v; - if (!GetArgumentInteger(&v, argv[arg_index])) { - font = argv[arg_index++]; - } + /* For we want a string. */ + + if (!GetArgumentInteger(&v, argv[arg_index])) { + font = argv[arg_index++]; } if (argc > arg_index) { /* For we want a number. */ - uint v; if (GetArgumentInteger(&v, argv[arg_index])) { size = v; arg_index++; } } - if (argc > arg_index) { - /* 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); + SetFont(argfs, font, size); } for (FontSize fs = FS_BEGIN; fs < FS_END; fs++) { @@ -2245,8 +2230,8 @@ DEF_CONSOLE_CMD(ConFont) fc = FontCache::Get(fs); } IConsolePrint(CC_DEFAULT, "{} font:", FontSizeToName(fs)); - IConsolePrint(CC_DEFAULT, "Currently active: \"{}\", size {}, {}", fc->GetFontName(), fc->GetFontSize(), GetFontAAState(fs) ? "aa" : "noaa"); - IConsolePrint(CC_DEFAULT, "Requested: \"{}\", size {}, {}", setting->font, setting->size, setting->aa ? "aa" : "noaa"); + IConsolePrint(CC_DEFAULT, "Currently active: \"{}\", size {}", fc->GetFontName(), fc->GetFontSize()); + IConsolePrint(CC_DEFAULT, "Requested: \"{}\", size {}", setting->font, setting->size); } return true; diff --git a/src/fontcache.cpp b/src/fontcache.cpp index 2a5772fc3b..1f01e9b327 100644 --- a/src/fontcache.cpp +++ b/src/fontcache.cpp @@ -91,15 +91,15 @@ int GetCharacterHeight(FontSize size) } /* 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 */ - 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); bool changed = false; @@ -114,11 +114,6 @@ void SetFont(FontSize fontsize, const std::string &font, uint size, bool aa) changed = true; } - if (setting->aa != aa) { - setting->aa = aa; - changed = true; - } - if (!changed) return; if (fontsize != FS_MONO) { @@ -233,19 +228,6 @@ void UninitFontCache() #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) bool SetFallbackFont(FontCacheSettings *, const std::string &, int, MissingGlyphSearcher *) { return false; } diff --git a/src/fontcache.h b/src/fontcache.h index 9ba6055504..fee0e26f3e 100644 --- a/src/fontcache.h +++ b/src/fontcache.h @@ -207,7 +207,6 @@ inline bool GetDrawGlyphShadow(FontSize size) struct FontCacheSubSetting { std::string font; ///< The name of the font, or path to 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. }; @@ -242,9 +241,8 @@ inline FontCacheSubSetting *GetFontCacheSubSetting(FontSize fs) void InitFontCache(bool monospace); void UninitFontCache(); -bool HasAntialiasedFonts(); -bool GetFontAAState(FontSize size, bool check_blitter = true); -void SetFont(FontSize fontsize, const std::string &font, uint size, bool aa); +bool GetFontAAState(); +void SetFont(FontSize fontsize, const std::string &font, uint size); #endif /* FONTCACHE_H */ diff --git a/src/fontcache/truetypefontcache.cpp b/src/fontcache/truetypefontcache.cpp index 196add775c..9e16c363c1 100644 --- a/src/fontcache/truetypefontcache.cpp +++ b/src/fontcache/truetypefontcache.cpp @@ -91,7 +91,7 @@ void TrueTypeFontCache::SetGlyphPtr(GlyphID key, const GlyphEntry *glyph, bool d bool TrueTypeFontCache::GetDrawGlyphShadow() { - return this->fs == FS_NORMAL && GetFontAAState(FS_NORMAL); + return this->fs == FS_NORMAL && GetFontAAState(); } 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) diff --git a/src/gfx_layout_icu.cpp b/src/gfx_layout_icu.cpp index e0008f2fa5..de9dae6c91 100644 --- a/src/gfx_layout_icu.cpp +++ b/src/gfx_layout_icu.cpp @@ -151,7 +151,7 @@ void ICURun::Shape(UChar *buff, size_t buff_length) { auto hbfont = hb_ft_font_create_referenced(*(static_cast(font->fc->GetOSHandle()))); /* 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. */ auto hbbuf = hb_buffer_create(); diff --git a/src/gfxinit.cpp b/src/gfxinit.cpp index 7971222ccf..62b69f2646 100644 --- a/src/gfxinit.cpp +++ b/src/gfxinit.cpp @@ -266,7 +266,7 @@ static bool SwitchNewGRFBlitter() if (c->palette & GRFP_BLT_32BPP) depth_wanted_by_grf = 32; } /* 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. */ static const struct { diff --git a/src/table/settings/misc_settings.ini b/src/table/settings/misc_settings.ini index 21fec3d5f3..e572d41773 100644 --- a/src/table/settings/misc_settings.ini +++ b/src/table/settings/misc_settings.ini @@ -237,30 +237,6 @@ def = 0 min = 0 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] ifdef = HAS_TRUETYPE_FONT name = ""global_aa"" From 672aa014d8e36ae3332621f1d8456a0f8f4a1d8d Mon Sep 17 00:00:00 2001 From: Koen Bussemaker Date: Mon, 15 Apr 2024 22:23:55 +0200 Subject: [PATCH 2/6] Doc: Updated Visual Studio, cpp standard and Cmake version --- COMPILING.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/COMPILING.md b/COMPILING.md index dfdcd4ead5..74e816253e 100644 --- a/COMPILING.md +++ b/COMPILING.md @@ -29,7 +29,7 @@ open most older savegames or use the content downloading system. ## 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 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. 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) 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 mkdir build cd build -cmake.exe .. -G"Visual Studio 16 2019" -DCMAKE_TOOLCHAIN_FILE="\vcpkg\scripts\buildsystems\vcpkg.cmake" -DVCPKG_TARGET_TRIPLET="x64-windows-static" +cmake.exe .. -G"Visual Studio 17 2022" -DCMAKE_TOOLCHAIN_FILE="\vcpkg\scripts\buildsystems\vcpkg.cmake" -DVCPKG_TARGET_TRIPLET="x64-windows-static" ``` Change `` 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. ## 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. This is a far slower build than release builds. @@ -115,9 +115,9 @@ builds. ## 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, -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. ## Compilation of base sets From 3ad143c43a7dce89060168a335557233471d7718 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Mon, 15 Apr 2024 23:07:36 +0100 Subject: [PATCH 3/6] Codechange: Use `x = y` instead of `x{y}` for value-type member initialisation. (#12501) This is easier to read and less likely to look like an array definition. --- src/bootstrap_gui.cpp | 8 ++++---- src/cargopacket.h | 18 +++++++++--------- src/cargotype.h | 8 ++++---- src/newgrf_storage.h | 2 +- src/station_base.h | 18 +++++++++--------- src/textfile_gui.h | 16 ++++++++-------- 6 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/bootstrap_gui.cpp b/src/bootstrap_gui.cpp index e2e0e37004..3f19c7fae0 100644 --- a/src/bootstrap_gui.cpp +++ b/src/bootstrap_gui.cpp @@ -291,10 +291,10 @@ public: # include "video/video_driver.hpp" class BootstrapEmscripten : public ContentCallback { - bool downloading{false}; - uint total_files{0}; - uint total_bytes{0}; - uint downloaded_bytes{0}; + bool downloading = false; + uint total_files = 0; + uint total_bytes = 0; + uint downloaded_bytes = 0; public: BootstrapEmscripten() diff --git a/src/cargopacket.h b/src/cargopacket.h index 6498760822..07ae8911d9 100644 --- a/src/cargopacket.h +++ b/src/cargopacket.h @@ -45,23 +45,23 @@ private: int16_t y; }; - uint16_t count{0}; ///< The amount of cargo in this packet. - uint16_t periods_in_transit{0}; ///< Amount of cargo aging periods this packet has been in transit. + uint16_t count = 0; ///< The amount of cargo in this packet. + uint16_t periods_in_transit = 0; ///< Amount of cargo aging periods this packet has been in transit. - Money feeder_share{0}; ///< Value of feeder pickup to be paid for on delivery of cargo. + Money feeder_share = 0; ///< Value of feeder pickup to be paid for on delivery of cargo. - TileIndex source_xy{INVALID_TILE}; ///< The origin of the cargo. + TileIndex source_xy = INVALID_TILE; ///< The origin of the cargo. Vector travelled{0, 0}; ///< If cargo is in station: the vector from the unload tile to the source tile. If in vehicle: an intermediate value. - SourceID source_id{INVALID_SOURCE}; ///< Index of industry/town/HQ, INVALID_SOURCE if unknown/invalid. - SourceType source_type{SourceType::Industry}; ///< Type of \c source_id. + SourceID source_id = INVALID_SOURCE; ///< Index of industry/town/HQ, INVALID_SOURCE if unknown/invalid. + SourceType source_type = SourceType::Industry; ///< Type of \c source_id. #ifdef WITH_ASSERT - bool in_vehicle{false}; ///< NOSAVE: Whether this cargo is in a vehicle or not. + bool in_vehicle = false; ///< NOSAVE: Whether this cargo is in a vehicle or not. #endif /* WITH_ASSERT */ - StationID first_station{INVALID_STATION}; ///< The station where the cargo came from first. - StationID next_hop{INVALID_STATION}; ///< Station where the cargo wants to go next. + StationID first_station = INVALID_STATION; ///< The station where the cargo came from first. + StationID next_hop = INVALID_STATION; ///< Station where the cargo wants to go next. /** The CargoList caches, thus needs to know about it. */ template friend class CargoList; diff --git a/src/cargotype.h b/src/cargotype.h index 9314d34482..10aae014d2 100644 --- a/src/cargotype.h +++ b/src/cargotype.h @@ -67,19 +67,19 @@ static const uint TOWN_PRODUCTION_DIVISOR = 256; /** Specification of a cargo type. */ struct CargoSpec { 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 rating_colour; 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 int32_t initial_payment; ///< Initial payment rate before inflation is applied. uint8_t transit_periods[2]; 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. - 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. + 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. uint8_t callback_mask; ///< Bitmask of cargo callbacks that have to be called StringID name; ///< Name of this type of cargo. diff --git a/src/newgrf_storage.h b/src/newgrf_storage.h index fe71caea1f..cad016d691 100644 --- a/src/newgrf_storage.h +++ b/src/newgrf_storage.h @@ -136,7 +136,7 @@ struct TemporaryStorageArray { StorageType storage{}; ///< Memory for the storage array 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. diff --git a/src/station_base.h b/src/station_base.h index 17e2147e21..12ed87355a 100644 --- a/src/station_base.h +++ b/src/station_base.h @@ -210,20 +210,20 @@ struct GoodsEntry { StationCargoList cargo{}; ///< The cargo packets of cargo waiting in this station FlowStatMap flows{}; ///< Planned flows through this station. - uint max_waiting_cargo{0}; ///< Max cargo from this station waiting at any station. - NodeID node{INVALID_NODE}; ///< ID of node in link graph referring to this goods entry. - LinkGraphID link_graph{INVALID_LINK_GRAPH}; ///< Link graph this station belongs to. + uint max_waiting_cargo = 0; ///< Max cargo from this station waiting at any station. + NodeID node = INVALID_NODE; ///< ID of node in link graph referring to this goods entry. + LinkGraphID link_graph = INVALID_LINK_GRAPH; ///< Link graph this station belongs to. - uint8_t status{0}; ///< Status of this cargo, see #GoodsEntryStatus. + uint8_t status = 0; ///< Status of this cargo, see #GoodsEntryStatus. /** * Number of rating-intervals (up to 255) since the last vehicle tried to load this cargo. * The unit used is STATION_RATING_TICKS. * This does not imply there was any cargo to load. */ - uint8_t time_since_pickup{255}; + uint8_t time_since_pickup = 255; - uint8_t rating{INITIAL_STATION_RATING}; ///< %Station rating for this cargo. + uint8_t rating = INITIAL_STATION_RATING; ///< %Station rating for this cargo. /** * Maximum speed (up to 255) of the last vehicle that tried to load this cargo. @@ -234,15 +234,15 @@ struct GoodsEntry { * - Ships: 0.5 * km-ish/h * - Aircraft: 8 * mph */ - uint8_t last_speed{0}; + uint8_t last_speed = 0; /** * Age in years (up to 255) of the last vehicle that tried to load this cargo. * This does not imply there was any cargo to load. */ - uint8_t last_age{255}; + uint8_t last_age = 255; - uint8_t amount_fract{0}; ///< Fractional part of the amount in the cargo list + uint8_t amount_fract = 0; ///< Fractional part of the amount in the cargo list /** * Reports whether a vehicle has ever tried to load the cargo at this station. diff --git a/src/textfile_gui.h b/src/textfile_gui.h index 09d55a355d..ab365d42d5 100644 --- a/src/textfile_gui.h +++ b/src/textfile_gui.h @@ -44,10 +44,10 @@ protected: void ConstructWindow(); struct Line { - int top{0}; ///< Top scroll position in visual lines. - int bottom{0}; ///< Bottom scroll position in visual lines. - std::string text{}; ///< Contents of the line. - TextColour colour{TC_WHITE}; ///< Colour to render text line in. + int top = 0; ///< Top scroll position in visual lines. + int bottom = 0; ///< Bottom scroll position in visual lines. + std::string text{}; ///< Contents of the line. + 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() {} @@ -73,8 +73,8 @@ protected: std::vector links; ///< Clickable links in lines. std::vector link_anchors; ///< Anchor names of headings that can be linked to. std::vector history; ///< Browsing history in this window. - 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). + 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). void LoadText(std::string_view buf); void FindHyperlinksInMarkdown(Line &line, size_t line_index); @@ -97,8 +97,8 @@ protected: void NavigateHistory(int delta); private: - uint search_iterator{0}; ///< Iterator for the font check search. - uint max_length{0}; ///< Maximum length of unwrapped text line. + uint search_iterator = 0; ///< Iterator for the font check search. + uint max_length = 0; ///< Maximum length of unwrapped text line. uint ReflowContent(); uint GetContentHeight(); From 8e2ccddd774ad35292e4d34948056b618c9369da Mon Sep 17 00:00:00 2001 From: translators Date: Tue, 16 Apr 2024 04:40:57 +0000 Subject: [PATCH 4/6] Update: Translations from eints portuguese (brazilian): 2 changes by pasantoro --- src/lang/brazilian_portuguese.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lang/brazilian_portuguese.txt b/src/lang/brazilian_portuguese.txt index bdf6cfa9ed..9ba9130d8c 100644 --- a/src/lang/brazilian_portuguese.txt +++ b/src/lang/brazilian_portuguese.txt @@ -446,7 +446,7 @@ STR_SETTINGS_MENU_CONFIG_SETTINGS_TREE :Configurações STR_SETTINGS_MENU_AI_SETTINGS :Configurações de IA STR_SETTINGS_MENU_GAMESCRIPT_SETTINGS :Configurações de Script de Jogo 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_TOWN_NAMES_DISPLAYED :Mostrar nomes de localidades 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 # 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_CHANGE_COMPANY :{LTBLUE}Jogando como empresa: {ORANGE}{COMMA} STR_CHEAT_EXTRA_DYNAMITE :{LTBLUE}Escavadeira mágica (remove indústrias, objetos estáticos): {ORANGE}{STRING} From 48eb9b8bc977ee17631a59aaedbc91094da49e1f Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Tue, 16 Apr 2024 16:25:07 +0100 Subject: [PATCH 5/6] Add: Check that towns can build roads before generating map. (#12503) --- src/genworld.cpp | 4 ++++ src/lang/english.txt | 5 +++++ src/town.h | 1 + src/town_cmd.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 49 insertions(+) diff --git a/src/genworld.cpp b/src/genworld.cpp index d5281a2f81..2499248cb1 100644 --- a/src/genworld.cpp +++ b/src/genworld.cpp @@ -103,6 +103,10 @@ static void _GenerateWorld() IncreaseGeneratingWorldProgress(GWP_MAP_INIT); /* Must start economy early because of the costs. */ StartupEconomy(); + if (!CheckTownRoadTypes()) { + HandleGeneratingWorldAbortion(); + return; + } bool landscape_generated = false; diff --git a/src/lang/english.txt b/src/lang/english.txt index 860915ac3c..6f24305f03 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -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_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 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... diff --git a/src/town.h b/src/town.h index 28ffa5047d..2b059dbe59 100644 --- a/src/town.h +++ b/src/town.h @@ -315,5 +315,6 @@ inline uint16_t TownTicksToGameTicks(uint16_t ticks) RoadType GetTownRoadType(); +bool CheckTownRoadTypes(); #endif /* TOWN_H */ diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index fa18e2b422..252e3b2fa0 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -940,6 +940,45 @@ RoadType GetTownRoadType() return best_rt; } +/** + * 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 TimerGameCalendar::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 <= TimerGameCalendar::date) 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. * Assuming a road from (tile - TileOffsByDiagDir(dir)) to tile, From b2218e75d4dea4261c6638579d3e501080b85bdc Mon Sep 17 00:00:00 2001 From: Rubidium Date: Tue, 16 Apr 2024 18:44:55 +0200 Subject: [PATCH 6/6] Codefix: missing space between close parenthesis and open curly brace --- src/build_vehicle_gui.cpp | 2 +- src/newgrf_townname.cpp | 4 ++-- src/rail_gui.cpp | 2 +- src/station_cmd.cpp | 2 +- src/tgp.cpp | 2 +- src/timer/timer_game_common.h | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index 9d97603b3c..ba73bf56f9 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -1260,7 +1260,7 @@ struct BuildVehicleWindow : Window { /* Select the first unshaded engine in the list as default when opening the window */ 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; this->SelectEngine(engine); } diff --git a/src/newgrf_townname.cpp b/src/newgrf_townname.cpp index d70f7892e2..ae95d79525 100644 --- a/src/newgrf_townname.cpp +++ b/src/newgrf_townname.cpp @@ -27,7 +27,7 @@ static std::vector _grf_townname_names; 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; return nullptr; } @@ -44,7 +44,7 @@ GRFTownName *AddGRFTownName(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) diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index d3dfd94db6..c09b5942eb 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -2299,7 +2299,7 @@ static void SetDefaultRailGui() case 0: { /* Use first available type */ std::vector::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; break; } diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 5385d78887..c1c81f893e 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -985,7 +985,7 @@ static CommandCost CheckFlatLandRoadStop(TileIndex cur_tile, int &allowed_z, DoC return ClearTile_Station(cur_tile, DC_AUTO); // Get error message. } /* 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); } StationID st = GetStationIndex(cur_tile); diff --git a/src/tgp.cpp b/src/tgp.cpp index d250f252d0..97860024fd 100644 --- a/src/tgp.cpp +++ b/src/tgp.cpp @@ -444,7 +444,7 @@ static int *HeightMapMakeHistogram(Height h_min, [[maybe_unused]] Height h_max, int *hist = hist_buf - h_min; /* 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_max); hist[h]++; diff --git a/src/timer/timer_game_common.h b/src/timer/timer_game_common.h index 1481f9581f..d3548cac48 100644 --- a/src/timer/timer_game_common.h +++ b/src/timer/timer_game_common.h @@ -23,7 +23,7 @@ * Other than that, make sure you only set one callback per priority. * * For example: - * IntervalTimer({TimerGameCalendar::DAY, TimerGameCalendar::Priority::NONE}, [](uint count){}); + * IntervalTimer({TimerGameCalendar::DAY, TimerGameCalendar::Priority::NONE}, [](uint count) {}); * * @note Callbacks are executed in the game-thread. */