diff --git a/src/openrct2/localisation/ConversionTables.cpp b/src/openrct2/localisation/ConversionTables.cpp index 0baeffb74c..d922ecba23 100644 --- a/src/openrct2/localisation/ConversionTables.cpp +++ b/src/openrct2/localisation/ConversionTables.cpp @@ -7,12 +7,13 @@ * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ -#include +#include "ConversionTables.h" #include "../core/Util.hpp" -#include "ConversionTables.h" #include "FormatCodes.h" +#include + // clang-format off const encoding_convert_entry RCT2ToUnicodeTable[256] = { diff --git a/src/openrct2/localisation/Convert.cpp b/src/openrct2/localisation/Convert.cpp index 3a21dd0e65..d3a6c44b7f 100644 --- a/src/openrct2/localisation/Convert.cpp +++ b/src/openrct2/localisation/Convert.cpp @@ -7,14 +7,15 @@ * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ -#include -#include -#include #include "../core/String.hpp" #include "../core/Util.hpp" #include "ConversionTables.h" #include "Language.h" +#include +#include +#include + /** * Decodes an RCT2 string to a wide char string still in the original code page. * An RCT2 string is a multi-byte string where every two-byte code point is preceeded with a byte value of 255. @@ -23,7 +24,7 @@ static std::wstring DecodeToWideChar(const std::string_view& src) { std::wstring decoded; decoded.reserve(src.size()); - for (auto it = src.begin(); it != src.end(); ) + for (auto it = src.begin(); it != src.end();) { uint8_t c = *it++; if (c == 255) @@ -88,7 +89,7 @@ static std::string DecodeToMultiByte(const std::string_view& src) static std::string Encode(const std::string_view& src) { std::string dst; - const utf8 * ch = src.data(); + const utf8* ch = src.data(); int32_t codepoint; while ((codepoint = utf8_get_next(ch, &ch)) != 0) { @@ -129,8 +130,7 @@ static int32_t GetCodePageForRCT2Language(RCT2LanguageId languageId) } } -template -static std::string DecodeConvertWithTable(const std::string_view& src, TConvertFunc func) +template static std::string DecodeConvertWithTable(const std::string_view& src, TConvertFunc func) { auto decoded = DecodeToWideChar(src); std::wstring u16; diff --git a/src/openrct2/localisation/Currency.cpp b/src/openrct2/localisation/Currency.cpp index 937b5f83e0..2b7f9a8c66 100644 --- a/src/openrct2/localisation/Currency.cpp +++ b/src/openrct2/localisation/Currency.cpp @@ -7,9 +7,10 @@ * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ +#include "Currency.h" + #include "../config/Config.h" #include "../util/Util.h" -#include "Currency.h" #include "StringIds.h" // clang-format off @@ -40,6 +41,9 @@ void currency_load_custom_currency_config() CurrencyDescriptors[CURRENCY_CUSTOM].affix_unicode = gConfigGeneral.custom_currency_affix; if (gConfigGeneral.custom_currency_symbol != nullptr) { - safe_strcpy(CurrencyDescriptors[CURRENCY_CUSTOM].symbol_unicode, gConfigGeneral.custom_currency_symbol, CURRENCY_SYMBOL_MAX_SIZE); + safe_strcpy( + CurrencyDescriptors[CURRENCY_CUSTOM].symbol_unicode, + gConfigGeneral.custom_currency_symbol, + CURRENCY_SYMBOL_MAX_SIZE); } } diff --git a/src/openrct2/localisation/Currency.h b/src/openrct2/localisation/Currency.h index 1c76c88e4a..63de732462 100644 --- a/src/openrct2/localisation/Currency.h +++ b/src/openrct2/localisation/Currency.h @@ -13,30 +13,32 @@ #include "../common.h" // List of currencies -enum CURRENCY_TYPE { - CURRENCY_POUNDS, // British Pound - CURRENCY_DOLLARS, // US Dollar - CURRENCY_FRANC, // French Franc - CURRENCY_DEUTSCHMARK, // Deutsche Mark - CURRENCY_YEN, // Japanese Yen - CURRENCY_PESETA, // Spanish Peseta - CURRENCY_LIRA, // Italian Lira - CURRENCY_GUILDERS, // Dutch Gilder - CURRENCY_KRONA, // Swedish Krona - CURRENCY_EUROS, // Euro - CURRENCY_WON, // South Korean Won - CURRENCY_ROUBLE, // Russian Rouble - CURRENCY_CZECH_KORUNA, // Czech koruna - CURRENCY_HKD, // Hong Kong Dollar - CURRENCY_TWD, // New Taiwan Dollar - CURRENCY_YUAN, // Chinese Yuan +enum CURRENCY_TYPE +{ + CURRENCY_POUNDS, // British Pound + CURRENCY_DOLLARS, // US Dollar + CURRENCY_FRANC, // French Franc + CURRENCY_DEUTSCHMARK, // Deutsche Mark + CURRENCY_YEN, // Japanese Yen + CURRENCY_PESETA, // Spanish Peseta + CURRENCY_LIRA, // Italian Lira + CURRENCY_GUILDERS, // Dutch Gilder + CURRENCY_KRONA, // Swedish Krona + CURRENCY_EUROS, // Euro + CURRENCY_WON, // South Korean Won + CURRENCY_ROUBLE, // Russian Rouble + CURRENCY_CZECH_KORUNA, // Czech koruna + CURRENCY_HKD, // Hong Kong Dollar + CURRENCY_TWD, // New Taiwan Dollar + CURRENCY_YUAN, // Chinese Yuan - CURRENCY_CUSTOM, // Custom currency + CURRENCY_CUSTOM, // Custom currency - CURRENCY_END // Last item + CURRENCY_END // Last item }; -enum CURRENCY_AFFIX { +enum CURRENCY_AFFIX +{ CURRENCY_PREFIX, CURRENCY_SUFFIX }; @@ -45,7 +47,8 @@ enum CURRENCY_AFFIX { #define CURRENCY_RATE_MAX_NUM_DIGITS 9 // Currency format specification - inspired by OpenTTD -struct currency_descriptor { +struct currency_descriptor +{ char isoCode[4]; // Rate is relative to 0.10 GBP int32_t rate; diff --git a/src/openrct2/localisation/Date.h b/src/openrct2/localisation/Date.h index 228945fea9..6417794aa2 100644 --- a/src/openrct2/localisation/Date.h +++ b/src/openrct2/localisation/Date.h @@ -12,7 +12,8 @@ #include "../common.h" -enum { +enum +{ MONTH_MARCH, MONTH_APRIL, MONTH_MAY, @@ -25,14 +26,16 @@ enum { MONTH_COUNT }; -enum { +enum +{ DATE_FORMAT_DAY_MONTH_YEAR, DATE_FORMAT_MONTH_DAY_YEAR, DATE_FORMAT_YEAR_MONTH_DAY, DATE_FORMAT_YEAR_DAY_MONTH }; -struct openrct_timeofday { +struct openrct_timeofday +{ uint8_t second; uint8_t minute; uint8_t hour; diff --git a/src/openrct2/localisation/FormatCodes.cpp b/src/openrct2/localisation/FormatCodes.cpp index d2466b84e6..5423ca06f7 100644 --- a/src/openrct2/localisation/FormatCodes.cpp +++ b/src/openrct2/localisation/FormatCodes.cpp @@ -7,16 +7,18 @@ * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ +#include "FormatCodes.h" + #include "../common.h" #include "../core/Util.hpp" -#include "FormatCodes.h" #include "Localisation.h" #pragma region Format codes -struct format_code_token { +struct format_code_token +{ uint32_t code; - const char *token; + const char* token; }; // clang-format off @@ -95,7 +97,7 @@ static constexpr const format_code_token format_code_tokens[] = { }; // clang-format on -uint32_t format_get_code(const char *token) +uint32_t format_get_code(const char* token) { for (uint32_t i = 0; i < Util::CountOf(format_code_tokens); i++) { @@ -105,7 +107,7 @@ uint32_t format_get_code(const char *token) return 0; } -const char *format_get_token(uint32_t code) +const char* format_get_token(uint32_t code) { for (uint32_t i = 0; i < Util::CountOf(format_code_tokens); i++) { @@ -117,24 +119,25 @@ const char *format_get_token(uint32_t code) bool utf8_should_use_sprite_for_codepoint(int32_t codepoint) { - switch (codepoint) { - case FORMAT_UP: - case FORMAT_DOWN: - case FORMAT_LEFTGUILLEMET: - case FORMAT_TICK: - case FORMAT_CROSS: - case FORMAT_RIGHT: - case FORMAT_RIGHTGUILLEMET: - case FORMAT_SMALLUP: - case FORMAT_SMALLDOWN: - case FORMAT_LEFT: - case FORMAT_OPENQUOTES: - case FORMAT_ENDQUOTES: - case UNICODE_DINGBATS_PLUS: - case UNICODE_DINGBATS_MINUS: - return true; - default: - return false; + switch (codepoint) + { + case FORMAT_UP: + case FORMAT_DOWN: + case FORMAT_LEFTGUILLEMET: + case FORMAT_TICK: + case FORMAT_CROSS: + case FORMAT_RIGHT: + case FORMAT_RIGHTGUILLEMET: + case FORMAT_SMALLUP: + case FORMAT_SMALLDOWN: + case FORMAT_LEFT: + case FORMAT_OPENQUOTES: + case FORMAT_ENDQUOTES: + case UNICODE_DINGBATS_PLUS: + case UNICODE_DINGBATS_MINUS: + return true; + default: + return false; } } diff --git a/src/openrct2/localisation/FormatCodes.h b/src/openrct2/localisation/FormatCodes.h index 96e113e45f..48d989da92 100644 --- a/src/openrct2/localisation/FormatCodes.h +++ b/src/openrct2/localisation/FormatCodes.h @@ -12,10 +12,11 @@ #include "../common.h" -uint32_t format_get_code(const char *token); -const char *format_get_token(uint32_t code); +uint32_t format_get_code(const char* token); +const char* format_get_token(uint32_t code); -enum { +enum +{ // Font format codes // The next byte specifies the X coordinate @@ -135,22 +136,22 @@ enum { enum RCT2Polish { RCT2_A_OGONEK_UC = 159, // 0x9F - RCT2_C_ACUTE_UC = 162, // 0xA2 + RCT2_C_ACUTE_UC = 162, // 0xA2 RCT2_E_OGONEK_UC = 166, // 0xA6 - RCT2_N_ACUTE_UC = 198, // 0xC6 + RCT2_N_ACUTE_UC = 198, // 0xC6 RCT2_L_STROKE_UC = 167, // 0xA7 - RCT2_S_ACUTE_UC = 208, // 0xD0 - RCT2_Z_DOT_UC = 216, // 0xD8 - RCT2_Z_ACUTE_UC = 215, // 0xD7 + RCT2_S_ACUTE_UC = 208, // 0xD0 + RCT2_Z_DOT_UC = 216, // 0xD8 + RCT2_Z_ACUTE_UC = 215, // 0xD7 RCT2_A_OGONEK = 221, // 0xDD - RCT2_C_ACUTE = 222, // 0xDE + RCT2_C_ACUTE = 222, // 0xDE RCT2_E_OGONEK = 230, // 0xE6 - RCT2_N_ACUTE = 240, // 0xF0 + RCT2_N_ACUTE = 240, // 0xF0 RCT2_L_STROKE = 247, // 0xF7 - RCT2_S_ACUTE = 248, // 0xF8 - RCT2_Z_DOT = 253, // 0xFD - RCT2_Z_ACUTE = 254, // 0xFE + RCT2_S_ACUTE = 248, // 0xF8 + RCT2_Z_DOT = 253, // 0xFD + RCT2_Z_ACUTE = 254, // 0xFE }; enum UnicodePolish diff --git a/src/openrct2/localisation/Language.cpp b/src/openrct2/localisation/Language.cpp index 133a8038f0..5766b3fc8b 100644 --- a/src/openrct2/localisation/Language.cpp +++ b/src/openrct2/localisation/Language.cpp @@ -7,18 +7,19 @@ * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ -#include #include "../Context.h" #include "../core/Path.hpp" #include "../core/String.hpp" -#include "../interface/Fonts.h" #include "../interface/FontFamilies.h" +#include "../interface/Fonts.h" #include "../object/ObjectManager.h" #include "../platform/platform.h" #include "LanguagePack.h" #include "Localisation.h" #include "LocalisationService.h" +#include + // clang-format off const language_descriptor LanguagesDescriptors[LANGUAGE_COUNT] = { @@ -56,10 +57,10 @@ const utf8 BlackRightArrowString[] = { (utf8)(uint8_t)0xC2, (utf8)(uint8_t)0x const utf8 CheckBoxMarkString[] = { (utf8)(uint8_t)0xE2, (utf8)(uint8_t)0x9C, (utf8)(uint8_t)0x93, (utf8)(uint8_t)0x00 }; // clang-format on -void utf8_remove_format_codes(utf8 * text, bool allowcolours) +void utf8_remove_format_codes(utf8* text, bool allowcolours) { - const utf8 * ch = text; - utf8 * dstCh = text; + const utf8* ch = text; + utf8* dstCh = text; int32_t codepoint; while ((codepoint = String::GetNextCodepoint(ch, &ch)) != 0) { @@ -71,10 +72,10 @@ void utf8_remove_format_codes(utf8 * text, bool allowcolours) *dstCh = 0; } -uint8_t language_get_id_from_locale(const char * locale) +uint8_t language_get_id_from_locale(const char* locale) { uint8_t i = 0; - for (const auto &langDesc : LanguagesDescriptors) + for (const auto& langDesc : LanguagesDescriptors) { if (String::Equals(locale, langDesc.locale)) { @@ -85,7 +86,7 @@ uint8_t language_get_id_from_locale(const char * locale) return LANGUAGE_UNDEFINED; } -const char * language_get_string(rct_string_id id) +const char* language_get_string(rct_string_id id) { const auto& localisationService = OpenRCT2::GetContext()->GetLocalisationService(); return localisationService.GetString(id); @@ -107,17 +108,14 @@ bool language_open(int32_t id) } } -bool language_get_localised_scenario_strings(const utf8 *scenarioFilename, rct_string_id *outStringIds) +bool language_get_localised_scenario_strings(const utf8* scenarioFilename, rct_string_id* outStringIds) { const auto& localisationService = OpenRCT2::GetContext()->GetLocalisationService(); auto result = localisationService.GetLocalisedScenarioStrings(scenarioFilename); outStringIds[0] = std::get<0>(result); outStringIds[1] = std::get<1>(result); outStringIds[2] = std::get<2>(result); - return - outStringIds[0] != STR_NONE || - outStringIds[1] != STR_NONE || - outStringIds[2] != STR_NONE; + return outStringIds[0] != STR_NONE || outStringIds[1] != STR_NONE || outStringIds[2] != STR_NONE; } void language_free_object_string(rct_string_id stringId) @@ -126,13 +124,13 @@ void language_free_object_string(rct_string_id stringId) localisationService.FreeObjectString(stringId); } -rct_string_id language_get_object_override_string_id(const char * identifier, uint8_t index) +rct_string_id language_get_object_override_string_id(const char* identifier, uint8_t index) { const auto& localisationService = OpenRCT2::GetContext()->GetLocalisationService(); return localisationService.GetObjectOverrideStringId(identifier, index); } -rct_string_id language_allocate_object_string(const std::string &target) +rct_string_id language_allocate_object_string(const std::string& target) { auto& localisationService = OpenRCT2::GetContext()->GetLocalisationService(); return localisationService.AllocateObjectString(target); diff --git a/src/openrct2/localisation/Language.h b/src/openrct2/localisation/Language.h index 297f8e21da..a6b6246f8b 100644 --- a/src/openrct2/localisation/Language.h +++ b/src/openrct2/localisation/Language.h @@ -10,12 +10,14 @@ #ifndef _LANGUAGE_H_ #define _LANGUAGE_H_ -#include -#include #include "../common.h" #include "../drawing/Font.h" -enum { +#include +#include + +enum +{ LANGUAGE_UNDEFINED, LANGUAGE_ARABIC, LANGUAGE_CATALAN, @@ -66,14 +68,15 @@ enum RCT2LanguageId #include "../interface/FontFamilies.h" -struct language_descriptor { - const char *locale; - const utf8 *english_name; - const utf8 *native_name; +struct language_descriptor +{ + const char* locale; + const utf8* english_name; + const utf8* native_name; #if !defined(NO_TTF) - TTFontFamily const * font_family; + TTFontFamily const* font_family; #else - void * font_family; + void* font_family; #endif RCT2LanguageId rct2_original_id; }; @@ -86,25 +89,25 @@ extern const utf8 BlackLeftArrowString[]; extern const utf8 BlackRightArrowString[]; extern const utf8 CheckBoxMarkString[]; -uint8_t language_get_id_from_locale(const char * locale); -const char *language_get_string(rct_string_id id); +uint8_t language_get_id_from_locale(const char* locale); +const char* language_get_string(rct_string_id id); bool language_open(int32_t id); -uint32_t utf8_get_next(const utf8 *char_ptr, const utf8 **nextchar_ptr); -utf8 *utf8_write_codepoint(utf8 *dst, uint32_t codepoint); -int32_t utf8_insert_codepoint(utf8 *dst, uint32_t codepoint); -bool utf8_is_codepoint_start(const utf8 *text); -void utf8_remove_format_codes(utf8 *text, bool allowcolours); +uint32_t utf8_get_next(const utf8* char_ptr, const utf8** nextchar_ptr); +utf8* utf8_write_codepoint(utf8* dst, uint32_t codepoint); +int32_t utf8_insert_codepoint(utf8* dst, uint32_t codepoint); +bool utf8_is_codepoint_start(const utf8* text); +void utf8_remove_format_codes(utf8* text, bool allowcolours); int32_t utf8_get_codepoint_length(int32_t codepoint); -int32_t utf8_length(const utf8 *text); -wchar_t *utf8_to_widechar(const utf8 *src); -utf8 *widechar_to_utf8(const wchar_t *src); +int32_t utf8_length(const utf8* text); +wchar_t* utf8_to_widechar(const utf8* src); +utf8* widechar_to_utf8(const wchar_t* src); std::string rct2_to_utf8(const std::string_view& src, RCT2LanguageId languageId); std::string utf8_to_rct2(const std::string_view& src); -bool language_get_localised_scenario_strings(const utf8 *scenarioFilename, rct_string_id *outStringIds); +bool language_get_localised_scenario_strings(const utf8* scenarioFilename, rct_string_id* outStringIds); void language_free_object_string(rct_string_id stringId); -rct_string_id language_get_object_override_string_id(const char * identifier, uint8_t index); -rct_string_id language_allocate_object_string(const std::string &target); +rct_string_id language_get_object_override_string_id(const char* identifier, uint8_t index); +rct_string_id language_allocate_object_string(const std::string& target); #endif diff --git a/src/openrct2/localisation/LanguagePack.cpp b/src/openrct2/localisation/LanguagePack.cpp index a8e079277a..ef69292e69 100644 --- a/src/openrct2/localisation/LanguagePack.cpp +++ b/src/openrct2/localisation/LanguagePack.cpp @@ -7,35 +7,35 @@ * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ -#include -#include -#include +#include "LanguagePack.h" #include "../common.h" -#include "Localisation.h" - #include "../core/FileStream.hpp" #include "../core/Math.hpp" #include "../core/Memory.hpp" #include "../core/String.hpp" #include "../core/StringBuilder.hpp" #include "../core/StringReader.hpp" -#include "LanguagePack.h" +#include "Localisation.h" + +#include +#include +#include // Don't try to load more than language files that exceed 64 MiB constexpr uint64_t MAX_LANGUAGE_SIZE = 64 * 1024 * 1024; constexpr uint64_t MAX_OBJECT_OVERRIDES = 4096; constexpr uint64_t MAX_SCENARIO_OVERRIDES = 4096; -constexpr rct_string_id ObjectOverrideBase = 0x6000; -constexpr int32_t ObjectOverrideMaxStringCount = 3; +constexpr rct_string_id ObjectOverrideBase = 0x6000; +constexpr int32_t ObjectOverrideMaxStringCount = 3; -constexpr rct_string_id ScenarioOverrideBase = 0x7000; -constexpr int32_t ScenarioOverrideMaxStringCount = 3; +constexpr rct_string_id ScenarioOverrideBase = 0x7000; +constexpr int32_t ScenarioOverrideMaxStringCount = 3; struct ObjectOverride { - char name[8] = { 0 }; + char name[8] = { 0 }; std::string strings[ObjectOverrideMaxStringCount]; }; @@ -49,24 +49,24 @@ class LanguagePack final : public ILanguagePack { private: uint16_t const _id; - std::vector _strings; - std::vector _objectOverrides; + std::vector _strings; + std::vector _objectOverrides; std::vector _scenarioOverrides; /////////////////////////////////////////////////////////////////////////// // Parsing work data /////////////////////////////////////////////////////////////////////////// - std::string _currentGroup; - ObjectOverride * _currentObjectOverride = nullptr; - ScenarioOverride * _currentScenarioOverride = nullptr; + std::string _currentGroup; + ObjectOverride* _currentObjectOverride = nullptr; + ScenarioOverride* _currentScenarioOverride = nullptr; public: - static LanguagePack * FromFile(uint16_t id, const utf8 * path) + static LanguagePack* FromFile(uint16_t id, const utf8* path) { Guard::ArgumentNotNull(path); // Load file directly into memory - utf8 * fileData = nullptr; + utf8* fileData = nullptr; try { FileStream fs = FileStream(path, FILE_MODE_OPEN); @@ -81,7 +81,7 @@ public: fs.Read(fileData, fileLength); fileData[fileLength] = '\0'; } - catch (const std::exception &ex) + catch (const std::exception& ex) { Memory::Free(fileData); log_error("Unable to open %s: %s", path, ex.what()); @@ -89,18 +89,18 @@ public: } // Parse the memory as text - LanguagePack * result = FromText(id, fileData); + LanguagePack* result = FromText(id, fileData); Memory::Free(fileData); return result; } - static LanguagePack * FromText(uint16_t id, const utf8 * text) + static LanguagePack* FromText(uint16_t id, const utf8* text) { return new LanguagePack(id, text); } - LanguagePack(uint16_t id, const utf8 * text) + LanguagePack(uint16_t id, const utf8* text) : _id(id) { Guard::ArgumentNotNull(text); @@ -135,7 +135,7 @@ public: } } - void SetString(rct_string_id stringId, const std::string &str) override + void SetString(rct_string_id stringId, const std::string& str) override { if (_strings.size() >= (size_t)stringId) { @@ -143,7 +143,7 @@ public: } } - const utf8 * GetString(rct_string_id stringId) const override + const utf8* GetString(rct_string_id stringId) const override { if (stringId >= ScenarioOverrideBase) { @@ -188,13 +188,13 @@ public: } } - rct_string_id GetObjectOverrideStringId(const char * objectIdentifier, uint8_t index) override + rct_string_id GetObjectOverrideStringId(const char* objectIdentifier, uint8_t index) override { Guard::ArgumentNotNull(objectIdentifier); Guard::Assert(index < ObjectOverrideMaxStringCount); int32_t ooIndex = 0; - for (const ObjectOverride &objectOverride : _objectOverrides) + for (const ObjectOverride& objectOverride : _objectOverrides) { if (strncmp(objectOverride.name, objectIdentifier, 8) == 0) { @@ -210,13 +210,13 @@ public: return STR_NONE; } - rct_string_id GetScenarioOverrideStringId(const utf8 * scenarioFilename, uint8_t index) override + rct_string_id GetScenarioOverrideStringId(const utf8* scenarioFilename, uint8_t index) override { Guard::ArgumentNotNull(scenarioFilename); Guard::Assert(index < ScenarioOverrideMaxStringCount); int32_t ooIndex = 0; - for (const ScenarioOverride &scenarioOverride : _scenarioOverrides) + for (const ScenarioOverride& scenarioOverride : _scenarioOverrides) { if (String::Equals(scenarioOverride.filename.c_str(), scenarioFilename, true)) { @@ -233,9 +233,9 @@ public: } private: - ObjectOverride * GetObjectOverride(const std::string &objectIdentifier) + ObjectOverride* GetObjectOverride(const std::string& objectIdentifier) { - for (auto &oo : _objectOverrides) + for (auto& oo : _objectOverrides) { if (strncmp(oo.name, objectIdentifier.c_str(), 8) == 0) { @@ -245,9 +245,9 @@ private: return nullptr; } - ScenarioOverride * GetScenarioOverride(const std::string &scenarioIdentifier) + ScenarioOverride* GetScenarioOverride(const std::string& scenarioIdentifier) { - for (auto &so : _scenarioOverrides) + for (auto& so : _scenarioOverrides) { if (String::Equals(so.strings[0], scenarioIdentifier.c_str(), true)) { @@ -267,9 +267,9 @@ private: // Unsure at how the original game decides which entries to write resource strings to, but this could affect adding new // strings for the time being. Further investigation is required. // - // When reading the language files, the STR_XXXX part is read and XXXX becomes the string id number. Everything after the colon - // and before the new line will be saved as the string. Tokens are written with inside curly braces {TOKEN}. - // Use # at the beginning of a line to leave a comment. + // When reading the language files, the STR_XXXX part is read and XXXX becomes the string id number. Everything after the + // colon and before the new line will be saved as the string. Tokens are written with inside curly braces {TOKEN}. Use # at + // the beginning of a line to leave a comment. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// static bool IsWhitespace(codepoint_t codepoint) @@ -282,7 +282,7 @@ private: return codepoint == '\r' || codepoint == '\n'; } - static void SkipWhitespace(IStringReader * reader) + static void SkipWhitespace(IStringReader* reader) { codepoint_t codepoint; while (reader->TryPeek(&codepoint)) @@ -298,7 +298,7 @@ private: } } - static void SkipNewLine(IStringReader * reader) + static void SkipNewLine(IStringReader* reader) { codepoint_t codepoint; while (reader->TryPeek(&codepoint)) @@ -314,10 +314,11 @@ private: } } - static void SkipToEndOfLine(IStringReader * reader) + static void SkipToEndOfLine(IStringReader* reader) { codepoint_t codepoint; - while (reader->TryPeek(&codepoint)) { + while (reader->TryPeek(&codepoint)) + { if (codepoint != '\r' && codepoint != '\n') { reader->Skip(); @@ -329,36 +330,37 @@ private: } } - void ParseLine(IStringReader *reader) + void ParseLine(IStringReader* reader) { SkipWhitespace(reader); codepoint_t codepoint; if (reader->TryPeek(&codepoint)) { - switch (codepoint) { - case '#': - SkipToEndOfLine(reader); - break; - case '[': - ParseGroupObject(reader); - break; - case '<': - ParseGroupScenario(reader); - break; - case '\r': - case '\n': - break; - default: - ParseString(reader); - break; + switch (codepoint) + { + case '#': + SkipToEndOfLine(reader); + break; + case '[': + ParseGroupObject(reader); + break; + case '<': + ParseGroupScenario(reader); + break; + case '\r': + case '\n': + break; + default: + ParseString(reader); + break; } SkipToEndOfLine(reader); SkipNewLine(reader); } } - void ParseGroupObject(IStringReader * reader) + void ParseGroupObject(IStringReader* reader) { auto sb = StringBuilder(); codepoint_t codepoint; @@ -370,7 +372,8 @@ private: bool closedCorrectly = false; while (reader->TryPeek(&codepoint)) { - if (IsNewLine(codepoint)) break; + if (IsNewLine(codepoint)) + break; reader->Skip(); if (codepoint == ']') @@ -407,7 +410,7 @@ private: } } - void ParseGroupScenario(IStringReader * reader) + void ParseGroupScenario(IStringReader* reader) { auto sb = StringBuilder(); codepoint_t codepoint; @@ -419,7 +422,8 @@ private: bool closedCorrectly = false; while (reader->TryPeek(&codepoint)) { - if (IsNewLine(codepoint)) break; + if (IsNewLine(codepoint)) + break; reader->Skip(); if (codepoint == '>') @@ -449,7 +453,7 @@ private: } } - void ParseString(IStringReader *reader) + void ParseString(IStringReader* reader) { auto sb = StringBuilder(); codepoint_t codepoint; @@ -484,7 +488,7 @@ private: reader->Skip(); // Validate identifier - const utf8 * identifier = sb.GetBuffer(); + const utf8* identifier = sb.GetBuffer(); int32_t stringId; if (_currentGroup.empty()) @@ -497,14 +501,33 @@ private: } else { - if (String::Equals(identifier, "STR_NAME")) { stringId = 0; } - else if (String::Equals(identifier, "STR_DESC")) { stringId = 1; } - else if (String::Equals(identifier, "STR_CPTY")) { stringId = 2; } + if (String::Equals(identifier, "STR_NAME")) + { + stringId = 0; + } + else if (String::Equals(identifier, "STR_DESC")) + { + stringId = 1; + } + else if (String::Equals(identifier, "STR_CPTY")) + { + stringId = 2; + } - else if (String::Equals(identifier, "STR_SCNR")) { stringId = 0; } - else if (String::Equals(identifier, "STR_PARK")) { stringId = 1; } - else if (String::Equals(identifier, "STR_DTLS")) { stringId = 2; } - else { + else if (String::Equals(identifier, "STR_SCNR")) + { + stringId = 0; + } + else if (String::Equals(identifier, "STR_PARK")) + { + stringId = 1; + } + else if (String::Equals(identifier, "STR_DTLS")) + { + stringId = 2; + } + else + { // Ignore line entirely return; } @@ -565,7 +588,7 @@ private: } } - bool ParseToken(IStringReader * reader, uint32_t * token, bool * isByte) + bool ParseToken(IStringReader* reader, uint32_t* token, bool* isByte) { auto sb = StringBuilder(); codepoint_t codepoint; @@ -575,17 +598,20 @@ private: while (reader->TryPeek(&codepoint)) { - if (IsNewLine(codepoint)) return false; - if (IsWhitespace(codepoint)) return false; + if (IsNewLine(codepoint)) + return false; + if (IsWhitespace(codepoint)) + return false; reader->Skip(); - if (codepoint == '}') break; + if (codepoint == '}') + break; sb.Append(codepoint); } - const utf8 * tokenName = sb.GetBuffer(); + const utf8* tokenName = sb.GetBuffer(); *token = format_get_code(tokenName); *isByte = false; @@ -606,13 +632,13 @@ private: namespace LanguagePackFactory { - ILanguagePack * FromFile(uint16_t id, const utf8 * path) + ILanguagePack* FromFile(uint16_t id, const utf8* path) { auto languagePack = LanguagePack::FromFile(id, path); return languagePack; } - ILanguagePack * FromText(uint16_t id, const utf8 * text) + ILanguagePack* FromText(uint16_t id, const utf8* text) { auto languagePack = LanguagePack::FromText(id, text); return languagePack; diff --git a/src/openrct2/localisation/LanguagePack.h b/src/openrct2/localisation/LanguagePack.h index 3aa51e2589..9a9e73439e 100644 --- a/src/openrct2/localisation/LanguagePack.h +++ b/src/openrct2/localisation/LanguagePack.h @@ -9,9 +9,10 @@ #pragma once -#include #include "../common.h" +#include + interface ILanguagePack { virtual ~ILanguagePack() = default; @@ -19,15 +20,15 @@ interface ILanguagePack virtual uint16_t GetId() const abstract; virtual uint32_t GetCount() const abstract; - virtual void RemoveString(rct_string_id stringId) abstract; - virtual void SetString(rct_string_id stringId, const std::string &str) abstract; - virtual const utf8 * GetString(rct_string_id stringId) const abstract; - virtual rct_string_id GetObjectOverrideStringId(const char * objectIdentifier, uint8_t index) abstract; - virtual rct_string_id GetScenarioOverrideStringId(const utf8 * scenarioFilename, uint8_t index) abstract; + virtual void RemoveString(rct_string_id stringId) abstract; + virtual void SetString(rct_string_id stringId, const std::string& str) abstract; + virtual const utf8* GetString(rct_string_id stringId) const abstract; + virtual rct_string_id GetObjectOverrideStringId(const char* objectIdentifier, uint8_t index) abstract; + virtual rct_string_id GetScenarioOverrideStringId(const utf8* scenarioFilename, uint8_t index) abstract; }; namespace LanguagePackFactory { - ILanguagePack * FromFile(uint16_t id, const utf8 * path); - ILanguagePack * FromText(uint16_t id, const utf8 * text); -} + ILanguagePack* FromFile(uint16_t id, const utf8* path); + ILanguagePack* FromText(uint16_t id, const utf8* text); +} // namespace LanguagePackFactory diff --git a/src/openrct2/localisation/Localisation.Date.cpp b/src/openrct2/localisation/Localisation.Date.cpp index 9df60d68a9..ef2ab07f67 100644 --- a/src/openrct2/localisation/Localisation.Date.cpp +++ b/src/openrct2/localisation/Localisation.Date.cpp @@ -7,12 +7,13 @@ * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ -#include #include "../Game.h" #include "../core/Math.hpp" #include "Date.h" #include "StringIds.h" +#include + uint16_t gDateMonthTicks; uint16_t gDateMonthsElapsed; @@ -89,7 +90,7 @@ void date_update() void date_update_real_time_of_day() { time_t timestamp = time(nullptr); - struct tm *now = localtime(×tamp); + struct tm* now = localtime(×tamp); gRealTimeOfDay.second = now->tm_sec; gRealTimeOfDay.minute = now->tm_min; diff --git a/src/openrct2/localisation/Localisation.cpp b/src/openrct2/localisation/Localisation.cpp index 2d416727ef..56f2660bdf 100644 --- a/src/openrct2/localisation/Localisation.cpp +++ b/src/openrct2/localisation/Localisation.cpp @@ -7,42 +7,42 @@ * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ -#include #include +#include #include #ifdef _WIN32 #include #elif defined(__ANDROID__) -#include #include +#include #else -#include #include +#include #endif // _WIN32 +#include "../Game.h" #include "../common.h" #include "../config/Config.h" #include "../core/Guard.hpp" #include "../core/Math.hpp" #include "../core/String.hpp" #include "../core/Util.hpp" -#include "Date.h" -#include "../Game.h" -#include "Localisation.h" #include "../management/Marketing.h" #include "../ride/Ride.h" #include "../util/Util.h" +#include "Date.h" +#include "Localisation.h" char gCommonStringFormatBuffer[256]; uint8_t gCommonFormatArgs[80]; uint8_t gMapTooltipFormatArgs[40]; #ifdef DEBUG - // Set to true before a string format call to see details of the formatting. - // Set to false after the call. - bool gDebugStringFormatting = false; +// Set to true before a string format call to see details of the formatting. +// Set to false after the call. +bool gDebugStringFormatting = false; #endif // clang-format off @@ -330,24 +330,54 @@ const rct_string_id DateGameShortMonthNames[MONTH_COUNT] = { }; // clang-format on -#define format_push_char_safe(C) { *(*dest)++ = (C); --(*size); } -#define format_handle_overflow(X) if ((*size) <= (X)) { *(*dest) = '\0'; (*size) = 0; return; } -#define format_push_char(C) { format_handle_overflow(1); format_push_char_safe(C); } +#define format_push_char_safe(C) \ + { \ + *(*dest)++ = (C); \ + --(*size); \ + } +#define format_handle_overflow(X) \ + if ((*size) <= (X)) \ + { \ + *(*dest) = '\0'; \ + (*size) = 0; \ + return; \ + } +#define format_push_char(C) \ + { \ + format_handle_overflow(1); \ + format_push_char_safe(C); \ + } -#define format_push_wrap(C) { *ncur = (C); if (ncur == (*dest)) ncur = nbegin; } -#define reverse_string() while (nbegin < nend) { tmp = *nbegin; *nbegin++ = *nend; *nend-- = tmp; } +#define format_push_wrap(C) \ + { \ + *ncur = (C); \ + if (ncur == (*dest)) \ + ncur = nbegin; \ + } +#define reverse_string() \ + while (nbegin < nend) \ + { \ + tmp = *nbegin; \ + *nbegin++ = *nend; \ + *nend-- = tmp; \ + } -static void format_string_part_from_raw(char **dest, size_t *size, const char *src, char **args); -static void format_string_part(char **dest, size_t *size, rct_string_id format, char **args); +static void format_string_part_from_raw(char** dest, size_t* size, const char* src, char** args); +static void format_string_part(char** dest, size_t* size, rct_string_id format, char** args); -static void format_append_string(char **dest, size_t *size, const utf8 *string) { - if ((*size) == 0) return; +static void format_append_string(char** dest, size_t* size, const utf8* string) +{ + if ((*size) == 0) + return; size_t length = strlen(string); - if (length < (*size)) { + if (length < (*size)) + { memcpy((*dest), string, length); (*dest) += length; (*size) -= length; - } else { + } + else + { memcpy((*dest), string, (*size) - 1); (*dest) += (*size) - 1; *(*dest)++ = '\0'; @@ -355,14 +385,19 @@ static void format_append_string(char **dest, size_t *size, const utf8 *string) } } -static void format_append_string_n(char **dest, size_t *size, const utf8 *string, size_t maxlen) { - if ((*size) == 0) return; +static void format_append_string_n(char** dest, size_t* size, const utf8* string, size_t maxlen) +{ + if ((*size) == 0) + return; size_t length = std::min(maxlen, strlen(string)); - if (length < (*size)) { + if (length < (*size)) + { memcpy((*dest), string, length); (*dest) += length; (*size) -= length; - } else { + } + else + { memcpy((*dest), string, (*size) - 1); (*dest) += (*size) - 1; *(*dest)++ = '\0'; @@ -370,21 +405,24 @@ static void format_append_string_n(char **dest, size_t *size, const utf8 *string } } -static void format_integer(char **dest, size_t *size, int64_t value) +static void format_integer(char** dest, size_t* size, int64_t value) { int32_t digit; char *nbegin, *nend, *ncur; char tmp; - if ((*size) == 0) return; + if ((*size) == 0) + return; // Negative sign - if (value < 0) { + if (value < 0) + { format_push_char('-'); value = -value; } - if (value == 0) { + if (value == 0) + { format_push_char('0'); return; } @@ -392,17 +430,20 @@ static void format_integer(char **dest, size_t *size, int64_t value) nbegin = (*dest); // Right to left - while (value > 0 && (*size) > 1) { + while (value > 0 && (*size) > 1) + { digit = value % 10; value /= 10; format_push_char_safe('0' + digit); } - if (value > 0) { + if (value > 0) + { ncur = nbegin; - while (value > 0) { + while (value > 0) + { digit = value % 10; value /= 10; @@ -419,30 +460,35 @@ static void format_integer(char **dest, size_t *size, int64_t value) reverse_string(); format_push_char_safe('\0'); // Truncate overflowed string - } else { + } + else + { // Reverse string nend = (*dest) - 1; reverse_string(); } } -static void format_comma_separated_integer(char **dest, size_t *size, int64_t value) +static void format_comma_separated_integer(char** dest, size_t* size, int64_t value) { int32_t digit, groupIndex; char *nbegin, *nend, *ncur; char tmp; - const char *commaMark = language_get_string(STR_LOCALE_THOUSANDS_SEPARATOR); - const char *ch = nullptr; + const char* commaMark = language_get_string(STR_LOCALE_THOUSANDS_SEPARATOR); + const char* ch = nullptr; - if ((*size) == 0) return; + if ((*size) == 0) + return; // Negative sign - if (value < 0) { + if (value < 0) + { format_push_char('-'); value = -value; } - if (value == 0) { + if (value == 0) + { format_push_char('0'); return; } @@ -451,17 +497,23 @@ static void format_comma_separated_integer(char **dest, size_t *size, int64_t va // Groups of three digits, right to left groupIndex = 0; - while (value > 0 && (*size) > 1) { + while (value > 0 && (*size) > 1) + { // Append group separator - if (groupIndex == 3) { + if (groupIndex == 3) + { groupIndex = 0; ch = commaMark; } - if (ch != nullptr ) { + if (ch != nullptr) + { format_push_char_safe(*ch++); - if (*ch == '\0') ch = nullptr; - } else { + if (*ch == '\0') + ch = nullptr; + } + else + { digit = value % 10; value /= 10; @@ -470,20 +522,27 @@ static void format_comma_separated_integer(char **dest, size_t *size, int64_t va } } - if (value > 0) { + if (value > 0) + { ncur = nbegin; - while (value > 0) { + while (value > 0) + { // Append group separator - if (groupIndex == 3) { + if (groupIndex == 3) + { groupIndex = 0; ch = commaMark; } - if (ch != nullptr ) { + if (ch != nullptr) + { format_push_wrap(*ch++); - if (*ch == '\0') ch = nullptr; - } else { + if (*ch == '\0') + ch = nullptr; + } + else + { digit = value % 10; value /= 10; @@ -502,27 +561,31 @@ static void format_comma_separated_integer(char **dest, size_t *size, int64_t va reverse_string(); format_push_char_safe('\0'); // Truncate overflowed string - } else { + } + else + { // Reverse string nend = *dest - 1; reverse_string(); } } -static void format_comma_separated_fixed_1dp(char **dest, size_t *size, int64_t value) +static void format_comma_separated_fixed_1dp(char** dest, size_t* size, int64_t value) { int32_t digit, groupIndex; char *nbegin, *nend, *ncur; char tmp; - const char *commaMark = language_get_string(STR_LOCALE_THOUSANDS_SEPARATOR); - const char *decimalMark = language_get_string(STR_LOCALE_DECIMAL_POINT); - const char *ch = nullptr; + const char* commaMark = language_get_string(STR_LOCALE_THOUSANDS_SEPARATOR); + const char* decimalMark = language_get_string(STR_LOCALE_DECIMAL_POINT); + const char* ch = nullptr; int32_t zeroNeeded = 1; - if ((*size) == 0) return; + if ((*size) == 0) + return; // Negative sign - if (value < 0) { + if (value < 0) + { format_push_char('-'); value = -value; } @@ -532,7 +595,8 @@ static void format_comma_separated_fixed_1dp(char **dest, size_t *size, int64_t // In the case of buffers this small, // all of this would be truncated anyways. format_handle_overflow(1); - if ((*size) > 2) { + if ((*size) > 2) + { // One decimal place digit = value % 10; format_push_char_safe('0' + digit); @@ -542,17 +606,23 @@ static void format_comma_separated_fixed_1dp(char **dest, size_t *size, int64_t value /= 10; groupIndex = 0; - while ((zeroNeeded || value > 0) && (*size) > 1) { + while ((zeroNeeded || value > 0) && (*size) > 1) + { // Append group separator - if (groupIndex == 3) { + if (groupIndex == 3) + { groupIndex = 0; ch = commaMark; } - if (ch != nullptr ) { + if (ch != nullptr) + { format_push_char_safe(*ch++); - if (*ch == '\0') ch = nullptr; - } else { + if (*ch == '\0') + ch = nullptr; + } + else + { zeroNeeded = 0; digit = value % 10; value /= 10; @@ -562,20 +632,27 @@ static void format_comma_separated_fixed_1dp(char **dest, size_t *size, int64_t } } - if (zeroNeeded || value > 0) { + if (zeroNeeded || value > 0) + { ncur = nbegin; - while (zeroNeeded || value > 0) { + while (zeroNeeded || value > 0) + { // Append group separator - if (groupIndex == 3) { + if (groupIndex == 3) + { groupIndex = 0; ch = commaMark; } - if (ch != nullptr ) { + if (ch != nullptr) + { format_push_wrap(*ch++); - if (*ch == '\0') ch = nullptr; - } else { + if (*ch == '\0') + ch = nullptr; + } + else + { zeroNeeded = 0; digit = value % 10; value /= 10; @@ -595,27 +672,31 @@ static void format_comma_separated_fixed_1dp(char **dest, size_t *size, int64_t reverse_string(); format_push_char_safe('\0'); // Truncate overflowed string - } else { + } + else + { // Reverse string nend = *dest - 1; reverse_string(); } } -static void format_comma_separated_fixed_2dp(char **dest, size_t *size, int64_t value) +static void format_comma_separated_fixed_2dp(char** dest, size_t* size, int64_t value) { int32_t digit, groupIndex; char *nbegin, *nend, *ncur; char tmp; - const char *commaMark = language_get_string(STR_LOCALE_THOUSANDS_SEPARATOR); - const char *decimalMark = language_get_string(STR_LOCALE_DECIMAL_POINT); - const char *ch = nullptr; + const char* commaMark = language_get_string(STR_LOCALE_THOUSANDS_SEPARATOR); + const char* decimalMark = language_get_string(STR_LOCALE_DECIMAL_POINT); + const char* ch = nullptr; int32_t zeroNeeded = 1; - if ((*size) == 0) return; + if ((*size) == 0) + return; // Negative sign - if (value < 0) { + if (value < 0) + { format_push_char('-'); value = -value; } @@ -625,9 +706,12 @@ static void format_comma_separated_fixed_2dp(char **dest, size_t *size, int64_t // In the case of buffers this small, // all of this would be truncated anyways. format_handle_overflow(1); - if ((*size) < 3) { + if ((*size) < 3) + { value /= 100; - } else { + } + else + { // Two decimal places digit = value % 10; value /= 10; @@ -641,17 +725,23 @@ static void format_comma_separated_fixed_2dp(char **dest, size_t *size, int64_t } groupIndex = 0; - while ((zeroNeeded || value > 0) && (*size) > 1) { + while ((zeroNeeded || value > 0) && (*size) > 1) + { // Append group separator - if (groupIndex == 3) { + if (groupIndex == 3) + { groupIndex = 0; ch = commaMark; } - if (ch != nullptr ) { + if (ch != nullptr) + { format_push_char_safe(*ch++); - if (*ch == '\0') ch = nullptr; - } else { + if (*ch == '\0') + ch = nullptr; + } + else + { zeroNeeded = 0; digit = value % 10; value /= 10; @@ -661,20 +751,27 @@ static void format_comma_separated_fixed_2dp(char **dest, size_t *size, int64_t } } - if (zeroNeeded || value > 0) { + if (zeroNeeded || value > 0) + { ncur = nbegin; - while (zeroNeeded || value > 0) { + while (zeroNeeded || value > 0) + { // Append group separator - if (groupIndex == 3) { + if (groupIndex == 3) + { groupIndex = 0; ch = commaMark; } - if (ch != nullptr ) { + if (ch != nullptr) + { format_push_wrap(*ch++); - if (*ch == '\0') ch = nullptr; - } else { + if (*ch == '\0') + ch = nullptr; + } + else + { zeroNeeded = 0; digit = value % 10; value /= 10; @@ -694,23 +791,27 @@ static void format_comma_separated_fixed_2dp(char **dest, size_t *size, int64_t reverse_string(); format_push_char_safe('\0'); // Truncate overflowed string - } else { + } + else + { // Reverse string nend = *dest - 1; reverse_string(); } } -static void format_currency(char **dest, size_t *size, int64_t value) +static void format_currency(char** dest, size_t* size, int64_t value) { - if ((*size) == 0) return; + if ((*size) == 0) + return; - const currency_descriptor *currencyDesc = &CurrencyDescriptors[gConfigGeneral.currency_format]; + const currency_descriptor* currencyDesc = &CurrencyDescriptors[gConfigGeneral.currency_format]; value *= currencyDesc->rate; // Negative sign - if (value < 0) { + if (value < 0) + { format_push_char('-'); value = -value; } @@ -719,9 +820,10 @@ static void format_currency(char **dest, size_t *size, int64_t value) value = (value + 99) / 100; // Currency symbol - const utf8 *symbol = currencyDesc->symbol_unicode; + const utf8* symbol = currencyDesc->symbol_unicode; uint8_t affix = currencyDesc->affix_unicode; - if (!font_supports_string(symbol, FONT_SIZE_MEDIUM)) { + if (!font_supports_string(symbol, FONT_SIZE_MEDIUM)) + { symbol = currencyDesc->symbol_ascii; affix = currencyDesc->affix_ascii; } @@ -729,35 +831,40 @@ static void format_currency(char **dest, size_t *size, int64_t value) // Prefix if (affix == CURRENCY_PREFIX) format_append_string(dest, size, symbol); - if ((*size) == 0) return; + if ((*size) == 0) + return; format_comma_separated_integer(dest, size, value); - if ((*size) == 0) return; + if ((*size) == 0) + return; // Currency symbol suffix if (affix == CURRENCY_SUFFIX) format_append_string(dest, size, symbol); } -static void format_currency_2dp(char **dest, size_t *size, int64_t value) +static void format_currency_2dp(char** dest, size_t* size, int64_t value) { - if ((*size) == 0) return; + if ((*size) == 0) + return; - const currency_descriptor *currencyDesc = &CurrencyDescriptors[gConfigGeneral.currency_format]; + const currency_descriptor* currencyDesc = &CurrencyDescriptors[gConfigGeneral.currency_format]; int32_t rate = currencyDesc->rate; value *= rate; // Negative sign - if (value < 0) { + if (value < 0) + { format_push_char('-'); value = -value; } // Currency symbol - const utf8 *symbol = currencyDesc->symbol_unicode; + const utf8* symbol = currencyDesc->symbol_unicode; uint8_t affix = currencyDesc->affix_unicode; - if (!font_supports_string(symbol, FONT_SIZE_MEDIUM)) { + if (!font_supports_string(symbol, FONT_SIZE_MEDIUM)) + { symbol = currencyDesc->symbol_ascii; affix = currencyDesc->affix_ascii; } @@ -765,80 +872,89 @@ static void format_currency_2dp(char **dest, size_t *size, int64_t value) // Prefix if (affix == CURRENCY_PREFIX) format_append_string(dest, size, symbol); - if ((*size) == 0) return; + if ((*size) == 0) + return; // Drop the pennies for "large" currencies - if (rate >= 100) { + if (rate >= 100) + { format_comma_separated_integer(dest, size, value / 100); - } else { + } + else + { format_comma_separated_fixed_2dp(dest, size, value); } - if ((*size) == 0) return; + if ((*size) == 0) + return; // Currency symbol suffix if (affix == CURRENCY_SUFFIX) format_append_string(dest, size, symbol); } -static void format_date(char **dest, size_t *size, uint16_t value) +static void format_date(char** dest, size_t* size, uint16_t value) { uint16_t args[] = { static_cast(date_get_month(value)), static_cast(date_get_year(value) + 1) }; - uint16_t *argsRef = args; + uint16_t* argsRef = args; format_string_part(dest, size, STR_DATE_FORMAT_MY, (char**)&argsRef); } -static void format_length(char **dest, size_t *size, int16_t value) +static void format_length(char** dest, size_t* size, int16_t value) { rct_string_id stringId = STR_UNIT_SUFFIX_METRES; - if (gConfigGeneral.measurement_format == MEASUREMENT_FORMAT_IMPERIAL) { + if (gConfigGeneral.measurement_format == MEASUREMENT_FORMAT_IMPERIAL) + { value = metres_to_feet(value); stringId = STR_UNIT_SUFFIX_FEET; } - int16_t *argRef = &value; + int16_t* argRef = &value; format_string_part(dest, size, stringId, (char**)&argRef); } -static void format_velocity(char **dest, size_t *size, uint16_t value) +static void format_velocity(char** dest, size_t* size, uint16_t value) { rct_string_id stringId; - switch (gConfigGeneral.measurement_format) { - default: - stringId = STR_UNIT_SUFFIX_MILES_PER_HOUR; - break; - case MEASUREMENT_FORMAT_METRIC: - value = mph_to_kmph(value); - stringId = STR_UNIT_SUFFIX_KILOMETRES_PER_HOUR; - break; - case MEASUREMENT_FORMAT_SI: - value = mph_to_dmps(value); - stringId = STR_UNIT_SUFFIX_METRES_PER_SECOND; - break; + switch (gConfigGeneral.measurement_format) + { + default: + stringId = STR_UNIT_SUFFIX_MILES_PER_HOUR; + break; + case MEASUREMENT_FORMAT_METRIC: + value = mph_to_kmph(value); + stringId = STR_UNIT_SUFFIX_KILOMETRES_PER_HOUR; + break; + case MEASUREMENT_FORMAT_SI: + value = mph_to_dmps(value); + stringId = STR_UNIT_SUFFIX_METRES_PER_SECOND; + break; } - uint16_t *argRef = &value; + uint16_t* argRef = &value; format_string_part(dest, size, stringId, (char**)&argRef); } static constexpr const rct_string_id DurationFormats[][2] = { - {STR_DURATION_SEC, STR_DURATION_SECS}, - {STR_DURATION_MIN_SEC, STR_DURATION_MIN_SECS}, - {STR_DURATION_MINS_SEC, STR_DURATION_MINS_SECS}, + { STR_DURATION_SEC, STR_DURATION_SECS }, + { STR_DURATION_MIN_SEC, STR_DURATION_MIN_SECS }, + { STR_DURATION_MINS_SEC, STR_DURATION_MINS_SECS }, }; -static void format_duration(char **dest, size_t *size, uint16_t value) +static void format_duration(char** dest, size_t* size, uint16_t value) { uint16_t minutes = value / 60; uint16_t seconds = value % 60; uint16_t args[] = { minutes, seconds }; - uint16_t *argsRef = &args[1]; + uint16_t* argsRef = &args[1]; int32_t minuteIndex = 0; - if (minutes > 0) { + if (minutes > 0) + { minuteIndex = 1; - if (minutes != 1) { + if (minutes != 1) + { minuteIndex = 2; } @@ -846,7 +962,8 @@ static void format_duration(char **dest, size_t *size, uint16_t value) } int32_t secondsIndex = 0; - if (seconds != 1) { + if (seconds != 1) + { secondsIndex = 1; } @@ -856,22 +973,24 @@ static void format_duration(char **dest, size_t *size, uint16_t value) } static constexpr const rct_string_id RealtimeFormats[][2] = { - {STR_REALTIME_MIN, STR_REALTIME_MINS}, - {STR_REALTIME_HOUR_MIN, STR_REALTIME_HOUR_MINS}, - {STR_REALTIME_HOURS_MIN, STR_REALTIME_HOURS_MINS}, + { STR_REALTIME_MIN, STR_REALTIME_MINS }, + { STR_REALTIME_HOUR_MIN, STR_REALTIME_HOUR_MINS }, + { STR_REALTIME_HOURS_MIN, STR_REALTIME_HOURS_MINS }, }; -static void format_realtime(char **dest, size_t *size, uint16_t value) +static void format_realtime(char** dest, size_t* size, uint16_t value) { uint16_t hours = value / 60; uint16_t minutes = value % 60; uint16_t args[] = { hours, minutes }; - uint16_t *argsRef = &args[1]; + uint16_t* argsRef = &args[1]; int32_t hourIndex = 0; - if (hours > 0) { + if (hours > 0) + { hourIndex = 1; - if (hours != 1) { + if (hours != 1) + { hourIndex = 2; } @@ -879,7 +998,8 @@ static void format_realtime(char **dest, size_t *size, uint16_t value) } int32_t minuteIndex = 0; - if (minutes != 1) { + if (minutes != 1) + { minuteIndex = 1; } @@ -888,180 +1008,195 @@ static void format_realtime(char **dest, size_t *size, uint16_t value) format_string_part(dest, size, stringId, (char**)&argsRef); } -static void format_string_code(uint32_t format_code, char **dest, size_t *size, char **args) +static void format_string_code(uint32_t format_code, char** dest, size_t* size, char** args) { intptr_t value; - if ((*size) == 0) return; + if ((*size) == 0) + return; #ifdef DEBUG - if (gDebugStringFormatting) { + if (gDebugStringFormatting) + { printf("format_string_code(\"%s\")\n", format_get_token(format_code)); } #endif - switch (format_code) { - case FORMAT_COMMA32: - // Pop argument - value = *((int32_t*)*args); - *args += 4; + switch (format_code) + { + case FORMAT_COMMA32: + // Pop argument + value = *((int32_t*)*args); + *args += 4; - format_comma_separated_integer(dest, size, value); - break; - case FORMAT_INT32: - // Pop argument - value = *((int32_t*)*args); - *args += 4; + format_comma_separated_integer(dest, size, value); + break; + case FORMAT_INT32: + // Pop argument + value = *((int32_t*)*args); + *args += 4; - format_integer(dest, size, value); - break; - case FORMAT_COMMA2DP32: - // Pop argument - value = *((int32_t*)*args); - *args += 4; + format_integer(dest, size, value); + break; + case FORMAT_COMMA2DP32: + // Pop argument + value = *((int32_t*)*args); + *args += 4; - format_comma_separated_fixed_2dp(dest, size, value); - break; - case FORMAT_COMMA1DP16: - // Pop argument - value = *((int16_t*)*args); - *args += 2; + format_comma_separated_fixed_2dp(dest, size, value); + break; + case FORMAT_COMMA1DP16: + // Pop argument + value = *((int16_t*)*args); + *args += 2; - format_comma_separated_fixed_1dp(dest, size, value); - break; - case FORMAT_COMMA16: - // Pop argument - value = *((int16_t*)*args); - *args += 2; + format_comma_separated_fixed_1dp(dest, size, value); + break; + case FORMAT_COMMA16: + // Pop argument + value = *((int16_t*)*args); + *args += 2; - format_comma_separated_integer(dest, size, value); - break; - case FORMAT_UINT16: - // Pop argument - value = *((uint16_t*)*args); - *args += 2; + format_comma_separated_integer(dest, size, value); + break; + case FORMAT_UINT16: + // Pop argument + value = *((uint16_t*)*args); + *args += 2; - format_integer(dest, size, value); - break; - case FORMAT_CURRENCY2DP: - // Pop argument - value = *((int32_t*)*args); - *args += 4; + format_integer(dest, size, value); + break; + case FORMAT_CURRENCY2DP: + // Pop argument + value = *((int32_t*)*args); + *args += 4; - format_currency_2dp(dest, size, value); - break; - case FORMAT_CURRENCY: - // Pop argument - value = *((int32_t*)*args); - *args += 4; + format_currency_2dp(dest, size, value); + break; + case FORMAT_CURRENCY: + // Pop argument + value = *((int32_t*)*args); + *args += 4; - format_currency(dest, size, value); - break; - case FORMAT_STRINGID: - case FORMAT_STRINGID2: - // Pop argument - value = *((uint16_t*)*args); - *args += 2; + format_currency(dest, size, value); + break; + case FORMAT_STRINGID: + case FORMAT_STRINGID2: + // Pop argument + value = *((uint16_t*)*args); + *args += 2; - format_string_part(dest, size, (rct_string_id)value, args); - break; - case FORMAT_STRING: - // Pop argument - value = *((uintptr_t*)*args); - *args += sizeof(uintptr_t); + format_string_part(dest, size, (rct_string_id)value, args); + break; + case FORMAT_STRING: + // Pop argument + value = *((uintptr_t*)*args); + *args += sizeof(uintptr_t); - if (value != 0) - format_append_string(dest, size, (char*)value); - break; - case FORMAT_MONTHYEAR: - // Pop argument - value = *((uint16_t*)*args); - *args += 2; + if (value != 0) + format_append_string(dest, size, (char*)value); + break; + case FORMAT_MONTHYEAR: + // Pop argument + value = *((uint16_t*)*args); + *args += 2; - format_date(dest, size, (uint16_t)value); - break; - case FORMAT_MONTH: - // Pop argument - value = *((uint16_t*)*args); - *args += 2; + format_date(dest, size, (uint16_t)value); + break; + case FORMAT_MONTH: + // Pop argument + value = *((uint16_t*)*args); + *args += 2; - format_append_string(dest, size, language_get_string(DateGameMonthNames[date_get_month((int32_t)value)])); - break; - case FORMAT_VELOCITY: - // Pop argument - value = *((int16_t*)*args); - *args += 2; + format_append_string(dest, size, language_get_string(DateGameMonthNames[date_get_month((int32_t)value)])); + break; + case FORMAT_VELOCITY: + // Pop argument + value = *((int16_t*)*args); + *args += 2; - format_velocity(dest, size, (uint16_t)value); - break; - case FORMAT_POP16: - *args += 2; - break; - case FORMAT_PUSH16: - *args -= 2; - break; - case FORMAT_DURATION: - // Pop argument - value = *((uint16_t*)*args); - *args += 2; + format_velocity(dest, size, (uint16_t)value); + break; + case FORMAT_POP16: + *args += 2; + break; + case FORMAT_PUSH16: + *args -= 2; + break; + case FORMAT_DURATION: + // Pop argument + value = *((uint16_t*)*args); + *args += 2; - format_duration(dest, size, (uint16_t)value); - break; - case FORMAT_REALTIME: - // Pop argument - value = *((uint16_t*)*args); - *args += 2; + format_duration(dest, size, (uint16_t)value); + break; + case FORMAT_REALTIME: + // Pop argument + value = *((uint16_t*)*args); + *args += 2; - format_realtime(dest, size, (uint16_t)value); - break; - case FORMAT_LENGTH: - // Pop argument - value = *((int16_t*)*args); - *args += 2; + format_realtime(dest, size, (uint16_t)value); + break; + case FORMAT_LENGTH: + // Pop argument + value = *((int16_t*)*args); + *args += 2; - format_length(dest, size, (int16_t)value); - break; - case FORMAT_SPRITE: - // Pop argument - value = *((uint32_t*)*args); - *args += 4; + format_length(dest, size, (int16_t)value); + break; + case FORMAT_SPRITE: + // Pop argument + value = *((uint32_t*)*args); + *args += 4; - format_handle_overflow(1 + sizeof(uint32_t)); + format_handle_overflow(1 + sizeof(uint32_t)); - format_push_char_safe('\x17'); - *((uint32_t*)(*dest)) = (uint32_t)value; - (*dest) += sizeof(uint32_t); - (*size) -= sizeof(uint32_t); - break; + format_push_char_safe('\x17'); + *((uint32_t*)(*dest)) = (uint32_t)value; + (*dest) += sizeof(uint32_t); + (*size) -= sizeof(uint32_t); + break; } } -static void format_string_part_from_raw(utf8 **dest, size_t *size, const utf8 *src, char **args) +static void format_string_part_from_raw(utf8** dest, size_t* size, const utf8* src, char** args) { #ifdef DEBUG - if (gDebugStringFormatting) { + if (gDebugStringFormatting) + { printf("format_string_part_from_raw(\"%s\")\n", src); } #endif - while (*size > 1) { + while (*size > 1) + { uint32_t code = utf8_get_next(src, &src); - if (code < ' ') { - if (code == 0) { + if (code < ' ') + { + if (code == 0) + { break; - } else if (code <= 4) { + } + else if (code <= 4) + { format_handle_overflow(2); format_push_char_safe(code); format_push_char_safe(*src++); - } else if (code <= 16) { + } + else if (code <= 16) + { format_handle_overflow(1); format_push_char_safe(code); - } else if (code <= 22) { + } + else if (code <= 22) + { format_handle_overflow(3); format_push_char_safe(code); format_push_char_safe(*src++); format_push_char_safe(*src++); - } else { + } + else + { format_handle_overflow(5); format_push_char_safe(code); format_push_char_safe(*src++); @@ -1069,14 +1204,21 @@ static void format_string_part_from_raw(utf8 **dest, size_t *size, const utf8 *s format_push_char_safe(*src++); format_push_char_safe(*src++); } - } else if (code <= 'z') { + } + else if (code <= 'z') + { format_push_char(code); - } else if (code < FORMAT_COLOUR_CODE_START || code == FORMAT_COMMA1DP16) { + } + else if (code < FORMAT_COLOUR_CODE_START || code == FORMAT_COMMA1DP16) + { format_string_code(code, dest, size, args); - } else { + } + else + { size_t codepointLength = (size_t)utf8_get_codepoint_length(code); format_handle_overflow(codepointLength); - if (*size > codepointLength) { + if (*size > codepointLength) + { *dest = utf8_write_codepoint(*dest, code); *size -= codepointLength; } @@ -1084,17 +1226,23 @@ static void format_string_part_from_raw(utf8 **dest, size_t *size, const utf8 *s } } -static void format_string_part(utf8 **dest, size_t *size, rct_string_id format, char **args) +static void format_string_part(utf8** dest, size_t* size, rct_string_id format, char** args) { - if (format == STR_NONE) { - if (*size > 0) { + if (format == STR_NONE) + { + if (*size > 0) + { *(*dest) = '\0'; } - } else if (format < USER_STRING_START) { + } + else if (format < USER_STRING_START) + { // Language string - const utf8 * rawString = language_get_string(format); + const utf8* rawString = language_get_string(format); format_string_part_from_raw(dest, size, rawString, args); - } else if (format <= USER_STRING_END) { + } + else if (format <= USER_STRING_END) + { // Custom string format -= 0x8000; @@ -1103,20 +1251,26 @@ static void format_string_part(utf8 **dest, size_t *size, rct_string_id format, format &= ~0xC00; format_append_string_n(dest, size, gUserStrings[format], USER_STRING_MAX_LENGTH); - if ((*size) > 0) *(*dest) = '\0'; - } else if (format <= REAL_NAME_END) { + if ((*size) > 0) + *(*dest) = '\0'; + } + else if (format <= REAL_NAME_END) + { // Real name auto realNameIndex = format - REAL_NAME_START; format_append_string(dest, size, real_names[realNameIndex % Util::CountOf(real_names)]); - if ((*size) == 0) return; + if ((*size) == 0) + return; format_push_char(' '); format_push_char(real_name_initials[(realNameIndex >> 10) % Util::CountOf(real_name_initials)]); format_push_char('.'); *(*dest) = '\0'; *args += 4; - } else { + } + else + { // ? log_error("Localisation CALLPROC reached. Please contact a dev"); assert(false); @@ -1130,26 +1284,31 @@ static void format_string_part(utf8 **dest, size_t *size, rct_string_id format, * format (ax) * args (ecx) */ -void format_string(utf8 *dest, size_t size, rct_string_id format, void *args) +void format_string(utf8* dest, size_t size, rct_string_id format, void* args) { #ifdef DEBUG - if (gDebugStringFormatting) { + if (gDebugStringFormatting) + { printf("format_string(%hu)\n", format); } #endif - if (size == 0) { + if (size == 0) + { return; } - utf8 *end = dest; + utf8* end = dest; size_t left = size; format_string_part(&end, &left, format, (char**)&args); - if (left == 0) { + if (left == 0) + { // Replace last character with null terminator *(end - 1) = '\0'; log_warning("Truncating formatted string \"%s\" to %d bytes.", dest, size); - } else { + } + else + { // Null terminate *end = '\0'; } @@ -1160,26 +1319,31 @@ void format_string(utf8 *dest, size_t size, rct_string_id format, void *args) #endif } -void format_string_raw(utf8 *dest, size_t size, utf8 *src, void *args) +void format_string_raw(utf8* dest, size_t size, utf8* src, void* args) { #ifdef DEBUG - if (gDebugStringFormatting) { + if (gDebugStringFormatting) + { printf("format_string_raw(\"%s\")\n", src); } #endif - if (size == 0) { + if (size == 0) + { return; } - utf8 *end = dest; + utf8* end = dest; size_t left = size; format_string_part_from_raw(&end, &left, src, (char**)&args); - if (left == 0) { + if (left == 0) + { // Replace last character with null terminator *(end - 1) = '\0'; log_warning("Truncating formatted string \"%s\" to %d bytes.", dest, size); - } else { + } + else + { // Null terminate *end = '\0'; } @@ -1197,15 +1361,17 @@ void format_string_raw(utf8 *dest, size_t size, utf8 *src, void *args) * format (ax) * args (ecx) */ -void format_string_to_upper(utf8 *dest, size_t size, rct_string_id format, void *args) +void format_string_to_upper(utf8* dest, size_t size, rct_string_id format, void* args) { #ifdef DEBUG - if (gDebugStringFormatting) { + if (gDebugStringFormatting) + { printf("format_string_to_upper(%hu)\n", format); } #endif - if (size == 0) { + if (size == 0) + { return; } @@ -1213,7 +1379,8 @@ void format_string_to_upper(utf8 *dest, size_t size, rct_string_id format, void std::string upperString = String::ToUpper(dest); - if (upperString.size() + 1 >= size) { + if (upperString.size() + 1 >= size) + { upperString.resize(size - 1); dest[size - 1] = '\0'; log_warning("Truncating formatted string \"%s\" to %d bytes.", dest, size); @@ -1323,7 +1490,7 @@ money32 string_to_money(const char* string_to_monetise) * @param forceDecimals Show decimals, even if the amount does not have them. Will be ignored if the current exchange * rate is too big to have decimals. */ -void money_to_string(money32 amount, char * buffer_to_put_value_to, size_t buffer_len, bool forceDecimals) +void money_to_string(money32 amount, char* buffer_to_put_value_to, size_t buffer_len, bool forceDecimals) { if (amount == MONEY32_UNDEFINED) { @@ -1331,7 +1498,7 @@ void money_to_string(money32 amount, char * buffer_to_put_value_to, size_t buffe return; } - const currency_descriptor *currencyDesc = &CurrencyDescriptors[gConfigGeneral.currency_format]; + const currency_descriptor* currencyDesc = &CurrencyDescriptors[gConfigGeneral.currency_format]; int sign = amount >= 0 ? 1 : -1; int a = abs(amount) * currencyDesc->rate; diff --git a/src/openrct2/localisation/Localisation.h b/src/openrct2/localisation/Localisation.h index 217388818f..03c7aadb36 100644 --- a/src/openrct2/localisation/Localisation.h +++ b/src/openrct2/localisation/Localisation.h @@ -10,14 +10,14 @@ #ifndef LOCALISATION_H #define LOCALISATION_H -#include - +#include "../management/Marketing.h" #include "Currency.h" #include "Date.h" #include "FormatCodes.h" #include "Language.h" #include "StringIds.h" -#include "../management/Marketing.h" + +#include bool utf8_is_format_code(int32_t codepoint); bool utf8_is_colour_code(int32_t codepoint); @@ -25,21 +25,21 @@ bool utf8_should_use_sprite_for_codepoint(int32_t codepoint); int32_t utf8_get_format_code_arg_length(int32_t codepoint); void utf8_remove_formatting(utf8* string, bool allowColours); -void format_string(char *dest, size_t size, rct_string_id format, void *args); -void format_string_raw(char *dest, size_t size, char *src, void *args); -void format_string_to_upper(char *dest, size_t size, rct_string_id format, void *args); +void format_string(char* dest, size_t size, rct_string_id format, void* args); +void format_string_raw(char* dest, size_t size, char* src, void* args); +void format_string_to_upper(char* dest, size_t size, rct_string_id format, void* args); void generate_string_file(); -utf8 *get_string_end(const utf8 *text); -size_t get_string_size(const utf8 *text); -int32_t get_string_length(const utf8 *text); +utf8* get_string_end(const utf8* text); +size_t get_string_size(const utf8* text); +int32_t get_string_length(const utf8* text); // The maximum number of characters allowed for string/money conversions (anything above will risk integer overflow issues) #define MONEY_STRING_MAXLENGTH 14 money32 string_to_money(const char* string_to_monetise); -void money_to_string(money32 amount, char * buffer_to_put_value_to, size_t buffer_len, bool forceDecimals); +void money_to_string(money32 amount, char* buffer_to_put_value_to, size_t buffer_len, bool forceDecimals); void user_string_clear_all(); -rct_string_id user_string_allocate(int32_t base, const utf8 *text); +rct_string_id user_string_allocate(int32_t base, const utf8* text); void user_string_free(rct_string_id id); bool is_user_string_id(rct_string_id stringId); @@ -47,19 +47,20 @@ bool is_user_string_id(rct_string_id stringId); #define USER_STRING_MAX_LENGTH 32 #define USER_STRING_START 0x8000 -#define USER_STRING_END 0x8FFF -#define REAL_NAME_START 0xA000 -#define REAL_NAME_END 0xDFFF +#define USER_STRING_END 0x8FFF +#define REAL_NAME_START 0xA000 +#define REAL_NAME_END 0xDFFF // Constants used by user_string_allocate -enum { +enum +{ USER_STRING_HIGH_ID_NUMBER = 1 << 2, USER_STRING_DUPLICATION_PERMITTED = 1 << 7 }; // Real name data extern const char real_name_initials[16]; -extern const char *real_names[1024]; +extern const char* real_names[1024]; extern utf8 gUserStrings[MAX_USER_STRINGS][USER_STRING_MAX_LENGTH]; extern char gCommonStringFormatBuffer[256]; @@ -77,20 +78,25 @@ extern const rct_string_id DateDayNames[31]; extern const rct_string_id DateGameMonthNames[MONTH_COUNT]; extern const rct_string_id DateGameShortMonthNames[MONTH_COUNT]; -[[maybe_unused]] static inline void set_format_arg_body(uint8_t *args, size_t offset, uintptr_t value, size_t size) +[[maybe_unused]] static inline void set_format_arg_body(uint8_t* args, size_t offset, uintptr_t value, size_t size) { memcpy(args + offset, &value, size); } -#define set_format_arg(offset, type, value) \ - do { static_assert(sizeof(type) <= sizeof(uintptr_t), "Type too large"); \ - set_format_arg_body(gCommonFormatArgs, offset, (uintptr_t)(value), sizeof(type)); } while (false) +#define set_format_arg(offset, type, value) \ + do \ + { \ + static_assert(sizeof(type) <= sizeof(uintptr_t), "Type too large"); \ + set_format_arg_body(gCommonFormatArgs, offset, (uintptr_t)(value), sizeof(type)); \ + } while (false) -#define set_format_arg_on(args, offset, type, value) \ - set_format_arg_body(args, offset, (uintptr_t)(value), sizeof(type)) +#define set_format_arg_on(args, offset, type, value) set_format_arg_body(args, offset, (uintptr_t)(value), sizeof(type)) -#define set_map_tooltip_format_arg(offset, type, value) \ - do { static_assert(sizeof(type) <= sizeof(uintptr_t), "Type too large"); \ - set_format_arg_body(gMapTooltipFormatArgs, offset, (uintptr_t)(value), sizeof(type)); } while (false) +#define set_map_tooltip_format_arg(offset, type, value) \ + do \ + { \ + static_assert(sizeof(type) <= sizeof(uintptr_t), "Type too large"); \ + set_format_arg_body(gMapTooltipFormatArgs, offset, (uintptr_t)(value), sizeof(type)); \ + } while (false) #endif diff --git a/src/openrct2/localisation/LocalisationService.cpp b/src/openrct2/localisation/LocalisationService.cpp index 691caa7fa5..370d30562b 100644 --- a/src/openrct2/localisation/LocalisationService.cpp +++ b/src/openrct2/localisation/LocalisationService.cpp @@ -7,17 +7,19 @@ * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ -#include +#include "LocalisationService.h" + #include "../Context.h" +#include "../PlatformEnvironment.h" #include "../core/Path.hpp" #include "../interface/Fonts.h" #include "../object/ObjectManager.h" -#include "../PlatformEnvironment.h" #include "Language.h" #include "LanguagePack.h" -#include "LocalisationService.h" #include "StringIds.h" +#include + using namespace OpenRCT2; using namespace OpenRCT2::Localisation; @@ -27,7 +29,8 @@ static constexpr uint16_t MAX_OBJECT_CACHED_STRINGS = 2048; LocalisationService::LocalisationService(const std::shared_ptr& env) : _env(env) { - for (rct_string_id stringId = NONSTEX_BASE_STRING_ID + MAX_OBJECT_CACHED_STRINGS; stringId >= NONSTEX_BASE_STRING_ID; stringId--) + for (rct_string_id stringId = NONSTEX_BASE_STRING_ID + MAX_OBJECT_CACHED_STRINGS; stringId >= NONSTEX_BASE_STRING_ID; + stringId--) { _availableObjectStringIds.push(stringId); } @@ -38,9 +41,9 @@ LocalisationService::~LocalisationService() { } -const char * LocalisationService::GetString(rct_string_id id) const +const char* LocalisationService::GetString(rct_string_id id) const { - const char * result = nullptr; + const char* result = nullptr; if (id == STR_EMPTY) { result = ""; @@ -83,7 +86,8 @@ void LocalisationService::OpenLanguage(int32_t id, IObjectManager& objectManager if (id != LANGUAGE_ENGLISH_UK) { filename = GetLanguagePath(LANGUAGE_ENGLISH_UK); - _languageFallback = std::unique_ptr(LanguagePackFactory::FromFile(LANGUAGE_ENGLISH_UK, filename.c_str())); + _languageFallback + = std::unique_ptr(LanguagePackFactory::FromFile(LANGUAGE_ENGLISH_UK, filename.c_str())); } filename = GetLanguagePath(id); @@ -109,7 +113,8 @@ void LocalisationService::CloseLanguages() _currentLanguage = LANGUAGE_UNDEFINED; } -std::tuple LocalisationService::GetLocalisedScenarioStrings(const std::string& scenarioFilename) const +std::tuple + LocalisationService::GetLocalisedScenarioStrings(const std::string& scenarioFilename) const { auto result0 = _languageCurrent->GetScenarioOverrideStringId(scenarioFilename.c_str(), 0); auto result1 = _languageCurrent->GetScenarioOverrideStringId(scenarioFilename.c_str(), 1); @@ -117,7 +122,7 @@ std::tuple LocalisationService::Get return std::make_tuple(result0, result1, result2); } -rct_string_id LocalisationService::GetObjectOverrideStringId(const char * identifier, uint8_t index) const +rct_string_id LocalisationService::GetObjectOverrideStringId(const char* identifier, uint8_t index) const { if (_languageCurrent == nullptr) { diff --git a/src/openrct2/localisation/LocalisationService.h b/src/openrct2/localisation/LocalisationService.h index 3d2094b458..9e766e5173 100644 --- a/src/openrct2/localisation/LocalisationService.h +++ b/src/openrct2/localisation/LocalisationService.h @@ -9,11 +9,12 @@ #pragma once +#include "../common.h" + #include #include #include #include -#include "../common.h" interface ILanguagePack; interface IObjectManager; @@ -36,16 +37,26 @@ namespace OpenRCT2::Localisation std::stack _availableObjectStringIds; public: - int32_t GetCurrentLanguage() const { return _currentLanguage; } - bool UseTrueTypeFont() const { return _useTrueTypeFont; } - void UseTrueTypeFont(bool value) { _useTrueTypeFont = value; } + int32_t GetCurrentLanguage() const + { + return _currentLanguage; + } + bool UseTrueTypeFont() const + { + return _useTrueTypeFont; + } + void UseTrueTypeFont(bool value) + { + _useTrueTypeFont = value; + } LocalisationService(const std::shared_ptr& env); ~LocalisationService(); - const char * GetString(rct_string_id id) const; - std::tuple GetLocalisedScenarioStrings(const std::string& scenarioFilename) const; - rct_string_id GetObjectOverrideStringId(const char * identifier, uint8_t index) const; + const char* GetString(rct_string_id id) const; + std::tuple + GetLocalisedScenarioStrings(const std::string& scenarioFilename) const; + rct_string_id GetObjectOverrideStringId(const char* identifier, uint8_t index) const; std::string GetLanguagePath(uint32_t languageId) const; void OpenLanguage(int32_t id, IObjectManager& objectManager); @@ -53,7 +64,7 @@ namespace OpenRCT2::Localisation rct_string_id AllocateObjectString(const std::string& target); void FreeObjectString(rct_string_id stringId); }; -} +} // namespace OpenRCT2::Localisation // Legacy getters // TODO Remove usages of these and instead call via shared reference diff --git a/src/openrct2/localisation/StringIds.h b/src/openrct2/localisation/StringIds.h index 2b32baea3a..6d74bb8a3c 100644 --- a/src/openrct2/localisation/StringIds.h +++ b/src/openrct2/localisation/StringIds.h @@ -15,7 +15,8 @@ #define STR_NONE ((rct_string_id)-1) #define STR_VIEWPORT ((rct_string_id)-2) -enum { +enum +{ STR_EMPTY = 0, // STR_0001 :{STRINGID} {COMMA16} STR_RIDE_NAME_SPIRAL_ROLLER_COASTER = 2, @@ -250,8 +251,8 @@ enum { STR_MONTH_SHORT_OCT = 819, STR_MONTH_SHORT_NOV = 820, // Unused STR_MONTH_SHORT_DEC = 821, // Unused -// STR_0822 :Unable to access graphic data file -// STR_0823 :Missing or inaccessible data file + // STR_0822 :Unable to access graphic data file + // STR_0823 :Missing or inaccessible data file STR_CLOSE_X = 824, STR_CHOSEN_NAME_IN_USE_ALREADY = 825, STR_TOO_MANY_NAMES_DEFINED = 826, @@ -264,21 +265,21 @@ enum { STR_PAUSE_GAME_TIP = 833, STR_DISC_AND_GAME_OPTIONS_TIP = 834, STR_ERR_GAME_INITIALISATION_FAILED = 835, -// STR_0835 :Game initialisation failed -// STR_0836 :Unable to start game in a minimised state -// STR_0837 :Unable to initialise graphics system -// STR_0838 : + // STR_0835 :Game initialisation failed + // STR_0836 :Unable to start game in a minimised state + // STR_0837 :Unable to initialise graphics system + // STR_0838 : STR_RESOLUTION_X_BY_Y = 839, STR_ARG_16_RESOLUTION_X_BY_Y = 840, -// STR_0841 : -// STR_0842 : -// STR_0843 : -// STR_0844 : -// STR_0845 : -// STR_0846 : + // STR_0841 : + // STR_0842 : + // STR_0843 : + // STR_0844 : + // STR_0845 : + // STR_0846 : STR_ABOUT = 847, STR_ROLLERCOASTER_TYCOON_2 = 848, - //STR_VERSION_X = 849, + // STR_VERSION_X = 849, STR_COPYRIGHT_CS = 850, STR_DESIGNED_AND_PROGRAMMED_BY_CS = 851, STR_GRAPHICS_BY_SF = 852, @@ -287,7 +288,7 @@ enum { STR_REPRESENTATION_BY_JL = 855, STR_THANKS_TO = 856, STR_THANKS_TO_PEOPLE = 857, -// STR_0858 to 0864 are removed. + // STR_0858 to 0864 are removed. STR_STRINGID = 865, STR_ARG_2_STRINGID = 866, // Unused STR_ARG_4_STRINGID = 867, // Unused @@ -313,7 +314,7 @@ enum { STR_QUIT_SCENARIO_EDITOR = 887, STR_QUIT_ROLLERCOASTER_DESIGNER = 888, STR_QUIT_TRACK_DESIGNS_MANAGER = 889, -// STR_0890 : + // STR_0890 : STR_SCREENSHOT = 891, STR_SCREENSHOT_SAVED_AS = 892, STR_SCREENSHOT_FAILED = 893, @@ -447,8 +448,8 @@ enum { STR_RIDE_VEHICLE_COUNT = 1021, STR_1_CAR_PER_TRAIN = 1022, STR_X_CARS_PER_TRAIN = 1023, -// STR_1024 :{COMMA16} car per train -// STR_1025 :{COMMA16} cars per train + // STR_1024 :{COMMA16} car per train + // STR_1025 :{COMMA16} cars per train STR_STATION_PLATFORM_TOO_LONG = 1026, STR_LOCATE_SUBJECT_TIP = 1027, STR_OFF_EDGE_OF_MAP = 1028, @@ -566,7 +567,7 @@ enum { STR_SELECT_VEHICLE_COLOUR_SCHEME_TIP = 1140, STR_SELECT_VEHICLE_TO_MODIFY_TIP = 1141, STR_DROPDOWN_MENU_LABEL = 1142, -// STR_1143 :{RIGHTGUILLEMET}{MOVE_X}{SMALLFONT}{STRINGID} + // STR_1143 :{RIGHTGUILLEMET}{MOVE_X}{SMALLFONT}{STRINGID} STR_CANT_BUILD_MOVE_ENTRANCE_FOR_THIS_RIDE_ATTRACTION = 1144, STR_CANT_BUILD_MOVE_EXIT_FOR_THIS_RIDE_ATTRACTION = 1145, STR_ENTRANCE_NOT_YET_BUILT = 1146, @@ -755,7 +756,7 @@ enum { STR_LAUNCH_SPEED = 1329, STR_LAUNCH_SPEED_TIP = 1330, STR_RIDE_MODE_SPEED_VALUE = 1331, -// 1332 not used. Likely ride_mode_speed value + // 1332 not used. Likely ride_mode_speed value STR_RIDE_STATION = 1333, STR_RIDE_STATION_X = 1334, STR_RIDE_ENTRANCE = 1335, @@ -951,11 +952,11 @@ enum { STR_PEEP_THOUGHT_TYPE_CHIPS = 1525, STR_PEEP_THOUGHT_TYPE_ICE_CREAM = 1526, STR_PEEP_THOUGHT_TYPE_CANDYFLOSS = 1527, -// STR_1528 : -// STR_1529 : -// STR_1530 : + // STR_1528 : + // STR_1529 : + // STR_1530 : STR_PEEP_THOUGHT_TYPE_PIZZA = 1531, -// STR_1532 : + // STR_1532 : STR_PEEP_THOUGHT_TYPE_POPCORN = 1533, STR_PEEP_THOUGHT_TYPE_HOT_DOG = 1534, STR_PEEP_THOUGHT_TYPE_TENTACLE = 1535, @@ -964,15 +965,15 @@ enum { STR_PEEP_THOUGHT_TYPE_TSHIRT = 1538, STR_PEEP_THOUGHT_TYPE_DOUGHNUT = 1539, STR_PEEP_THOUGHT_TYPE_COFFEE = 1540, -// STR_1541 : + // STR_1541 : STR_PEEP_THOUGHT_TYPE_CHICKEN = 1542, STR_PEEP_THOUGHT_TYPE_LEMONADE = 1543, -// STR_1544 : -// STR_1545 : -// STR_1546 : + // STR_1544 : + // STR_1545 : + // STR_1546 : STR_PEEP_THOUGHT_TYPE_WOW = 1547, // This string is empty! STR_1547 : -// STR_1548 : -// STR_1549 : + // STR_1548 : + // STR_1549 : STR_PEEP_THOUGHT_TYPE_WOW2 = 1550, STR_PEEP_THOUGHT_TYPE_WATCHED = 1551, STR_PEEP_THOUGHT_TYPE_BALLOON_MUCH = 1552, @@ -985,11 +986,11 @@ enum { STR_PEEP_THOUGHT_TYPE_CHIPS_MUCH = 1559, STR_PEEP_THOUGHT_TYPE_ICE_CREAM_MUCH = 1560, STR_PEEP_THOUGHT_TYPE_CANDYFLOSS_MUCH = 1561, -// STR_1562 : -// STR_1563 : -// STR_1564 : + // STR_1562 : + // STR_1563 : + // STR_1564 : STR_PEEP_THOUGHT_TYPE_PIZZA_MUCH = 1565, -// STR_1566 : + // STR_1566 : STR_PEEP_THOUGHT_TYPE_POPCORN_MUCH = 1567, STR_PEEP_THOUGHT_TYPE_HOT_DOG_MUCH = 1568, STR_PEEP_THOUGHT_TYPE_TENTACLE_MUCH = 1569, @@ -998,15 +999,15 @@ enum { STR_PEEP_THOUGHT_TYPE_TSHIRT_MUCH = 1572, STR_PEEP_THOUGHT_TYPE_DOUGHNUT_MUCH = 1573, STR_PEEP_THOUGHT_TYPE_COFFEE_MUCH = 1574, -// STR_1575 : + // STR_1575 : STR_PEEP_THOUGHT_TYPE_CHICKEN_MUCH = 1576, STR_PEEP_THOUGHT_TYPE_LEMONADE_MUCH = 1577, -// STR_1578 : -// STR_1579 : -// STR_1580 : -// STR_1581 : -// STR_1582 : -// STR_1583 : + // STR_1578 : + // STR_1579 : + // STR_1580 : + // STR_1581 : + // STR_1582 : + // STR_1583 : STR_PEEP_THOUGHT_TYPE_PHOTO2 = 1584, STR_PEEP_THOUGHT_TYPE_PHOTO3 = 1585, STR_PEEP_THOUGHT_TYPE_PHOTO4 = 1586, @@ -1024,21 +1025,21 @@ enum { STR_PEEP_THOUGHT_TYPE_SU_JONGKWA = 1598, STR_PEEP_THOUGHT_TYPE_SUB_SANDWICH = 1599, STR_PEEP_THOUGHT_TYPE_COOKIE = 1600, -// STR_1601 : -// STR_1602 : -// STR_1603 : + // STR_1601 : + // STR_1602 : + // STR_1603 : STR_PEEP_THOUGHT_TYPE_ROAST_SAUSAGE = 1604, -// STR_1605 : -// STR_1606 : -// STR_1607 : -// STR_1608 : -// STR_1609 : -// STR_1610 : -// STR_1611 : -// STR_1612 : -// STR_1613 : -// STR_1614 : -// STR_1615 : + // STR_1605 : + // STR_1606 : + // STR_1607 : + // STR_1608 : + // STR_1609 : + // STR_1610 : + // STR_1611 : + // STR_1612 : + // STR_1613 : + // STR_1614 : + // STR_1615 : STR_PEEP_THOUGHT_TYPE_PHOTO2_MUCH = 1616, STR_PEEP_THOUGHT_TYPE_PHOTO3_MUCH = 1617, STR_PEEP_THOUGHT_TYPE_PHOTO4_MUCH = 1618, @@ -1056,21 +1057,21 @@ enum { STR_PEEP_THOUGHT_TYPE_SU_JONGKWA_MUCH = 1630, STR_PEEP_THOUGHT_TYPE_SUB_SANDWICH_MUCH = 1631, STR_PEEP_THOUGHT_TYPE_COOKIE_MUCH = 1632, -// STR_1633 : -// STR_1634 : -// STR_1635 : + // STR_1633 : + // STR_1634 : + // STR_1635 : STR_PEEP_THOUGHT_TYPE_ROAST_SAUSAGE_MUCH = 1636, -// STR_1637 : -// STR_1638 : -// STR_1639 : -// STR_1640 : -// STR_1641 : -// STR_1642 : -// STR_1643 : -// STR_1644 : -// STR_1645 : -// STR_1646 : -// STR_1647 : + // STR_1637 : + // STR_1638 : + // STR_1639 : + // STR_1640 : + // STR_1641 : + // STR_1642 : + // STR_1643 : + // STR_1644 : + // STR_1645 : + // STR_1646 : + // STR_1647 : STR_PEEP_THOUGHT_TYPE_HELP = 1648, STR_PEEP_THOUGHT_TYPE_RUNNING_OUT = 1649, STR_PEEP_THOUGHT_TYPE_NEW_RIDE = 1650, @@ -1160,7 +1161,7 @@ enum { STR_NUMBER_OF_LAPS = 1734, STR_NUMBER_OF_LAPS_TIP = 1735, STR_NUMBER_OF_LAPS_VALUE = 1736, -// STR_1737 :{COMMA16} + // STR_1737 :{COMMA16} STR_CANT_CHANGE_NUMBER_OF_LAPS = 1738, STR_RACE_WON_BY_GUEST = 1739, STR_RACE_WON_BY = 1740, @@ -1168,12 +1169,12 @@ enum { STR_MAX_PEOPLE_ON_RIDE = 1742, STR_MAX_PEOPLE_ON_RIDE_TIP = 1743, STR_MAX_PEOPLE_ON_RIDE_VALUE = 1744, -// STR_1745 :{COMMA16} + // STR_1745 :{COMMA16} STR_CANT_CHANGE_THIS = 1746, STR_TIME_LIMIT = 1747, STR_TIME_LIMIT_TIP = 1748, STR_RIDE_MODE_TIME_LIMIT_VALUE = 1749, -// STR_1750 :{DURATION} + // STR_1750 :{DURATION} STR_CANT_CHANGE_TIME_LIMIT = 1751, STR_INDIVIDUAL_GUESTS_TIP = 1752, STR_SUMMARISED_GUESTS_TIP = 1753, @@ -1195,11 +1196,11 @@ enum { STR_NUMBER_OF_SWINGS = 1769, STR_NUMBER_OF_SWINGS_TIP = 1770, STR_RIDE_MODE_NUMBER_OF_SWINGS_VALUE = 1771, -// STR_1772 :{COMMA16} + // STR_1772 :{COMMA16} STR_ONLY_ONE_ON_RIDE_PHOTO_PER_RIDE = 1773, STR_ONLY_ONE_CABLE_LIFT_HILL_PER_RIDE = 1774, -// STR_OPTIONS_RIDE_MUSIC_OFF = 1775, -// STR_OPTIONS_RIDE_MUSIC_ON = 1776, + // STR_OPTIONS_RIDE_MUSIC_OFF = 1775, + // STR_OPTIONS_RIDE_MUSIC_ON = 1776, STR_RIDE_MUSIC = 1777, STR_SCROLLING_SIGN_TEXT = 1778, STR_STAFF_OPTION_COSTUME_PANDA = 1779, @@ -1220,7 +1221,7 @@ enum { STR_FIXING_RIDE = 1794, STR_ANSWERING_RADIO_CALL = 1795, STR_HAS_BROKEN_DOWN_AND_REQUIRES_FIXING = 1796, -// STR_1797 :This option cannot be changed for this ride + // STR_1797 :This option cannot be changed for this ride STR_WHIRLPOOL = 1798, STR_RIDE_SECONDARY_PRICE_VALUE = 1799, STR_RIDE_BREAKDOWN_SAFETY_CUT_OUT = 1800, @@ -1268,7 +1269,7 @@ enum { STR_GUESTS_FAVOURITE_LABEL = 1842, STR_GUESTS_FAVOURITE_PLURAL_LABEL = 1843, STR_RIDE_LIST_INFORMATION_TYPE_TIP = 1844, -// STR_1845 :{MONTHYEAR} // Used in window_game_bottom_toolbar_onpaint + // STR_1845 :{MONTHYEAR} // Used in window_game_bottom_toolbar_onpaint STR_BOTTOM_TOOLBAR_NUM_GUESTS_STABLE = 1846, STR_BOTTOM_TOOLBAR_NUM_GUESTS_DECREASE = 1847, STR_BOTTOM_TOOLBAR_NUM_GUESTS_INCREASE = 1848, @@ -1295,7 +1296,7 @@ enum { STR_NUMBER_OF_ROTATIONS = 1869, STR_NUMBER_OF_ROTATIONS_TIP = 1870, STR_NUMBER_OF_ROTATIONS_VALUE = 1871, -// STR_1872 :{COMMA16} + // STR_1872 :{COMMA16} STR_INCOME_PER_HOUR = 1873, STR_PROFIT_PER_HOUR = 1874, STR_GUEST_ITEM_FORMAT = 1875, @@ -1315,8 +1316,8 @@ enum { STR_DOWN_TIME_LABEL_1889 = 1889, STR_SELECT_HOW_OFTEN_A_MECHANIC_SHOULD_CHECK_THIS_RIDE = 1890, STR_NO_THING_IN_PARK_YET = 1891, -// STR_1892 : -// STR_1893 : + // STR_1892 : + // STR_1893 : STR_ITEMS_SOLD = 1894, STR_BUILD_RIDE_TIP = 1895, STR_FINANCES_SUMMARY_EXPENDITURE_INCOME = 1896, @@ -1348,7 +1349,7 @@ enum { STR_CONTINUE_SAVED_GAME_TIP = 1922, STR_EXIT = 1924, STR_ERR_CANT_PLACE_PERSON_HERE = 1925, -// STR_1926 :{SMALLFONT} // Used in window_game_bottom_toolbar_onpaint and window_news_onscrollpaint + // STR_1926 :{SMALLFONT} // Used in window_game_bottom_toolbar_onpaint and window_news_onscrollpaint STR_RIDE_IS_BROKEN_DOWN = 1927, STR_RIDE_HAS_CRASHED = 1928, STR_RIDE_IS_STILL_NOT_FIXED = 1929, @@ -1380,8 +1381,8 @@ enum { STR_NUMBER_OF_CIRCUITS = 1955, STR_NUMBER_OF_CIRCUITS_TIP = 1956, STR_NUMBER_OF_CIRCUITS_VALUE = 1957, -// STR_1958 :{COMMA16} -// STR_1959 :Can't change number of circuits... + // STR_1958 :{COMMA16} + // STR_1959 :Can't change number of circuits... STR_SHOP_ITEM_PRICE_LABEL_BALLOON = 1960, STR_SHOP_ITEM_PRICE_LABEL_CUDDLY_TOY = 1961, STR_SHOP_ITEM_PRICE_LABEL_PARK_MAP = 1962, @@ -1392,8 +1393,8 @@ enum { STR_SHOP_ITEM_PRICE_LABEL_CHIPS = 1967, STR_SHOP_ITEM_PRICE_LABEL_ICE_CREAM = 1968, STR_SHOP_ITEM_PRICE_LABEL_CANDYFLOSS = 1969, - STR_SHOP_ITEM_PRICE_LABEL_EMPTY_CAN = 1970, // Empty - STR_SHOP_ITEM_PRICE_LABEL_RUBBISH = 1971, // Empty + STR_SHOP_ITEM_PRICE_LABEL_EMPTY_CAN = 1970, // Empty + STR_SHOP_ITEM_PRICE_LABEL_RUBBISH = 1971, // Empty STR_SHOP_ITEM_PRICE_LABEL_EMPTY_BURGER_BOX = 1972, // Empty STR_SHOP_ITEM_PRICE_LABEL_PIZZA = 1973, STR_SHOP_ITEM_PRICE_LABEL_VOUCHER = 1974, // Empty @@ -1408,7 +1409,7 @@ enum { STR_SHOP_ITEM_PRICE_LABEL_EMPTY_CUP = 1983, // Empty STR_SHOP_ITEM_PRICE_LABEL_FRIED_CHICKEN = 1984, STR_SHOP_ITEM_PRICE_LABEL_LEMONADE = 1985, - STR_SHOP_ITEM_PRICE_LABEL_EMPTY_BOX = 1986, // Empty + STR_SHOP_ITEM_PRICE_LABEL_EMPTY_BOX = 1986, // Empty STR_SHOP_ITEM_PRICE_LABEL_EMPTY_BOTTLE = 1987, // Empty STR_SHOP_ITEM_SINGULAR_BALLOON = 1988, STR_SHOP_ITEM_SINGULAR_CUDDLY_TOY = 1989, @@ -1539,14 +1540,14 @@ enum { STR_SHOP_ITEM_PRICE_LABEL_SUJONGKWA = 2114, STR_SHOP_ITEM_PRICE_LABEL_SUB_SANDWICH = 2115, STR_SHOP_ITEM_PRICE_LABEL_COOKIE = 2116, - STR_SHOP_ITEM_PRICE_LABEL_EMPTY_BOWL_RED = 2117, // Empty + STR_SHOP_ITEM_PRICE_LABEL_EMPTY_BOWL_RED = 2117, // Empty STR_SHOP_ITEM_PRICE_LABEL_EMPTY_DRINK_CARTON = 2118, // Empty - STR_SHOP_ITEM_PRICE_LABEL_EMPTY_JUICE_CUP = 2119, // Empty + STR_SHOP_ITEM_PRICE_LABEL_EMPTY_JUICE_CUP = 2119, // Empty STR_SHOP_ITEM_PRICE_LABEL_ROAST_SAUSAGE = 2120, STR_SHOP_ITEM_PRICE_LABEL_EMPTY_BOWL_BLUE = 2121, // Empty - STR_SHOP_ITEM_SINGULAR_ON_RIDE_PHOTO2 = 2122, // Unused - STR_SHOP_ITEM_SINGULAR_ON_RIDE_PHOTO3 = 2123, // Unused - STR_SHOP_ITEM_SINGULAR_ON_RIDE_PHOTO4 = 2124, // Unused + STR_SHOP_ITEM_SINGULAR_ON_RIDE_PHOTO2 = 2122, // Unused + STR_SHOP_ITEM_SINGULAR_ON_RIDE_PHOTO3 = 2123, // Unused + STR_SHOP_ITEM_SINGULAR_ON_RIDE_PHOTO4 = 2124, // Unused STR_SHOP_ITEM_SINGULAR_PRETZEL = 2125, STR_SHOP_ITEM_SINGULAR_HOT_CHOCOLATE = 2126, STR_SHOP_ITEM_SINGULAR_ICED_TEA = 2127, @@ -1658,7 +1659,7 @@ enum { STR_PARK_INFORMATION_TIP = 2233, STR_RECENT_MESSAGES = 2234, STR_NEWS_DATE_FORMAT = 2235, - STR_MONTH_JANUARY = 2236, // unused + STR_MONTH_JANUARY = 2236, // unused STR_MONTH_FEBRUARY = 2237, // unused STR_MONTH_MARCH = 2238, STR_MONTH_APRIL = 2239, @@ -1673,7 +1674,7 @@ enum { STR_CANT_DEMOLISH_RIDE = 2248, STR_NEWS_ITEM_RESEARCH_NEW_RIDE_AVAILABLE = 2249, STR_NEWS_ITEM_RESEARCH_NEW_SCENERY_SET_AVAILABLE = 2250, -// STR_2251 :Can only be built on paths! + // STR_2251 :Can only be built on paths! STR_CAN_ONLY_BE_BUILT_ACROSS_PATHS = 2252, STR_RESEARCH_NEW_TRANSPORT_RIDES = 2253, STR_RESEARCH_NEW_GENTLE_RIDES = 2254, @@ -1701,18 +1702,18 @@ enum { STR_RESEARCH_AND_DEVELOPMENT_TIP = 2276, STR_RESEARCH_UNKNOWN = 2277, STR_RESEARCH_CATEGORY_TRANSPORT = 2278, - STR_RESEARCH_CATEGORY_GENTLE = 2279, + STR_RESEARCH_CATEGORY_GENTLE = 2279, STR_RESEARCH_CATEGORY_ROLLERCOASTER = 2280, - STR_RESEARCH_CATEGORY_THRILL = 2281, - STR_RESEARCH_CATEGORY_WATER = 2282, - STR_RESEARCH_CATEGORY_SHOP = 2283, + STR_RESEARCH_CATEGORY_THRILL = 2281, + STR_RESEARCH_CATEGORY_WATER = 2282, + STR_RESEARCH_CATEGORY_SHOP = 2283, STR_RESEARCH_CATEGORY_SCENERY_GROUP = 2284, STR_RESEARCH_STAGE_INITIAL_RESEARCH = 2285, STR_RESEARCH_STAGE_DESIGNING = 2286, STR_RESEARCH_STAGE_COMPLETING_DESIGN = 2287, STR_RESEARCH_STAGE_UNKNOWN = 2288, STR_RESEARCH_EXPECTED_FORMAT = 2289, -// STR_2290 : + // STR_2290 : STR_SELECT_SCENARIO = 2291, STR_GUEST_LABEL_RIDES_BEEN_ON = 2292, STR_NOTHING = 2293, @@ -1727,8 +1728,8 @@ enum { STR_GUEST_EXPENSES_DRINK_PLURAL = 2302, STR_GUEST_EXPENSES_SOUVENIR = 2303, STR_GUEST_EXPENSES_SOUVENIR_PLURAL = 2304, -// STR_2305 :Track design files -// STR_2306 :Save track design + // STR_2305 :Track design files + // STR_2306 :Save track design STR_SELECT_DESIGN = 2307, STR_TRACK_DESIGNS = 2308, STR_TRACK_DESIGN_INSTALL_WINDOW_TITLE = 2309, @@ -1739,10 +1740,10 @@ enum { STR_TRACK_LIST_RIDE_LENGTH = 2314, STR_TRACK_LIST_COST_AROUND = 2315, STR_TRACK_LIST_SPACE_REQUIRED = 2316, -// STR_2317 : -// STR_2318 : -// STR_2319 : -// STR_2320 : + // STR_2317 : + // STR_2318 : + // STR_2319 : + // STR_2320 : STR_NUMBER_OF_RIDES_LABEL = 2321, STR_STAFF_LABEL = 2322, STR_PARK_SIZE_METRIC_LABEL = 2323, @@ -1779,9 +1780,9 @@ enum { STR_STAFF_STAT_BINS_EMPTIED = 2354, STR_STAFF_STAT_RIDES_FIXED = 2355, STR_STAFF_STAT_RIDES_INSPECTED = 2356, -// STR_2357 :House -// STR_2358 :Units - //STR_UNITS = 2358, + // STR_2357 :House + // STR_2358 :Units + // STR_UNITS = 2358, STR_REAL_VALUES = 2359, STR_DISPLAY_RESOLUTION = 2360, STR_TILE_SMOOTHING = 2361, @@ -1845,8 +1846,8 @@ enum { STR_PEEP_INVENTORY_VOUCHER_RIDE_FREE = 2419, STR_PEEP_INVENTORY_VOUCHER_PARK_ENTRY_HALF_PRICE = 2420, STR_PEEP_INVENTORY_VOUCHER_FOOD_OR_DRINK_FREE = 2421, -// STR_2422 :Advertising campaign for {STRINGID} -// STR_2423 :Advertising campaign for {STRINGID} + // STR_2422 :Advertising campaign for {STRINGID} + // STR_2423 :Advertising campaign for {STRINGID} STR_MARKETING_VOUCHERS_FOR_FREE_ENTRY_TO_THE_PARK = 2424, STR_MARKETING_VOUCHERS_FOR_FREE_RIDES_ON_A_PARTICULAR_RIDE = 2425, STR_MARKETING_VOUCHERS_FOR_HALF_PRICE_ENTRY_TO_THE_PARK = 2426, @@ -1860,12 +1861,12 @@ enum { STR_ADVERTISING_CAMPAIGN_FOR_1 = 2434, STR_ADVERTISING_CAMPAIGN_FOR_2 = 2435, STR_MARKETING_1_WEEK = 2436, -// STR_2437 : -// STR_2438 : -// STR_2439 : -// STR_2440 : -// STR_2441 : -// STR_2442 : + // STR_2437 : + // STR_2438 : + // STR_2439 : + // STR_2440 : + // STR_2441 : + // STR_2442 : STR_MARKETING_COST_PER_WEEK = 2443, STR_MARKETING_TOTAL_COST = 2444, STR_MARKETING_START_THIS_MARKETING_CAMPAIGN = 2445, @@ -1909,7 +1910,7 @@ enum { STR_FINANCES_WEEKLY_PROFIT_POSITIVE = 2483, STR_FINANCES_WEEKLY_PROFIT_LOSS = 2484, STR_CONTROLS = 2485, // Unused - STR_GENERAL = 2486, // Unused + STR_GENERAL = 2486, // Unused STR_REAL_NAME = 2487, STR_REAL_NAME_TIP = 2488, STR_HOTKEY = 2489, @@ -1950,165 +1951,165 @@ enum { STR_SHORTCUT_SCREENSHOT = 2524, STR_SHORTCUT_KEY_UNKNOWN = 2525, -// STR_2525 :??? -// STR_2526 :??? -// STR_2527 :??? -// STR_2528 :??? -// STR_2529 :??? -// STR_2530 :??? -// STR_2531 :??? -// STR_2532 :??? -// STR_2533 :Backspace -// STR_2534 :Tab -// STR_2535 :??? -// STR_2536 :??? -// STR_2537 :Clear -// STR_2538 :Return -// STR_2539 :??? -// STR_2540 :??? -// STR_2541 :??? -// STR_2542 :??? -// STR_2543 :Alt/Menu -// STR_2544 :Pause -// STR_2545 :Caps -// STR_2546 :??? -// STR_2547 :??? -// STR_2548 :??? -// STR_2549 :??? -// STR_2550 :??? -// STR_2551 :??? -// STR_2552 :Escape -// STR_2553 :??? -// STR_2554 :??? -// STR_2555 :??? -// STR_2556 :??? -// STR_2557 :Spacebar -// STR_2558 :PgUp -// STR_2559 :PgDn -// STR_2560 :End -// STR_2561 :Home -// STR_2562 :Left -// STR_2563 :Up -// STR_2564 :Right -// STR_2565 :Down -// STR_2566 :Select -// STR_2567 :Print -// STR_2568 :Execute -// STR_2569 :Snapshot -// STR_2570 :Insert -// STR_2571 :Delete -// STR_2572 :Help -// STR_2573 :0 -// STR_2574 :1 -// STR_2575 :2 -// STR_2576 :3 -// STR_2577 :4 -// STR_2578 :5 -// STR_2579 :6 -// STR_2580 :7 -// STR_2581 :8 -// STR_2582 :9 -// STR_2583 :??? -// STR_2584 :??? -// STR_2585 :??? -// STR_2586 :??? -// STR_2587 :??? -// STR_2588 :??? -// STR_2589 :??? -// STR_2590 :A -// STR_2591 :B -// STR_2592 :C -// STR_2593 :D -// STR_2594 :E -// STR_2595 :F -// STR_2596 :G -// STR_2597 :H -// STR_2598 :I -// STR_2599 :J -// STR_2600 :K -// STR_2601 :L -// STR_2602 :M -// STR_2603 :N -// STR_2604 :O -// STR_2605 :P -// STR_2606 :Q -// STR_2607 :R -// STR_2608 :S -// STR_2609 :T -// STR_2610 :U -// STR_2611 :V -// STR_2612 :W -// STR_2613 :X -// STR_2614 :Y -// STR_2615 :Z -// STR_2616 :??? -// STR_2617 :??? -// STR_2618 :Menu -// STR_2619 :??? -// STR_2620 :??? -// STR_2621 :NumPad 0 -// STR_2622 :NumPad 1 -// STR_2623 :NumPad 2 -// STR_2624 :NumPad 3 -// STR_2625 :NumPad 4 -// STR_2626 :NumPad 5 -// STR_2627 :NumPad 6 -// STR_2628 :NumPad 7 -// STR_2629 :NumPad 8 -// STR_2630 :NumPad 9 -// STR_2631 :NumPad * -// STR_2632 :NumPad + -// STR_2633 :??? -// STR_2634 :NumPad - -// STR_2635 :NumPad . -// STR_2636 :NumPad / -// STR_2637 :F1 -// STR_2638 :F2 -// STR_2639 :F3 -// STR_2640 :F4 -// STR_2641 :F5 -// STR_2642 :F6 -// STR_2643 :F7 -// STR_2644 :F8 -// STR_2645 :F9 -// STR_2646 :F10 -// STR_2647 :F11 -// STR_2648 :F12 -// STR_2649 :F13 -// STR_2650 :F14 -// STR_2651 :F15 -// STR_2652 :F16 -// STR_2653 :F17 -// STR_2654 :F18 -// STR_2655 :F19 -// STR_2656 :F20 -// STR_2657 :F21 -// STR_2658 :F22 -// STR_2659 :F23 -// STR_2660 :F24 -// STR_2661 :??? -// STR_2662 :??? -// STR_2663 :??? -// STR_2664 :??? -// STR_2665 :??? -// STR_2666 :??? -// STR_2667 :??? -// STR_2668 :??? -// STR_2669 :NumLock -// STR_2670 :Scroll -// STR_2671 :??? -// STR_2672 :??? -// STR_2673 :??? -// STR_2674 :??? -// STR_2675 :??? -// STR_2676 :??? -// STR_2677 :??? -// STR_2678 :??? -// STR_2679 :??? + // STR_2525 :??? + // STR_2526 :??? + // STR_2527 :??? + // STR_2528 :??? + // STR_2529 :??? + // STR_2530 :??? + // STR_2531 :??? + // STR_2532 :??? + // STR_2533 :Backspace + // STR_2534 :Tab + // STR_2535 :??? + // STR_2536 :??? + // STR_2537 :Clear + // STR_2538 :Return + // STR_2539 :??? + // STR_2540 :??? + // STR_2541 :??? + // STR_2542 :??? + // STR_2543 :Alt/Menu + // STR_2544 :Pause + // STR_2545 :Caps + // STR_2546 :??? + // STR_2547 :??? + // STR_2548 :??? + // STR_2549 :??? + // STR_2550 :??? + // STR_2551 :??? + // STR_2552 :Escape + // STR_2553 :??? + // STR_2554 :??? + // STR_2555 :??? + // STR_2556 :??? + // STR_2557 :Spacebar + // STR_2558 :PgUp + // STR_2559 :PgDn + // STR_2560 :End + // STR_2561 :Home + // STR_2562 :Left + // STR_2563 :Up + // STR_2564 :Right + // STR_2565 :Down + // STR_2566 :Select + // STR_2567 :Print + // STR_2568 :Execute + // STR_2569 :Snapshot + // STR_2570 :Insert + // STR_2571 :Delete + // STR_2572 :Help + // STR_2573 :0 + // STR_2574 :1 + // STR_2575 :2 + // STR_2576 :3 + // STR_2577 :4 + // STR_2578 :5 + // STR_2579 :6 + // STR_2580 :7 + // STR_2581 :8 + // STR_2582 :9 + // STR_2583 :??? + // STR_2584 :??? + // STR_2585 :??? + // STR_2586 :??? + // STR_2587 :??? + // STR_2588 :??? + // STR_2589 :??? + // STR_2590 :A + // STR_2591 :B + // STR_2592 :C + // STR_2593 :D + // STR_2594 :E + // STR_2595 :F + // STR_2596 :G + // STR_2597 :H + // STR_2598 :I + // STR_2599 :J + // STR_2600 :K + // STR_2601 :L + // STR_2602 :M + // STR_2603 :N + // STR_2604 :O + // STR_2605 :P + // STR_2606 :Q + // STR_2607 :R + // STR_2608 :S + // STR_2609 :T + // STR_2610 :U + // STR_2611 :V + // STR_2612 :W + // STR_2613 :X + // STR_2614 :Y + // STR_2615 :Z + // STR_2616 :??? + // STR_2617 :??? + // STR_2618 :Menu + // STR_2619 :??? + // STR_2620 :??? + // STR_2621 :NumPad 0 + // STR_2622 :NumPad 1 + // STR_2623 :NumPad 2 + // STR_2624 :NumPad 3 + // STR_2625 :NumPad 4 + // STR_2626 :NumPad 5 + // STR_2627 :NumPad 6 + // STR_2628 :NumPad 7 + // STR_2629 :NumPad 8 + // STR_2630 :NumPad 9 + // STR_2631 :NumPad * + // STR_2632 :NumPad + + // STR_2633 :??? + // STR_2634 :NumPad - + // STR_2635 :NumPad . + // STR_2636 :NumPad / + // STR_2637 :F1 + // STR_2638 :F2 + // STR_2639 :F3 + // STR_2640 :F4 + // STR_2641 :F5 + // STR_2642 :F6 + // STR_2643 :F7 + // STR_2644 :F8 + // STR_2645 :F9 + // STR_2646 :F10 + // STR_2647 :F11 + // STR_2648 :F12 + // STR_2649 :F13 + // STR_2650 :F14 + // STR_2651 :F15 + // STR_2652 :F16 + // STR_2653 :F17 + // STR_2654 :F18 + // STR_2655 :F19 + // STR_2656 :F20 + // STR_2657 :F21 + // STR_2658 :F22 + // STR_2659 :F23 + // STR_2660 :F24 + // STR_2661 :??? + // STR_2662 :??? + // STR_2663 :??? + // STR_2664 :??? + // STR_2665 :??? + // STR_2666 :??? + // STR_2667 :??? + // STR_2668 :??? + // STR_2669 :NumLock + // STR_2670 :Scroll + // STR_2671 :??? + // STR_2672 :??? + // STR_2673 :??? + // STR_2674 :??? + // STR_2675 :??? + // STR_2676 :??? + // STR_2677 :??? + // STR_2678 :??? + // STR_2679 :??? STR_RESEARCH_COMPLETED_AL = 2680, STR_CHEAT_5K_MONEY_TIP = 2681, -// STR_2682 : -// STR_2683 : + // STR_2682 : + // STR_2683 : STR_CHEAT_LARGE_TRAM_GUESTS_TIP = 2684, STR_MAPGEN_SIMPLEX_NOISE = 2685, STR_MAPGEN_SIMPLEX_NOISE_LOW_ = 2686, @@ -2122,9 +2123,9 @@ enum { STR_MAPGEN_ACTION_GENERATE = 2694, STR_MAPGEN_OPTION_RANDOM_TERRAIN = 2695, STR_MAPGEN_OPTION_PLACE_TREES = 2696, -// STR_2697 :??? -// STR_2698 :??? -// STR_2699 :??? + // STR_2697 :??? + // STR_2698 :??? + // STR_2699 :??? STR_OPTIONS_AUTOSAVE_FREQUENCY_LABEL = 2700, STR_SAVE_EVERY_MINUTE = 2701, STR_SAVE_EVERY_5MINUTES = 2702, @@ -2136,13 +2137,13 @@ enum { STR_FILEBROWSER_OVERWRITE_PROMPT = 2708, STR_FILEBROWSER_OVERWRITE_TITLE = 2709, STR_FILEBROWSER_FILE_NAME_PROMPT = 2710, -// STR_2711 :; -// STR_2712 := -// STR_2713 :, -// STR_2714 :- -// STR_2715 :. -// STR_2716 :/ -// STR_2717 :' + // STR_2711 :; + // STR_2712 := + // STR_2713 :, + // STR_2714 :- + // STR_2715 :. + // STR_2716 :/ + // STR_2717 :' STR_FILEBROWSER_ACTION_UP = 2718, STR_FILEBROWSER_ACTION_NEW_FILE = 2719, STR_DURATION_SEC = 2720, @@ -2169,11 +2170,11 @@ enum { STR_ROLLERCOASTER_TYCOON_2_DROPDOWN = 2741, STR_OPTIONS_MUSIC_ERR_CSS50_NOT_FOUND = 2742, STR_OPTIONS_MUSIC_ERR_CSS50_NOT_FOUND_HINT = 2743, -// STR_2744 :[ -// STR_2745 :\ + // STR_2744 :[ + // STR_2745 :\ // STR_2746 :] -// STR_2747 :{ENDQUOTES} -// STR_2748 :Bar + // STR_2747 :{ENDQUOTES} + // STR_2748 :Bar STR_MY_NEW_SCENARIO = 2749, STR_MOVE_ALL_TOP = 2750, STR_MOVE_ALL_BOTTOM = 2751, @@ -2182,22 +2183,22 @@ enum { STR_CHEAT_WATER_PLANTS = 2754, STR_CHEAT_FIX_VANDALISM = 2755, STR_CHEAT_REMOVE_LITTER = 2756, - STR_CHEAT_FORCE_SUN = 2757, // - STR_CHEAT_FORCE_THUNDER = 2758, // + STR_CHEAT_FORCE_SUN = 2757, // + STR_CHEAT_FORCE_THUNDER = 2758, // STR_CHEAT_ZERO_CLEARANCE = 2759, // STR_CHEAT_5K_MONEY = 2760, -// STR_2761 : -// STR_2762 : -// STR_2763 :??? -// STR_2764 : + // STR_2761 : + // STR_2762 : + // STR_2763 :??? + // STR_2764 : STR_CHEAT_LARGE_TRAM_GUESTS = 2765, STR_CHEAT_WIN_SCENARIO = 2766, STR_CHEAT_FREEZE_CLIMATE = 2767, STR_CHEAT_UNFREEZE_CLIMATE = 2768, STR_CHEAT_OPEN_PARK = 2769, STR_CHEAT_CLOSE_PARK = 2770, -// STR_2771 :Slower Gamespeed -// STR_2772 :Faster Gamespeed + // STR_2771 :Slower Gamespeed + // STR_2772 :Faster Gamespeed STR_OPTIONS_DISPLAY_WINDOWED = 2773, STR_OPTIONS_DISPLAY_FULLSCREEN = 2774, STR_OPTIONS_DISPLAY_FULLSCREEN_BORDERLESS = 2775, @@ -2274,15 +2275,15 @@ enum { STR_NEWS_ITEM_MOST_CONFUSING_LAYOUT = STR_NEWS_ITEM_AWARD_MOST_UNTIDY + 15, STR_NEWS_ITEM_BEST_GENTLE_RIDES = STR_NEWS_ITEM_AWARD_MOST_UNTIDY + 16, STR_NO_RECENT_AWARDS = 2848, -// STR_2849 :New scenario installed successfully -// STR_2850 :New track design installed successfully -// STR_2851 :Scenario already installed -// STR_2852 :Track design already installed + // STR_2849 :New scenario installed successfully + // STR_2850 :New track design installed successfully + // STR_2851 :Scenario already installed + // STR_2852 :Track design already installed STR_FORBIDDEN_BY_THE_LOCAL_AUTHORITY = 2853, STR_ENTRANCE_NOT_CONNECTED = 2854, STR_EXIT_NOT_CONNECTED = 2855, STR_CANT_START_MARKETING_CAMPAIGN = 2858, -// STR_2859 :Another instance of OpenRCT2 is already running + // STR_2859 :Another instance of OpenRCT2 is already running STR_LICENSED_TO_INFOGRAMES_INTERACTIVE_INC = 2861, STR_MUSIC_ACKNOWLEDGEMENTS_ELLIPSIS = 2862, STR_MUSIC_ACKNOWLEDGEMENTS = 2863, @@ -2454,7 +2455,7 @@ enum { STR_LIFT_HILL_CHAIN_SPEED = 3095, STR_LIFT_HILL_CHAIN_SPEED_VALUE = 3096, STR_SELECT_LIFT_HILL_CHAIN_SPEED_TIP = 3097, -// STR_3098 :Can't change lift hill speed... + // STR_3098 :Can't change lift hill speed... STR_SELECT_COLOUR = 3099, STR_SELECT_SECONDARY_COLOUR = 3100, STR_SELECT_TERNARY_COLOUR = 3101, @@ -2501,29 +2502,29 @@ enum { STR_CAPACITY = 3142, STR_SHOW_PEOPLE_ON_MAP_TIP = 3143, STR_SHOW_RIDES_STALLS_ON_MAP_TIP = 3144, - STR_SCROLL_LEFT_TIP = 3145, // Unused - STR_SCROLL_RIGHT_TIP = STR_SCROLL_LEFT_TIP + 1, // Unused - STR_SCROLL_LEFT_FAST_TIP = STR_SCROLL_LEFT_TIP + 2, // Unused + STR_SCROLL_LEFT_TIP = 3145, // Unused + STR_SCROLL_RIGHT_TIP = STR_SCROLL_LEFT_TIP + 1, // Unused + STR_SCROLL_LEFT_FAST_TIP = STR_SCROLL_LEFT_TIP + 2, // Unused STR_SCROLL_RIGHT_FAST_TIP = STR_SCROLL_LEFT_TIP + 3, // Unused STR_SCROLL_LEFT_RIGHT_TIP = STR_SCROLL_LEFT_TIP + 4, // Unused - STR_SCROLL_UP_TIP = STR_SCROLL_LEFT_TIP + 5, // Unused - STR_SCROLL_DOWN_TIP = STR_SCROLL_LEFT_TIP + 6, // Unused - STR_SCROLL_UP_FAST_TIP = STR_SCROLL_LEFT_TIP + 7, // Unused - STR_SCROLL_DOWN_FAST_TIP = STR_SCROLL_LEFT_TIP + 8, // Unused - STR_SCROLL_UP_DOWN_TIP = STR_SCROLL_LEFT_TIP + 9, // Unused -// STR_3155 : -// STR_3156 : + STR_SCROLL_UP_TIP = STR_SCROLL_LEFT_TIP + 5, // Unused + STR_SCROLL_DOWN_TIP = STR_SCROLL_LEFT_TIP + 6, // Unused + STR_SCROLL_UP_FAST_TIP = STR_SCROLL_LEFT_TIP + 7, // Unused + STR_SCROLL_DOWN_FAST_TIP = STR_SCROLL_LEFT_TIP + 8, // Unused + STR_SCROLL_UP_DOWN_TIP = STR_SCROLL_LEFT_TIP + 9, // Unused + // STR_3155 : + // STR_3156 : STR_MAP = 3157, STR_GRAPH = 3158, STR_LIST = 3159, STR_SELECT_NUMBER_OF_CIRCUITS_TIP = 3160, -// STR_3161 : + // STR_3161 : STR_ERR_REASON_NOT_ENOUGH_MEMORY = 3162, -// STR_3163 :Installing new data: + // STR_3163 :Installing new data: STR_OBJECT_SELECTION_SELECTION_SIZE = 3164, -// STR_PLACEHOLDER = 3165, -// STR_3166 :{BLACK}(ID: -// STR_3167 :{WINDOW_COLOUR_2}Includes: {BLACK}{COMMA16} objects + // STR_PLACEHOLDER = 3165, + // STR_3166 :{BLACK}(ID: + // STR_3167 :{WINDOW_COLOUR_2}Includes: {BLACK}{COMMA16} objects STR_OBJECT_SELECTION_DESCRIPTION_SCENARIO_TEXT = 3168, STR_OBJECT_SELECTION_ERR_OBJECT_DATA_NOT_FOUND = 3169, STR_OBJECT_SELECTION_ERR_NOT_ENOUGH_SPACE_FOR_GRAPHICS = 3170, @@ -2677,7 +2678,7 @@ enum { STR_SELECT_WHICH_GROUP_THIS_SCENARIO_APPEARS_IN = 3318, STR_WINDOW_SCENARIO_GROUP = 3319, STR_UNABLE_TO_SAVE_SCENARIO_FILE = 3320, -// STR_3321 :New objects installed successfully + // STR_3321 :New objects installed successfully STR_OBJECTIVE = 3322, STR_MISSING_OBJECT_DATA_ID = 3323, STR_REQUIRES_THE_FOLLOWING_ADDON_PACK = 3324, @@ -2693,7 +2694,7 @@ enum { STR_SAVE_PLUGIN_DATA_TIP = 3334, STR_ROLLER_COASTER_DESIGNER_SELECT_RIDE_TYPES_VEHICLES = 3335, STR_TRACK_DESIGNS_MANAGER_SELECT_RIDE_TYPE = 3336, -// STR_3337 : + // STR_3337 : STR_CUSTOM_DESIGNED_LAYOUT = 3338, STR_1_DESIGN_AVAILABLE = 3339, STR_X_DESIGNS_AVAILABLE = 3340, @@ -2718,8 +2719,8 @@ enum { STR_NO_TRACK_DESIGNS_OF_THIS_TYPE = 3359, STR_WARNING = 3360, STR_TOO_MANY_TRACK_DESIGNS_OF_THIS_TYPE = 3361, -// STR_3362 : -// STR_3363 : + // STR_3362 : + // STR_3363 : STR_OBJECT_SELECTION_ADVANCED = 3364, STR_OBJECT_SELECTION_ADVANCED_TIP = 3365, STR_MAP_RIDE = 3366, @@ -2737,14 +2738,14 @@ enum { STR_INSTALL_NEW_TRACK_DESIGN_INSTALL = 3378, STR_INSTALL_NEW_TRACK_DESIGN_CANCEL = 3379, STR_UNABLE_TO_INSTALL_THIS_TRACK_DESIGN = 3380, -// STR_3381 :File is not compatible or contains invalid data -// STR_3382 :File copy failed + // STR_3381 :File is not compatible or contains invalid data + // STR_3382 :File copy failed STR_SELECT_NEW_NAME_FOR_TRACK_DESIGN = 3383, STR_AN_EXISTING_TRACK_DESIGN_ALREADY_HAS_THIS_NAME = 3384, -// STR_3388 :Unable to switch to selected mode + // STR_3388 :Unable to switch to selected mode STR_SAVE_TRACK_SCENERY_UNABLE_TO_SELECT_ADDITIONAL_ITEM_OF_SCENERY = 3389, STR_SAVE_TRACK_SCENERY_TOO_MANY_ITEMS_SELECTED = 3390, -// TUTORIAL + // TUTORIAL STR_CLEAR_SCENERY_TIP = 3437, STR_UNABLE_TO_REMOVE_ALL_SCENERY_FROM_HERE = 3438, STR_CLEAR_SCENERY = 3439, @@ -2762,7 +2763,7 @@ enum { STR_RESEARCH_BUTTON_ON_TOOLBAR = 5121, STR_CHEAT_RENEW_RIDES = 5123, -// STR_5124 : + // STR_5124 : STR_CHEAT_MAKE_DESTRUCTABLE = 5125, STR_OPTIONS_MUSIC_VALUE_RANDOM = 5126, STR_DISABLE_ELEVATION = 5127, @@ -2913,7 +2914,7 @@ enum { STR_CLEAR_SCENERY_REMOVE_SMALL_SCENERY_TIP = 5272, STR_CLEAR_SCENERY_REMOVE_LARGE_SCENERY_TIP = 5273, STR_CLEAR_SCENERY_REMOVE_FOOTPATHS_TIP = 5274, - STR_OBJECT_SEARCH = 5275, // Unused (commented out) + STR_OBJECT_SEARCH = 5275, // Unused (commented out) STR_OBJECT_SEARCH_DESC = 5276, // Unused (commented out) STR_OBJECT_SEARCH_CLEAR = 5277, STR_CHEAT_SANDBOX_MODE = 5278, @@ -3033,13 +3034,13 @@ enum { STR_TITLE_EDITOR_ACTION_RENAME_TIP = 5394, STR_TITLE_EDITOR_ACTION_LOAD_TIP = 5395, STR_TITLE_EDITOR_ACTION_RELOAD_TIP = 5396, -// STR_5397 :Can only be used on the title screen + // STR_5397 :Can only be used on the title screen STR_TITLE_EDITOR_ERR_CANT_EDIT_WHILE_PLAYING = 5398, STR_TITLE_EDITOR_PRESS_STOP_TO_CONTINUE_EDITING = 5399, STR_ERROR_CANT_CHANGE_TITLE_SEQUENCE = 5400, -// STR_5401 :Create a new title sequence to make changes to + // STR_5401 :Create a new title sequence to make changes to STR_ERR_FAILED_TO_LOAD_TITLE_SEQUENCE = 5402, -// STR_5403 :There may be no Load or Wait command or a save may be invalid + // STR_5403 :There may be no Load or Wait command or a save may be invalid STR_ERROR_EXISTING_NAME = 5404, STR_TITLE_EDITOR_ENTER_NAME_FOR_SAVE = 5405, STR_TITLE_EDITOR_ENTER_NAME_FOR_SEQUENCE = 5406, @@ -3130,7 +3131,7 @@ enum { STR_DEBUG_DROPDOWN_INVENTIONS_LIST = 5491, STR_DEBUG_DROPDOWN_SCENARIO_OPTIONS = 5492, STR_SEND_MESSAGE = 5493, -// STR_5494 : + // STR_5494 : STR_PLAYER_LIST = 5495, // Unused STR_PLAYER = 5496, STR_PING = 5497, @@ -3244,7 +3245,8 @@ enum { STR_NOTIFICATION_GUEST_DIED = 5606, STR_TILE_INSPECTOR_BASE_HEIGHT_SHORT = 5608, STR_TILE_INSPECTOR_CLEARANGE_HEIGHT_SHORT = 5609, -// STR_5610 :{SMALLFONT}{BLACK}Remove the currently selected map element. This will forcefully remove it, so no cash will be used/gained. Use with caution. + // STR_5610 :{SMALLFONT}{BLACK}Remove the currently selected map element. This will forcefully remove it, so no cash will + // be used/gained. Use with caution. STR_REMOVE_SELECTED_ELEMENT_TIP = 5610, STR_TILE_INSPECTOR_FLAG_GHOST_SHORT = 5611, STR_TILE_INSPECTOR_FLAG_GHOST = 5612, @@ -3302,7 +3304,7 @@ enum { STR_ACTION_CHEAT = 5664, STR_ACTION_TOGGLE_SCENERY_CLUSTER = 5665, STR_ACTION_PASSWORDLESS_LOGIN = 5666, -// Empty block + // Empty block STR_LAST_ACTION_RAN = 5701, STR_LOCATE_PLAYER_TIP = 5702, STR_CANT_KICK_THE_HOST = 5703, @@ -3315,7 +3317,7 @@ enum { STR_GROUP_NAME = 5710, STR_ENTER_NEW_NAME_FOR_THIS_GROUP = 5711, STR_CANT_MODIFY_PERMISSION_THAT_YOU_DO_NOT_HAVE_YOURSELF = 5712, -// STR_5713 :Kick Player (unused) + // STR_5713 :Kick Player (unused) STR_SHORTCUT_SHOW_OPTIONS = 5714, STR_NEW_GAME = 5715, STR_NOT_ALLOWED_IN_MULTIPLAYER = 5716, // Unused @@ -3330,7 +3332,7 @@ enum { STR_FORCE_WEATHER = 5725, STR_FORCE_WEATHER_TOOLTIP = 5726, STR_SCALING_QUALITY = 5727, - STR_REQUIRES_HW_DISPLAY = 5728, // unused + STR_REQUIRES_HW_DISPLAY = 5728, // unused STR_REQUIRES_HW_DISPLAY_TIP = 5729, // unused STR_SCALING_QUALITY_LINEAR = 5731, STR_OPTIONS_RENDERING_TIP = 5734, @@ -3365,7 +3367,7 @@ enum { STR_ALL_FILES = 5763, STR_INVALID_RIDE_TYPE = 5764, STR_CANT_EDIT_INVALID_RIDE_TYPE = 5765, -// 5766 is unused + // 5766 is unused STR_RIDE_LIST_INCOME = 5767, STR_RIDE_LIST_TOTAL_CUSTOMERS = 5768, STR_RIDE_LIST_TOTAL_PROFIT = 5769, diff --git a/src/openrct2/localisation/UTF8.cpp b/src/openrct2/localisation/UTF8.cpp index a3748bcc17..e420605c52 100644 --- a/src/openrct2/localisation/UTF8.cpp +++ b/src/openrct2/localisation/UTF8.cpp @@ -8,26 +8,37 @@ *****************************************************************************/ #include "Localisation.h" + #include -uint32_t utf8_get_next(const utf8 *char_ptr, const utf8 **nextchar_ptr) +uint32_t utf8_get_next(const utf8* char_ptr, const utf8** nextchar_ptr) { int32_t result; int32_t numBytes; - if (!(char_ptr[0] & 0x80)) { + if (!(char_ptr[0] & 0x80)) + { result = char_ptr[0]; numBytes = 1; - } else if ((char_ptr[0] & 0xE0) == 0xC0) { + } + else if ((char_ptr[0] & 0xE0) == 0xC0) + { result = ((char_ptr[0] & 0x1F) << 6) | (char_ptr[1] & 0x3F); numBytes = 2; - } else if ((char_ptr[0] & 0xF0) == 0xE0) { + } + else if ((char_ptr[0] & 0xF0) == 0xE0) + { result = ((char_ptr[0] & 0x0F) << 12) | ((char_ptr[1] & 0x3F) << 6) | (char_ptr[2] & 0x3F); numBytes = 3; - } else if ((char_ptr[0] & 0xF8) == 0xF0) { - result = ((char_ptr[0] & 0x07) << 18) | ((char_ptr[1] & 0x3F) << 12) | ((char_ptr[1] & 0x3F) << 6) | (char_ptr[2] & 0x3F); + } + else if ((char_ptr[0] & 0xF8) == 0xF0) + { + result + = ((char_ptr[0] & 0x07) << 18) | ((char_ptr[1] & 0x3F) << 12) | ((char_ptr[1] & 0x3F) << 6) | (char_ptr[2] & 0x3F); numBytes = 4; - } else { + } + else + { // TODO 4 bytes result = ' '; numBytes = 1; @@ -38,21 +49,28 @@ uint32_t utf8_get_next(const utf8 *char_ptr, const utf8 **nextchar_ptr) return result; } -utf8 *utf8_write_codepoint(utf8 *dst, uint32_t codepoint) +utf8* utf8_write_codepoint(utf8* dst, uint32_t codepoint) { - if (codepoint <= 0x7F) { + if (codepoint <= 0x7F) + { dst[0] = (utf8)codepoint; return dst + 1; - } else if (codepoint <= 0x7FF) { + } + else if (codepoint <= 0x7FF) + { dst[0] = 0xC0 | ((codepoint >> 6) & 0x1F); dst[1] = 0x80 | (codepoint & 0x3F); return dst + 2; - } else if (codepoint <= 0xFFFF) { + } + else if (codepoint <= 0xFFFF) + { dst[0] = 0xE0 | ((codepoint >> 12) & 0x0F); dst[1] = 0x80 | ((codepoint >> 6) & 0x3F); dst[2] = 0x80 | (codepoint & 0x3F); return dst + 3; - } else { + } + else + { dst[0] = 0xF0 | ((codepoint >> 18) & 0x07); dst[1] = 0x80 | ((codepoint >> 12) & 0x3F); dst[2] = 0x80 | ((codepoint >> 6) & 0x3F); @@ -65,31 +83,40 @@ utf8 *utf8_write_codepoint(utf8 *dst, uint32_t codepoint) * Inserts the given codepoint at the given address, shifting all characters after along. * @returns the size of the inserted codepoint. */ -int32_t utf8_insert_codepoint(utf8 *dst, uint32_t codepoint) +int32_t utf8_insert_codepoint(utf8* dst, uint32_t codepoint) { int32_t shift = utf8_get_codepoint_length(codepoint); - utf8 *endPoint = get_string_end(dst); + utf8* endPoint = get_string_end(dst); memmove(dst + shift, dst, endPoint - dst + 1); utf8_write_codepoint(dst, codepoint); return shift; } -bool utf8_is_codepoint_start(const utf8 *text) +bool utf8_is_codepoint_start(const utf8* text) { - if ((text[0] & 0x80) == 0) return true; - if ((text[0] & 0xC0) == 0xC0) return true; + if ((text[0] & 0x80) == 0) + return true; + if ((text[0] & 0xC0) == 0xC0) + return true; return false; } int32_t utf8_get_codepoint_length(int32_t codepoint) { - if (codepoint <= 0x7F) { + if (codepoint <= 0x7F) + { return 1; - } else if (codepoint <= 0x7FF) { + } + else if (codepoint <= 0x7FF) + { return 2; - } else if (codepoint <= 0xFFFF) { + } + else if (codepoint <= 0xFFFF) + { return 3; - } else { + } + else + { return 4; } } @@ -98,28 +125,33 @@ int32_t utf8_get_codepoint_length(int32_t codepoint) * Gets the number of characters / codepoints in a UTF-8 string (not necessarily 1:1 with bytes and not including null * terminator). */ -int32_t utf8_length(const utf8 *text) +int32_t utf8_length(const utf8* text) { - const utf8 *ch = text; + const utf8* ch = text; int32_t count = 0; - while (utf8_get_next(ch, &ch) != 0) { + while (utf8_get_next(ch, &ch) != 0) + { count++; } return count; } -wchar_t *utf8_to_widechar(const utf8 *src) +wchar_t* utf8_to_widechar(const utf8* src) { - wchar_t * result = (wchar_t *)malloc((utf8_length(src) + 1) * sizeof(wchar_t)); - wchar_t *dst = result; + wchar_t* result = (wchar_t*)malloc((utf8_length(src) + 1) * sizeof(wchar_t)); + wchar_t* dst = result; - const utf8 *ch = src; + const utf8* ch = src; int32_t codepoint; - while ((codepoint = utf8_get_next(ch, &ch)) != 0) { - if ((uint32_t)codepoint > 0xFFFF) { + while ((codepoint = utf8_get_next(ch, &ch)) != 0) + { + if ((uint32_t)codepoint > 0xFFFF) + { *dst++ = '?'; - } else { + } + else + { *dst++ = codepoint; } } @@ -128,30 +160,31 @@ wchar_t *utf8_to_widechar(const utf8 *src) return result; } -utf8 *widechar_to_utf8(const wchar_t *src) +utf8* widechar_to_utf8(const wchar_t* src) { - utf8 *result = (utf8 *)malloc((wcslen(src) * 4) + 1); - utf8 *dst = result; + utf8* result = (utf8*)malloc((wcslen(src) * 4) + 1); + utf8* dst = result; - for (; *src != 0; src++) { + for (; *src != 0; src++) + { dst = utf8_write_codepoint(dst, *src); } *dst++ = 0; size_t size = (size_t)(dst - result); - return (utf8 *)realloc(result, size); + return (utf8*)realloc(result, size); } - /** * Returns a pointer to the null terminator of the given UTF-8 string. */ -utf8 *get_string_end(const utf8 *text) +utf8* get_string_end(const utf8* text) { int32_t codepoint; - const utf8 *ch = text; + const utf8* ch = text; - while ((codepoint = utf8_get_next(ch, &ch)) != 0) { + while ((codepoint = utf8_get_next(ch, &ch)) != 0) + { int32_t argLength = utf8_get_format_code_arg_length(codepoint); ch += argLength; } @@ -161,7 +194,7 @@ utf8 *get_string_end(const utf8 *text) /** * Return the number of bytes (including the null terminator) in the given UTF-8 string. */ -size_t get_string_size(const utf8 *text) +size_t get_string_size(const utf8* text) { return get_string_end(text) - text + 1; } @@ -169,16 +202,20 @@ size_t get_string_size(const utf8 *text) /** * Return the number of visible characters (excludes format codes) in the given UTF-8 string. */ -int32_t get_string_length(const utf8 *text) +int32_t get_string_length(const utf8* text) { int32_t codepoint; - const utf8 *ch = text; + const utf8* ch = text; int32_t count = 0; - while ((codepoint = utf8_get_next(ch, &ch)) != 0) { - if (utf8_is_format_code(codepoint)) { + while ((codepoint = utf8_get_next(ch, &ch)) != 0) + { + if (utf8_is_format_code(codepoint)) + { ch += utf8_get_format_code_arg_length(codepoint); - } else { + } + else + { count++; } } @@ -187,32 +224,38 @@ int32_t get_string_length(const utf8 *text) int32_t utf8_get_format_code_arg_length(int32_t codepoint) { - switch (codepoint) { - case FORMAT_MOVE_X: - case FORMAT_ADJUST_PALETTE: - case 3: - case 4: - return 1; - case FORMAT_NEWLINE_X_Y: - return 2; - case FORMAT_INLINE_SPRITE: - return 4; - default: - return 0; + switch (codepoint) + { + case FORMAT_MOVE_X: + case FORMAT_ADJUST_PALETTE: + case 3: + case 4: + return 1; + case FORMAT_NEWLINE_X_Y: + return 2; + case FORMAT_INLINE_SPRITE: + return 4; + default: + return 0; } } -void utf8_remove_formatting(utf8* string, bool allowColours) { +void utf8_remove_formatting(utf8* string, bool allowColours) +{ utf8* readPtr = string; utf8* writePtr = string; - while (true) { + while (true) + { uint32_t code = utf8_get_next(readPtr, (const utf8**)&readPtr); - if (code == 0) { + if (code == 0) + { *writePtr = 0; break; - } else if (!utf8_is_format_code(code) || (allowColours && utf8_is_colour_code(code))) { + } + else if (!utf8_is_format_code(code) || (allowColours && utf8_is_colour_code(code))) + { writePtr = utf8_write_codepoint(writePtr, code); } } @@ -220,15 +263,20 @@ void utf8_remove_formatting(utf8* string, bool allowColours) { bool utf8_is_format_code(int32_t codepoint) { - if (codepoint < 32) return true; - if (codepoint >= FORMAT_ARGUMENT_CODE_START && codepoint <= FORMAT_ARGUMENT_CODE_END) return true; - if (codepoint >= FORMAT_COLOUR_CODE_START && codepoint <= FORMAT_COLOUR_CODE_END) return true; - if (codepoint == FORMAT_COMMA1DP16) return true; + if (codepoint < 32) + return true; + if (codepoint >= FORMAT_ARGUMENT_CODE_START && codepoint <= FORMAT_ARGUMENT_CODE_END) + return true; + if (codepoint >= FORMAT_COLOUR_CODE_START && codepoint <= FORMAT_COLOUR_CODE_END) + return true; + if (codepoint == FORMAT_COMMA1DP16) + return true; return false; } bool utf8_is_colour_code(int32_t codepoint) { - if (codepoint >= FORMAT_COLOUR_CODE_START && codepoint <= FORMAT_COLOUR_CODE_END) return true; + if (codepoint >= FORMAT_COLOUR_CODE_START && codepoint <= FORMAT_COLOUR_CODE_END) + return true; return false; } diff --git a/src/openrct2/localisation/User.cpp b/src/openrct2/localisation/User.cpp index 9fc9cfa1c0..5bc8fd2d4a 100644 --- a/src/openrct2/localisation/User.cpp +++ b/src/openrct2/localisation/User.cpp @@ -7,15 +7,16 @@ * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ +#include "User.h" + #include "../Game.h" #include "../ride/Ride.h" #include "../util/Util.h" #include "Localisation.h" -#include "User.h" utf8 gUserStrings[MAX_USER_STRINGS][USER_STRING_MAX_LENGTH]; -static bool user_string_exists(const utf8 *text); +static bool user_string_exists(const utf8* text); /** * @@ -30,19 +31,20 @@ void user_string_clear_all() * * rct2: 0x006C421D */ -rct_string_id user_string_allocate(int32_t base, const utf8 *text) +rct_string_id user_string_allocate(int32_t base, const utf8* text) { int32_t highBits = (base & 0x7F) << 9; bool allowDuplicates = base & USER_STRING_DUPLICATION_PERMITTED; - if (!allowDuplicates && user_string_exists(text)) { + if (!allowDuplicates && user_string_exists(text)) + { gGameCommandErrorText = STR_CHOSEN_NAME_IN_USE_ALREADY; return 0; } for (int32_t i = 0; i < MAX_USER_STRINGS; i++) { - char * userString = gUserStrings[i]; + char* userString = gUserStrings[i]; if (userString[0] != 0) continue; @@ -67,9 +69,9 @@ void user_string_free(rct_string_id id) gUserStrings[id][0] = 0; } -static bool user_string_exists(const utf8 *text) +static bool user_string_exists(const utf8* text) { - char * userString; + char* userString; for (int32_t i = 0; i < MAX_USER_STRINGS; i++) { userString = gUserStrings[i];