1
0
Fork 0

Codechange: C++ initialise LanguageHeaderPack

pull/10004/merge
Rubidium 2025-05-06 18:33:22 +02:00 committed by rubidium42
parent 8f1e94c546
commit d70aeb72a7
3 changed files with 21 additions and 25 deletions

View File

@ -10,8 +10,6 @@
#ifndef MEM_FUNC_HPP
#define MEM_FUNC_HPP
#include "math_func.hpp"
/**
* Type-safe version of memcpy().
*

View File

@ -24,22 +24,22 @@ static const uint8_t MAX_NUM_CASES = 16; ///< Maximum number of supported case
struct LanguagePackHeader {
static const uint32_t IDENT = 0x474E414C; ///< Identifier for OpenTTD language files, big endian for "LANG"
uint32_t ident; ///< 32-bits identifier
uint32_t version; ///< 32-bits of auto generated version info which is basically a hash of strings.h
char name[32]; ///< the international name of this language
char own_name[32]; ///< the localized name of this language
char isocode[16]; ///< the ISO code for the language (not country code)
uint16_t offsets[TEXT_TAB_END]; ///< the offsets
uint32_t ident = 0; ///< 32-bits identifier
uint32_t version = 0; ///< 32-bits of auto generated version info which is basically a hash of strings.h
char name[32] = ""; ///< the international name of this language
char own_name[32] = ""; ///< the localized name of this language
char isocode[16] = ""; ///< the ISO code for the language (not country code)
uint16_t offsets[TEXT_TAB_END] = {}; ///< the offsets
/** Thousand separator used for anything not currencies */
char digit_group_separator[8];
char digit_group_separator[8] = ",";
/** Thousand separator used for currencies */
char digit_group_separator_currency[8];
char digit_group_separator_currency[8] = ",";
/** Decimal separator */
char digit_decimal_separator[8];
uint16_t missing; ///< number of missing strings.
uint8_t plural_form; ///< plural form index
uint8_t text_dir; ///< default direction of the text
char digit_decimal_separator[8] = ".";
uint16_t missing = 0; ///< number of missing strings.
uint8_t plural_form = 0; ///< plural form index
uint8_t text_dir = 0; ///< default direction of the text
/**
* Windows language ID:
* Windows cannot and will not convert isocodes to something it can use to
@ -48,14 +48,14 @@ struct LanguagePackHeader {
* what language it is in "Windows". The ID is the 'locale identifier' on:
* http://msdn.microsoft.com/en-us/library/ms776294.aspx
*/
uint16_t winlangid; ///< windows language id
uint8_t newgrflangid; ///< newgrf language id
uint8_t num_genders; ///< the number of genders of this language
uint8_t num_cases; ///< the number of cases of this language
uint8_t pad[3]; ///< pad header to be a multiple of 4
uint16_t winlangid = 0; ///< windows language id
uint8_t newgrflangid = 0; ///< newgrf language id
uint8_t num_genders = 0; ///< the number of genders of this language
uint8_t num_cases = 0; ///< the number of cases of this language
uint8_t pad[3] = {}; ///< pad header to be a multiple of 4
char genders[MAX_NUM_GENDERS][CASE_GENDER_LEN]; ///< the genders used by this translation
char cases[MAX_NUM_CASES][CASE_GENDER_LEN]; ///< the cases used by this translation
char genders[MAX_NUM_GENDERS][CASE_GENDER_LEN] = {}; ///< the genders used by this translation
char cases[MAX_NUM_CASES][CASE_GENDER_LEN] = {}; ///< the cases used by this translation
bool IsValid() const;
bool IsReasonablyFinished() const;

View File

@ -10,6 +10,7 @@
#include "../stdafx.h"
#include "../core/endian_func.hpp"
#include "../core/mem_func.hpp"
#include "../core/math_func.hpp"
#include "../error_func.h"
#include "../string_func.h"
#include "../core/string_builder.hpp"
@ -588,10 +589,7 @@ void StringReader::ParseFile()
_strgen.file = this->file;
/* For each new file we parse, reset the genders, and language codes. */
MemSetT(&_strgen.lang, 0);
strecpy(_strgen.lang.digit_group_separator, ",");
strecpy(_strgen.lang.digit_group_separator_currency, ",");
strecpy(_strgen.lang.digit_decimal_separator, ".");
_strgen.lang = {};
_strgen.cur_line = 1;
while (this->data.next_string_id < this->data.max_strings) {