1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-17 09:22:42 +01:00

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:
Rubidium
2023-05-08 19:01:06 +02:00
committed by rubidium42
parent 4f4810dc28
commit eaae0bb5e7
564 changed files with 4561 additions and 4561 deletions

View File

@@ -28,10 +28,10 @@ Randomizer _random, _interactive_random;
* Generate the next pseudo random number
* @return the random number
*/
uint32 Randomizer::Next()
uint32_t Randomizer::Next()
{
const uint32 s = this->state[0];
const uint32 t = this->state[1];
const uint32_t s = this->state[0];
const uint32_t t = this->state[1];
this->state[0] = s + ROR(t ^ 0x1234567F, 7) + 1;
return this->state[1] = ROR(s, 3) - 1;
@@ -43,16 +43,16 @@ uint32 Randomizer::Next()
* @param limit Limit of the range to be generated from.
* @return Random number in [0,\a limit)
*/
uint32 Randomizer::Next(uint32 limit)
uint32_t Randomizer::Next(uint32_t limit)
{
return ((uint64)this->Next() * (uint64)limit) >> 32;
return ((uint64_t)this->Next() * (uint64_t)limit) >> 32;
}
/**
* (Re)set the state of the random number generator.
* @param seed the new state
*/
void Randomizer::SetSeed(uint32 seed)
void Randomizer::SetSeed(uint32_t seed)
{
this->state[0] = seed;
this->state[1] = seed;
@@ -62,14 +62,14 @@ void Randomizer::SetSeed(uint32 seed)
* (Re)set the state of the random number generators.
* @param seed the new state
*/
void SetRandomSeed(uint32 seed)
void SetRandomSeed(uint32_t seed)
{
_random.SetSeed(seed);
_interactive_random.SetSeed(seed * 0x1234567);
}
#ifdef RANDOM_DEBUG
uint32 DoRandom(int line, const char *file)
uint32_t DoRandom(int line, const char *file)
{
if (_networking && (!_network_server || (NetworkClientSocket::IsValidID(0) && NetworkClientSocket::Get(0)->status != NetworkClientSocket::STATUS_INACTIVE))) {
Debug(random, 0, "{:08x}; {:02x}; {:04x}; {:02x}; {}:{}", TimerGameCalendar::date, TimerGameCalendar::date_fract, _frame_counter, (byte)_current_company, file, line);
@@ -78,8 +78,8 @@ uint32 DoRandom(int line, const char *file)
return _random.Next();
}
uint32 DoRandomRange(uint32 limit, int line, const char *file)
uint32_t DoRandomRange(uint32_t limit, int line, const char *file)
{
return ((uint64)DoRandom(line, file) * (uint64)limit) >> 32;
return ((uint64_t)DoRandom(line, file) * (uint64_t)limit) >> 32;
}
#endif /* RANDOM_DEBUG */