Codechange: automatic adding of _t to (u)int types, and WChar to char32_t
for i in `find src -type f|grep -v 3rdparty/fmt|grep -v 3rdparty/catch2|grep -v 3rdparty/opengl|grep -v stdafx.h`; do sed 's/uint16& /uint16 \&/g;s/int8\([ >*),;[]\)/int8_t\1/g;s/int16\([ >*),;[]\)/int16_t\1/g;s/int32\([ >*),;[]\)/int32_t\1/g;s/int64\([ >*),;[]\)/int64_t\1/g;s/ uint32(/ uint32_t(/g;s/_uint8_t/_uint8/;s/Uint8_t/Uint8/;s/ft_int64_t/ft_int64/g;s/uint64$/uint64_t/;s/WChar/char32_t/g;s/char32_t char32_t/char32_t WChar/' -i $i; done
This commit is contained in:
@@ -64,8 +64,8 @@ enum GRFExtendedLanguages {
|
||||
* since it is NOT SUPPOSED to happen.
|
||||
*/
|
||||
struct GRFTextEntry {
|
||||
uint32 grfid;
|
||||
uint16 stringid;
|
||||
uint32_t grfid;
|
||||
uint16_t stringid;
|
||||
StringID def_string;
|
||||
GRFTextList textholder;
|
||||
};
|
||||
@@ -158,13 +158,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;
|
||||
@@ -234,7 +234,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;
|
||||
@@ -243,7 +243,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) {
|
||||
@@ -257,7 +257,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);
|
||||
@@ -306,8 +306,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;
|
||||
@@ -351,8 +351,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;
|
||||
@@ -506,7 +506,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));
|
||||
}
|
||||
@@ -520,7 +520,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);
|
||||
@@ -541,7 +541,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
|
||||
@@ -591,7 +591,7 @@ 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)
|
||||
{
|
||||
for (uint id = 0; id < _num_grf_texts; id++) {
|
||||
if (_grf_text[id].grfid == grfid && _grf_text[id].stringid == stringid) {
|
||||
@@ -643,7 +643,7 @@ const char *GetGRFStringFromGRFText(const GRFTextWrapper &text)
|
||||
/**
|
||||
* Get a C-string from a stringid set by a newgrf.
|
||||
*/
|
||||
const char *GetGRFStringPtr(uint16 stringid)
|
||||
const char *GetGRFStringPtr(uint16_t stringid)
|
||||
{
|
||||
assert(_grf_text[stringid].grfid != 0);
|
||||
|
||||
@@ -706,29 +706,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()
|
||||
@@ -739,7 +739,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;
|
||||
@@ -811,15 +811,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++;
|
||||
|
Reference in New Issue
Block a user