Skip to content

Commit

Permalink
Codechange: automatic adding of _t to (u)int types
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rubidium42 committed Jun 26, 2023
1 parent 103d88e commit cd52110
Show file tree
Hide file tree
Showing 564 changed files with 4,584 additions and 4,584 deletions.
48 changes: 24 additions & 24 deletions src/3rdparty/md5/md5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@

#include "../../safeguards.h"

#define T_MASK ((uint32)~0)
#define T_MASK ((uint32_t)~0)
#define T1 /* 0xd76aa478 */ (T_MASK ^ 0x28955b87)
#define T2 /* 0xe8c7b756 */ (T_MASK ^ 0x173848a9)
#define T3 0x242070db
Expand Down Expand Up @@ -126,31 +126,31 @@
#define T63 0x2ad7d2bb
#define T64 /* 0xeb86d391 */ (T_MASK ^ 0x14792c6e)

static inline void Md5Set1(const uint32 *X, uint32 *a, const uint32 *b, const uint32 *c, const uint32 *d, const uint8 k, const uint8 s, const uint32 Ti)
static inline void Md5Set1(const uint32_t *X, uint32_t *a, const uint32_t *b, const uint32_t *c, const uint32_t *d, const uint8_t k, const uint8_t s, const uint32_t Ti)
{
uint32 t = (*b & *c) | (~*b & *d);
uint32_t t = (*b & *c) | (~*b & *d);
t += *a + X[k] + Ti;
*a = ROL(t, s) + *b;
}

static inline void Md5Set2(const uint32 *X, uint32 *a, const uint32 *b, const uint32 *c, const uint32 *d, const uint8 k, const uint8 s, const uint32 Ti)
static inline void Md5Set2(const uint32_t *X, uint32_t *a, const uint32_t *b, const uint32_t *c, const uint32_t *d, const uint8_t k, const uint8_t s, const uint32_t Ti)
{
uint32 t = (*b & *d) | (*c & ~*d);
uint32_t t = (*b & *d) | (*c & ~*d);
t += *a + X[k] + Ti;
*a = ROL(t, s) + *b;
}


static inline void Md5Set3(const uint32 *X, uint32 *a, const uint32 *b, const uint32 *c, const uint32 *d, const uint8 k, const uint8 s, const uint32 Ti)
static inline void Md5Set3(const uint32_t *X, uint32_t *a, const uint32_t *b, const uint32_t *c, const uint32_t *d, const uint8_t k, const uint8_t s, const uint32_t Ti)
{
uint32 t = *b ^ *c ^ *d;
uint32_t t = *b ^ *c ^ *d;
t += *a + X[k] + Ti;
*a = ROL(t, s) + *b;
}

static inline void Md5Set4(const uint32 *X, uint32 *a, const uint32 *b, const uint32 *c, const uint32 *d, const uint8 k, const uint8 s, const uint32 Ti)
static inline void Md5Set4(const uint32_t *X, uint32_t *a, const uint32_t *b, const uint32_t *c, const uint32_t *d, const uint8_t k, const uint8_t s, const uint32_t Ti)
{
uint32 t = *c ^ (*b | ~*d);
uint32_t t = *c ^ (*b | ~*d);
t += *a + X[k] + Ti;
*a = ROL(t, s) + *b;
}
Expand All @@ -165,17 +165,17 @@ Md5::Md5()
abcd[3] = 0x10325476;
}

void Md5::Process(const uint8 *data /*[64]*/)
void Md5::Process(const uint8_t *data /*[64]*/)
{
uint32 a = this->abcd[0];
uint32 b = this->abcd[1];
uint32 c = this->abcd[2];
uint32 d = this->abcd[3];
uint32_t a = this->abcd[0];
uint32_t b = this->abcd[1];
uint32_t c = this->abcd[2];
uint32_t d = this->abcd[3];

uint32 X[16];
uint32_t X[16];

/* Convert the uint8 data to uint32 LE */
const uint32 *px = (const uint32 *)data;
/* Convert the uint8_t data to uint32_t LE */
const uint32_t *px = (const uint32_t *)data;
for (uint i = 0; i < 16; i++) {
X[i] = TO_LE32(*px);
px++;
Expand Down Expand Up @@ -264,15 +264,15 @@ void Md5::Process(const uint8 *data /*[64]*/)

void Md5::Append(const void *data, const size_t nbytes)
{
const uint8 *p = (const uint8 *)data;
const uint8_t *p = (const uint8_t *)data;
size_t left = nbytes;
const size_t offset = (this->count[0] >> 3) & 63;
const uint32 nbits = (uint32)(nbytes << 3);
const uint32_t nbits = (uint32_t)(nbytes << 3);

if (nbytes <= 0) return;

/* Update the message length. */
this->count[1] += (uint32)(nbytes >> 29);
this->count[1] += (uint32_t)(nbytes >> 29);
this->count[0] += nbits;

if (this->count[0] < nbits) this->count[1]++;
Expand All @@ -299,17 +299,17 @@ void Md5::Append(const void *data, const size_t nbytes)

void Md5::Finish(MD5Hash &digest)
{
static const uint8 pad[64] = {
static const uint8_t pad[64] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
uint8 data[8];
uint8_t data[8];

/* Save the length before padding. */
for (uint i = 0; i < 8; ++i) {
data[i] = (uint8)(this->count[i >> 2] >> ((i & 3) << 3));
data[i] = (uint8_t)(this->count[i >> 2] >> ((i & 3) << 3));
}

/* Pad to 56 bytes mod 64. */
Expand All @@ -318,6 +318,6 @@ void Md5::Finish(MD5Hash &digest)
this->Append(data, 8);

for (uint i = 0; i < 16; ++i) {
digest[i] = (uint8)(this->abcd[i >> 2] >> ((i & 3) << 3));
digest[i] = (uint8_t)(this->abcd[i >> 2] >> ((i & 3) << 3));
}
}
8 changes: 4 additions & 4 deletions src/3rdparty/md5/md5.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ struct MD5Hash : std::array<byte, MD5_HASH_BYTES> {

struct Md5 {
private:
uint32 count[2]; ///< message length in bits, lsw first
uint32 abcd[4]; ///< digest buffer
uint8 buf[64]; ///< accumulate block
uint32_t count[2]; ///< message length in bits, lsw first
uint32_t abcd[4]; ///< digest buffer
uint8_t buf[64]; ///< accumulate block

void Process(const uint8 *data);
void Process(const uint8_t *data);

public:
Md5();
Expand Down
2 changes: 1 addition & 1 deletion src/3rdparty/squirrel/include/squirrel.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ typedef void (*SQPRINTFUNCTION)(HSQUIRRELVM,const std::string &);
typedef SQInteger (*SQWRITEFUNC)(SQUserPointer,SQUserPointer,SQInteger);
typedef SQInteger (*SQREADFUNC)(SQUserPointer,SQUserPointer,SQInteger);

typedef WChar (*SQLEXREADFUNC)(SQUserPointer);
typedef char32_t (*SQLEXREADFUNC)(SQUserPointer);

typedef struct tagSQRegFunction{
const SQChar *name;
Expand Down
6 changes: 3 additions & 3 deletions src/3rdparty/squirrel/squirrel/sqapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1259,9 +1259,9 @@ struct BufState{
SQInteger size;
};

WChar buf_lexfeed(SQUserPointer file)
char32_t buf_lexfeed(SQUserPointer file)
{
/* Convert an UTF-8 character into a WChar */
/* Convert an UTF-8 character into a char32_t */
BufState *buf = (BufState *)file;
const char *p = &buf->buf[buf->ptr];

Expand All @@ -1279,7 +1279,7 @@ WChar buf_lexfeed(SQUserPointer file)
buf->ptr += len;

/* Convert the character, and when definitely invalid, bail out as well. */
WChar c;
char32_t c;
if (Utf8Decode(&c, p) != len) return -1;

return c;
Expand Down
6 changes: 3 additions & 3 deletions src/3rdparty/squirrel/squirrel/sqlexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ SQLexer::~SQLexer()
_keywords->Release();
}

void SQLexer::APPEND_CHAR(WChar c)
void SQLexer::APPEND_CHAR(char32_t c)
{
char buf[4];
size_t chars = Utf8Encode(buf, c);
Expand Down Expand Up @@ -101,7 +101,7 @@ NORETURN void SQLexer::Error(const SQChar *err)

void SQLexer::Next()
{
WChar t = _readf(_up);
char32_t t = _readf(_up);
if(t > MAX_CHAR) Error("Invalid character");
if(t != 0) {
_currdata = t;
Expand Down Expand Up @@ -287,7 +287,7 @@ SQInteger SQLexer::GetIDType(SQChar *s)
}


SQInteger SQLexer::ReadString(WChar ndelim,bool verbatim)
SQInteger SQLexer::ReadString(char32_t ndelim,bool verbatim)
{
INIT_TEMP_STRING();
NEXT();
Expand Down
6 changes: 3 additions & 3 deletions src/3rdparty/squirrel/squirrel/sqlexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ struct SQLexer
const SQChar *Tok2Str(SQInteger tok);
private:
SQInteger GetIDType(SQChar *s);
SQInteger ReadString(WChar ndelim,bool verbatim);
SQInteger ReadString(char32_t ndelim,bool verbatim);
SQInteger ReadNumber();
void LexBlockComment();
SQInteger ReadID();
void Next();
SQInteger _curtoken;
SQTable *_keywords;
void INIT_TEMP_STRING() { _longstr.resize(0); }
void APPEND_CHAR(WChar c);
void APPEND_CHAR(char32_t c);
void TERMINATE_BUFFER() { _longstr.push_back('\0'); }

public:
Expand All @@ -32,7 +32,7 @@ struct SQLexer
SQFloat _fvalue;
SQLEXREADFUNC _readf;
SQUserPointer _up;
WChar _currdata;
char32_t _currdata;
SQSharedState *_sharedstate;
sqvector<SQChar> _longstr;
CompilerErrorFunc _errfunc;
Expand Down
8 changes: 4 additions & 4 deletions src/aircraft.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ int GetAircraftFlightLevel(T *v, bool takeoff = false);

/** Variables that are cached to improve performance and such. */
struct AircraftCache {
uint32 cached_max_range_sqr; ///< Cached squared maximum range.
uint16 cached_max_range; ///< Cached maximum range.
uint32_t cached_max_range_sqr; ///< Cached squared maximum range.
uint16_t cached_max_range; ///< Cached maximum range.
};

/**
* Aircraft, helicopters, rotors and their shadows belong to this class.
*/
struct Aircraft FINAL : public SpecializedVehicle<Aircraft, VEH_AIRCRAFT> {
uint16 crashed_counter; ///< Timer for handling crash animations.
uint16_t crashed_counter; ///< Timer for handling crash animations.
byte pos; ///< Next desired position of the aircraft.
byte previous_pos; ///< Previous desired position of the aircraft.
StationID targetairport; ///< Airport to go to next.
Expand Down Expand Up @@ -130,7 +130,7 @@ struct Aircraft FINAL : public SpecializedVehicle<Aircraft, VEH_AIRCRAFT> {
* Get the range of this aircraft.
* @return Range in tiles or 0 if unlimited range.
*/
uint16 GetRange() const
uint16_t GetRange() const
{
return this->acache.cached_max_range;
}
Expand Down
24 changes: 12 additions & 12 deletions src/aircraft_cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ static const SpriteID _aircraft_sprite[] = {
};

template <>
bool IsValidImageIndex<VEH_AIRCRAFT>(uint8 image_index)
bool IsValidImageIndex<VEH_AIRCRAFT>(uint8_t image_index)
{
return image_index < lengthof(_aircraft_sprite);
}
Expand Down Expand Up @@ -172,7 +172,7 @@ static StationID FindNearestHangar(const Aircraft *v)

void Aircraft::GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const
{
uint8 spritenum = this->spritenum;
uint8_t spritenum = this->spritenum;

if (is_custom_sprite(spritenum)) {
GetCustomVehicleSprite(this, direction, image_type, result);
Expand Down Expand Up @@ -202,7 +202,7 @@ void GetRotorImage(const Aircraft *v, EngineImageType image_type, VehicleSpriteS
static void GetAircraftIcon(EngineID engine, EngineImageType image_type, VehicleSpriteSeq *result)
{
const Engine *e = Engine::Get(engine);
uint8 spritenum = e->u.air.image_index;
uint8_t spritenum = e->u.air.image_index;

if (is_custom_sprite(spritenum)) {
GetCustomVehicleIcon(engine, DIR_W, image_type, result);
Expand Down Expand Up @@ -1174,7 +1174,7 @@ static bool HandleCrashedAircraft(Aircraft *v)
}

if (v->crashed_counter < 650) {
uint32 r;
uint32_t r;
if (Chance16R(1, 32, r)) {
static const DirDiff delta[] = {
DIRDIFF_45LEFT, DIRDIFF_SAME, DIRDIFF_SAME, DIRDIFF_45RIGHT
Expand Down Expand Up @@ -1218,8 +1218,8 @@ static bool HandleCrashedAircraft(Aircraft *v)
static void HandleAircraftSmoke(Aircraft *v, bool mode)
{
static const struct {
int8 x;
int8 y;
int8_t x;
int8_t y;
} smoke_pos[] = {
{ 5, 5 },
{ 6, 0 },
Expand Down Expand Up @@ -1358,7 +1358,7 @@ static void MaybeCrashAirplane(Aircraft *v)

Station *st = Station::Get(v->targetairport);

uint32 prob;
uint32_t prob;
if ((st->airport.GetFTA()->flags & AirportFTAClass::SHORT_STRIP) &&
(AircraftVehInfo(v->engine_type)->subtype & AIR_FAST) &&
!_cheats.no_jetcrash.value) {
Expand Down Expand Up @@ -1655,8 +1655,8 @@ static void AircraftEventHandler_Flying(Aircraft *v, const AirportFTAClass *apc)
/* save speed before, since if AirportHasBlock is false, it resets them to 0
* we don't want that for plane in air
* hack for speed thingie */
uint16 tcur_speed = v->cur_speed;
uint16 tsubspeed = v->subspeed;
uint16_t tcur_speed = v->cur_speed;
uint16_t tsubspeed = v->subspeed;
if (!AirportHasBlock(v, current, apc)) {
v->state = landingtype; // LANDING / HELILANDING
if (v->state == HELILANDING) SetBit(v->flags, VAF_HELI_DIRECT_DESCENT);
Expand Down Expand Up @@ -1840,7 +1840,7 @@ static bool AirportHasBlock(Aircraft *v, const AirportFTA *current_pos, const Ai
/* same block, then of course we can move */
if (apc->layout[current_pos->position].block != next->block) {
const Station *st = Station::Get(v->targetairport);
uint64 airport_flags = next->block;
uint64_t airport_flags = next->block;

/* check additional possible extra blocks */
if (current_pos != reference && current_pos->block != NOTHING_block) {
Expand Down Expand Up @@ -1870,7 +1870,7 @@ static bool AirportSetBlocks(Aircraft *v, const AirportFTA *current_pos, const A

/* if the next position is in another block, check it and wait until it is free */
if ((apc->layout[current_pos->position].block & next->block) != next->block) {
uint64 airport_flags = next->block;
uint64_t airport_flags = next->block;
/* search for all all elements in the list with the same state, and blocks != N
* this means more blocks should be checked/set */
const AirportFTA *current = current_pos;
Expand Down Expand Up @@ -1907,7 +1907,7 @@ static bool AirportSetBlocks(Aircraft *v, const AirportFTA *current_pos, const A
*/
struct MovementTerminalMapping {
AirportMovementStates state; ///< Aircraft movement state when going to this terminal.
uint64 airport_flag; ///< Bitmask in the airport flags that need to be free for this terminal.
uint64_t airport_flag; ///< Bitmask in the airport flags that need to be free for this terminal.
};

/** A list of all valid terminals and their associated blocks. */
Expand Down
8 changes: 4 additions & 4 deletions src/airport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ AIRPORT_GENERIC(dummy, nullptr, 0, AirportFTAClass::ALL, 0)
#include "table/airport_defaults.h"


static uint16 AirportGetNofElements(const AirportFTAbuildup *apFA);
static uint16_t AirportGetNofElements(const AirportFTAbuildup *apFA);
static AirportFTA *AirportBuildAutomata(uint nofelements, const AirportFTAbuildup *apFA);


Expand Down Expand Up @@ -147,9 +147,9 @@ AirportFTAClass::~AirportFTAClass()
* Since it is actually just a big array of AirportFTA types, we only
* know one element from the other by differing 'position' identifiers
*/
static uint16 AirportGetNofElements(const AirportFTAbuildup *apFA)
static uint16_t AirportGetNofElements(const AirportFTAbuildup *apFA)
{
uint16 nofelements = 0;
uint16_t nofelements = 0;
int temp = apFA[0].position;

for (uint i = 0; i < MAX_ELEMENTS; i++) {
Expand All @@ -171,7 +171,7 @@ static uint16 AirportGetNofElements(const AirportFTAbuildup *apFA)
static AirportFTA *AirportBuildAutomata(uint nofelements, const AirportFTAbuildup *apFA)
{
AirportFTA *FAutomata = MallocT<AirportFTA>(nofelements);
uint16 internalcounter = 0;
uint16_t internalcounter = 0;

for (uint i = 0; i < nofelements; i++) {
AirportFTA *current = &FAutomata[i];
Expand Down

0 comments on commit cd52110

Please sign in to comment.