Merge branch 'master' into jgrpp-beta
# Conflicts: # .github/workflows/commit-checker.yml # src/company_cmd.cpp # src/console_cmds.cpp # src/crashlog.cpp # src/lang/english.txt # src/lang/german.txt # src/lang/indonesian.txt # src/lang/japanese.txt # src/lang/korean.txt # src/lang/swedish.txt # src/linkgraph/linkgraphjob.cpp # src/linkgraph/mcf.cpp # src/network/core/tcp.cpp # src/network/core/tcp.h # src/network/core/tcp_game.h # src/network/core/udp.h # src/network/network.cpp # src/network/network_admin.cpp # src/network/network_admin.h # src/network/network_chat_gui.cpp # src/network/network_client.cpp # src/network/network_client.h # src/network/network_func.h # src/network/network_internal.h # src/network/network_server.cpp # src/network/network_server.h # src/newgrf.cpp # src/newgrf_station.cpp # src/order_gui.cpp # src/rail_cmd.cpp # src/saveload/saveload.cpp # src/settings.cpp # src/settings_gui.cpp # src/settings_internal.h # src/settings_type.h # src/station_cmd.cpp # src/stdafx.h # src/table/currency_settings.ini # src/table/misc_settings.ini # src/table/settings.h.preamble # src/table/settings.ini # src/terraform_cmd.cpp # src/timetable_gui.cpp # src/train_cmd.cpp # src/tree_cmd.cpp # src/water_cmd.cpp
This commit is contained in:
@@ -289,6 +289,18 @@ char *GetString(char *buffr, StringID string, const char *last)
|
||||
return GetStringWithArgs(buffr, string, &_global_string_params, last);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the given StringID into a std::string with all the associated
|
||||
* DParam lookups and formatting.
|
||||
* @param string The unique identifier of the translatable string.
|
||||
* @return The std::string of the translated string.
|
||||
*/
|
||||
std::string GetString(StringID string)
|
||||
{
|
||||
char buffer[DRAW_STRING_BUFFER];
|
||||
GetString(buffer, string, lastof(buffer));
|
||||
return buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is used to "bind" a C string to a OpenTTD dparam slot.
|
||||
@@ -347,8 +359,8 @@ static char *FormatNumber(char *buff, int64 number, const char *last, const char
|
||||
uint64 tot = 0;
|
||||
for (int i = 0; i < max_digits; i++) {
|
||||
if (i == max_digits - fractional_digits) {
|
||||
const char *decimal_separator = _settings_game.locale.digit_decimal_separator;
|
||||
if (decimal_separator == nullptr) decimal_separator = _langpack.langpack->digit_decimal_separator;
|
||||
const char *decimal_separator = _settings_game.locale.digit_decimal_separator.c_str();
|
||||
if (StrEmpty(decimal_separator)) decimal_separator = _langpack.langpack->digit_decimal_separator;
|
||||
buff += seprintf(buff, last, "%s", decimal_separator);
|
||||
}
|
||||
|
||||
@@ -372,8 +384,8 @@ static char *FormatNumber(char *buff, int64 number, const char *last, const char
|
||||
|
||||
static char *FormatCommaNumber(char *buff, int64 number, const char *last, int fractional_digits = 0)
|
||||
{
|
||||
const char *separator = _settings_game.locale.digit_group_separator;
|
||||
if (separator == nullptr) separator = _langpack.langpack->digit_group_separator;
|
||||
const char *separator = _settings_game.locale.digit_group_separator.c_str();
|
||||
if (StrEmpty(separator)) separator = _langpack.langpack->digit_group_separator;
|
||||
return FormatNumber(buff, number, last, separator, 1, fractional_digits);
|
||||
}
|
||||
|
||||
@@ -395,9 +407,9 @@ static char *FormatHexNumber(char *buff, uint64 number, const char *last)
|
||||
WChar GetDecimalSeparatorChar()
|
||||
{
|
||||
WChar decimal_char = '.';
|
||||
const char *decimal_separator = _settings_game.locale.digit_decimal_separator;
|
||||
if (decimal_separator == nullptr) decimal_separator = _langpack.langpack->digit_decimal_separator;
|
||||
if (decimal_separator != nullptr) Utf8Decode(&decimal_char, decimal_separator);
|
||||
const char *decimal_separator = _settings_game.locale.digit_decimal_separator.c_str();
|
||||
if (StrEmpty(decimal_separator)) decimal_separator = _langpack.langpack->digit_decimal_separator;
|
||||
if (!StrEmpty(decimal_separator)) Utf8Decode(&decimal_char, decimal_separator);
|
||||
return decimal_char;
|
||||
}
|
||||
|
||||
@@ -420,8 +432,8 @@ static char *FormatBytes(char *buff, int64 number, const char *last)
|
||||
id++;
|
||||
}
|
||||
|
||||
const char *decimal_separator = _settings_game.locale.digit_decimal_separator;
|
||||
if (decimal_separator == nullptr) decimal_separator = _langpack.langpack->digit_decimal_separator;
|
||||
const char *decimal_separator = _settings_game.locale.digit_decimal_separator.c_str();
|
||||
if (StrEmpty(decimal_separator)) decimal_separator = _langpack.langpack->digit_decimal_separator;
|
||||
|
||||
if (number < 1024) {
|
||||
id = 0;
|
||||
@@ -532,7 +544,7 @@ static char *FormatGenericCurrency(char *buff, const CurrencySpec *spec, Money n
|
||||
/* Add prefix part, following symbol_pos specification.
|
||||
* Here, it can can be either 0 (prefix) or 2 (both prefix and suffix).
|
||||
* The only remaining value is 1 (suffix), so everything that is not 1 */
|
||||
if (spec->symbol_pos != 1) buff = strecpy(buff, spec->prefix, last);
|
||||
if (spec->symbol_pos != 1) buff = strecpy(buff, spec->prefix.c_str(), last);
|
||||
|
||||
/* for huge numbers, compact the number into k or M */
|
||||
if (compact) {
|
||||
@@ -547,16 +559,16 @@ static char *FormatGenericCurrency(char *buff, const CurrencySpec *spec, Money n
|
||||
}
|
||||
}
|
||||
|
||||
const char *separator = _settings_game.locale.digit_group_separator_currency;
|
||||
if (separator == nullptr && !StrEmpty(_currency->separator)) separator = _currency->separator;
|
||||
if (separator == nullptr) separator = _langpack.langpack->digit_group_separator_currency;
|
||||
const char *separator = _settings_game.locale.digit_group_separator_currency.c_str();
|
||||
if (StrEmpty(separator)) separator = _currency->separator.c_str();
|
||||
if (StrEmpty(separator)) separator = _langpack.langpack->digit_group_separator_currency;
|
||||
buff = FormatNumber(buff, number, last, separator);
|
||||
buff = strecpy(buff, multiplier, last);
|
||||
|
||||
/* Add suffix part, following symbol_pos specification.
|
||||
* Here, it can can be either 1 (suffix) or 2 (both prefix and suffix).
|
||||
* The only remaining value is 1 (prefix), so everything that is not 0 */
|
||||
if (spec->symbol_pos != 0) buff = strecpy(buff, spec->suffix, last);
|
||||
if (spec->symbol_pos != 0) buff = strecpy(buff, spec->suffix.c_str(), last);
|
||||
|
||||
if (negative) {
|
||||
if (buff + Utf8CharLen(SCC_POP_COLOUR) > last) return buff;
|
||||
@@ -1081,7 +1093,7 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
|
||||
const char *&str = str_stack.top();
|
||||
|
||||
if (SCC_NEWGRF_FIRST <= b && b <= SCC_NEWGRF_LAST) {
|
||||
/* We need to pass some stuff as it might be modified; oh boy. */
|
||||
/* We need to pass some stuff as it might be modified. */
|
||||
//todo: should argve be passed here too?
|
||||
b = RemapNewGRFStringControlCode(b, buf_start, &buff, &str, (int64 *)args->GetDataPointer(), args->GetDataLeft(), dry_run);
|
||||
if (b == 0) continue;
|
||||
@@ -2459,9 +2471,9 @@ class LanguagePackGlyphSearcher : public MissingGlyphSearcher {
|
||||
void SetFontNames(FreeTypeSettings *settings, const char *font_name, const void *os_data) override
|
||||
{
|
||||
#if defined(WITH_FREETYPE) || defined(_WIN32) || defined(WITH_COCOA)
|
||||
strecpy(settings->small.font, font_name, lastof(settings->small.font));
|
||||
strecpy(settings->medium.font, font_name, lastof(settings->medium.font));
|
||||
strecpy(settings->large.font, font_name, lastof(settings->large.font));
|
||||
settings->small.font = font_name;
|
||||
settings->medium.font = font_name;
|
||||
settings->large.font = font_name;
|
||||
|
||||
settings->small.os_handle = os_data;
|
||||
settings->medium.os_handle = os_data;
|
||||
@@ -2492,15 +2504,14 @@ void CheckForMissingGlyphs(bool base_font, MissingGlyphSearcher *searcher)
|
||||
if (bad_font) {
|
||||
/* We found an unprintable character... lets try whether we can find
|
||||
* a fallback font that can print the characters in the current language. */
|
||||
FreeTypeSettings backup;
|
||||
memcpy(&backup, &_freetype, sizeof(backup));
|
||||
FreeTypeSettings backup = _freetype;
|
||||
|
||||
_freetype.mono.os_handle = nullptr;
|
||||
_freetype.medium.os_handle = nullptr;
|
||||
|
||||
bad_font = !SetFallbackFont(&_freetype, _langpack.langpack->isocode, _langpack.langpack->winlangid, searcher);
|
||||
|
||||
memcpy(&_freetype, &backup, sizeof(backup));
|
||||
_freetype = backup;
|
||||
|
||||
if (!bad_font) {
|
||||
/* Show that we loaded fallback font. To do this properly we have
|
||||
|
Reference in New Issue
Block a user