Adding of _t to (u)int types, and WChar to char32_t

See: eaae0bb5e
This commit is contained in:
Jonathan G Rennison
2024-01-07 16:41:53 +00:00
parent 55d78a23be
commit 97e6f3062e
655 changed files with 7555 additions and 7555 deletions

View File

@@ -73,8 +73,8 @@ enum GRFExtendedLanguages {
struct GRFTextEntry {
GRFTextList textholder;
StringID def_string;
uint32 grfid;
uint16 stringid;
uint32_t grfid;
uint16_t stringid;
};
@@ -164,13 +164,13 @@ struct UnmappedChoiceList {
/* "<NUM CASES>" */
int count = 0;
for (uint8 i = 0; i < _current_language->num_cases; i++) {
for (uint8_t i = 0; i < _current_language->num_cases; i++) {
/* Count the ones we have a mapped string for. */
if (this->strings.find(lm->GetReverseMapping(i, false)) != this->strings.end()) count++;
}
*d++ = count;
for (uint8 i = 0; i < _current_language->num_cases; i++) {
for (uint8_t i = 0; i < _current_language->num_cases; i++) {
/* Resolve the string we're looking for. */
int idx = lm->GetReverseMapping(i, false);
if (this->strings.find(idx) == this->strings.end()) continue;
@@ -240,7 +240,7 @@ struct UnmappedChoiceList {
* @param byte80 The control code to use as replacement for the 0x80-value.
* @return The translated string.
*/
std::string TranslateTTDPatchCodes(uint32 grfid, uint8 language_id, bool allow_newlines, const std::string &str, StringControlCode byte80)
std::string TranslateTTDPatchCodes(uint32_t grfid, uint8_t language_id, bool allow_newlines, const std::string &str, StringControlCode byte80)
{
/* Empty input string? Nothing to do here. */
if (str.empty()) return str;
@@ -249,7 +249,7 @@ std::string TranslateTTDPatchCodes(uint32 grfid, uint8 language_id, bool allow_n
/* Is this an unicode string? */
bool unicode = false;
WChar marker;
char32_t marker;
size_t len = Utf8Decode(&marker, &*src);
if (marker == NFO_UTF8_IDENTIFIER) {
@@ -263,7 +263,7 @@ std::string TranslateTTDPatchCodes(uint32 grfid, uint8 language_id, bool allow_n
std::ostringstream dest;
std::ostreambuf_iterator<char> d(dest);
while (src != str.cend()) {
WChar c;
char32_t c;
if (unicode && Utf8EncodedCharLen(*src) != 0) {
c = Utf8Consume(src);
@@ -312,8 +312,8 @@ std::string TranslateTTDPatchCodes(uint32 grfid, uint8 language_id, bool allow_n
{
if (src[0] == '\0' || src[1] == '\0') goto string_end;
StringID string;
string = ((uint8)* src++);
string |= ((uint8)* src++) << 8;
string = ((uint8_t)* src++);
string |= ((uint8_t)* src++) << 8;
Utf8Encode(d, SCC_NEWGRF_STRINL);
Utf8Encode(d, MapGRFStringID(grfid, string));
break;
@@ -357,8 +357,8 @@ std::string TranslateTTDPatchCodes(uint32 grfid, uint8 language_id, bool allow_n
case 0x03:
{
if (src[0] == '\0' || src[1] == '\0') goto string_end;
uint16 tmp = ((uint8)* src++);
tmp |= ((uint8)* src++) << 8;
uint16_t tmp = ((uint8_t)* src++);
tmp |= ((uint8_t)* src++) << 8;
Utf8Encode(d, SCC_NEWGRF_PUSH_WORD);
Utf8Encode(d, tmp);
break;
@@ -517,7 +517,7 @@ static void AddGRFTextToList(GRFTextList &list, byte langid, const std::string &
* @param text_to_add The text to add to the list.
* @note All text-codes will be translated.
*/
void AddGRFTextToList(GRFTextList &list, byte langid, uint32 grfid, bool allow_newlines, const char *text_to_add)
void AddGRFTextToList(GRFTextList &list, byte langid, uint32_t grfid, bool allow_newlines, const char *text_to_add)
{
AddGRFTextToList(list, langid, TranslateTTDPatchCodes(grfid, langid, allow_newlines, text_to_add));
}
@@ -531,7 +531,7 @@ void AddGRFTextToList(GRFTextList &list, byte langid, uint32 grfid, bool allow_n
* @param text_to_add The text to add to the list.
* @note All text-codes will be translated.
*/
void AddGRFTextToList(GRFTextWrapper &list, byte langid, uint32 grfid, bool allow_newlines, const char *text_to_add)
void AddGRFTextToList(GRFTextWrapper &list, byte langid, uint32_t grfid, bool allow_newlines, const char *text_to_add)
{
if (!list) list.reset(new GRFTextList());
AddGRFTextToList(*list, langid, grfid, allow_newlines, text_to_add);
@@ -552,7 +552,7 @@ void AddGRFTextToList(GRFTextWrapper &list, const std::string &text_to_add)
/**
* Add the new read string into our structure.
*/
StringID AddGRFString(uint32 grfid, uint16 stringid, byte langid_to_add, bool new_scheme, bool allow_newlines, const char *text_to_add, StringID def_string)
StringID AddGRFString(uint32_t grfid, uint16_t stringid, byte langid_to_add, bool new_scheme, bool allow_newlines, const char *text_to_add, StringID def_string)
{
/* When working with the old language scheme (grf_version is less than 7) and
* English or American is among the set bits, simply add it as English in
@@ -573,7 +573,7 @@ StringID AddGRFString(uint32 grfid, uint16 stringid, byte langid_to_add, bool ne
}
uint id;
extern GRFFile *GetFileByGRFIDExpectCurrent(uint32 grfid);
extern GRFFile *GetFileByGRFIDExpectCurrent(uint32_t grfid);
GRFFile *grf = GetFileByGRFIDExpectCurrent(grfid);
if (grf == nullptr) return STR_EMPTY;
@@ -609,11 +609,11 @@ StringID AddGRFString(uint32 grfid, uint16 stringid, byte langid_to_add, bool ne
/**
* Returns the index for this stringid associated with its grfID
*/
StringID GetGRFStringID(uint32 grfid, StringID stringid)
StringID GetGRFStringID(uint32_t grfid, StringID stringid)
{
if (stringid > UINT16_MAX) return STR_UNDEFINED;
extern GRFFile *GetFileByGRFIDExpectCurrent(uint32 grfid);
extern GRFFile *GetFileByGRFIDExpectCurrent(uint32_t grfid);
GRFFile *grf = GetFileByGRFIDExpectCurrent(grfid);
if (unlikely(grf == nullptr)) {
for (uint id = 0; id < (uint)_grf_text.size(); id++) {
@@ -670,7 +670,7 @@ const char *GetDefaultLangGRFStringFromGRFText(const GRFTextList &text_list)
return default_text;
}
static std::array<std::pair<uint32, const char *>, 16> _grf_string_ptr_log;
static std::array<std::pair<uint32_t, const char *>, 16> _grf_string_ptr_log;
static unsigned int _grf_string_ptr_log_next = 0;
/**
@@ -693,7 +693,7 @@ const char *GetDefaultLangGRFStringFromGRFText(const GRFTextWrapper &text)
/**
* Get a C-string from a stringid set by a newgrf.
*/
const char *GetGRFStringPtr(uint32 stringid)
const char *GetGRFStringPtr(uint32_t stringid)
{
#if 0
assert_msg(stringid < _grf_text.size(), "stringid: %u, size: %u", stringid, (uint)_grf_text.size());
@@ -711,7 +711,7 @@ const char *GetGRFStringPtr(uint32 stringid)
str = GetStringPtr(_grf_text[stringid].def_string);
}
_grf_string_ptr_log[_grf_string_ptr_log_next] = std::pair<uint32, const char *>(stringid, str);
_grf_string_ptr_log[_grf_string_ptr_log_next] = std::pair<uint32_t, const char *>(stringid, str);
_grf_string_ptr_log_next = (_grf_string_ptr_log_next + 1) % _grf_string_ptr_log.size();
return str;
@@ -768,29 +768,29 @@ struct TextRefStack {
TextRefStack() : position(0), grffile(nullptr), used(false) {}
uint8 PopUnsignedByte() { assert(this->position < this->stack.size()); return this->stack[this->position++]; }
int8 PopSignedByte() { return (int8)this->PopUnsignedByte(); }
uint8_t PopUnsignedByte() { assert(this->position < this->stack.size()); return this->stack[this->position++]; }
int8_t PopSignedByte() { return (int8_t)this->PopUnsignedByte(); }
uint16 PopUnsignedWord()
uint16_t PopUnsignedWord()
{
uint16 val = this->PopUnsignedByte();
uint16_t val = this->PopUnsignedByte();
return val | (this->PopUnsignedByte() << 8);
}
int16 PopSignedWord() { return (int32)this->PopUnsignedWord(); }
int16_t PopSignedWord() { return (int32_t)this->PopUnsignedWord(); }
uint32 PopUnsignedDWord()
uint32_t PopUnsignedDWord()
{
uint32 val = this->PopUnsignedWord();
uint32_t val = this->PopUnsignedWord();
return val | (this->PopUnsignedWord() << 16);
}
int32 PopSignedDWord() { return (int32)this->PopUnsignedDWord(); }
int32_t PopSignedDWord() { return (int32_t)this->PopUnsignedDWord(); }
uint64 PopUnsignedQWord()
uint64_t PopUnsignedQWord()
{
uint64 val = this->PopUnsignedDWord();
return val | (((uint64)this->PopUnsignedDWord()) << 32);
uint64_t val = this->PopUnsignedDWord();
return val | (((uint64_t)this->PopUnsignedDWord()) << 32);
}
int64 PopSignedQWord() { return (int64)this->PopUnsignedQWord(); }
int64_t PopSignedQWord() { return (int64_t)this->PopUnsignedQWord(); }
/** Rotate the top four words down: W1, W2, W3, W4 -> W4, W1, W2, W3 */
void RotateTop4Words()
@@ -801,7 +801,7 @@ struct TextRefStack {
for (int i = 0; i < 2; i++) this->stack[this->position + i] = tmp[i];
}
void PushWord(uint16 word)
void PushWord(uint16_t word)
{
if (this->position >= 2) {
this->position -= 2;
@@ -871,15 +871,15 @@ void RestoreTextRefStackBackup(struct TextRefStack *backup)
* @param numEntries number of entries to copy from the registers
* @param values values to copy onto the stack; if nullptr the temporary NewGRF registers will be used instead
*/
void StartTextRefStackUsage(const GRFFile *grffile, byte numEntries, const uint32 *values)
void StartTextRefStackUsage(const GRFFile *grffile, byte numEntries, const uint32_t *values)
{
extern TemporaryStorageArray<int32, 0x110> _temp_store;
extern TemporaryStorageArray<int32_t, 0x110> _temp_store;
_newgrf_textrefstack.ResetStack(grffile);
auto stack_it = _newgrf_textrefstack.stack.begin();
for (uint i = 0; i < numEntries; i++) {
uint32 value = values != nullptr ? values[i] : _temp_store.GetValue(0x100 + i);
uint32_t value = values != nullptr ? values[i] : _temp_store.GetValue(0x100 + i);
for (uint j = 0; j < 32; j += 8) {
*stack_it = GB(value, j, 8);
stack_it++;
@@ -906,10 +906,10 @@ uint RemapNewGRFStringControlCode(uint scc, std::string *buffer, const char **st
{
auto too_many_newgrf_params = [&]() {
const char *buffer = *str;
uint32 grfid = 0;
uint32_t grfid = 0;
for (uint entry = 0; entry < _grf_string_ptr_log.size(); entry++) {
const char *txt = _grf_string_ptr_log[entry].second;
uint32 stringid = _grf_string_ptr_log[entry].first;
uint32_t stringid = _grf_string_ptr_log[entry].first;
if (txt != nullptr &&
buffer >= txt && buffer < txt + 8192 &&
buffer < txt + strlen(txt) &&
@@ -919,7 +919,7 @@ uint RemapNewGRFStringControlCode(uint scc, std::string *buffer, const char **st
}
}
if (grfid) {
extern GRFFile *GetFileByGRFID(uint32 grfid);
extern GRFFile *GetFileByGRFID(uint32_t grfid);
const GRFFile *grffile = GetFileByGRFID(grfid);
DEBUG(misc, 0, "Too many NewGRF string parameters (in %X, %s).", BSWAP32(grfid), grffile ? grffile->filename.c_str() : "????");
} else {
@@ -1117,7 +1117,7 @@ uint RemapNewGRFStringControlCode(uint scc, std::string *buffer, const char **st
}
}
uint32 GetStringGRFID(StringID string)
uint32_t GetStringGRFID(StringID string)
{
switch (GetStringTab(string)) {
case TEXT_TAB_NEWGRF_START: