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:
		@@ -290,10 +290,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()
 | 
			
		||||
 
 | 
			
		||||
@@ -1658,7 +1658,7 @@ struct BuildVehicleWindow : BuildVehicleWindowBase {
 | 
			
		||||
 | 
			
		||||
		/* 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);
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -67,21 +67,21 @@ 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.
 | 
			
		||||
	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 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 classes;                     ///< Classes of this cargo type. @see CargoClass
 | 
			
		||||
	int32_t initial_payment;              ///< Initial payment rate before inflation is applied.
 | 
			
		||||
	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 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.
 | 
			
		||||
	uint8_t callback_mask;                ///< Bitmask of cargo callbacks that have to be called
 | 
			
		||||
	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.
 | 
			
		||||
	uint8_t callback_mask;                                         ///< Bitmask of cargo callbacks that have to be called
 | 
			
		||||
 | 
			
		||||
	StringID name;                        ///< Name of this type of cargo.
 | 
			
		||||
	StringID name_single;                 ///< Name of a single entity of this type of cargo.
 | 
			
		||||
 
 | 
			
		||||
@@ -2440,10 +2440,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] [<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, "  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, "  The <size> is automatically multiplied by the current interface scaling.");
 | 
			
		||||
		return true;
 | 
			
		||||
@@ -2461,38 +2461,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 <name> we want a string. */
 | 
			
		||||
			uint v;
 | 
			
		||||
			if (!GetArgumentInteger(&v, argv[arg_index])) {
 | 
			
		||||
				font = argv[arg_index++];
 | 
			
		||||
			}
 | 
			
		||||
		/* For <name> we want a string. */
 | 
			
		||||
 | 
			
		||||
		if (!GetArgumentInteger(&v, argv[arg_index])) {
 | 
			
		||||
			font = argv[arg_index++];
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (argc > arg_index) {
 | 
			
		||||
			/* For <size> 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++) {
 | 
			
		||||
@@ -2504,8 +2489,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);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	FontChanged();
 | 
			
		||||
 
 | 
			
		||||
@@ -74,15 +74,15 @@ void UpdateFontHeightCache()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* 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;
 | 
			
		||||
@@ -97,11 +97,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) {
 | 
			
		||||
@@ -216,19 +211,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; }
 | 
			
		||||
 
 | 
			
		||||
@@ -211,7 +211,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.
 | 
			
		||||
};
 | 
			
		||||
@@ -246,9 +245,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 */
 | 
			
		||||
 
 | 
			
		||||
@@ -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)
 | 
			
		||||
 
 | 
			
		||||
@@ -115,6 +115,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;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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())));
 | 
			
		||||
	/* 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();
 | 
			
		||||
 
 | 
			
		||||
@@ -325,7 +325,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 {
 | 
			
		||||
 
 | 
			
		||||
@@ -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}
 | 
			
		||||
 
 | 
			
		||||
@@ -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...
 | 
			
		||||
 
 | 
			
		||||
@@ -137,7 +137,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.
 | 
			
		||||
 
 | 
			
		||||
@@ -27,7 +27,7 @@ static std::vector<StringID> _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)
 | 
			
		||||
 
 | 
			
		||||
@@ -2759,7 +2759,7 @@ static void SetDefaultRailGui()
 | 
			
		||||
		case 0: {
 | 
			
		||||
			/* Use first available type */
 | 
			
		||||
			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;
 | 
			
		||||
			break;
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
@@ -1144,7 +1144,7 @@ CommandCost CheckFlatLandRoadStop(TileArea tile_area, const RoadStopSpec *spec,
 | 
			
		||||
					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);
 | 
			
		||||
 
 | 
			
		||||
@@ -247,30 +247,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""
 | 
			
		||||
 
 | 
			
		||||
@@ -56,10 +56,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() {}
 | 
			
		||||
@@ -85,8 +85,8 @@ protected:
 | 
			
		||||
	std::vector<Hyperlink> links;        ///< Clickable links in lines.
 | 
			
		||||
	std::vector<Hyperlink> link_anchors; ///< Anchor names of headings that can be linked to.
 | 
			
		||||
	std::vector<HistoryEntry> 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);
 | 
			
		||||
@@ -109,8 +109,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();
 | 
			
		||||
 
 | 
			
		||||
@@ -446,7 +446,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]++;
 | 
			
		||||
 
 | 
			
		||||
@@ -382,6 +382,7 @@ inline uint16_t TownTicksToGameTicks(uint16_t ticks)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
RoadType GetTownRoadType();
 | 
			
		||||
bool CheckTownRoadTypes();
 | 
			
		||||
bool MayTownModifyRoad(TileIndex tile);
 | 
			
		||||
 | 
			
		||||
#endif /* TOWN_H */
 | 
			
		||||
 
 | 
			
		||||
@@ -1088,6 +1088,45 @@ bool MayTownModifyRoad(TileIndex tile)
 | 
			
		||||
	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.
 | 
			
		||||
 *   Assuming a road from (tile - TileOffsByDiagDir(dir)) to tile,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user