Changeset - r27737:728d55b97775
[Not reviewed]
master
! ! !
Rubidium - 12 months ago 2023-05-08 17:01:06
rubidium@openttd.org
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
122 files changed:
Changeset was too big and was cut off... Show full diff anyway
0 comments (0 inline, 0 general)
src/3rdparty/md5/md5.cpp
Show inline comments
 
@@ -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
 
@@ -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;
 
}
 
@@ -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++;
 
@@ -264,15 +264,15 @@ void Md5::Process(const uint8 *data /*[6
 

	
 
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]++;
 
@@ -299,17 +299,17 @@ void Md5::Append(const void *data, const
 

	
 
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. */
 
@@ -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));
 
	}
 
}
src/3rdparty/md5/md5.h
Show inline comments
 
@@ -74,11 +74,11 @@ struct MD5Hash : std::array<byte, MD5_HA
 

	
 
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();
src/3rdparty/squirrel/include/squirrel.h
Show inline comments
 
@@ -179,7 +179,7 @@ typedef void (*SQPRINTFUNCTION)(HSQUIRRE
 
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;
src/3rdparty/squirrel/squirrel/sqapi.cpp
Show inline comments
 
@@ -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];
 

	
 
@@ -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;
src/3rdparty/squirrel/squirrel/sqlexer.cpp
Show inline comments
 
@@ -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);
 
@@ -101,7 +101,7 @@ NORETURN void SQLexer::Error(const SQCha
 

	
 
void SQLexer::Next()
 
{
 
	WChar t = _readf(_up);
 
	char32_t t = _readf(_up);
 
	if(t > MAX_CHAR) Error("Invalid character");
 
	if(t != 0) {
 
		_currdata = t;
 
@@ -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();
src/3rdparty/squirrel/squirrel/sqlexer.h
Show inline comments
 
@@ -11,7 +11,7 @@ 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();
 
@@ -19,7 +19,7 @@ private:
 
	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:
 
@@ -32,7 +32,7 @@ public:
 
	SQFloat _fvalue;
 
	SQLEXREADFUNC _readf;
 
	SQUserPointer _up;
 
	WChar _currdata;
 
	char32_t _currdata;
 
	SQSharedState *_sharedstate;
 
	sqvector<SQChar> _longstr;
 
	CompilerErrorFunc _errfunc;
src/aircraft.h
Show inline comments
 
@@ -64,15 +64,15 @@ int GetAircraftFlightLevel(T *v, bool ta
 

	
 
/** 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.
 
@@ -130,7 +130,7 @@ struct Aircraft FINAL : public Specializ
 
	 * 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;
 
	}
src/aircraft_cmd.cpp
Show inline comments
 
@@ -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);
 
}
 
@@ -172,7 +172,7 @@ static StationID FindNearestHangar(const
 

	
 
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);
 
@@ -202,7 +202,7 @@ void GetRotorImage(const Aircraft *v, En
 
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);
 
@@ -1174,7 +1174,7 @@ static bool HandleCrashedAircraft(Aircra
 
	}
 

	
 
	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
 
@@ -1218,8 +1218,8 @@ static bool HandleCrashedAircraft(Aircra
 
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 },
 
@@ -1358,7 +1358,7 @@ static void MaybeCrashAirplane(Aircraft 
 

	
 
	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) {
 
@@ -1655,8 +1655,8 @@ static void AircraftEventHandler_Flying(
 
				/* 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);
 
@@ -1840,7 +1840,7 @@ static bool AirportHasBlock(Aircraft *v,
 
	/* 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) {
 
@@ -1870,7 +1870,7 @@ static bool AirportSetBlocks(Aircraft *v
 

	
 
	/* 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;
 
@@ -1907,7 +1907,7 @@ static bool AirportSetBlocks(Aircraft *v
 
 */
 
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. */
src/airport.cpp
Show inline comments
 
@@ -65,7 +65,7 @@ AIRPORT_GENERIC(dummy, nullptr, 0, Airpo
 
#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);
 

	
 

	
 
@@ -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++) {
 
@@ -171,7 +171,7 @@ static uint16 AirportGetNofElements(cons
 
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];
src/airport.h
Show inline comments
 
@@ -85,7 +85,7 @@ enum AirportMovementStates {
 
};
 

	
 
/** Movement Blocks on Airports blocks (eg_airport_flags). */
 
static const uint64
 
static const uint64_t
 
	TERM1_block              = 1ULL <<  0, ///< Block belonging to terminal 1.
 
	TERM2_block              = 1ULL <<  1, ///< Block belonging to terminal 2.
 
	TERM3_block              = 1ULL <<  2, ///< Block belonging to terminal 3.
 
@@ -129,9 +129,9 @@ static const uint64
 

	
 
/** A single location on an airport where aircraft can move to. */
 
struct AirportMovingData {
 
	int16 x;             ///< x-coordinate of the destination.
 
	int16 y;             ///< y-coordinate of the destination.
 
	uint16 flag;         ///< special flags when moving towards the destination.
 
	int16_t x;             ///< x-coordinate of the destination.
 
	int16_t y;             ///< y-coordinate of the destination.
 
	uint16_t flag;         ///< special flags when moving towards the destination.
 
	Direction direction; ///< Direction to turn the aircraft after reaching the destination.
 
};
 

	
 
@@ -189,7 +189,7 @@ DECLARE_ENUM_AS_BIT_SET(AirportFTAClass:
 
/** Internal structure used in openttd - Finite sTate mAchine --> FTA */
 
struct AirportFTA {
 
	AirportFTA *next;        ///< possible extra movement choices from this position
 
	uint64 block;            ///< 64 bit blocks (st->airport.flags), should be enough for the most complex airports
 
	uint64_t block;            ///< 64 bit blocks (st->airport.flags), should be enough for the most complex airports
 
	byte position;           ///< the position that an airplane is at
 
	byte next_position;      ///< next position from this position
 
	byte heading;            ///< heading (current orders), guiding an airplane to its target on an airport
src/articulated_vehicles.cpp
Show inline comments
 
@@ -36,7 +36,7 @@ static EngineID GetNextArticulatedPart(u
 

	
 
	const Engine *front_engine = Engine::Get(front_type);
 

	
 
	uint16 callback = GetVehicleCallback(CBID_VEHICLE_ARTIC_ENGINE, index, 0, front_type, front);
 
	uint16_t callback = GetVehicleCallback(CBID_VEHICLE_ARTIC_ENGINE, index, 0, front_type, front);
 
	if (callback == CALLBACK_FAILED) return INVALID_ENGINE;
 

	
 
	if (front_engine->GetGRF()->grf_version < 8) {
 
@@ -103,7 +103,7 @@ uint CountArticulatedParts(EngineID engi
 
 * @param cargo_type returns the default cargo type, if needed
 
 * @return capacity
 
 */
 
static inline uint16 GetVehicleDefaultCapacity(EngineID engine, CargoID *cargo_type)
 
static inline uint16_t GetVehicleDefaultCapacity(EngineID engine, CargoID *cargo_type)
 
{
 
	const Engine *e = Engine::Get(engine);
 
	CargoID cargo = (e->CanCarryCargo() ? e->GetDefaultCargoType() : (CargoID)CT_INVALID);
 
@@ -143,7 +143,7 @@ CargoArray GetCapacityOfArticulatedParts
 
	const Engine *e = Engine::Get(engine);
 

	
 
	CargoID cargo_type;
 
	uint16 cargo_capacity = GetVehicleDefaultCapacity(engine, &cargo_type);
 
	uint16_t cargo_capacity = GetVehicleDefaultCapacity(engine, &cargo_type);
 
	if (cargo_type < NUM_CARGO) capacity[cargo_type] = cargo_capacity;
 

	
 
	if (!e->IsGroundVehicle()) return capacity;
src/autoreplace_base.h
Show inline comments
 
@@ -15,7 +15,7 @@
 
#include "engine_type.h"
 
#include "group_type.h"
 

	
 
typedef uint16 EngineRenewID;
 
typedef uint16_t EngineRenewID;
 

	
 
/**
 
 * Memory pool for engine renew elements. DO NOT USE outside of engine.c. Is
src/autoreplace_cmd.cpp
Show inline comments
 
@@ -498,7 +498,7 @@ static CommandCost ReplaceChain(Vehicle 
 

	
 
	if (old_head->type == VEH_TRAIN) {
 
		/* Store the length of the old vehicle chain, rounded up to whole tiles */
 
		uint16 old_total_length = CeilDiv(Train::From(old_head)->gcache.cached_total_length, TILE_SIZE) * TILE_SIZE;
 
		uint16_t old_total_length = CeilDiv(Train::From(old_head)->gcache.cached_total_length, TILE_SIZE) * TILE_SIZE;
 

	
 
		int num_units = 0; ///< Number of units in the chain
 
		for (Train *w = Train::From(old_head); w != nullptr; w = w->GetNextUnit()) num_units++;
src/autoreplace_gui.cpp
Show inline comments
 
@@ -33,7 +33,7 @@
 

	
 
#include "safeguards.h"
 

	
 
void DrawEngineList(VehicleType type, const Rect &r, const GUIEngineList &eng_list, uint16 min, uint16 max, EngineID selected_id, bool show_count, GroupID selected_group);
 
void DrawEngineList(VehicleType type, const Rect &r, const GUIEngineList &eng_list, uint16_t min, uint16_t max, EngineID selected_id, bool show_count, GroupID selected_group);
 

	
 
static bool EngineNumberSorter(const GUIEngineListItem &a, const GUIEngineListItem &b)
 
{
src/base_consist.h
Show inline comments
 
@@ -18,16 +18,16 @@ struct BaseConsist {
 
	std::string name;                   ///< Name of vehicle
 

	
 
	/* Used for timetabling. */
 
	uint32 current_order_time;               ///< How many ticks have passed since this order started.
 
	int32 lateness_counter;                  ///< How many ticks late (or early if negative) this vehicle is.
 
	uint32_t current_order_time;               ///< How many ticks have passed since this order started.
 
	int32_t lateness_counter;                  ///< How many ticks late (or early if negative) this vehicle is.
 
	TimerGameCalendar::Date timetable_start; ///< When the vehicle is supposed to start the timetable.
 

	
 
	uint16 service_interval;            ///< The interval for (automatic) servicing; either in days or %.
 
	uint16_t service_interval;            ///< The interval for (automatic) servicing; either in days or %.
 

	
 
	VehicleOrderID cur_real_order_index;///< The index to the current real (non-implicit) order
 
	VehicleOrderID cur_implicit_order_index;///< The index to the current implicit order
 

	
 
	uint16 vehicle_flags;               ///< Used for gradual loading and other miscellaneous things (@see VehicleFlags enum)
 
	uint16_t vehicle_flags;               ///< Used for gradual loading and other miscellaneous things (@see VehicleFlags enum)
 

	
 
	virtual ~BaseConsist() = default;
 

	
src/base_media_base.h
Show inline comments
 
@@ -60,8 +60,8 @@ struct BaseSet {
 

	
 
	std::string name;              ///< The name of the base set
 
	TranslatedStrings description; ///< Description of the base set
 
	uint32 shortname;              ///< Four letter short variant of the name
 
	uint32 version;                ///< The version of this base set
 
	uint32_t shortname;              ///< Four letter short variant of the name
 
	uint32_t version;                ///< The version of this base set
 
	bool fallback;                 ///< This set is a fallback set, i.e. it should be used only as last resort
 

	
 
	MD5File files[NUM_FILES];      ///< All files part of this set
src/base_media_func.h
Show inline comments
 
@@ -59,7 +59,7 @@ bool BaseSet<T, Tnum_files, Tsearch_in_t
 

	
 
	fetch_metadata("shortname");
 
	for (uint i = 0; (*item->value)[i] != '\0' && i < 4; i++) {
 
		this->shortname |= ((uint8)(*item->value)[i]) << (i * 8);
 
		this->shortname |= ((uint8_t)(*item->value)[i]) << (i * 8);
 
	}
 

	
 
	fetch_metadata("version");
src/base_station_base.h
Show inline comments
 
@@ -21,20 +21,20 @@ extern StationPool _station_pool;
 

	
 
struct StationSpecList {
 
	const StationSpec *spec;
 
	uint32 grfid;      ///< GRF ID of this custom station
 
	uint32_t grfid;      ///< GRF ID of this custom station
 
	uint16_t localidx; ///< Station ID within GRF of station
 
};
 

	
 
struct RoadStopSpecList {
 
	const RoadStopSpec *spec;
 
	uint32 grfid;      ///< GRF ID of this custom road stop
 
	uint32_t grfid;      ///< GRF ID of this custom road stop
 
	uint16_t localidx; ///< Station ID within GRF of road stop
 
};
 

	
 
struct RoadStopTileData {
 
	TileIndex tile;
 
	uint8 random_bits;
 
	uint8 animation_frame;
 
	uint8_t random_bits;
 
	uint8_t animation_frame;
 
};
 

	
 
/** StationRect - used to track station spread out rectangle - cheaper than scanning whole map */
 
@@ -79,10 +79,10 @@ struct BaseStation : StationPool::PoolIt
 

	
 
	TimerGameCalendar::Date build_date; ///< Date of construction
 

	
 
	uint16 random_bits;             ///< Random bits assigned to this station
 
	uint16_t random_bits;             ///< Random bits assigned to this station
 
	byte waiting_triggers;          ///< Waiting triggers (NewGRF) for this station
 
	uint8 cached_anim_triggers;                ///< NOSAVE: Combined animation trigger bitmask, used to determine if trigger processing should happen.
 
	uint8 cached_roadstop_anim_triggers;       ///< NOSAVE: Combined animation trigger bitmask for road stops, used to determine if trigger processing should happen.
 
	uint8_t cached_anim_triggers;                ///< NOSAVE: Combined animation trigger bitmask, used to determine if trigger processing should happen.
 
	uint8_t cached_roadstop_anim_triggers;       ///< NOSAVE: Combined animation trigger bitmask for road stops, used to determine if trigger processing should happen.
 
	CargoTypes cached_cargo_triggers;          ///< NOSAVE: Combined cargo trigger bitmask
 
	CargoTypes cached_roadstop_cargo_triggers; ///< NOSAVE: Combined cargo trigger bitmask for road stops
 

	
 
@@ -118,7 +118,7 @@ struct BaseStation : StationPool::PoolIt
 
	 * @param available will return false if ever the variable asked for does not exist
 
	 * @return the value stored in the corresponding variable
 
	 */
 
	virtual uint32 GetNewGRFVariable(const struct ResolverObject &object, byte variable, byte parameter, bool *available) const = 0;
 
	virtual uint32_t GetNewGRFVariable(const struct ResolverObject &object, byte variable, byte parameter, bool *available) const = 0;
 

	
 
	/**
 
	 * Update the coordinated of the sign (as shown in the viewport).
src/blitter/32bpp_anim.cpp
Show inline comments
 
@@ -30,26 +30,26 @@ inline void Blitter_32bppAnim::Draw(cons
 
	const SpriteData *src = (const SpriteData *)bp->sprite;
 

	
 
	const Colour *src_px = (const Colour *)(src->data + src->offset[zoom][0]);
 
	const uint16 *src_n  = (const uint16 *)(src->data + src->offset[zoom][1]);
 
	const uint16_t *src_n  = (const uint16_t *)(src->data + src->offset[zoom][1]);
 

	
 
	for (uint i = bp->skip_top; i != 0; i--) {
 
		src_px = (const Colour *)((const byte *)src_px + *(const uint32 *)src_px);
 
		src_n  = (const uint16 *)((const byte *)src_n  + *(const uint32 *)src_n);
 
		src_px = (const Colour *)((const byte *)src_px + *(const uint32_t *)src_px);
 
		src_n  = (const uint16_t *)((const byte *)src_n  + *(const uint32_t *)src_n);
 
	}
 

	
 
	Colour *dst = (Colour *)bp->dst + bp->top * bp->pitch + bp->left;
 
	uint16 *anim = this->anim_buf + this->ScreenToAnimOffset((uint32 *)bp->dst) + bp->top * this->anim_buf_pitch + bp->left;
 
	uint16_t *anim = this->anim_buf + this->ScreenToAnimOffset((uint32_t *)bp->dst) + bp->top * this->anim_buf_pitch + bp->left;
 

	
 
	const byte *remap = bp->remap; // store so we don't have to access it via bp every time
 

	
 
	for (int y = 0; y < bp->height; y++) {
 
		Colour *dst_ln = dst + bp->pitch;
 
		uint16 *anim_ln = anim + this->anim_buf_pitch;
 
		uint16_t *anim_ln = anim + this->anim_buf_pitch;
 

	
 
		const Colour *src_px_ln = (const Colour *)((const byte *)src_px + *(const uint32 *)src_px);
 
		const Colour *src_px_ln = (const Colour *)((const byte *)src_px + *(const uint32_t *)src_px);
 
		src_px++;
 

	
 
		const uint16 *src_n_ln = (const uint16 *)((const byte *)src_n + *(const uint32 *)src_n);
 
		const uint16_t *src_n_ln = (const uint16_t *)((const byte *)src_n + *(const uint32_t *)src_n);
 
		src_n += 2;
 

	
 
		Colour *dst_end = dst + bp->skip_left;
 
@@ -144,7 +144,7 @@ inline void Blitter_32bppAnim::Draw(cons
 
						do {
 
							uint m = *src_n;
 
							if (m == 0) {
 
								uint8 g = MakeDark(src_px->r, src_px->g, src_px->b);
 
								uint8_t g = MakeDark(src_px->r, src_px->g, src_px->b);
 
								*dst = ComposeColourRGBA(g, g, g, src_px->a, *dst);
 
								*anim = 0;
 
							} else {
 
@@ -162,7 +162,7 @@ inline void Blitter_32bppAnim::Draw(cons
 
							uint m = *src_n;
 
							if (m == 0) {
 
								if (src_px->a != 0) {
 
									uint8 g = MakeDark(src_px->r, src_px->g, src_px->b);
 
									uint8_t g = MakeDark(src_px->r, src_px->g, src_px->b);
 
									*dst = ComposeColourRGBA(g, g, g, src_px->a, *dst);
 
									*anim = 0;
 
								}
 
@@ -278,7 +278,7 @@ void Blitter_32bppAnim::DrawColourMappin
 
	}
 

	
 
	Colour *udst = (Colour *)dst;
 
	uint16 *anim = this->anim_buf + this->ScreenToAnimOffset((uint32 *)dst);
 
	uint16_t *anim = this->anim_buf + this->ScreenToAnimOffset((uint32_t *)dst);
 

	
 
	if (pal == PALETTE_TO_TRANSPARENT) {
 
		do {
 
@@ -310,17 +310,17 @@ void Blitter_32bppAnim::DrawColourMappin
 
	Debug(misc, 0, "32bpp blitter doesn't know how to draw this colour table ('{}')", pal);
 
}
 

	
 
void Blitter_32bppAnim::SetPixel(void *video, int x, int y, uint8 colour)
 
void Blitter_32bppAnim::SetPixel(void *video, int x, int y, uint8_t colour)
 
{
 
	*((Colour *)video + x + y * _screen.pitch) = LookupColourInPalette(colour);
 

	
 
	/* Set the colour in the anim-buffer too, if we are rendering to the screen */
 
	if (_screen_disable_anim) return;
 

	
 
	this->anim_buf[this->ScreenToAnimOffset((uint32 *)video) + x + y * this->anim_buf_pitch] = colour | (DEFAULT_BRIGHTNESS << 8);
 
	this->anim_buf[this->ScreenToAnimOffset((uint32_t *)video) + x + y * this->anim_buf_pitch] = colour | (DEFAULT_BRIGHTNESS << 8);
 
}
 

	
 
void Blitter_32bppAnim::DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash)
 
void Blitter_32bppAnim::DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8_t colour, int width, int dash)
 
{
 
	const Colour c = LookupColourInPalette(colour);
 

	
 
@@ -329,8 +329,8 @@ void Blitter_32bppAnim::DrawLine(void *v
 
			*((Colour *)video + x + y * _screen.pitch) = c;
 
		});
 
	} else {
 
		uint16 * const offset_anim_buf = this->anim_buf + this->ScreenToAnimOffset((uint32 *)video);
 
		const uint16 anim_colour = colour | (DEFAULT_BRIGHTNESS << 8);
 
		uint16_t * const offset_anim_buf = this->anim_buf + this->ScreenToAnimOffset((uint32_t *)video);
 
		const uint16_t anim_colour = colour | (DEFAULT_BRIGHTNESS << 8);
 
		this->DrawLineGeneric(x, y, x2, y2, screen_width, screen_height, width, dash, [&](int x, int y) {
 
			*((Colour *)video + x + y * _screen.pitch) = c;
 
			offset_anim_buf[x + y * this->anim_buf_pitch] = anim_colour;
 
@@ -338,7 +338,7 @@ void Blitter_32bppAnim::DrawLine(void *v
 
	}
 
}
 

	
 
void Blitter_32bppAnim::DrawRect(void *video, int width, int height, uint8 colour)
 
void Blitter_32bppAnim::DrawRect(void *video, int width, int height, uint8_t colour)
 
{
 
	if (_screen_disable_anim) {
 
		/* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent DrawRect() */
 
@@ -347,11 +347,11 @@ void Blitter_32bppAnim::DrawRect(void *v
 
	}
 

	
 
	Colour colour32 = LookupColourInPalette(colour);
 
	uint16 *anim_line = this->ScreenToAnimOffset((uint32 *)video) + this->anim_buf;
 
	uint16_t *anim_line = this->ScreenToAnimOffset((uint32_t *)video) + this->anim_buf;
 

	
 
	do {
 
		Colour *dst = (Colour *)video;
 
		uint16 *anim = anim_line;
 
		uint16_t *anim = anim_line;
 

	
 
		for (int i = width; i > 0; i--) {
 
			*dst = colour32;
 
@@ -360,7 +360,7 @@ void Blitter_32bppAnim::DrawRect(void *v
 
			dst++;
 
			anim++;
 
		}
 
		video = (uint32 *)video + _screen.pitch;
 
		video = (uint32_t *)video + _screen.pitch;
 
		anim_line += this->anim_buf_pitch;
 
	} while (--height);
 
}
 
@@ -368,22 +368,22 @@ void Blitter_32bppAnim::DrawRect(void *v
 
void Blitter_32bppAnim::CopyFromBuffer(void *video, const void *src, int width, int height)
 
{
 
	assert(!_screen_disable_anim);
 
	assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
 
	assert(video >= _screen.dst_ptr && video <= (uint32_t *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
 
	Colour *dst = (Colour *)video;
 
	const uint32 *usrc = (const uint32 *)src;
 
	uint16 *anim_line = this->ScreenToAnimOffset((uint32 *)video) + this->anim_buf;
 
	const uint32_t *usrc = (const uint32_t *)src;
 
	uint16_t *anim_line = this->ScreenToAnimOffset((uint32_t *)video) + this->anim_buf;
 

	
 
	for (; height > 0; height--) {
 
		/* We need to keep those for palette animation. */
 
		Colour *dst_pal = dst;
 
		uint16 *anim_pal = anim_line;
 
		uint16_t *anim_pal = anim_line;
 

	
 
		memcpy(static_cast<void *>(dst), usrc, width * sizeof(uint32));
 
		memcpy(static_cast<void *>(dst), usrc, width * sizeof(uint32_t));
 
		usrc += width;
 
		dst += _screen.pitch;
 
		/* Copy back the anim-buffer */
 
		memcpy(anim_line, usrc, width * sizeof(uint16));
 
		usrc = (const uint32 *)&((const uint16 *)usrc)[width];
 
		memcpy(anim_line, usrc, width * sizeof(uint16_t));
 
		usrc = (const uint32_t *)&((const uint16_t *)usrc)[width];
 
		anim_line += this->anim_buf_pitch;
 

	
 
		/* Okay, it is *very* likely that the image we stored is using
 
@@ -408,21 +408,21 @@ void Blitter_32bppAnim::CopyFromBuffer(v
 
void Blitter_32bppAnim::CopyToBuffer(const void *video, void *dst, int width, int height)
 
{
 
	assert(!_screen_disable_anim);
 
	assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
 
	uint32 *udst = (uint32 *)dst;
 
	const uint32 *src = (const uint32 *)video;
 
	assert(video >= _screen.dst_ptr && video <= (uint32_t *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
 
	uint32_t *udst = (uint32_t *)dst;
 
	const uint32_t *src = (const uint32_t *)video;
 

	
 
	if (this->anim_buf == nullptr) return;
 

	
 
	const uint16 *anim_line = this->ScreenToAnimOffset((const uint32 *)video) + this->anim_buf;
 
	const uint16_t *anim_line = this->ScreenToAnimOffset((const uint32_t *)video) + this->anim_buf;
 

	
 
	for (; height > 0; height--) {
 
		memcpy(udst, src, width * sizeof(uint32));
 
		memcpy(udst, src, width * sizeof(uint32_t));
 
		src += _screen.pitch;
 
		udst += width;
 
		/* Copy the anim-buffer */
 
		memcpy(udst, anim_line, width * sizeof(uint16));
 
		udst = (uint32 *)&((uint16 *)udst)[width];
 
		memcpy(udst, anim_line, width * sizeof(uint16_t));
 
		udst = (uint32_t *)&((uint16_t *)udst)[width];
 
		anim_line += this->anim_buf_pitch;
 
	}
 
}
 
@@ -430,8 +430,8 @@ void Blitter_32bppAnim::CopyToBuffer(con
 
void Blitter_32bppAnim::ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y)
 
{
 
	assert(!_screen_disable_anim);
 
	assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
 
	uint16 *dst, *src;
 
	assert(video >= _screen.dst_ptr && video <= (uint32_t *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
 
	uint16_t *dst, *src;
 

	
 
	/* We need to scroll the anim-buffer too */
 
	if (scroll_y > 0) {
 
@@ -448,7 +448,7 @@ void Blitter_32bppAnim::ScrollBuffer(voi
 
		uint tw = width + (scroll_x >= 0 ? -scroll_x : scroll_x);
 
		uint th = height - scroll_y;
 
		for (; th > 0; th--) {
 
			memcpy(dst, src, tw * sizeof(uint16));
 
			memcpy(dst, src, tw * sizeof(uint16_t));
 
			src -= this->anim_buf_pitch;
 
			dst -= this->anim_buf_pitch;
 
		}
 
@@ -469,7 +469,7 @@ void Blitter_32bppAnim::ScrollBuffer(voi
 
		uint tw = width + (scroll_x >= 0 ? -scroll_x : scroll_x);
 
		uint th = height + scroll_y;
 
		for (; th > 0; th--) {
 
			memmove(dst, src, tw * sizeof(uint16));
 
			memmove(dst, src, tw * sizeof(uint16_t));
 
			src += this->anim_buf_pitch;
 
			dst += this->anim_buf_pitch;
 
		}
 
@@ -480,7 +480,7 @@ void Blitter_32bppAnim::ScrollBuffer(voi
 

	
 
size_t Blitter_32bppAnim::BufferSize(uint width, uint height)
 
{
 
	return (sizeof(uint32) + sizeof(uint16)) * width * height;
 
	return (sizeof(uint32_t) + sizeof(uint16_t)) * width * height;
 
}
 

	
 
void Blitter_32bppAnim::PaletteAnimate(const Palette &palette)
 
@@ -493,7 +493,7 @@ void Blitter_32bppAnim::PaletteAnimate(c
 
	 *  Especially when going between toyland and non-toyland. */
 
	assert(this->palette.first_dirty == PALETTE_ANIM_START || this->palette.first_dirty == 0);
 

	
 
	const uint16 *anim = this->anim_buf;
 
	const uint16_t *anim = this->anim_buf;
 
	Colour *dst = (Colour *)_screen.dst_ptr;
 

	
 
	/* Let's walk the anim buffer and try to find the pixels */
 
@@ -502,8 +502,8 @@ void Blitter_32bppAnim::PaletteAnimate(c
 
	const int anim_pitch_offset = this->anim_buf_pitch - width;
 
	for (int y = this->anim_buf_height; y != 0 ; y--) {
 
		for (int x = width; x != 0 ; x--) {
 
			uint16 value = *anim;
 
			uint8 colour = GB(value, 0, 8);
 
			uint16_t value = *anim;
 
			uint8_t colour = GB(value, 0, 8);
 
			if (colour >= PALETTE_ANIM_START) {
 
				/* Update this pixel */
 
				*dst = this->AdjustBrightness(LookupColourInPalette(colour), GB(value, 8, 8));
 
@@ -533,9 +533,9 @@ void Blitter_32bppAnim::PostResize()
 
		this->anim_buf_width = _screen.width;
 
		this->anim_buf_height = _screen.height;
 
		this->anim_buf_pitch = (_screen.width + 7) & ~7;
 
		this->anim_alloc = CallocT<uint16>(this->anim_buf_pitch * this->anim_buf_height + 8);
 
		this->anim_alloc = CallocT<uint16_t>(this->anim_buf_pitch * this->anim_buf_height + 8);
 

	
 
		/* align buffer to next 16 byte boundary */
 
		this->anim_buf = reinterpret_cast<uint16 *>((reinterpret_cast<uintptr_t>(this->anim_alloc) + 0xF) & (~0xF));
 
		this->anim_buf = reinterpret_cast<uint16_t *>((reinterpret_cast<uintptr_t>(this->anim_alloc) + 0xF) & (~0xF));
 
	}
 
}
src/blitter/32bpp_anim.hpp
Show inline comments
 
@@ -15,7 +15,7 @@
 
/** The optimised 32 bpp blitter with palette animation. */
 
class Blitter_32bppAnim : public Blitter_32bppOptimized {
 
protected:
 
	uint16 *anim_buf;    ///< In this buffer we keep track of the 8bpp indexes so we can do palette animation
 
	uint16_t *anim_buf;    ///< In this buffer we keep track of the 8bpp indexes so we can do palette animation
 
	void *anim_alloc;    ///< The raw allocated buffer, not necessarily aligned correctly
 
	int anim_buf_width;  ///< The width of the animation buffer.
 
	int anim_buf_height; ///< The height of the animation buffer.
 
@@ -37,9 +37,9 @@ public:
 

	
 
	void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override;
 
	void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) override;
 
	void SetPixel(void *video, int x, int y, uint8 colour) override;
 
	void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash) override;
 
	void DrawRect(void *video, int width, int height, uint8 colour) override;
 
	void SetPixel(void *video, int x, int y, uint8_t colour) override;
 
	void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8_t colour, int width, int dash) override;
 
	void DrawRect(void *video, int width, int height, uint8_t colour) override;
 
	void CopyFromBuffer(void *video, const void *src, int width, int height) override;
 
	void CopyToBuffer(const void *video, void *dst, int width, int height) override;
 
	void ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y) override;
 
@@ -59,9 +59,9 @@ public:
 
		return this->palette.palette[index];
 
	}
 

	
 
	inline int ScreenToAnimOffset(const uint32 *video)
 
	inline int ScreenToAnimOffset(const uint32_t *video)
 
	{
 
		int raw_offset = video - (const uint32 *)_screen.dst_ptr;
 
		int raw_offset = video - (const uint32_t *)_screen.dst_ptr;
 
		if (_screen.pitch == this->anim_buf_pitch) return raw_offset;
 
		int lines = raw_offset / _screen.pitch;
 
		int across = raw_offset % _screen.pitch;
src/blitter/32bpp_anim_sse2.cpp
Show inline comments
 
@@ -30,7 +30,7 @@ void Blitter_32bppSSE2_Anim::PaletteAnim
 
	 *  Especially when going between toyland and non-toyland. */
 
	assert(this->palette.first_dirty == PALETTE_ANIM_START || this->palette.first_dirty == 0);
 

	
 
	const uint16 *anim = this->anim_buf;
 
	const uint16_t *anim = this->anim_buf;
 
	Colour *dst = (Colour *)_screen.dst_ptr;
 

	
 
	bool screen_dirty = false;
 
@@ -44,7 +44,7 @@ void Blitter_32bppSSE2_Anim::PaletteAnim
 
	__m128i colour_mask = _mm_set1_epi16(0xFF);
 
	for (int y = this->anim_buf_height; y != 0 ; y--) {
 
		Colour *next_dst_ln = dst + screen_pitch;
 
		const uint16 *next_anim_ln = anim + anim_pitch;
 
		const uint16_t *next_anim_ln = anim + anim_pitch;
 
		int x = width;
 
		while (x > 0) {
 
			__m128i data = _mm_load_si128((const __m128i *) anim);
 
@@ -61,7 +61,7 @@ void Blitter_32bppSSE2_Anim::PaletteAnim
 
					/* slow path: < 8 pixels left or unexpected brightnesses */
 
					for (int z = std::min<int>(x, 8); z != 0 ; z--) {
 
						int value = _mm_extract_epi16(data, 0);
 
						uint8 colour = GB(value, 0, 8);
 
						uint8_t colour = GB(value, 0, 8);
 
						if (colour >= PALETTE_ANIM_START) {
 
							/* Update this pixel */
 
							*dst = AdjustBrightneSSE(LookupColourInPalette(colour), GB(value, 8, 8));
src/blitter/32bpp_anim_sse4.cpp
Show inline comments
 
@@ -34,7 +34,7 @@ inline void Blitter_32bppSSE4_Anim::Draw
 
{
 
	const byte * const remap = bp->remap;
 
	Colour *dst_line = (Colour *) bp->dst + bp->top * bp->pitch + bp->left;
 
	uint16 *anim_line = this->anim_buf + this->ScreenToAnimOffset((uint32 *)bp->dst) + bp->top * this->anim_buf_pitch + bp->left;
 
	uint16_t *anim_line = this->anim_buf + this->ScreenToAnimOffset((uint32_t *)bp->dst) + bp->top * this->anim_buf_pitch + bp->left;
 
	int effective_width = bp->width;
 

	
 
	/* Find where to start reading in the source sprite. */
 
@@ -59,7 +59,7 @@ inline void Blitter_32bppSSE4_Anim::Draw
 
		Colour *dst = dst_line;
 
		const Colour *src = src_rgba_line + META_LENGTH;
 
		if (mode != BM_TRANSPARENT) src_mv = src_mv_line;
 
		uint16 *anim = anim_line;
 
		uint16_t *anim = anim_line;
 

	
 
		if (read_mode == RM_WITH_MARGIN) {
 
			assert(bt_last == BT_NONE); // or you must ensure block type is preserved
 
@@ -81,7 +81,7 @@ inline void Blitter_32bppSSE4_Anim::Draw
 
					for (uint x = (uint) effective_width; x > 0; x--) {
 
						if (src->a) {
 
							if (animated) {
 
								*anim = *(const uint16*) src_mv;
 
								*anim = *(const uint16_t*) src_mv;
 
								*dst = (src_mv->m >= PALETTE_ANIM_START) ? AdjustBrightneSSE(this->LookupColourInPalette(src_mv->m), src_mv->v) : src->data;
 
							} else {
 
								*anim = 0;
 
@@ -97,7 +97,7 @@ inline void Blitter_32bppSSE4_Anim::Draw
 
				}
 

	
 
				for (uint x = (uint) effective_width/2; x != 0; x--) {
 
					uint32 mvX2 = *((uint32 *) const_cast<MapValue *>(src_mv));
 
					uint32_t mvX2 = *((uint32_t *) const_cast<MapValue *>(src_mv));
 
					__m128i srcABCD = _mm_loadl_epi64((const __m128i*) src);
 
					__m128i dstABCD = _mm_loadl_epi64((__m128i*) dst);
 

	
 
@@ -117,26 +117,26 @@ inline void Blitter_32bppSSE4_Anim::Draw
 
						/* Update anim buffer. */
 
						const byte a0 = src[0].a;
 
						const byte a1 = src[1].a;
 
						uint32 anim01 = 0;
 
						uint32_t anim01 = 0;
 
						if (a0 == 255) {
 
							if (a1 == 255) {
 
								*(uint32*) anim = mvX2;
 
								*(uint32_t*) anim = mvX2;
 
								goto bmno_full_opacity;
 
							}
 
							anim01 = (uint16) mvX2;
 
							anim01 = (uint16_t) mvX2;
 
						} else if (a0 == 0) {
 
							if (a1 == 0) {
 
								goto bmno_full_transparency;
 
							} else {
 
								if (a1 == 255) anim[1] = (uint16) (mvX2 >> 16);
 
								if (a1 == 255) anim[1] = (uint16_t) (mvX2 >> 16);
 
								goto bmno_alpha_blend;
 
							}
 
						}
 
						if (a1 > 0) {
 
							if (a1 == 255) anim01 |= mvX2 & 0xFFFF0000;
 
							*(uint32*) anim = anim01;
 
							*(uint32_t*) anim = anim01;
 
						} else {
 
							anim[0] = (uint16) anim01;
 
							anim[0] = (uint16_t) anim01;
 
						}
 
					} else {
 
						if (src[0].a) anim[0] = 0;
 
@@ -159,7 +159,7 @@ bmno_full_transparency:
 
					if (src->a == 0) {
 
						/* Complete transparency. */
 
					} else if (src->a == 255) {
 
						*anim = *(const uint16*) src_mv;
 
						*anim = *(const uint16_t*) src_mv;
 
						*dst = (src_mv->m >= PALETTE_ANIM_START) ? AdjustBrightneSSE(LookupColourInPalette(src_mv->m), src_mv->v) : *src;
 
					} else {
 
						*anim = 0;
 
@@ -179,7 +179,7 @@ bmno_full_transparency:
 

	
 
			case BM_COLOUR_REMAP:
 
				for (uint x = (uint) effective_width / 2; x != 0; x--) {
 
					uint32 mvX2 = *((uint32 *) const_cast<MapValue *>(src_mv));
 
					uint32_t mvX2 = *((uint32_t *) const_cast<MapValue *>(src_mv));
 
					__m128i srcABCD = _mm_loadl_epi64((const __m128i*) src);
 
					__m128i dstABCD = _mm_loadl_epi64((__m128i*) dst);
 

	
 
@@ -201,14 +201,14 @@ bmno_full_transparency:
 
							m_colour = m != 0 ? m_colour : srcm; \
 
							}
 
#ifdef POINTER_IS_64BIT
 
						uint64 srcs = _mm_cvtsi128_si64(srcABCD);
 
						uint64 dsts;
 
						uint64_t srcs = _mm_cvtsi128_si64(srcABCD);
 
						uint64_t dsts;
 
						if (animated) dsts = _mm_cvtsi128_si64(dstABCD);
 
						uint64 remapped_src = 0;
 
						uint64_t remapped_src = 0;
 
						CMOV_REMAP(c0, animated ? dsts : 0, srcs, mvX2);
 
						remapped_src = c0.data;
 
						CMOV_REMAP(c1, animated ? dsts >> 32 : 0, srcs >> 32, mvX2 >> 16);
 
						remapped_src |= (uint64) c1.data << 32;
 
						remapped_src |= (uint64_t) c1.data << 32;
 
						srcABCD = _mm_cvtsi64_si128(remapped_src);
 
#else
 
						Colour remapped_src[2];
 
@@ -226,11 +226,11 @@ bmno_full_transparency:
 
					if (animated) {
 
						const byte a0 = src[0].a;
 
						const byte a1 = src[1].a;
 
						uint32 anim01 = mvX2 & 0xFF00FF00;
 
						uint32_t anim01 = mvX2 & 0xFF00FF00;
 
						if (a0 == 255) {
 
							anim01 |= r0;
 
							if (a1 == 255) {
 
								*(uint32*) anim = anim01 | (r1 << 16);
 
								*(uint32_t*) anim = anim01 | (r1 << 16);
 
								goto bmcr_full_opacity;
 
							}
 
						} else if (a0 == 0) {
 
@@ -245,9 +245,9 @@ bmno_full_transparency:
 
						}
 
						if (a1 > 0) {
 
							if (a1 == 255) anim01 |= r1 << 16;
 
							*(uint32*) anim = anim01;
 
							*(uint32_t*) anim = anim01;
 
						} else {
 
							anim[0] = (uint16) anim01;
 
							anim[0] = (uint16_t) anim01;
 
						}
 
					} else {
 
						if (src[0].a) anim[0] = 0;
 
@@ -272,7 +272,7 @@ bmcr_full_transparency:
 
					if (src->a == 0) break;
 
					if (src_mv->m) {
 
						const uint r = remap[src_mv->m];
 
						*anim = (animated && src->a == 255) ? r | ((uint16) src_mv->v << 8 ) : 0;
 
						*anim = (animated && src->a == 255) ? r | ((uint16_t) src_mv->v << 8 ) : 0;
 
						if (r != 0) {
 
							Colour remapped_colour = AdjustBrightneSSE(this->LookupColourInPalette(r), src_mv->v);
 
							if (src->a == 255) {
 
@@ -321,7 +321,7 @@ bmcr_alpha_blend_single:
 
				for (uint x = (uint) bp->width; x > 0; x--) {
 
					if (src_mv->m == 0) {
 
						if (src->a != 0) {
 
							uint8 g = MakeDark(src->r, src->g, src->b);
 
							uint8_t g = MakeDark(src->r, src->g, src->b);
 
							*dst = ComposeColourRGBA(g, g, g, src->a, *dst);
 
							*anim = 0;
 
						}
src/blitter/32bpp_base.cpp
Show inline comments
 
@@ -15,15 +15,15 @@
 

	
 
void *Blitter_32bppBase::MoveTo(void *video, int x, int y)
 
{
 
	return (uint32 *)video + x + y * _screen.pitch;
 
	return (uint32_t *)video + x + y * _screen.pitch;
 
}
 

	
 
void Blitter_32bppBase::SetPixel(void *video, int x, int y, uint8 colour)
 
void Blitter_32bppBase::SetPixel(void *video, int x, int y, uint8_t colour)
 
{
 
	*((Colour *)video + x + y * _screen.pitch) = LookupColourInPalette(colour);
 
}
 

	
 
void Blitter_32bppBase::DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash)
 
void Blitter_32bppBase::DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8_t colour, int width, int dash)
 
{
 
	const Colour c = LookupColourInPalette(colour);
 
	this->DrawLineGeneric(x, y, x2, y2, screen_width, screen_height, width, dash, [=](int x, int y) {
 
@@ -31,7 +31,7 @@ void Blitter_32bppBase::DrawLine(void *v
 
	});
 
}
 

	
 
void Blitter_32bppBase::DrawRect(void *video, int width, int height, uint8 colour)
 
void Blitter_32bppBase::DrawRect(void *video, int width, int height, uint8_t colour)
 
{
 
	Colour colour32 = LookupColourInPalette(colour);
 

	
 
@@ -41,17 +41,17 @@ void Blitter_32bppBase::DrawRect(void *v
 
			*dst = colour32;
 
			dst++;
 
		}
 
		video = (uint32 *)video + _screen.pitch;
 
		video = (uint32_t *)video + _screen.pitch;
 
	} while (--height);
 
}
 

	
 
void Blitter_32bppBase::CopyFromBuffer(void *video, const void *src, int width, int height)
 
{
 
	uint32 *dst = (uint32 *)video;
 
	const uint32 *usrc = (const uint32 *)src;
 
	uint32_t *dst = (uint32_t *)video;
 
	const uint32_t *usrc = (const uint32_t *)src;
 

	
 
	for (; height > 0; height--) {
 
		memcpy(dst, usrc, width * sizeof(uint32));
 
		memcpy(dst, usrc, width * sizeof(uint32_t));
 
		usrc += width;
 
		dst += _screen.pitch;
 
	}
 
@@ -59,11 +59,11 @@ void Blitter_32bppBase::CopyFromBuffer(v
 

	
 
void Blitter_32bppBase::CopyToBuffer(const void *video, void *dst, int width, int height)
 
{
 
	uint32 *udst = (uint32 *)dst;
 
	const uint32 *src = (const uint32 *)video;
 
	uint32_t *udst = (uint32_t *)dst;
 
	const uint32_t *src = (const uint32_t *)video;
 

	
 
	for (; height > 0; height--) {
 
		memcpy(udst, src, width * sizeof(uint32));
 
		memcpy(udst, src, width * sizeof(uint32_t));
 
		src += _screen.pitch;
 
		udst += width;
 
	}
 
@@ -71,11 +71,11 @@ void Blitter_32bppBase::CopyToBuffer(con
 

	
 
void Blitter_32bppBase::CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch)
 
{
 
	uint32 *udst = (uint32 *)dst;
 
	const uint32 *src = (const uint32 *)video;
 
	uint32_t *udst = (uint32_t *)dst;
 
	const uint32_t *src = (const uint32_t *)video;
 

	
 
	for (; height > 0; height--) {
 
		memcpy(udst, src, width * sizeof(uint32));
 
		memcpy(udst, src, width * sizeof(uint32_t));
 
		src += _screen.pitch;
 
		udst += dst_pitch;
 
	}
 
@@ -83,12 +83,12 @@ void Blitter_32bppBase::CopyImageToBuffe
 

	
 
void Blitter_32bppBase::ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y)
 
{
 
	const uint32 *src;
 
	uint32 *dst;
 
	const uint32_t *src;
 
	uint32_t *dst;
 

	
 
	if (scroll_y > 0) {
 
		/* Calculate pointers */
 
		dst = (uint32 *)video + left + (top + height - 1) * _screen.pitch;
 
		dst = (uint32_t *)video + left + (top + height - 1) * _screen.pitch;
 
		src = dst - scroll_y * _screen.pitch;
 

	
 
		/* Decrease height and increase top */
 
@@ -107,13 +107,13 @@ void Blitter_32bppBase::ScrollBuffer(voi
 
		}
 

	
 
		for (int h = height; h > 0; h--) {
 
			memcpy(dst, src, width * sizeof(uint32));
 
			memcpy(dst, src, width * sizeof(uint32_t));
 
			src -= _screen.pitch;
 
			dst -= _screen.pitch;
 
		}
 
	} else {
 
		/* Calculate pointers */
 
		dst = (uint32 *)video + left + top * _screen.pitch;
 
		dst = (uint32_t *)video + left + top * _screen.pitch;
 
		src = dst - scroll_y * _screen.pitch;
 

	
 
		/* Decrease height. (scroll_y is <=0). */
 
@@ -133,7 +133,7 @@ void Blitter_32bppBase::ScrollBuffer(voi
 
		/* the y-displacement may be 0 therefore we have to use memmove,
 
		 * because source and destination may overlap */
 
		for (int h = height; h > 0; h--) {
 
			memmove(dst, src, width * sizeof(uint32));
 
			memmove(dst, src, width * sizeof(uint32_t));
 
			src += _screen.pitch;
 
			dst += _screen.pitch;
 
		}
 
@@ -142,7 +142,7 @@ void Blitter_32bppBase::ScrollBuffer(voi
 

	
 
size_t Blitter_32bppBase::BufferSize(uint width, uint height)
 
{
 
	return sizeof(uint32) * width * height;
 
	return sizeof(uint32_t) * width * height;
 
}
 

	
 
void Blitter_32bppBase::PaletteAnimate(const Palette &palette)
 
@@ -150,22 +150,22 @@ void Blitter_32bppBase::PaletteAnimate(c
 
	/* By default, 32bpp doesn't have palette animation */
 
}
 

	
 
Colour Blitter_32bppBase::ReallyAdjustBrightness(Colour colour, uint8 brightness)
 
Colour Blitter_32bppBase::ReallyAdjustBrightness(Colour colour, uint8_t brightness)
 
{
 
	assert(DEFAULT_BRIGHTNESS == 1 << 7);
 

	
 
	uint64 combined = (((uint64) colour.r) << 32) | (((uint64) colour.g) << 16) | ((uint64) colour.b);
 
	uint64_t combined = (((uint64_t) colour.r) << 32) | (((uint64_t) colour.g) << 16) | ((uint64_t) colour.b);
 
	combined *= brightness;
 

	
 
	uint16 r = GB(combined, 39, 9);
 
	uint16 g = GB(combined, 23, 9);
 
	uint16 b = GB(combined, 7, 9);
 
	uint16_t r = GB(combined, 39, 9);
 
	uint16_t g = GB(combined, 23, 9);
 
	uint16_t b = GB(combined, 7, 9);
 

	
 
	if ((combined & 0x800080008000L) == 0L) {
 
		return Colour(r, g, b, colour.a);
 
	}
 

	
 
	uint16 ob = 0;
 
	uint16_t ob = 0;
 
	/* Sum overbright */
 
	if (r > 255) ob += r - 255;
 
	if (g > 255) ob += g - 255;
src/blitter/32bpp_base.hpp
Show inline comments
 
@@ -18,11 +18,11 @@
 
/** Base for all 32bpp blitters. */
 
class Blitter_32bppBase : public Blitter {
 
public:
 
	uint8 GetScreenDepth() override { return 32; }
 
	uint8_t GetScreenDepth() override { return 32; }
 
	void *MoveTo(void *video, int x, int y) override;
 
	void SetPixel(void *video, int x, int y, uint8 colour) override;
 
	void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash) override;
 
	void DrawRect(void *video, int width, int height, uint8 colour) override;
 
	void SetPixel(void *video, int x, int y, uint8_t colour) override;
 
	void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8_t colour, int width, int dash) override;
 
	void DrawRect(void *video, int width, int height, uint8_t colour) override;
 
	void CopyFromBuffer(void *video, const void *src, int width, int height) override;
 
	void CopyToBuffer(const void *video, void *dst, int width, int height) override;
 
	void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) override;
 
@@ -118,7 +118,7 @@ public:
 
	 * @param b blue component
 
	 * @return the brightness value of the new colour, now dark grey.
 
	 */
 
	static inline uint8 MakeDark(uint8 r, uint8 g, uint8 b)
 
	static inline uint8_t MakeDark(uint8_t r, uint8_t g, uint8_t b)
 
	{
 
		/* Magic-numbers are ~66% of those used in MakeGrey() */
 
		return ((r * 13063) + (g * 25647) + (b * 4981)) / 65536;
 
@@ -131,7 +131,7 @@ public:
 
	 */
 
	static inline Colour MakeDark(Colour colour)
 
	{
 
		uint8 d = MakeDark(colour.r, colour.g, colour.b);
 
		uint8_t d = MakeDark(colour.r, colour.g, colour.b);
 

	
 
		return Colour(d, d, d);
 
	}
 
@@ -157,9 +157,9 @@ public:
 

	
 
	static const int DEFAULT_BRIGHTNESS = 128;
 

	
 
	static Colour ReallyAdjustBrightness(Colour colour, uint8 brightness);
 
	static Colour ReallyAdjustBrightness(Colour colour, uint8_t brightness);
 

	
 
	static inline Colour AdjustBrightness(Colour colour, uint8 brightness)
 
	static inline Colour AdjustBrightness(Colour colour, uint8_t brightness)
 
	{
 
		/* Shortcut for normal brightness */
 
		if (brightness == DEFAULT_BRIGHTNESS) return colour;
 
@@ -167,9 +167,9 @@ public:
 
		return ReallyAdjustBrightness(colour, brightness);
 
	}
 

	
 
	static inline uint8 GetColourBrightness(Colour colour)
 
	static inline uint8_t GetColourBrightness(Colour colour)
 
	{
 
		uint8 rgb_max = std::max(colour.r, std::max(colour.g, colour.b));
 
		uint8_t rgb_max = std::max(colour.r, std::max(colour.g, colour.b));
 

	
 
		/* Black pixel (8bpp or old 32bpp image), so use default value */
 
		if (rgb_max == 0) rgb_max = DEFAULT_BRIGHTNESS;
src/blitter/32bpp_optimized.cpp
Show inline comments
 
@@ -29,18 +29,18 @@ inline void Blitter_32bppOptimized::Draw
 
{
 
	const SpriteData *src = (const SpriteData *)bp->sprite;
 

	
 
	/* src_px : each line begins with uint32 n = 'number of bytes in this line',
 
	/* src_px : each line begins with uint32_t n = 'number of bytes in this line',
 
	 *          then n times is the Colour struct for this line */
 
	const Colour *src_px = (const Colour *)(src->data + src->offset[zoom][0]);
 
	/* src_n  : each line begins with uint32 n = 'number of bytes in this line',
 
	/* src_n  : each line begins with uint32_t n = 'number of bytes in this line',
 
	 *          then interleaved stream of 'm' and 'n' channels. 'm' is remap,
 
	 *          'n' is number of bytes with the same alpha channel class */
 
	const uint16 *src_n  = (const uint16 *)(src->data + src->offset[zoom][1]);
 
	const uint16_t *src_n  = (const uint16_t *)(src->data + src->offset[zoom][1]);
 

	
 
	/* skip upper lines in src_px and src_n */
 
	for (uint i = bp->skip_top; i != 0; i--) {
 
		src_px = (const Colour *)((const byte *)src_px + *(const uint32 *)src_px);
 
		src_n = (const uint16 *)((const byte *)src_n + *(const uint32 *)src_n);
 
		src_px = (const Colour *)((const byte *)src_px + *(const uint32_t *)src_px);
 
		src_n = (const uint16_t *)((const byte *)src_n + *(const uint32_t *)src_n);
 
	}
 

	
 
	/* skip lines in dst */
 
@@ -54,11 +54,11 @@ inline void Blitter_32bppOptimized::Draw
 
		Colour *dst_ln = dst + bp->pitch;
 

	
 
		/* next src line begins here */
 
		const Colour *src_px_ln = (const Colour *)((const byte *)src_px + *(const uint32 *)src_px);
 
		const Colour *src_px_ln = (const Colour *)((const byte *)src_px + *(const uint32_t *)src_px);
 
		src_px++;
 

	
 
		/* next src_n line begins here */
 
		const uint16 *src_n_ln = (const uint16 *)((const byte *)src_n + *(const uint32 *)src_n);
 
		const uint16_t *src_n_ln = (const uint16_t *)((const byte *)src_n + *(const uint32_t *)src_n);
 
		src_n += 2;
 

	
 
		/* we will end this line when we reach this point */
 
@@ -146,7 +146,7 @@ inline void Blitter_32bppOptimized::Draw
 
						do {
 
							uint m = *src_n;
 
							if (m == 0) {
 
								uint8 g = MakeDark(src_px->r, src_px->g, src_px->b);
 
								uint8_t g = MakeDark(src_px->r, src_px->g, src_px->b);
 
								*dst = ComposeColourRGBA(g, g, g, src_px->a, *dst);
 
							} else {
 
								uint r = remap[GB(m, 0, 8)];
 
@@ -161,7 +161,7 @@ inline void Blitter_32bppOptimized::Draw
 
							uint m = *src_n;
 
							if (m == 0) {
 
								if (src_px->a != 0) {
 
									uint8 g = MakeDark(src_px->r, src_px->g, src_px->b);
 
									uint8_t g = MakeDark(src_px->r, src_px->g, src_px->b);
 
									*dst = ComposeColourRGBA(g, g, g, src_px->a, *dst);
 
								}
 
							} else {
 
@@ -285,10 +285,10 @@ template <bool Tpal_to_rgb> Sprite *Blit
 
	 *
 
	 * it has to be stored in one stream so fewer registers are used -
 
	 * x86 has problems with register allocation even with this solution */
 
	uint16 *dst_n_orig[ZOOM_LVL_COUNT];
 
	uint16_t *dst_n_orig[ZOOM_LVL_COUNT];
 

	
 
	/* lengths of streams */
 
	uint32 lengths[ZOOM_LVL_COUNT][2];
 
	uint32_t lengths[ZOOM_LVL_COUNT][2];
 

	
 
	ZoomLevel zoom_min;
 
	ZoomLevel zoom_max;
 
@@ -308,25 +308,25 @@ template <bool Tpal_to_rgb> Sprite *Blit
 
		uint size = src_orig->height * src_orig->width;
 

	
 
		dst_px_orig[z] = CallocT<Colour>(size + src_orig->height * 2);
 
		dst_n_orig[z]  = CallocT<uint16>(size * 2 + src_orig->height * 4 * 2);
 
		dst_n_orig[z]  = CallocT<uint16_t>(size * 2 + src_orig->height * 4 * 2);
 

	
 
		uint32 *dst_px_ln = (uint32 *)dst_px_orig[z];
 
		uint32 *dst_n_ln  = (uint32 *)dst_n_orig[z];
 
		uint32_t *dst_px_ln = (uint32_t *)dst_px_orig[z];
 
		uint32_t *dst_n_ln  = (uint32_t *)dst_n_orig[z];
 

	
 
		const SpriteLoader::CommonPixel *src = (const SpriteLoader::CommonPixel *)src_orig->data;
 

	
 
		for (uint y = src_orig->height; y > 0; y--) {
 
			/* Index 0 of dst_px and dst_n is left as space to save the length of the row to be filled later. */
 
			Colour *dst_px = (Colour *)&dst_px_ln[1];
 
			uint16 *dst_n = (uint16 *)&dst_n_ln[1];
 
			uint16_t *dst_n = (uint16_t *)&dst_n_ln[1];
 

	
 
			uint16 *dst_len = dst_n++;
 
			uint16_t *dst_len = dst_n++;
 

	
 
			uint last = 3;
 
			int len = 0;
 

	
 
			for (uint x = src_orig->width; x > 0; x--) {
 
				uint8 a = src->a;
 
				uint8_t a = src->a;
 
				uint t = a > 0 && a < 255 ? 1 : a;
 

	
 
				if (last != t || len == 65535) {
 
@@ -345,7 +345,7 @@ template <bool Tpal_to_rgb> Sprite *Blit
 
					*dst_n = src->m;
 
					if (src->m != 0) {
 
						/* Get brightest value */
 
						uint8 rgb_max = std::max({ src->r, src->g, src->b });
 
						uint8_t rgb_max = std::max({ src->r, src->g, src->b });
 

	
 
						/* Black pixel (8bpp or old 32bpp image), so use default value */
 
						if (rgb_max == 0) rgb_max = DEFAULT_BRIGHTNESS;
 
@@ -383,13 +383,13 @@ template <bool Tpal_to_rgb> Sprite *Blit
 
			}
 

	
 
			dst_px = (Colour *)AlignPtr(dst_px, 4);
 
			dst_n  = (uint16 *)AlignPtr(dst_n, 4);
 
			dst_n  = (uint16_t *)AlignPtr(dst_n, 4);
 

	
 
			*dst_px_ln = (uint8 *)dst_px - (uint8 *)dst_px_ln;
 
			*dst_n_ln  = (uint8 *)dst_n  - (uint8 *)dst_n_ln;
 
			*dst_px_ln = (uint8_t *)dst_px - (uint8_t *)dst_px_ln;
 
			*dst_n_ln  = (uint8_t *)dst_n  - (uint8_t *)dst_n_ln;
 

	
 
			dst_px_ln = (uint32 *)dst_px;
 
			dst_n_ln =  (uint32 *)dst_n;
 
			dst_px_ln = (uint32_t *)dst_px;
 
			dst_n_ln =  (uint32_t *)dst_n;
 
		}
 

	
 
		lengths[z][0] = (byte *)dst_px_ln - (byte *)dst_px_orig[z]; // all are aligned to 4B boundary
src/blitter/32bpp_optimized.hpp
Show inline comments
 
@@ -17,7 +17,7 @@ class Blitter_32bppOptimized : public Bl
 
public:
 
	/** Data stored about a (single) sprite. */
 
	struct SpriteData {
 
		uint32 offset[ZOOM_LVL_COUNT][2]; ///< Offsets (from .data) to streams for different zoom levels, and the normal and remap image information.
 
		uint32_t offset[ZOOM_LVL_COUNT][2]; ///< Offsets (from .data) to streams for different zoom levels, and the normal and remap image information.
 
		byte data[];                      ///< Data, all zoomlevels.
 
	};
 

	
src/blitter/32bpp_simple.cpp
Show inline comments
 
@@ -48,7 +48,7 @@ void Blitter_32bppSimple::Draw(Blitter::
 
				case BM_CRASH_REMAP:
 
					if (src->m == 0) {
 
						if (src->a != 0) {
 
							uint8 g = MakeDark(src->r, src->g, src->b);
 
							uint8_t g = MakeDark(src->r, src->g, src->b);
 
							*dst = ComposeColourRGBA(g, g, g, src->a, *dst);
 
						}
 
					} else {
 
@@ -132,7 +132,7 @@ Sprite *Blitter_32bppSimple::Encode(cons
 
			dst[i].v = 0;
 
		} else {
 
			/* Get brightest value */
 
			uint8 rgb_max = std::max({src->r, src->g, src->b});
 
			uint8_t rgb_max = std::max({src->r, src->g, src->b});
 

	
 
			/* Black pixel (8bpp or old 32bpp image), so use default value */
 
			if (rgb_max == 0) rgb_max = DEFAULT_BRIGHTNESS;
src/blitter/32bpp_simple.hpp
Show inline comments
 
@@ -16,12 +16,12 @@
 
/** The most trivial 32 bpp blitter (without palette animation). */
 
class Blitter_32bppSimple : public Blitter_32bppBase {
 
	struct Pixel {
 
		uint8 r;  ///< Red-channel
 
		uint8 g;  ///< Green-channel
 
		uint8 b;  ///< Blue-channel
 
		uint8 a;  ///< Alpha-channel
 
		uint8 m;  ///< Remap-channel
 
		uint8 v;  ///< Brightness-channel
 
		uint8_t r;  ///< Red-channel
 
		uint8_t g;  ///< Green-channel
 
		uint8_t b;  ///< Blue-channel
 
		uint8_t a;  ///< Alpha-channel
 
		uint8_t m;  ///< Remap-channel
 
		uint8_t v;  ///< Brightness-channel
 
	};
 
public:
 
	void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override;
src/blitter/32bpp_sse2.cpp
Show inline comments
 
@@ -22,8 +22,8 @@ static FBlitter_32bppSSE2 iFBlitter_32bp
 

	
 
Sprite *Blitter_32bppSSE_Base::Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator)
 
{
 
	/* First uint32 of a line = the number of transparent pixels from the left.
 
	 * Second uint32 of a line = the number of transparent pixels from the right.
 
	/* First uint32_t of a line = the number of transparent pixels from the left.
 
	 * Second uint32_t of a line = the number of transparent pixels from the right.
 
	 * Then all RGBA then all MV.
 
	 */
 
	ZoomLevel zoom_min = ZOOM_LVL_NORMAL;
 
@@ -42,7 +42,7 @@ Sprite *Blitter_32bppSSE_Base::Encode(co
 
		const SpriteLoader::Sprite *src_sprite = &sprite[z];
 
		sd.infos[z].sprite_width = src_sprite->width;
 
		sd.infos[z].sprite_offset = all_sprites_size;
 
		sd.infos[z].sprite_line_size = sizeof(Colour) * src_sprite->width + sizeof(uint32) * META_LENGTH;
 
		sd.infos[z].sprite_line_size = sizeof(Colour) * src_sprite->width + sizeof(uint32_t) * META_LENGTH;
 

	
 
		const uint rgba_size = sd.infos[z].sprite_line_size * src_sprite->height;
 
		sd.infos[z].mv_offset = all_sprites_size + rgba_size;
 
@@ -80,7 +80,7 @@ Sprite *Blitter_32bppSSE_Base::Encode(co
 
						if (src->m >= PALETTE_ANIM_START) has_anim = true;
 

	
 
						/* Get brightest value (or default brightness if it's a black pixel). */
 
						const uint8 rgb_max = std::max({src->r, src->g, src->b});
 
						const uint8_t rgb_max = std::max({src->r, src->g, src->b});
 
						dst_mv->v = (rgb_max == 0) ? Blitter_32bppBase::DEFAULT_BRIGHTNESS : rgb_max;
 

	
 
						/* Pre-convert the mapping channel to a RGB value. */
 
@@ -96,7 +96,7 @@ Sprite *Blitter_32bppSSE_Base::Encode(co
 
					}
 
				} else {
 
					dst_rgba->data = 0;
 
					*(uint16*) dst_mv = 0;
 
					*(uint16_t*) dst_mv = 0;
 
				}
 
				dst_rgba++;
 
				dst_mv++;
 
@@ -105,7 +105,7 @@ Sprite *Blitter_32bppSSE_Base::Encode(co
 

	
 
			/* Count the number of transparent pixels from the left. */
 
			dst_rgba = dst_rgba_line + META_LENGTH;
 
			uint32 nb_pix_transp = 0;
 
			uint32_t nb_pix_transp = 0;
 
			for (uint x = src_sprite->width; x != 0; x--) {
 
				if (dst_rgba->a == 0) nb_pix_transp++;
 
				else break;
src/blitter/32bpp_sse2.hpp
Show inline comments
 
@@ -32,8 +32,8 @@ public:
 
	virtual ~Blitter_32bppSSE_Base() = default;
 

	
 
	struct MapValue {
 
		uint8 m;
 
		uint8 v;
 
		uint8_t m;
 
		uint8_t v;
 
	};
 
	static_assert(sizeof(MapValue) == 2);
 

	
 
@@ -65,10 +65,10 @@ public:
 

	
 
	/** Data stored about a (single) sprite. */
 
	struct SpriteInfo {
 
		uint32 sprite_offset;    ///< The offset to the sprite data.
 
		uint32 mv_offset;        ///< The offset to the map value data.
 
		uint16 sprite_line_size; ///< The size of a single line (pitch).
 
		uint16 sprite_width;     ///< The width of the sprite.
 
		uint32_t sprite_offset;    ///< The offset to the sprite data.
 
		uint32_t mv_offset;        ///< The offset to the map value data.
 
		uint16_t sprite_line_size; ///< The size of a single line (pitch).
 
		uint16_t sprite_width;     ///< The width of the sprite.
 
	};
 
	struct SpriteData {
 
		SpriteFlags flags;
src/blitter/32bpp_sse_func.hpp
Show inline comments
 
@@ -13,7 +13,7 @@
 
#ifdef WITH_SSE
 

	
 
GNU_TARGET(SSE_TARGET)
 
static inline void InsertFirstUint32(const uint32 value, __m128i &into)
 
static inline void InsertFirstUint32(const uint32_t value, __m128i &into)
 
{
 
#if (SSE_VERSION >= 4)
 
	into = _mm_insert_epi32(into, value, 0);
 
@@ -24,7 +24,7 @@ static inline void InsertFirstUint32(con
 
}
 

	
 
GNU_TARGET(SSE_TARGET)
 
static inline void InsertSecondUint32(const uint32 value, __m128i &into)
 
static inline void InsertSecondUint32(const uint32_t value, __m128i &into)
 
{
 
#if (SSE_VERSION >= 4)
 
	into = _mm_insert_epi32(into, value, 1);
 
@@ -35,7 +35,7 @@ static inline void InsertSecondUint32(co
 
}
 

	
 
GNU_TARGET(SSE_TARGET)
 
static inline void LoadUint64(const uint64 value, __m128i &into)
 
static inline void LoadUint64(const uint64_t value, __m128i &into)
 
{
 
#ifdef POINTER_IS_64BIT
 
	into = _mm_cvtsi64_si128(value);
 
@@ -75,7 +75,7 @@ static inline __m128i DistributeAlpha(co
 
GNU_TARGET(SSE_TARGET)
 
static inline __m128i AlphaBlendTwoPixels(__m128i src, __m128i dst, const __m128i &distribution_mask, const __m128i &pack_mask, const __m128i &alpha_mask)
 
{
 
	__m128i srcAB = _mm_unpacklo_epi8(src, _mm_setzero_si128());   // PUNPCKLBW, expand each uint8 into uint16
 
	__m128i srcAB = _mm_unpacklo_epi8(src, _mm_setzero_si128());   // PUNPCKLBW, expand each uint8_t into uint16
 
	__m128i dstAB = _mm_unpacklo_epi8(dst, _mm_setzero_si128());
 

	
 
	__m128i alphaMaskAB = _mm_cmpgt_epi16(srcAB, _mm_setzero_si128()); // PCMPGTW (alpha > 0) ? 0xFFFF : 0
 
@@ -111,19 +111,19 @@ static inline __m128i DarkenTwoPixels(__
 

	
 
IGNORE_UNINITIALIZED_WARNING_START
 
GNU_TARGET(SSE_TARGET)
 
static Colour ReallyAdjustBrightness(Colour colour, uint8 brightness)
 
static Colour ReallyAdjustBrightness(Colour colour, uint8_t brightness)
 
{
 
	uint64 c16 = colour.b | (uint64) colour.g << 16 | (uint64) colour.r << 32;
 
	uint64_t c16 = colour.b | (uint64_t) colour.g << 16 | (uint64_t) colour.r << 32;
 
	c16 *= brightness;
 
	uint64 c16_ob = c16; // Helps out of order execution.
 
	uint64_t c16_ob = c16; // Helps out of order execution.
 
	c16 /= Blitter_32bppBase::DEFAULT_BRIGHTNESS;
 
	c16 &= 0x01FF01FF01FFULL;
 

	
 
	/* Sum overbright (maximum for each rgb is 508, 9 bits, -255 is changed in -256 so we just have to take the 8 lower bits into account). */
 
	c16_ob = (((c16_ob >> (8 + 7)) & 0x0100010001ULL) * 0xFF) & c16;
 
	const uint ob = ((uint16) c16_ob + (uint16) (c16_ob >> 16) + (uint16) (c16_ob >> 32)) / 2;
 
	const uint ob = ((uint16_t) c16_ob + (uint16_t) (c16_ob >> 16) + (uint16_t) (c16_ob >> 32)) / 2;
 

	
 
	const uint32 alpha32 = colour.data & 0xFF000000;
 
	const uint32_t alpha32 = colour.data & 0xFF000000;
 
	__m128i ret;
 
	LoadUint64(c16, ret);
 
	if (ob != 0) {
 
@@ -145,7 +145,7 @@ IGNORE_UNINITIALIZED_WARNING_STOP
 
/** ReallyAdjustBrightness() is not called that often.
 
 * Inlining this function implies a far jump, which has a huge latency.
 
 */
 
static inline Colour AdjustBrightneSSE(Colour colour, uint8 brightness)
 
static inline Colour AdjustBrightneSSE(Colour colour, uint8_t brightness)
 
{
 
	/* Shortcut for normal brightness. */
 
	if (brightness == Blitter_32bppBase::DEFAULT_BRIGHTNESS) return colour;
 
@@ -154,7 +154,7 @@ static inline Colour AdjustBrightneSSE(C
 
}
 

	
 
GNU_TARGET(SSE_TARGET)
 
static inline __m128i AdjustBrightnessOfTwoPixels(__m128i from, uint32 brightness)
 
static inline __m128i AdjustBrightnessOfTwoPixels(__m128i from, uint32_t brightness)
 
{
 
#if (SSE_VERSION < 3)
 
	NOT_REACHED();
 
@@ -298,7 +298,7 @@ inline void Blitter_32bppSSE4::Draw(cons
 
				for (uint x = (uint) effective_width / 2; x > 0; x--) {
 
					__m128i srcABCD = _mm_loadl_epi64((const __m128i*) src);
 
					__m128i dstABCD = _mm_loadl_epi64((__m128i*) dst);
 
					uint32 mvX2 = *((uint32 *) const_cast<MapValue *>(src_mv));
 
					uint32_t mvX2 = *((uint32_t *) const_cast<MapValue *>(src_mv));
 

	
 
					/* Remap colours. */
 
					if (mvX2 & 0x00FF00FF) {
 
@@ -314,12 +314,12 @@ inline void Blitter_32bppSSE4::Draw(cons
 
							m_colour = m != 0 ? m_colour : srcm; \
 
							}
 
#ifdef POINTER_IS_64BIT
 
						uint64 srcs = _mm_cvtsi128_si64(srcABCD);
 
						uint64 remapped_src = 0;
 
						uint64_t srcs = _mm_cvtsi128_si64(srcABCD);
 
						uint64_t remapped_src = 0;
 
						CMOV_REMAP(c0, 0, srcs, mvX2);
 
						remapped_src = c0.data;
 
						CMOV_REMAP(c1, 0, srcs >> 32, mvX2 >> 16);
 
						remapped_src |= (uint64) c1.data << 32;
 
						remapped_src |= (uint64_t) c1.data << 32;
 
						srcABCD = _mm_cvtsi64_si128(remapped_src);
 
#else
 
						Colour remapped_src[2];
 
@@ -396,7 +396,7 @@ bmcr_alpha_blend_single:
 
				for (uint x = (uint) bp->width; x > 0; x--) {
 
					if (src_mv->m == 0) {
 
						if (src->a != 0) {
 
							uint8 g = MakeDark(src->r, src->g, src->b);
 
							uint8_t g = MakeDark(src->r, src->g, src->b);
 
							*dst = ComposeColourRGBA(g, g, g, src->a, *dst);
 
						}
 
					} else {
src/blitter/32bpp_sse_type.h
Show inline comments
 
@@ -21,7 +21,7 @@
 
#include <smmintrin.h>
 
#endif
 

	
 
#define META_LENGTH 2 ///< Number of uint32 inserted before each line of pixels in a sprite.
 
#define META_LENGTH 2 ///< Number of uint32_t inserted before each line of pixels in a sprite.
 
#define MARGIN_NORMAL_THRESHOLD (zoom == ZOOM_LVL_OUT_32X ? 8 : 4) ///< Minimum width to use margins with BM_NORMAL.
 
#define MARGIN_REMAP_THRESHOLD 4 ///< Minimum width to use margins with BM_COLOUR_REMAP.
 

	
 
@@ -35,10 +35,10 @@
 

	
 
typedef union ALIGN(16) um128i {
 
	__m128i m128i;
 
	uint8 m128i_u8[16];
 
	uint16 m128i_u16[8];
 
	uint32 m128i_u32[4];
 
	uint64 m128i_u64[2];
 
	uint8_t m128i_u8[16];
 
	uint16_t m128i_u16[8];
 
	uint32_t m128i_u32[4];
 
	uint64_t m128i_u64[2];
 
} um128i;
 

	
 
#define CLEAR_HIGH_BYTE_MASK        _mm_setr_epi8(-1,  0, -1,  0, -1,  0, -1,  0, -1,  0, -1,  0, -1,  0, -1,  0)
src/blitter/40bpp_anim.cpp
Show inline comments
 
@@ -26,7 +26,7 @@ static FBlitter_40bppAnim iFBlitter_40bp
 
static const Colour _black_colour(0, 0, 0);
 

	
 

	
 
void Blitter_40bppAnim::SetPixel(void *video, int x, int y, uint8 colour)
 
void Blitter_40bppAnim::SetPixel(void *video, int x, int y, uint8_t colour)
 
{
 
	if (_screen_disable_anim) {
 
		Blitter_32bppOptimized::SetPixel(video, x, y, colour);
 
@@ -34,11 +34,11 @@ void Blitter_40bppAnim::SetPixel(void *v
 
		size_t y_offset = static_cast<size_t>(y) * _screen.pitch;
 
		*((Colour *)video + x + y_offset) = _black_colour;
 

	
 
		VideoDriver::GetInstance()->GetAnimBuffer()[((uint32 *)video - (uint32 *)_screen.dst_ptr) + x + y_offset] = colour;
 
		VideoDriver::GetInstance()->GetAnimBuffer()[((uint32_t *)video - (uint32_t *)_screen.dst_ptr) + x + y_offset] = colour;
 
	}
 
}
 

	
 
void Blitter_40bppAnim::DrawRect(void *video, int width, int height, uint8 colour)
 
void Blitter_40bppAnim::DrawRect(void *video, int width, int height, uint8_t colour)
 
{
 
	if (_screen_disable_anim) {
 
		/* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent DrawRect() */
 
@@ -47,11 +47,11 @@ void Blitter_40bppAnim::DrawRect(void *v
 
	}
 

	
 
	assert(VideoDriver::GetInstance()->GetAnimBuffer() != nullptr);
 
	uint8 *anim_line = ((uint32 *)video - (uint32 *)_screen.dst_ptr) + VideoDriver::GetInstance()->GetAnimBuffer();
 
	uint8_t *anim_line = ((uint32_t *)video - (uint32_t *)_screen.dst_ptr) + VideoDriver::GetInstance()->GetAnimBuffer();
 

	
 
	do {
 
		Colour *dst = (Colour *)video;
 
		uint8 *anim = anim_line;
 
		uint8_t *anim = anim_line;
 

	
 
		for (int i = width; i > 0; i--) {
 
			*dst = _black_colour;
 
@@ -59,12 +59,12 @@ void Blitter_40bppAnim::DrawRect(void *v
 
			dst++;
 
			anim++;
 
		}
 
		video = (uint32 *)video + _screen.pitch;
 
		video = (uint32_t *)video + _screen.pitch;
 
		anim_line += _screen.pitch;
 
	} while (--height);
 
}
 

	
 
void Blitter_40bppAnim::DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash)
 
void Blitter_40bppAnim::DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8_t colour, int width, int dash)
 
{
 
	if (_screen_disable_anim) {
 
		/* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent DrawRect() */
 
@@ -73,7 +73,7 @@ void Blitter_40bppAnim::DrawLine(void *v
 
	}
 

	
 
	assert(VideoDriver::GetInstance()->GetAnimBuffer() != nullptr);
 
	uint8 *anim = ((uint32 *)video - (uint32 *)_screen.dst_ptr) + VideoDriver::GetInstance()->GetAnimBuffer();
 
	uint8_t *anim = ((uint32_t *)video - (uint32_t *)_screen.dst_ptr) + VideoDriver::GetInstance()->GetAnimBuffer();
 

	
 
	this->DrawLineGeneric(x, y, x2, y2, screen_width, screen_height, width, dash, [=](int x, int y) {
 
		*((Colour *)video + x + y * _screen.pitch) = _black_colour;
 
@@ -93,24 +93,24 @@ inline void Blitter_40bppAnim::Draw(cons
 
{
 
	const SpriteData *src = (const SpriteData *)bp->sprite;
 

	
 
	/* src_px : each line begins with uint32 n = 'number of bytes in this line',
 
	/* src_px : each line begins with uint32_t n = 'number of bytes in this line',
 
	 *          then n times is the Colour struct for this line */
 
	const Colour *src_px = (const Colour *)(src->data + src->offset[zoom][0]);
 
	/* src_n  : each line begins with uint32 n = 'number of bytes in this line',
 
	/* src_n  : each line begins with uint32_t n = 'number of bytes in this line',
 
	 *          then interleaved stream of 'm' and 'n' channels. 'm' is remap,
 
	 *          'n' is number of bytes with the same alpha channel class */
 
	const uint16 *src_n  = (const uint16 *)(src->data + src->offset[zoom][1]);
 
	const uint16_t *src_n  = (const uint16_t *)(src->data + src->offset[zoom][1]);
 

	
 
	/* skip upper lines in src_px and src_n */
 
	for (uint i = bp->skip_top; i != 0; i--) {
 
		src_px = (const Colour *)((const byte *)src_px + *(const uint32 *)src_px);
 
		src_n = (const uint16 *)((const byte *)src_n + *(const uint32 *)src_n);
 
		src_px = (const Colour *)((const byte *)src_px + *(const uint32_t *)src_px);
 
		src_n = (const uint16_t *)((const byte *)src_n + *(const uint32_t *)src_n);
 
	}
 

	
 
	/* skip lines in dst */
 
	Colour *dst = (Colour *)bp->dst + bp->top * bp->pitch + bp->left;
 
	assert(VideoDriver::GetInstance()->GetAnimBuffer() != nullptr);
 
	uint8 *anim = VideoDriver::GetInstance()->GetAnimBuffer() + ((uint32 *)bp->dst - (uint32 *)_screen.dst_ptr) + bp->top * bp->pitch + bp->left;
 
	uint8_t *anim = VideoDriver::GetInstance()->GetAnimBuffer() + ((uint32_t *)bp->dst - (uint32_t *)_screen.dst_ptr) + bp->top * bp->pitch + bp->left;
 

	
 
	/* store so we don't have to access it via bp everytime (compiler assumes pointer aliasing) */
 
	const byte *remap = bp->remap;
 
@@ -118,14 +118,14 @@ inline void Blitter_40bppAnim::Draw(cons
 
	for (int y = 0; y < bp->height; y++) {
 
		/* next dst line begins here */
 
		Colour *dst_ln = dst + bp->pitch;
 
		uint8 *anim_ln = anim + bp->pitch;
 
		uint8_t *anim_ln = anim + bp->pitch;
 

	
 
		/* next src line begins here */
 
		const Colour *src_px_ln = (const Colour *)((const byte *)src_px + *(const uint32 *)src_px);
 
		const Colour *src_px_ln = (const Colour *)((const byte *)src_px + *(const uint32_t *)src_px);
 
		src_px++;
 

	
 
		/* next src_n line begins here */
 
		const uint16 *src_n_ln = (const uint16 *)((const byte *)src_n + *(const uint32 *)src_n);
 
		const uint16_t *src_n_ln = (const uint16_t *)((const byte *)src_n + *(const uint32_t *)src_n);
 
		src_n += 2;
 

	
 
		/* we will end this line when we reach this point */
 
@@ -184,7 +184,7 @@ inline void Blitter_40bppAnim::Draw(cons
 
				case BM_CRASH_REMAP:
 
					if (src_px->a == 255) {
 
						do {
 
							uint8 m = GB(*src_n, 0, 8);
 
							uint8_t m = GB(*src_n, 0, 8);
 
							/* In case the m-channel is zero, only apply the crash remap by darkening the RGB colour. */
 
							if (m == 0) {
 
								*dst = mode == BM_CRASH_REMAP ? this->MakeDark(*src_px) : *src_px;
 
@@ -203,7 +203,7 @@ inline void Blitter_40bppAnim::Draw(cons
 
						} while (--n != 0);
 
					} else {
 
						do {
 
							uint8 m = GB(*src_n, 0, 8);
 
							uint8_t m = GB(*src_n, 0, 8);
 
							Colour b = this->RealizeBlendedColour(*anim, *dst);
 
							if (m == 0) {
 
								Colour c = mode == BM_CRASH_REMAP ? this->MakeDark(*src_px) : *src_px;
 
@@ -274,7 +274,7 @@ inline void Blitter_40bppAnim::Draw(cons
 
						break;
 
					} else {
 
						do {
 
							uint8 m = GB(*src_n, 0, 8);
 
							uint8_t m = GB(*src_n, 0, 8);
 
							Colour b = this->RealizeBlendedColour(*anim, *dst);
 

	
 
							if (m == 0) {
 
@@ -337,7 +337,7 @@ void Blitter_40bppAnim::DrawColourMappin
 
	}
 

	
 
	Colour *udst = (Colour *)dst;
 
	uint8 *anim = VideoDriver::GetInstance()->GetAnimBuffer() + ((uint32 *)dst - (uint32 *)_screen.dst_ptr);
 
	uint8_t *anim = VideoDriver::GetInstance()->GetAnimBuffer() + ((uint32_t *)dst - (uint32_t *)_screen.dst_ptr);
 

	
 
	if (pal == PALETTE_TO_TRANSPARENT) {
 
		/* If the anim buffer contains a color value, the image composition will
 
@@ -354,7 +354,7 @@ void Blitter_40bppAnim::DrawColourMappin
 
			anim = anim - width + _screen.pitch;
 
		} while (--height);
 
	} else if (pal == PALETTE_NEWSPAPER) {
 
		const uint8 *remap = GetNonSprite(pal, SpriteType::Recolour) + 1;
 
		const uint8_t *remap = GetNonSprite(pal, SpriteType::Recolour) + 1;
 
		do {
 
			for (int i = 0; i != width; i++) {
 
				if (*anim == 0) *udst = MakeGrey(*udst);
 
@@ -366,7 +366,7 @@ void Blitter_40bppAnim::DrawColourMappin
 
			anim = anim - width + _screen.pitch;
 
		} while (--height);
 
	} else {
 
		const uint8 *remap = GetNonSprite(pal, SpriteType::Recolour) + 1;
 
		const uint8_t *remap = GetNonSprite(pal, SpriteType::Recolour) + 1;
 
		do {
 
			for (int i = 0; i != width; i++) {
 
				*anim = remap[*anim];
 
@@ -386,21 +386,21 @@ Sprite *Blitter_40bppAnim::Encode(const 
 
void Blitter_40bppAnim::CopyFromBuffer(void *video, const void *src, int width, int height)
 
{
 
	assert(!_screen_disable_anim);
 
	assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
 
	uint32 *dst = (uint32 *)video;
 
	const uint32 *usrc = (const uint32 *)src;
 
	assert(video >= _screen.dst_ptr && video <= (uint32_t *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
 
	uint32_t *dst = (uint32_t *)video;
 
	const uint32_t *usrc = (const uint32_t *)src;
 

	
 
	uint8 *anim_buf = VideoDriver::GetInstance()->GetAnimBuffer();
 
	uint8_t *anim_buf = VideoDriver::GetInstance()->GetAnimBuffer();
 
	if (anim_buf == nullptr) return;
 
	uint8 *anim_line = ((uint32 *)video - (uint32 *)_screen.dst_ptr) + anim_buf;
 
	uint8_t *anim_line = ((uint32_t *)video - (uint32_t *)_screen.dst_ptr) + anim_buf;
 

	
 
	for (; height > 0; height--) {
 
		memcpy(dst, usrc, width * sizeof(uint32));
 
		memcpy(dst, usrc, width * sizeof(uint32_t));
 
		usrc += width;
 
		dst += _screen.pitch;
 
		/* Copy back the anim-buffer */
 
		memcpy(anim_line, usrc, width * sizeof(uint8));
 
		usrc = (const uint32 *)((const uint8 *)usrc + width);
 
		memcpy(anim_line, usrc, width * sizeof(uint8_t));
 
		usrc = (const uint32_t *)((const uint8_t *)usrc + width);
 
		anim_line += _screen.pitch;
 
	}
 
}
 
@@ -408,36 +408,36 @@ void Blitter_40bppAnim::CopyFromBuffer(v
 
void Blitter_40bppAnim::CopyToBuffer(const void *video, void *dst, int width, int height)
 
{
 
	assert(!_screen_disable_anim);
 
	assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
 
	uint32 *udst = (uint32 *)dst;
 
	const uint32 *src = (const uint32 *)video;
 
	assert(video >= _screen.dst_ptr && video <= (uint32_t *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
 
	uint32_t *udst = (uint32_t *)dst;
 
	const uint32_t *src = (const uint32_t *)video;
 

	
 
	uint8 *anim_buf = VideoDriver::GetInstance()->GetAnimBuffer();
 
	uint8_t *anim_buf = VideoDriver::GetInstance()->GetAnimBuffer();
 
	if (anim_buf == nullptr) return;
 
	const uint8 *anim_line = ((const uint32 *)video - (uint32 *)_screen.dst_ptr) + anim_buf;
 
	const uint8_t *anim_line = ((const uint32_t *)video - (uint32_t *)_screen.dst_ptr) + anim_buf;
 

	
 
	for (; height > 0; height--) {
 
		memcpy(udst, src, width * sizeof(uint32));
 
		memcpy(udst, src, width * sizeof(uint32_t));
 
		src += _screen.pitch;
 
		udst += width;
 
		/* Copy the anim-buffer */
 
		memcpy(udst, anim_line, width * sizeof(uint8));
 
		udst = (uint32 *)((uint8 *)udst + width);
 
		memcpy(udst, anim_line, width * sizeof(uint8_t));
 
		udst = (uint32_t *)((uint8_t *)udst + width);
 
		anim_line += _screen.pitch;
 
	}
 
}
 

	
 
void Blitter_40bppAnim::CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch)
 
{
 
	uint8 *anim_buf = VideoDriver::GetInstance()->GetAnimBuffer();
 
	uint8_t *anim_buf = VideoDriver::GetInstance()->GetAnimBuffer();
 
	if (anim_buf == nullptr) {
 
		Blitter_32bppOptimized::CopyImageToBuffer(video, dst, width, height, dst_pitch);
 
		return;
 
	}
 

	
 
	uint32 *udst = (uint32 *)dst;
 
	const uint32 *src = (const uint32 *)video;
 
	const uint8 *anim_line = ((const uint32 *)video - (uint32 *)_screen.dst_ptr) + anim_buf;
 
	uint32_t *udst = (uint32_t *)dst;
 
	const uint32_t *src = (const uint32_t *)video;
 
	const uint8_t *anim_line = ((const uint32_t *)video - (uint32_t *)_screen.dst_ptr) + anim_buf;
 

	
 
	for (; height > 0; height--) {
 
		for (int x = 0; x < width; x++) {
 
@@ -452,9 +452,9 @@ void Blitter_40bppAnim::CopyImageToBuffe
 
void Blitter_40bppAnim::ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y)
 
{
 
	assert(!_screen_disable_anim);
 
	assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
 
	uint8 *anim_buf = VideoDriver::GetInstance()->GetAnimBuffer();
 
	uint8 *dst, *src;
 
	assert(video >= _screen.dst_ptr && video <= (uint32_t *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
 
	uint8_t *anim_buf = VideoDriver::GetInstance()->GetAnimBuffer();
 
	uint8_t *dst, *src;
 

	
 
	/* We need to scroll the anim-buffer too */
 
	if (scroll_y > 0) {
 
@@ -471,7 +471,7 @@ void Blitter_40bppAnim::ScrollBuffer(voi
 
		uint tw = width + (scroll_x >= 0 ? -scroll_x : scroll_x);
 
		uint th = height - scroll_y;
 
		for (; th > 0; th--) {
 
			memcpy(dst, src, tw * sizeof(uint8));
 
			memcpy(dst, src, tw * sizeof(uint8_t));
 
			src -= _screen.pitch;
 
			dst -= _screen.pitch;
 
		}
 
@@ -492,7 +492,7 @@ void Blitter_40bppAnim::ScrollBuffer(voi
 
		uint tw = width + (scroll_x >= 0 ? -scroll_x : scroll_x);
 
		uint th = height + scroll_y;
 
		for (; th > 0; th--) {
 
			memmove(dst, src, tw * sizeof(uint8));
 
			memmove(dst, src, tw * sizeof(uint8_t));
 
			src += _screen.pitch;
 
			dst += _screen.pitch;
 
		}
 
@@ -503,7 +503,7 @@ void Blitter_40bppAnim::ScrollBuffer(voi
 

	
 
size_t Blitter_40bppAnim::BufferSize(uint width, uint height)
 
{
 
	return (sizeof(uint32) + sizeof(uint8)) * width * height;
 
	return (sizeof(uint32_t) + sizeof(uint8_t)) * width * height;
 
}
 

	
 
Blitter::PaletteAnimation Blitter_40bppAnim::UsePaletteAnimation()
src/blitter/40bpp_anim.hpp
Show inline comments
 
@@ -18,9 +18,9 @@
 
class Blitter_40bppAnim : public Blitter_32bppOptimized {
 
public:
 

	
 
	void SetPixel(void *video, int x, int y, uint8 colour) override;
 
	void DrawRect(void *video, int width, int height, uint8 colour) override;
 
	void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash) override;
 
	void SetPixel(void *video, int x, int y, uint8_t colour) override;
 
	void DrawRect(void *video, int width, int height, uint8_t colour) override;
 
	void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8_t colour, int width, int dash) override;
 
	void CopyFromBuffer(void *video, const void *src, int width, int height) override;
 
	void CopyToBuffer(const void *video, void *dst, int width, int height) override;
 
	void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) override;
 
@@ -38,7 +38,7 @@ public:
 
	template <BlitterMode mode> void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom);
 

	
 
protected:
 
	static inline Colour RealizeBlendedColour(uint8 anim, Colour c)
 
	static inline Colour RealizeBlendedColour(uint8_t anim, Colour c)
 
	{
 
		return anim != 0 ? AdjustBrightness(LookupColourInPalette(anim), GetColourBrightness(c)) : c;
 
	}
src/blitter/8bpp_base.cpp
Show inline comments
 
@@ -16,46 +16,46 @@
 

	
 
void Blitter_8bppBase::DrawColourMappingRect(void *dst, int width, int height, PaletteID pal)
 
{
 
	const uint8 *ctab = GetNonSprite(pal, SpriteType::Recolour) + 1;
 
	const uint8_t *ctab = GetNonSprite(pal, SpriteType::Recolour) + 1;
 

	
 
	do {
 
		for (int i = 0; i != width; i++) *((uint8 *)dst + i) = ctab[((uint8 *)dst)[i]];
 
		dst = (uint8 *)dst + _screen.pitch;
 
		for (int i = 0; i != width; i++) *((uint8_t *)dst + i) = ctab[((uint8_t *)dst)[i]];
 
		dst = (uint8_t *)dst + _screen.pitch;
 
	} while (--height);
 
}
 

	
 
void *Blitter_8bppBase::MoveTo(void *video, int x, int y)
 
{
 
	return (uint8 *)video + x + y * _screen.pitch;
 
	return (uint8_t *)video + x + y * _screen.pitch;
 
}
 

	
 
void Blitter_8bppBase::SetPixel(void *video, int x, int y, uint8 colour)
 
void Blitter_8bppBase::SetPixel(void *video, int x, int y, uint8_t colour)
 
{
 
	*((uint8 *)video + x + y * _screen.pitch) = colour;
 
	*((uint8_t *)video + x + y * _screen.pitch) = colour;
 
}
 

	
 
void Blitter_8bppBase::DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash)
 
void Blitter_8bppBase::DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8_t colour, int width, int dash)
 
{
 
	this->DrawLineGeneric(x, y, x2, y2, screen_width, screen_height, width, dash, [=](int x, int y) {
 
		*((uint8 *)video + x + y * _screen.pitch) = colour;
 
		*((uint8_t *)video + x + y * _screen.pitch) = colour;
 
	});
 
}
 

	
 
void Blitter_8bppBase::DrawRect(void *video, int width, int height, uint8 colour)
 
void Blitter_8bppBase::DrawRect(void *video, int width, int height, uint8_t colour)
 
{
 
	do {
 
		memset(video, colour, width);
 
		video = (uint8 *)video + _screen.pitch;
 
		video = (uint8_t *)video + _screen.pitch;
 
	} while (--height);
 
}
 

	
 
void Blitter_8bppBase::CopyFromBuffer(void *video, const void *src, int width, int height)
 
{
 
	uint8 *dst = (uint8 *)video;
 
	const uint8 *usrc = (const uint8 *)src;
 
	uint8_t *dst = (uint8_t *)video;
 
	const uint8_t *usrc = (const uint8_t *)src;
 

	
 
	for (; height > 0; height--) {
 
		memcpy(dst, usrc, width * sizeof(uint8));
 
		memcpy(dst, usrc, width * sizeof(uint8_t));
 
		usrc += width;
 
		dst += _screen.pitch;
 
	}
 
@@ -63,11 +63,11 @@ void Blitter_8bppBase::CopyFromBuffer(vo
 

	
 
void Blitter_8bppBase::CopyToBuffer(const void *video, void *dst, int width, int height)
 
{
 
	uint8 *udst = (uint8 *)dst;
 
	const uint8 *src = (const uint8 *)video;
 
	uint8_t *udst = (uint8_t *)dst;
 
	const uint8_t *src = (const uint8_t *)video;
 

	
 
	for (; height > 0; height--) {
 
		memcpy(udst, src, width * sizeof(uint8));
 
		memcpy(udst, src, width * sizeof(uint8_t));
 
		src += _screen.pitch;
 
		udst += width;
 
	}
 
@@ -75,11 +75,11 @@ void Blitter_8bppBase::CopyToBuffer(cons
 

	
 
void Blitter_8bppBase::CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch)
 
{
 
	uint8 *udst = (uint8 *)dst;
 
	const uint8 *src = (const uint8 *)video;
 
	uint8_t *udst = (uint8_t *)dst;
 
	const uint8_t *src = (const uint8_t *)video;
 

	
 
	for (; height > 0; height--) {
 
		memcpy(udst, src, width * sizeof(uint8));
 
		memcpy(udst, src, width * sizeof(uint8_t));
 
		src += _screen.pitch;
 
		udst += dst_pitch;
 
	}
 
@@ -87,12 +87,12 @@ void Blitter_8bppBase::CopyImageToBuffer
 

	
 
void Blitter_8bppBase::ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y)
 
{
 
	const uint8 *src;
 
	uint8 *dst;
 
	const uint8_t *src;
 
	uint8_t *dst;
 

	
 
	if (scroll_y > 0) {
 
		/* Calculate pointers */
 
		dst = (uint8 *)video + left + (top + height - 1) * _screen.pitch;
 
		dst = (uint8_t *)video + left + (top + height - 1) * _screen.pitch;
 
		src = dst - scroll_y * _screen.pitch;
 

	
 
		/* Decrease height and increase top */
 
@@ -111,13 +111,13 @@ void Blitter_8bppBase::ScrollBuffer(void
 
		}
 

	
 
		for (int h = height; h > 0; h--) {
 
			memcpy(dst, src, width * sizeof(uint8));
 
			memcpy(dst, src, width * sizeof(uint8_t));
 
			src -= _screen.pitch;
 
			dst -= _screen.pitch;
 
		}
 
	} else {
 
		/* Calculate pointers */
 
		dst = (uint8 *)video + left + top * _screen.pitch;
 
		dst = (uint8_t *)video + left + top * _screen.pitch;
 
		src = dst - scroll_y * _screen.pitch;
 

	
 
		/* Decrease height. (scroll_y is <=0). */
 
@@ -137,7 +137,7 @@ void Blitter_8bppBase::ScrollBuffer(void
 
		/* the y-displacement may be 0 therefore we have to use memmove,
 
		 * because source and destination may overlap */
 
		for (int h = height; h > 0; h--) {
 
			memmove(dst, src, width * sizeof(uint8));
 
			memmove(dst, src, width * sizeof(uint8_t));
 
			src += _screen.pitch;
 
			dst += _screen.pitch;
 
		}
src/blitter/8bpp_base.hpp
Show inline comments
 
@@ -15,12 +15,12 @@
 
/** Base for all 8bpp blitters. */
 
class Blitter_8bppBase : public Blitter {
 
public:
 
	uint8 GetScreenDepth() override { return 8; }
 
	uint8_t GetScreenDepth() override { return 8; }
 
	void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) override;
 
	void *MoveTo(void *video, int x, int y) override;
 
	void SetPixel(void *video, int x, int y, uint8 colour) override;
 
	void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash) override;
 
	void DrawRect(void *video, int width, int height, uint8 colour) override;
 
	void SetPixel(void *video, int x, int y, uint8_t colour) override;
 
	void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8_t colour, int width, int dash) override;
 
	void DrawRect(void *video, int width, int height, uint8_t colour) override;
 
	void CopyFromBuffer(void *video, const void *src, int width, int height) override;
 
	void CopyToBuffer(const void *video, void *dst, int width, int height) override;
 
	void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) override;
src/blitter/8bpp_optimized.cpp
Show inline comments
 
@@ -26,8 +26,8 @@ void Blitter_8bppOptimized::Draw(Blitter
 
	uint offset = sprite_src->offset[zoom];
 

	
 
	/* Find where to start reading in the source sprite */
 
	const uint8 *src = sprite_src->data + offset;
 
	uint8 *dst_line = (uint8 *)bp->dst + bp->top * bp->pitch + bp->left;
 
	const uint8_t *src = sprite_src->data + offset;
 
	uint8_t *dst_line = (uint8_t *)bp->dst + bp->top * bp->pitch + bp->left;
 

	
 
	/* Skip over the top lines in the source image */
 
	for (int y = 0; y < bp->skip_top; y++) {
 
@@ -39,10 +39,10 @@ void Blitter_8bppOptimized::Draw(Blitter
 
		}
 
	}
 

	
 
	const uint8 *src_next = src;
 
	const uint8_t *src_next = src;
 

	
 
	for (int y = 0; y < bp->height; y++) {
 
		uint8 *dst = dst_line;
 
		uint8_t *dst = dst_line;
 
		dst_line += bp->pitch;
 

	
 
		uint skip_left = bp->skip_left;
 
@@ -86,7 +86,7 @@ void Blitter_8bppOptimized::Draw(Blitter
 
			switch (mode) {
 
				case BM_COLOUR_REMAP:
 
				case BM_CRASH_REMAP: {
 
					const uint8 *remap = bp->remap;
 
					const uint8_t *remap = bp->remap;
 
					do {
 
						uint m = remap[*src];
 
						if (m != 0) *dst = m;
 
@@ -101,7 +101,7 @@ void Blitter_8bppOptimized::Draw(Blitter
 
					break;
 

	
 
				case BM_TRANSPARENT: {
 
					const uint8 *remap = bp->remap;
 
					const uint8_t *remap = bp->remap;
 
					src += pixels;
 
					do {
 
						*dst = remap[*dst];
src/blitter/8bpp_optimized.hpp
Show inline comments
 
@@ -18,7 +18,7 @@ class Blitter_8bppOptimized FINAL : publ
 
public:
 
	/** Data stored about a (single) sprite. */
 
	struct SpriteData {
 
		uint32 offset[ZOOM_LVL_COUNT]; ///< Offsets (from .data) to streams for different zoom levels.
 
		uint32_t offset[ZOOM_LVL_COUNT]; ///< Offsets (from .data) to streams for different zoom levels.
 
		byte data[];                   ///< Data, all zoomlevels.
 
	};
 

	
src/blitter/8bpp_simple.cpp
Show inline comments
 
@@ -18,12 +18,12 @@ static FBlitter_8bppSimple iFBlitter_8bp
 

	
 
void Blitter_8bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom)
 
{
 
	const uint8 *src, *src_line;
 
	uint8 *dst, *dst_line;
 
	const uint8_t *src, *src_line;
 
	uint8_t *dst, *dst_line;
 

	
 
	/* Find where to start reading in the source sprite */
 
	src_line = (const uint8 *)bp->sprite + (bp->skip_top * bp->sprite_width + bp->skip_left) * ScaleByZoom(1, zoom);
 
	dst_line = (uint8 *)bp->dst + bp->top * bp->pitch + bp->left;
 
	src_line = (const uint8_t *)bp->sprite + (bp->skip_top * bp->sprite_width + bp->skip_left) * ScaleByZoom(1, zoom);
 
	dst_line = (uint8_t *)bp->dst + bp->top * bp->pitch + bp->left;
 

	
 
	for (int y = 0; y < bp->height; y++) {
 
		dst = dst_line;
src/blitter/base.hpp
Show inline comments
 
@@ -56,7 +56,7 @@ public:
 
	 * Get the screen depth this blitter works for.
 
	 *  This is either: 8, 16, 24 or 32.
 
	 */
 
	virtual uint8 GetScreenDepth() = 0;
 
	virtual uint8_t GetScreenDepth() = 0;
 

	
 
	bool Is32BppSupported() override
 
	{
 
@@ -96,7 +96,7 @@ public:
 
	 * @param y The y position within video-buffer.
 
	 * @param colour A 8bpp mapping colour.
 
	 */
 
	virtual void SetPixel(void *video, int x, int y, uint8 colour) = 0;
 
	virtual void SetPixel(void *video, int x, int y, uint8_t colour) = 0;
 

	
 
	/**
 
	 * Make a single horizontal line in a single colour on the video-buffer.
 
@@ -105,7 +105,7 @@ public:
 
	 * @param height The height of the line.
 
	 * @param colour A 8bpp mapping colour.
 
	 */
 
	virtual void DrawRect(void *video, int width, int height, uint8 colour) = 0;
 
	virtual void DrawRect(void *video, int width, int height, uint8_t colour) = 0;
 

	
 
	/**
 
	 * Draw a line with a given colour.
 
@@ -120,7 +120,7 @@ public:
 
	 * @param width Line width.
 
	 * @param dash Length of dashes for dashed lines. 0 means solid line.
 
	 */
 
	virtual void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash = 0) = 0;
 
	virtual void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8_t colour, int width, int dash = 0) = 0;
 

	
 
	/**
 
	 * Copy from a buffer to the screen.
src/blitter/common.hpp
Show inline comments
 
@@ -50,11 +50,11 @@ void Blitter::DrawLineGeneric(int x1, in
 
		/* compute frac_diff = width * sqrt(dx*dx + dy*dy)
 
		 * Start interval:
 
		 *    max(dx, dy) <= sqrt(dx*dx + dy*dy) <= sqrt(2) * max(dx, dy) <= 3/2 * max(dx, dy) */
 
		int64 frac_sq = ((int64) width) * ((int64) width) * (((int64) dx) * ((int64) dx) + ((int64) dy) * ((int64) dy));
 
		int64_t frac_sq = ((int64_t) width) * ((int64_t) width) * (((int64_t) dx) * ((int64_t) dx) + ((int64_t) dy) * ((int64_t) dy));
 
		int frac_max = 3 * frac_diff / 2;
 
		while (frac_diff < frac_max) {
 
			int frac_test = (frac_diff + frac_max) / 2;
 
			if (((int64) frac_test) * ((int64) frac_test) < frac_sq) {
 
			if (((int64_t) frac_test) * ((int64_t) frac_test) < frac_sq) {
 
				frac_diff = frac_test + 1;
 
			} else {
 
				frac_max = frac_test - 1;
 
@@ -89,8 +89,8 @@ void Blitter::DrawLineGeneric(int x1, in
 

	
 
		if (x1 < 0) {
 
			dash_count = (-x1) % (dash + gap);
 
			auto adjust_frac = [&](int64 frac, int &y_bound) -> int {
 
				frac -= ((int64) dy) * ((int64) x1);
 
			auto adjust_frac = [&](int64_t frac, int &y_bound) -> int {
 
				frac -= ((int64_t) dy) * ((int64_t) x1);
 
				if (frac >= 0) {
 
					int quotient = frac / dx;
 
					int remainder = frac % dx;
 
@@ -151,8 +151,8 @@ void Blitter::DrawLineGeneric(int x1, in
 

	
 
		if (y1 < 0) {
 
			dash_count = (-y1) % (dash + gap);
 
			auto adjust_frac = [&](int64 frac, int &x_bound) -> int {
 
				frac -= ((int64) dx) * ((int64) y1);
 
			auto adjust_frac = [&](int64_t frac, int &x_bound) -> int {
 
				frac -= ((int64_t) dx) * ((int64_t) y1);
 
				if (frac >= 0) {
 
					int quotient = frac / dy;
 
					int remainder = frac % dy;
src/blitter/null.hpp
Show inline comments
 
@@ -15,14 +15,14 @@
 
/** Blitter that does nothing. */
 
class Blitter_Null : public Blitter {
 
public:
 
	uint8 GetScreenDepth() override { return 0; }
 
	uint8_t GetScreenDepth() override { return 0; }
 
	void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override {};
 
	void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) override {};
 
	Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) override;
 
	void *MoveTo(void *video, int x, int y) override { return nullptr; };
 
	void SetPixel(void *video, int x, int y, uint8 colour) override {};
 
	void DrawRect(void *video, int width, int height, uint8 colour) override {};
 
	void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash) override {};
 
	void SetPixel(void *video, int x, int y, uint8_t colour) override {};
 
	void DrawRect(void *video, int width, int height, uint8_t colour) override {};
 
	void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8_t colour, int width, int dash) override {};
 
	void CopyFromBuffer(void *video, const void *src, int width, int height) override {};
 
	void CopyToBuffer(const void *video, void *dst, int width, int height) override {};
 
	void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) override {};
src/bmp.cpp
Show inline comments
 
@@ -48,15 +48,15 @@ static inline byte ReadByte(BmpBuffer *b
 
	return buffer->data[buffer->pos++];
 
}
 

	
 
static inline uint16 ReadWord(BmpBuffer *buffer)
 
static inline uint16_t ReadWord(BmpBuffer *buffer)
 
{
 
	uint16 var = ReadByte(buffer);
 
	uint16_t var = ReadByte(buffer);
 
	return var | (ReadByte(buffer) << 8);
 
}
 

	
 
static inline uint32 ReadDword(BmpBuffer *buffer)
 
static inline uint32_t ReadDword(BmpBuffer *buffer)
 
{
 
	uint32 var = ReadWord(buffer);
 
	uint32_t var = ReadWord(buffer);
 
	return var | (ReadWord(buffer) << 16);
 
}
 

	
 
@@ -316,7 +316,7 @@ static inline bool BmpRead24(BmpBuffer *
 
 */
 
bool BmpReadHeader(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
 
{
 
	uint32 header_size;
 
	uint32_t header_size;
 
	assert(info != nullptr);
 
	MemSetT(info, 0);
 

	
src/bmp.h
Show inline comments
 
@@ -13,13 +13,13 @@
 
#include "gfx_type.h"
 

	
 
struct BmpInfo {
 
	uint32 offset;       ///< offset of bitmap data from .bmp file beginning
 
	uint32 width;        ///< bitmap width
 
	uint32 height;       ///< bitmap height
 
	uint32_t offset;       ///< offset of bitmap data from .bmp file beginning
 
	uint32_t width;        ///< bitmap width
 
	uint32_t height;       ///< bitmap height
 
	bool os2_bmp;        ///< true if OS/2 1.x or windows 2.x bitmap
 
	uint16 bpp;          ///< bits per pixel
 
	uint32 compression;  ///< compression method (0 = none, 1 = 8-bit RLE, 2 = 4-bit RLE)
 
	uint32 palette_size; ///< number of colours in palette
 
	uint16_t bpp;          ///< bits per pixel
 
	uint32_t compression;  ///< compression method (0 = none, 1 = 8-bit RLE, 2 = 4-bit RLE)
 
	uint32_t palette_size; ///< number of colours in palette
 
};
 

	
 
struct BmpData {
src/bridge.h
Show inline comments
 
@@ -42,9 +42,9 @@ typedef uint BridgeType; ///< Bridge spe
 
struct BridgeSpec {
 
	TimerGameCalendar::Year avail_year; ///< the year where it becomes available
 
	byte min_length;                    ///< the minimum length (not counting start and end tile)
 
	uint16 max_length;                  ///< the maximum length (not counting start and end tile)
 
	uint16 price;                       ///< the price multiplier
 
	uint16 speed;                       ///< maximum travel speed (1 unit = 1/1.6 mph = 1 km-ish/h)
 
	uint16_t max_length;                  ///< the maximum length (not counting start and end tile)
 
	uint16_t price;                       ///< the price multiplier
 
	uint16_t speed;                       ///< maximum travel speed (1 unit = 1/1.6 mph = 1 km-ish/h)
 
	SpriteID sprite;                    ///< the sprite which is used in the GUI
 
	PaletteID pal;                      ///< the palette which is used in the GUI
 
	StringID material;                  ///< the string that contains the bridge description
src/bridge_gui.cpp
Show inline comments
 
@@ -214,7 +214,7 @@ public:
 
		}
 
	}
 

	
 
	Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) override
 
	Point OnInitialPosition(int16_t sm_width, int16_t sm_height, int window_number) override
 
	{
 
		/* Position the window so hopefully the first bridge from the list is under the mouse pointer. */
 
		NWidgetBase *list = this->GetWidget<NWidgetBase>(WID_BBS_BRIDGE_LIST);
 
@@ -245,9 +245,9 @@ public:
 
		}
 
	}
 

	
 
	EventState OnKeyPress(WChar key, uint16 keycode) override
 
	EventState OnKeyPress(char32_t key, uint16_t keycode) override
 
	{
 
		const uint8 i = keycode - '1';
 
		const uint8_t i = keycode - '1';
 
		if (i < 9 && i < this->bridges.size()) {
 
			/* Build the requested bridge */
 
			this->BuildBridge(this->bridges[i].index);
 
@@ -432,7 +432,7 @@ void ShowBuildBridgeWindow(TileIndex sta
 
				item.spec = GetBridgeSpec(brd_type);
 
				/* Add to terraforming & bulldozing costs the cost of the
 
				 * bridge itself (not computed with DC_QUERY_COST) */
 
				item.cost = ret.GetCost() + (((int64)tot_bridgedata_len * _price[PR_BUILD_BRIDGE] * item.spec->price) >> 8) + infra_cost;
 
				item.cost = ret.GetCost() + (((int64_t)tot_bridgedata_len * _price[PR_BUILD_BRIDGE] * item.spec->price) >> 8) + infra_cost;
 
				any_available = true;
 
			}
 
		}
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -401,7 +401,7 @@ static bool AircraftEngineCargoSorter(co
 
	const Engine *e_a = Engine::Get(a.engine_id);
 
	const Engine *e_b = Engine::Get(b.engine_id);
 

	
 
	uint16 mail_a, mail_b;
 
	uint16_t mail_a, mail_b;
 
	int va = e_a->GetDisplayDefaultCapacity(&mail_a);
 
	int vb = e_b->GetDisplayDefaultCapacity(&mail_b);
 
	int r = va - vb;
 
@@ -426,8 +426,8 @@ static bool AircraftEngineCargoSorter(co
 
 */
 
static bool AircraftRangeSorter(const GUIEngineListItem &a, const GUIEngineListItem &b)
 
{
 
	uint16 r_a = Engine::Get(a.engine_id)->GetRange();
 
	uint16 r_b = Engine::Get(b.engine_id)->GetRange();
 
	uint16_t r_a = Engine::Get(a.engine_id)->GetRange();
 
	uint16_t r_b = Engine::Get(b.engine_id)->GetRange();
 

	
 
	int r = r_a - r_b;
 

	
 
@@ -697,7 +697,7 @@ static int DrawRoadVehPurchaseInfo(int l
 
		y += FONT_HEIGHT_NORMAL;
 

	
 
		/* Road vehicle weight - (including cargo) */
 
		int16 weight = e->GetDisplayWeight();
 
		int16_t weight = e->GetDisplayWeight();
 
		SetDParam(0, weight);
 
		SetDParam(1, GetCargoWeight(te.all_capacities, VEH_ROAD) + weight);
 
		DrawString(left, right, y, STR_PURCHASE_INFO_WEIGHT_CWEIGHT);
 
@@ -847,7 +847,7 @@ static int DrawAircraftPurchaseInfo(int 
 
	y += FONT_HEIGHT_NORMAL;
 

	
 
	/* Aircraft range, if available. */
 
	uint16 range = e->GetRange();
 
	uint16_t range = e->GetRange();
 
	if (range != 0) {
 
		SetDParam(0, range);
 
		DrawString(left, right, y, STR_PURCHASE_INFO_AIRCRAFT_RANGE);
 
@@ -865,7 +865,7 @@ static int DrawAircraftPurchaseInfo(int 
 
 */
 
static std::optional<std::string> GetNewGRFAdditionalText(EngineID engine)
 
{
 
	uint16 callback = GetVehicleCallback(CBID_VEHICLE_ADDITIONAL_TEXT, 0, 0, engine, nullptr);
 
	uint16_t callback = GetVehicleCallback(CBID_VEHICLE_ADDITIONAL_TEXT, 0, 0, engine, nullptr);
 
	if (callback == CALLBACK_FAILED || callback == 0x400) return std::nullopt;
 
	const GRFFile *grffile = Engine::Get(engine)->GetGRF();
 
	assert(grffile != nullptr);
 
@@ -1004,7 +1004,7 @@ int DrawVehiclePurchaseInfo(int left, in
 
 * @param show_count Whether to show the amount of engines or not
 
 * @param selected_group the group to list the engines of
 
 */
 
void DrawEngineList(VehicleType type, const Rect &r, const GUIEngineList &eng_list, uint16 min, uint16 max, EngineID selected_id, bool show_count, GroupID selected_group)
 
void DrawEngineList(VehicleType type, const Rect &r, const GUIEngineList &eng_list, uint16_t min, uint16_t max, EngineID selected_id, bool show_count, GroupID selected_group)
 
{
 
	static const int sprite_y_offsets[] = { -1, -1, -2, -2 };
 

	
 
@@ -1093,7 +1093,7 @@ void DrawEngineList(VehicleType type, co
 
 */
 
void DisplayVehicleSortDropDown(Window *w, VehicleType vehicle_type, int selected, int button)
 
{
 
	uint32 hidden_mask = 0;
 
	uint32_t hidden_mask = 0;
 
	/* Disable sorting by power or tractive effort when the original acceleration model for road vehicles is being used. */
 
	if (vehicle_type == VEH_ROAD && _settings_game.vehicle.roadveh_acceleration_model == AM_ORIGINAL) {
 
		SetBit(hidden_mask, 3); // power
 
@@ -1770,7 +1770,7 @@ struct BuildVehicleWindow : Window {
 
					r,
 
					this->eng_list,
 
					this->vscroll->GetPosition(),
 
					static_cast<uint16>(std::min<size_t>(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->eng_list.size())),
 
					static_cast<uint16_t>(std::min<size_t>(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->eng_list.size())),
 
					this->sel_engine,
 
					false,
 
					DEFAULT_GROUP
src/cargo_type.h
Show inline comments
 
@@ -74,7 +74,7 @@ inline bool IsValidCargoType(CargoType t
 
/** Test whether cargo type is not CT_INVALID */
 
inline bool IsValidCargoID(CargoID t) { return t != CT_INVALID; }
 

	
 
typedef uint64 CargoTypes;
 
typedef uint64_t CargoTypes;
 

	
 
static const CargoTypes ALL_CARGOTYPES = (CargoTypes)UINT64_MAX;
 

	
 
@@ -108,7 +108,7 @@ enum class SourceType : byte {
 
	Headquarters, ///< Source/destination are company headquarters
 
};
 

	
 
typedef uint16 SourceID; ///< Contains either industry ID, town ID or company ID (or INVALID_SOURCE)
 
typedef uint16_t SourceID; ///< Contains either industry ID, town ID or company ID (or INVALID_SOURCE)
 
static const SourceID INVALID_SOURCE = 0xFFFF; ///< Invalid/unknown index of source
 

	
 
#endif /* CARGO_TYPE_H */
src/cargomonitor.cpp
Show inline comments
 
@@ -66,17 +66,17 @@ void ClearCargoDeliveryMonitoring(Compan
 
 * @param keep_monitoring After returning from this call, continue monitoring.
 
 * @return Amount collected since last query/activation for the monitored combination.
 
 */
 
static int32 GetAmount(CargoMonitorMap &monitor_map, CargoMonitorID monitor, bool keep_monitoring)
 
static int32_t GetAmount(CargoMonitorMap &monitor_map, CargoMonitorID monitor, bool keep_monitoring)
 
{
 
	CargoMonitorMap::iterator iter = monitor_map.find(monitor);
 
	if (iter == monitor_map.end()) {
 
		if (keep_monitoring) {
 
			std::pair<CargoMonitorID, uint32> p(monitor, 0);
 
			std::pair<CargoMonitorID, uint32_t> p(monitor, 0);
 
			monitor_map.insert(p);
 
		}
 
		return 0;
 
	} else {
 
		int32 result = iter->second;
 
		int32_t result = iter->second;
 
		iter->second = 0;
 
		if (!keep_monitoring) monitor_map.erase(iter);
 
		return result;
 
@@ -89,7 +89,7 @@ static int32 GetAmount(CargoMonitorMap &
 
 * @param keep_monitoring After returning from this call, continue monitoring.
 
 * @return Amount of delivered cargo for the monitored combination.
 
 */
 
int32 GetDeliveryAmount(CargoMonitorID monitor, bool keep_monitoring)
 
int32_t GetDeliveryAmount(CargoMonitorID monitor, bool keep_monitoring)
 
{
 
	return GetAmount(_cargo_deliveries, monitor, keep_monitoring);
 
}
 
@@ -101,7 +101,7 @@ int32 GetDeliveryAmount(CargoMonitorID m
 
 * @return Amount of picked up cargo for the monitored combination.
 
 * @note Cargo pick up is counted on final delivery, to prevent users getting credit for picking up cargo without delivering it.
 
 */
 
int32 GetPickupAmount(CargoMonitorID monitor, bool keep_monitoring)
 
int32_t GetPickupAmount(CargoMonitorID monitor, bool keep_monitoring)
 
{
 
	return GetAmount(_cargo_pickups, monitor, keep_monitoring);
 
}
 
@@ -116,7 +116,7 @@ int32 GetPickupAmount(CargoMonitorID mon
 
 * @param st station where the cargo is delivered to.
 
 * @param dest industry index where the cargo is delivered to.
 
 */
 
void AddCargoDelivery(CargoID cargo_type, CompanyID company, uint32 amount, SourceType src_type, SourceID src, const Station *st, IndustryID dest)
 
void AddCargoDelivery(CargoID cargo_type, CompanyID company, uint32_t amount, SourceType src_type, SourceID src, const Station *st, IndustryID dest)
 
{
 
	if (amount == 0) return;
 

	
src/cargomonitor.h
Show inline comments
 
@@ -26,7 +26,7 @@ struct Station;
 
 * - bits 19-23 Cargo type.
 
 * - bits 24-31 %Company number.
 
 */
 
typedef uint32 CargoMonitorID; ///< Type of the cargo monitor number.
 
typedef uint32_t CargoMonitorID; ///< Type of the cargo monitor number.
 

	
 
/** Map type for storing and updating active cargo monitor numbers and their amounts. */
 
typedef std::map<CargoMonitorID, OverflowSafeInt32> CargoMonitorMap;
 
@@ -63,7 +63,7 @@ static inline CargoMonitorID EncodeCargo
 
	assert(ctype < (1 << CCB_CARGO_TYPE_LENGTH));
 
	assert(company < (1 << CCB_COMPANY_LENGTH));
 

	
 
	uint32 ret = 0;
 
	uint32_t ret = 0;
 
	SB(ret, CCB_TOWN_IND_NUMBER_START, CCB_TOWN_IND_NUMBER_LENGTH, ind);
 
	SetBit(ret, CCB_IS_INDUSTRY_BIT);
 
	SB(ret, CCB_CARGO_TYPE_START, CCB_CARGO_TYPE_LENGTH, ctype);
 
@@ -83,7 +83,7 @@ static inline CargoMonitorID EncodeCargo
 
	assert(ctype < (1 << CCB_CARGO_TYPE_LENGTH));
 
	assert(company < (1 << CCB_COMPANY_LENGTH));
 

	
 
	uint32 ret = 0;
 
	uint32_t ret = 0;
 
	SB(ret, CCB_TOWN_IND_NUMBER_START, CCB_TOWN_IND_NUMBER_LENGTH, town);
 
	SB(ret, CCB_CARGO_TYPE_START, CCB_CARGO_TYPE_LENGTH, ctype);
 
	SB(ret, CCB_COMPANY_START, CCB_COMPANY_LENGTH, company);
 
@@ -144,8 +144,8 @@ static inline TownID DecodeMonitorTown(C
 

	
 
void ClearCargoPickupMonitoring(CompanyID company = INVALID_OWNER);
 
void ClearCargoDeliveryMonitoring(CompanyID company = INVALID_OWNER);
 
int32 GetDeliveryAmount(CargoMonitorID monitor, bool keep_monitoring);
 
int32 GetPickupAmount(CargoMonitorID monitor, bool keep_monitoring);
 
void AddCargoDelivery(CargoID cargo_type, CompanyID company, uint32 amount, SourceType src_type, SourceID src, const Station *st, IndustryID dest = INVALID_INDUSTRY);
 
int32_t GetDeliveryAmount(CargoMonitorID monitor, bool keep_monitoring);
 
int32_t GetPickupAmount(CargoMonitorID monitor, bool keep_monitoring);
 
void AddCargoDelivery(CargoID cargo_type, CompanyID company, uint32_t amount, SourceType src_type, SourceID src, const Station *st, IndustryID dest = INVALID_INDUSTRY);
 

	
 
#endif /* CARGOMONITOR_H */
src/cargopacket.cpp
Show inline comments
 
@@ -41,7 +41,7 @@ CargoPacket::CargoPacket()
 
 * @note We have to zero memory ourselves here because we are using a 'new'
 
 * that, in contrary to all other pools, does not memset to 0.
 
 */
 
CargoPacket::CargoPacket(StationID source, TileIndex source_xy, uint16 count, SourceType source_type, SourceID source_id) :
 
CargoPacket::CargoPacket(StationID source, TileIndex source_xy, uint16_t count, SourceType source_type, SourceID source_id) :
 
	feeder_share(0),
 
	count(count),
 
	periods_in_transit(0),
 
@@ -68,7 +68,7 @@ CargoPacket::CargoPacket(StationID sourc
 
 * @note We have to zero memory ourselves here because we are using a 'new'
 
 * that, in contrary to all other pools, does not memset to 0.
 
 */
 
CargoPacket::CargoPacket(uint16 count, uint16 periods_in_transit, StationID source, TileIndex source_xy, TileIndex loaded_at_xy, Money feeder_share, SourceType source_type, SourceID source_id) :
 
CargoPacket::CargoPacket(uint16_t count, uint16_t periods_in_transit, StationID source, TileIndex source_xy, TileIndex loaded_at_xy, Money feeder_share, SourceType source_type, SourceID source_id) :
 
		feeder_share(feeder_share),
 
		count(count),
 
		periods_in_transit(periods_in_transit),
 
@@ -442,7 +442,7 @@ void VehicleCargoList::SetTransferLoadPl
 
 * @param payment Payment object for registering transfers.
 
 * return If any cargo will be unloaded.
 
 */
 
bool VehicleCargoList::Stage(bool accepted, StationID current_station, StationIDStack next_station, uint8 order_flags, const GoodsEntry *ge, CargoPayment *payment)
 
bool VehicleCargoList::Stage(bool accepted, StationID current_station, StationIDStack next_station, uint8_t order_flags, const GoodsEntry *ge, CargoPayment *payment)
 
{
 
	this->AssertCountConsistency();
 
	assert(this->action_counts[MTA_LOAD] == 0);
src/cargopacket.h
Show inline comments
 
@@ -20,7 +20,7 @@
 
#include "saveload/saveload.h"
 

	
 
/** Unique identifier for a single cargo packet. */
 
typedef uint32 CargoPacketID;
 
typedef uint32_t CargoPacketID;
 
struct CargoPacket;
 

	
 
/** Type of the pool for cargo packets for a little over 16 million packets. */
 
@@ -34,7 +34,7 @@ template <class Tinst, class Tcont> clas
 
class StationCargoList; // forward-declare, so we can use it in VehicleCargoList.
 
extern SaveLoadTable GetCargoPacketDesc();
 

	
 
typedef uint32 TileOrStationID;
 
typedef uint32_t TileOrStationID;
 

	
 
/**
 
 * Container for cargo from the same location and time.
 
@@ -42,8 +42,8 @@ typedef uint32 TileOrStationID;
 
struct CargoPacket : CargoPacketPool::PoolItem<&_cargopacket_pool> {
 
private:
 
	Money feeder_share;     ///< Value of feeder pickup to be paid for on delivery of cargo.
 
	uint16 count;           ///< The amount of cargo in this packet.
 
	uint16 periods_in_transit; ///< Amount of cargo aging periods this packet has been in transit.
 
	uint16_t count;           ///< The amount of cargo in this packet.
 
	uint16_t periods_in_transit; ///< Amount of cargo aging periods this packet has been in transit.
 
	SourceType source_type; ///< Type of \c source_id.
 
	SourceID source_id;     ///< Index of source, INVALID_SOURCE if unknown/invalid.
 
	StationID source;       ///< The station where the cargo came from first.
 
@@ -61,11 +61,11 @@ private:
 
	friend SaveLoadTable GetCargoPacketDesc();
 
public:
 
	/** Maximum number of items in a single cargo packet. */
 
	static const uint16 MAX_COUNT = UINT16_MAX;
 
	static const uint16_t MAX_COUNT = UINT16_MAX;
 

	
 
	CargoPacket();
 
	CargoPacket(StationID source, TileIndex source_xy, uint16 count, SourceType source_type, SourceID source_id);
 
	CargoPacket(uint16 count, uint16 periods_in_transit, StationID source, TileIndex source_xy, TileIndex loaded_at_xy, Money feeder_share = 0, SourceType source_type = SourceType::Industry, SourceID source_id = INVALID_SOURCE);
 
	CargoPacket(StationID source, TileIndex source_xy, uint16_t count, SourceType source_type, SourceID source_id);
 
	CargoPacket(uint16_t count, uint16_t periods_in_transit, StationID source, TileIndex source_xy, TileIndex loaded_at_xy, Money feeder_share = 0, SourceType source_type = SourceType::Industry, SourceID source_id = INVALID_SOURCE);
 

	
 
	/** Destroy the packet. */
 
	~CargoPacket() { }
 
@@ -96,7 +96,7 @@ public:
 
	 * Gets the number of 'items' in this packet.
 
	 * @return Item count.
 
	 */
 
	inline uint16 Count() const
 
	inline uint16_t Count() const
 
	{
 
		return this->count;
 
	}
 
@@ -129,7 +129,7 @@ public:
 
	 * value is capped at UINT16_MAX.
 
	 * @return Length this cargo has been in transit.
 
	 */
 
	inline uint16 PeriodsInTransit() const
 
	inline uint16_t PeriodsInTransit() const
 
	{
 
		return this->periods_in_transit;
 
	}
 
@@ -222,7 +222,7 @@ public:
 

	
 
protected:
 
	uint count;                   ///< Cache for the number of cargo entities.
 
	uint64 cargo_periods_in_transit; ///< Cache for the sum of number of cargo aging periods in transit of each entity; comparable to man-hours.
 
	uint64_t cargo_periods_in_transit; ///< Cache for the sum of number of cargo aging periods in transit of each entity; comparable to man-hours.
 

	
 
	Tcont packets;              ///< The cargo packets in this list.
 

	
 
@@ -398,7 +398,7 @@ public:
 

	
 
	void SetTransferLoadPlace(TileIndex xy);
 

	
 
	bool Stage(bool accepted, StationID current_station, StationIDStack next_station, uint8 order_flags, const GoodsEntry *ge, CargoPayment *payment);
 
	bool Stage(bool accepted, StationID current_station, StationIDStack next_station, uint8_t order_flags, const GoodsEntry *ge, CargoPayment *payment);
 

	
 
	/**
 
	 * Marks all cargo in the vehicle as to be kept. This is mostly useful for
src/cargotype.cpp
Show inline comments
 
@@ -121,7 +121,7 @@ CargoID GetCargoIDByLabel(CargoLabel cl)
 
 * @param bitnum 'bitnum' to find.
 
 * @return First CargoID with the given bitnum, or #CT_INVALID if not found or if the provided \a bitnum is invalid.
 
 */
 
CargoID GetCargoIDByBitnum(uint8 bitnum)
 
CargoID GetCargoIDByBitnum(uint8_t bitnum)
 
{
 
	if (bitnum == INVALID_CARGO) return CT_INVALID;
 

	
 
@@ -196,7 +196,7 @@ void InitializeSortedCargoSpecs()
 

	
 
	/* Count the number of standard cargos and fill the mask. */
 
	_standard_cargo_mask = 0;
 
	uint8 nb_standard_cargo = 0;
 
	uint8_t nb_standard_cargo = 0;
 
	for (const auto &cargo : _sorted_cargo_specs) {
 
		if (cargo->classes & CC_SPECIAL) break;
 
		nb_standard_cargo++;
 
@@ -207,7 +207,7 @@ void InitializeSortedCargoSpecs()
 
	_sorted_standard_cargo_specs = { _sorted_cargo_specs.data(), nb_standard_cargo };
 
}
 

	
 
uint64 CargoSpec::WeightOfNUnitsInTrain(uint32 n) const
 
uint64_t CargoSpec::WeightOfNUnitsInTrain(uint32_t n) const
 
{
 
	if (this->is_freight) n *= _settings_game.vehicle.freight_trains;
 
	return this->WeightOfNUnits(n);
src/cargotype.h
Show inline comments
 
@@ -19,7 +19,7 @@
 
#include "core/span_type.hpp"
 

	
 
/** Globally unique label of a cargo type. */
 
typedef uint32 CargoLabel;
 
typedef uint32_t CargoLabel;
 

	
 
/** Town growth effect when delivering cargo. */
 
enum TownEffect : byte {
 
@@ -54,18 +54,18 @@ static const byte INVALID_CARGO = 0xFF; 
 

	
 
/** Specification of a cargo type. */
 
struct CargoSpec {
 
	uint8 bitnum;                    ///< Cargo bit number, is #INVALID_CARGO for a non-used spec.
 
	uint8_t bitnum;                    ///< Cargo bit number, is #INVALID_CARGO for a non-used spec.
 
	CargoLabel label;                ///< Unique label of the cargo type.
 
	uint8 legend_colour;
 
	uint8 rating_colour;
 
	uint8 weight;                    ///< Weight of a single unit of this cargo type in 1/16 ton (62.5 kg).
 
	uint16 multiplier;               ///< Capacity multiplier for vehicles. (8 fractional bits)
 
	int32 initial_payment;           ///< Initial payment rate before inflation is applied.
 
	uint8 transit_periods[2];
 
	uint8_t legend_colour;
 
	uint8_t rating_colour;
 
	uint8_t weight;                    ///< Weight of a single unit of this cargo type in 1/16 ton (62.5 kg).
 
	uint16_t multiplier;               ///< Capacity multiplier for vehicles. (8 fractional bits)
 
	int32_t initial_payment;           ///< Initial payment rate before inflation is applied.
 
	uint8_t transit_periods[2];
 

	
 
	bool is_freight;                 ///< Cargo type is considered to be freight (affects train freight multiplier).
 
	TownEffect town_effect;          ///< The effect that delivering this cargo type has on towns. Also affects destination of subsidies.
 
	uint8 callback_mask;             ///< Bitmask of cargo callbacks that have to be called
 
	uint8_t callback_mask;             ///< Bitmask of cargo callbacks that have to be called
 

	
 
	StringID name;                   ///< Name of this type of cargo.
 
	StringID name_single;            ///< Name of a single entity of this type of cargo.
 
@@ -75,7 +75,7 @@ struct CargoSpec {
 

	
 
	SpriteID sprite;                 ///< Icon to display this cargo type, may be \c 0xFFF (which means to resolve an action123 chain).
 

	
 
	uint16 classes;                  ///< Classes of this cargo type. @see CargoClass
 
	uint16_t classes;                  ///< Classes of this cargo type. @see CargoClass
 
	const struct GRFFile *grffile;   ///< NewGRF where #group belongs to.
 
	const struct SpriteGroup *group;
 

	
 
@@ -122,12 +122,12 @@ struct CargoSpec {
 

	
 
	SpriteID GetCargoIcon() const;
 

	
 
	inline uint64 WeightOfNUnits(uint32 n) const
 
	inline uint64_t WeightOfNUnits(uint32_t n) const
 
	{
 
		return n * this->weight / 16u;
 
	}
 

	
 
	uint64 WeightOfNUnitsInTrain(uint32 n) const;
 
	uint64_t WeightOfNUnitsInTrain(uint32_t n) const;
 

	
 
	/**
 
	 * Iterator to iterate all valid CargoSpec
 
@@ -183,7 +183,7 @@ extern CargoTypes _standard_cargo_mask;
 

	
 
void SetupCargoForClimate(LandscapeID l);
 
CargoID GetCargoIDByLabel(CargoLabel cl);
 
CargoID GetCargoIDByBitnum(uint8 bitnum);
 
CargoID GetCargoIDByBitnum(uint8_t bitnum);
 
CargoID GetDefaultCargoID(LandscapeID l, CargoType ct);
 

	
 
void InitializeSortedCargoSpecs();
src/cheat_gui.cpp
Show inline comments
 
@@ -44,7 +44,7 @@
 
 * This variable is semantically a constant value, but because the cheat
 
 * code requires to be able to write to the variable it is not constified.
 
 */
 
static int32 _money_cheat_amount = 10000000;
 
static int32_t _money_cheat_amount = 10000000;
 

	
 
/**
 
 * Handle cheating of money.
 
@@ -55,7 +55,7 @@ static int32 _money_cheat_amount = 10000
 
 * @param change_direction is -1 or +1 (down/up)
 
 * @return Amount of money cheat.
 
 */
 
static int32 ClickMoneyCheat(int32 new_value, int32 change_direction)
 
static int32_t ClickMoneyCheat(int32_t new_value, int32_t change_direction)
 
{
 
	Command<CMD_MONEY_CHEAT>::Post(Money(_money_cheat_amount) * change_direction);
 
	return _money_cheat_amount;
 
@@ -67,7 +67,7 @@ static int32 ClickMoneyCheat(int32 new_v
 
 * @param change_direction is -1 or +1 (down/up)
 
 * @return The new company.
 
 */
 
static int32 ClickChangeCompanyCheat(int32 new_value, int32 change_direction)
 
static int32_t ClickChangeCompanyCheat(int32_t new_value, int32_t change_direction)
 
{
 
	while ((uint)new_value < Company::GetPoolSize()) {
 
		if (Company::IsValidID((CompanyID)new_value)) {
 
@@ -86,7 +86,7 @@ static int32 ClickChangeCompanyCheat(int
 
 * @param change_direction unused
 
 * @return New value allowing change of industry production.
 
 */
 
static int32 ClickSetProdCheat(int32 new_value, int32 change_direction)
 
static int32_t ClickSetProdCheat(int32_t new_value, int32_t change_direction)
 
{
 
	_cheats.setup_prod.value = (new_value != 0);
 
	InvalidateWindowClassesData(WC_INDUSTRY_VIEW);
 
@@ -101,7 +101,7 @@ extern void EnginesMonthlyLoop();
 
 * @param change_direction +1 (increase) or -1 (decrease).
 
 * @return New year.
 
 */
 
static int32 ClickChangeDateCheat(int32 new_value, int32 change_direction)
 
static int32_t ClickChangeDateCheat(int32_t new_value, int32_t change_direction)
 
{
 
	/* Don't allow changing to an invalid year, or the current year. */
 
	new_value = Clamp(new_value, MIN_YEAR, MAX_YEAR);
 
@@ -135,14 +135,14 @@ static int32 ClickChangeDateCheat(int32 
 
 * @return New value (or unchanged old value) of the maximum
 
 *         allowed heightlevel value.
 
 */
 
static int32 ClickChangeMaxHlCheat(int32 new_value, int32 change_direction)
 
static int32_t ClickChangeMaxHlCheat(int32_t new_value, int32_t change_direction)
 
{
 
	new_value = Clamp(new_value, MIN_MAP_HEIGHT_LIMIT, MAX_MAP_HEIGHT_LIMIT);
 

	
 
	/* Check if at least one mountain on the map is higher than the new value.
 
	 * If yes, disallow the change. */
 
	for (TileIndex t = 0; t < Map::Size(); t++) {
 
		if ((int32)TileHeight(t) > new_value) {
 
		if ((int32_t)TileHeight(t) > new_value) {
 
			ShowErrorMessage(STR_CONFIG_SETTING_TOO_HIGH_MOUNTAIN, INVALID_STRING_ID, WL_ERROR);
 
			/* Return old, unchanged value */
 
			return _settings_game.construction.map_height_limit;
 
@@ -178,7 +178,7 @@ enum CheatNumbers {
 
 * @param new_value The new value.
 
 * @param change_direction Change direction (+1, +1), \c 0 for boolean settings.
 
 */
 
typedef int32 CheckButtonClick(int32 new_value, int32 change_direction);
 
typedef int32_t CheckButtonClick(int32_t new_value, int32_t change_direction);
 

	
 
/** Information of a cheat. */
 
struct CheatEntry {
 
@@ -272,7 +272,7 @@ struct CheatWindow : Window {
 
				}
 

	
 
				default: {
 
					int32 val = (int32)ReadValue(ce->variable, ce->type);
 
					int32_t val = (int32_t)ReadValue(ce->variable, ce->type);
 

	
 
					/* Draw [<][>] boxes for settings of an integer-type */
 
					DrawArrowButtons(button_left, y + button_y_offset, COLOUR_YELLOW, clicked - (i * 2), true, true);
 
@@ -358,7 +358,7 @@ struct CheatWindow : Window {
 
		if (btn >= lengthof(_cheats_ui)) return;
 

	
 
		const CheatEntry *ce = &_cheats_ui[btn];
 
		int value = (int32)ReadValue(ce->variable, ce->type);
 
		int value = (int32_t)ReadValue(ce->variable, ce->type);
 
		int oldvalue = value;
 

	
 
		if (btn == CHT_CHANGE_DATE && x >= WidgetDimensions::scaled.hsep_wide * 2 + this->box.width + SETTING_BUTTON_WIDTH) {
 
@@ -394,7 +394,7 @@ struct CheatWindow : Window {
 
				break;
 
		}
 

	
 
		if (value != oldvalue) WriteValue(ce->variable, ce->type, (int64)value);
 
		if (value != oldvalue) WriteValue(ce->variable, ce->type, (int64_t)value);
 

	
 
		this->SetTimeout();
 

	
 
@@ -413,12 +413,12 @@ struct CheatWindow : Window {
 
		if (str == nullptr || StrEmpty(str)) return;
 

	
 
		const CheatEntry *ce = &_cheats_ui[clicked_widget];
 
		int oldvalue = (int32)ReadValue(ce->variable, ce->type);
 
		int oldvalue = (int32_t)ReadValue(ce->variable, ce->type);
 
		int value = atoi(str);
 
		*ce->been_used = true;
 
		value = ce->proc(value, value - oldvalue);
 

	
 
		if (value != oldvalue) WriteValue(ce->variable, ce->type, (int64)value);
 
		if (value != oldvalue) WriteValue(ce->variable, ce->type, (int64_t)value);
 
		this->SetDirty();
 
	}
 

	
src/clear_cmd.cpp
Show inline comments
 
@@ -319,7 +319,7 @@ void GenerateClearTile()
 
	/* add rocky tiles */
 
	i = gi;
 
	do {
 
		uint32 r = Random();
 
		uint32_t r = Random();
 
		tile = RandomTileSeed(r);
 

	
 
		IncreaseGeneratingWorldProgress(GWP_ROUGH_ROCKY);
src/command.cpp
Show inline comments
 
@@ -428,7 +428,7 @@ void CommandCost::AddCost(const CommandC
 
 * There is only one static instance of the array, just like there is only one
 
 * instance of normal DParams.
 
 */
 
uint32 CommandCost::textref_stack[16];
 
uint32_t CommandCost::textref_stack[16];
 

	
 
/**
 
 * Activate usage of the NewGRF #TextRefStack for the error message.
 
@@ -437,7 +437,7 @@ uint32 CommandCost::textref_stack[16];
 
 */
 
void CommandCost::UseTextRefStack(const GRFFile *grffile, uint num_registers)
 
{
 
	extern TemporaryStorageArray<int32, 0x110> _temp_store;
 
	extern TemporaryStorageArray<int32_t, 0x110> _temp_store;
 

	
 
	assert(num_registers < lengthof(textref_stack));
 
	this->textref_stack_grffile = grffile;
src/command_type.h
Show inline comments
 
@@ -26,10 +26,10 @@ class CommandCost {
 
	StringID message;                           ///< Warning message for when success is unset
 
	bool success;                               ///< Whether the command went fine up to this moment
 
	const GRFFile *textref_stack_grffile;       ///< NewGRF providing the #TextRefStack content.
 
	uint textref_stack_size;                    ///< Number of uint32 values to put on the #TextRefStack for the error message.
 
	uint textref_stack_size;                    ///< Number of uint32_t values to put on the #TextRefStack for the error message.
 
	StringID extra_message = INVALID_STRING_ID; ///< Additional warning message for when success is unset
 

	
 
	static uint32 textref_stack[16];
 
	static uint32_t textref_stack[16];
 

	
 
public:
 
	/**
 
@@ -118,8 +118,8 @@ public:
 
	}
 

	
 
	/**
 
	 * Returns the number of uint32 values for the #TextRefStack of the error message.
 
	 * @return number of uint32 values.
 
	 * Returns the number of uint32_t values for the #TextRefStack of the error message.
 
	 * @return number of uint32_t values.
 
	 */
 
	uint GetTextRefStackSize() const
 
	{
 
@@ -128,9 +128,9 @@ public:
 

	
 
	/**
 
	 * Returns a pointer to the values for the #TextRefStack of the error message.
 
	 * @return uint32 values for the #TextRefStack
 
	 * @return uint32_t values for the #TextRefStack
 
	 */
 
	const uint32 *GetTextRefStack() const
 
	const uint32_t *GetTextRefStack() const
 
	{
 
		return textref_stack;
 
	}
 
@@ -184,7 +184,7 @@ public:
 
 *
 
 * @see _command_proc_table
 
 */
 
enum Commands : uint16 {
 
enum Commands : uint16_t {
 
	CMD_BUILD_RAILROAD_TRACK,         ///< build a rail track
 
	CMD_REMOVE_RAILROAD_TRACK,        ///< remove a rail track
 
	CMD_BUILD_SINGLE_RAIL,            ///< build a single rail track
src/company_base.h
Show inline comments
 
@@ -23,28 +23,28 @@ struct CompanyEconomyEntry {
 
	Money income;               ///< The amount of income.
 
	Money expenses;             ///< The amount of expenses.
 
	CargoArray delivered_cargo{}; ///< The amount of delivered cargo.
 
	int32 performance_history;  ///< Company score (scale 0-1000)
 
	int32_t performance_history;  ///< Company score (scale 0-1000)
 
	Money company_value;        ///< The value of the company.
 
};
 

	
 
struct CompanyInfrastructure {
 
	uint32 road[ROADTYPE_END]; ///< Count of company owned track bits for each road type.
 
	uint32 signal;             ///< Count of company owned signals.
 
	uint32 rail[RAILTYPE_END]; ///< Count of company owned track bits for each rail type.
 
	uint32 water;              ///< Count of company owned track bits for canals.
 
	uint32 station;            ///< Count of company owned station tiles.
 
	uint32 airport;            ///< Count of company owned airports.
 
	uint32_t road[ROADTYPE_END]; ///< Count of company owned track bits for each road type.
 
	uint32_t signal;             ///< Count of company owned signals.
 
	uint32_t rail[RAILTYPE_END]; ///< Count of company owned track bits for each rail type.
 
	uint32_t water;              ///< Count of company owned track bits for canals.
 
	uint32_t station;            ///< Count of company owned station tiles.
 
	uint32_t airport;            ///< Count of company owned airports.
 

	
 
	/** Get total sum of all owned track bits. */
 
	uint32 GetRailTotal() const
 
	uint32_t GetRailTotal() const
 
	{
 
		uint32 total = 0;
 
		uint32_t total = 0;
 
		for (RailType rt =  RAILTYPE_BEGIN; rt < RAILTYPE_END; rt++) total += this->rail[rt];
 
		return total;
 
	}
 

	
 
	uint32 GetRoadTotal() const;
 
	uint32 GetTramTotal() const;
 
	uint32_t GetRoadTotal() const;
 
	uint32_t GetTramTotal() const;
 
};
 

	
 
typedef Pool<Company, CompanyID, 1, MAX_COMPANIES> CompanyPool;
 
@@ -53,12 +53,12 @@ extern CompanyPool _company_pool;
 

	
 
/** Statically loadable part of Company pool item */
 
struct CompanyProperties {
 
	uint32 name_2;                   ///< Parameter of #name_1.
 
	uint32_t name_2;                   ///< Parameter of #name_1.
 
	StringID name_1;                 ///< Name of the company if the user did not change it.
 
	std::string name;                ///< Name of the company if the user changed it.
 

	
 
	StringID president_name_1;       ///< Name of the president if the user did not change it.
 
	uint32 president_name_2;         ///< Parameter of #president_name_1
 
	uint32_t president_name_2;         ///< Parameter of #president_name_1
 
	std::string president_name;      ///< Name of the president if the user changed it.
 

	
 
	CompanyManagerFace face;         ///< Face description of the president.
 
@@ -78,13 +78,13 @@ struct CompanyProperties {
 

	
 
	byte months_of_bankruptcy;       ///< Number of months that the company is unable to pay its debts
 
	CompanyMask bankrupt_asked;      ///< which companies were asked about buying it?
 
	int16 bankrupt_timeout;          ///< If bigger than \c 0, amount of time to wait for an answer on an offer to buy this company.
 
	int16_t bankrupt_timeout;          ///< If bigger than \c 0, amount of time to wait for an answer on an offer to buy this company.
 
	Money bankrupt_value;
 

	
 
	uint32 terraform_limit;          ///< Amount of tileheights we can (still) terraform (times 65536).
 
	uint32 clear_limit;              ///< Amount of tiles we can (still) clear (times 65536).
 
	uint32 tree_limit;               ///< Amount of trees we can (still) plant (times 65536).
 
	uint32 build_object_limit;       ///< Amount of tiles we can (still) build objects on (times 65536). Also applies to buying land.
 
	uint32_t terraform_limit;          ///< Amount of tileheights we can (still) terraform (times 65536).
 
	uint32_t clear_limit;              ///< Amount of tiles we can (still) clear (times 65536).
 
	uint32_t tree_limit;               ///< Amount of trees we can (still) plant (times 65536).
 
	uint32_t build_object_limit;       ///< Amount of tiles we can (still) build objects on (times 65536). Also applies to buying land.
 

	
 
	/**
 
	 * If \c true, the company is (also) controlled by the computer (a NoAI program).
 
@@ -112,7 +112,7 @@ struct CompanyProperties {
 
};
 

	
 
struct Company : CompanyProperties, CompanyPool::PoolItem<&_company_pool> {
 
	Company(uint16 name_1 = 0, bool is_ai = false);
 
	Company(uint16_t name_1 = 0, bool is_ai = false);
 
	~Company();
 

	
 
	RailTypes avail_railtypes;         ///< Rail types available to this company.
src/company_cmd.cpp
Show inline comments
 
@@ -60,15 +60,15 @@ INSTANTIATE_POOL_METHODS(Company)
 
 * @param name_1 Name of the company.
 
 * @param is_ai  A computer program is running for this company.
 
 */
 
Company::Company(uint16 name_1, bool is_ai)
 
Company::Company(uint16_t name_1, bool is_ai)
 
{
 
	this->name_1 = name_1;
 
	this->location_of_HQ = INVALID_TILE;
 
	this->is_ai = is_ai;
 
	this->terraform_limit    = (uint32)_settings_game.construction.terraform_frame_burst << 16;
 
	this->clear_limit        = (uint32)_settings_game.construction.clear_frame_burst << 16;
 
	this->tree_limit         = (uint32)_settings_game.construction.tree_frame_burst << 16;
 
	this->build_object_limit = (uint32)_settings_game.construction.build_object_frame_burst << 16;
 
	this->terraform_limit    = (uint32_t)_settings_game.construction.terraform_frame_burst << 16;
 
	this->clear_limit        = (uint32_t)_settings_game.construction.clear_frame_burst << 16;
 
	this->tree_limit         = (uint32_t)_settings_game.construction.tree_frame_burst << 16;
 
	this->build_object_limit = (uint32_t)_settings_game.construction.build_object_frame_burst << 16;
 

	
 
	InvalidateWindowData(WC_PERFORMANCE_DETAIL, 0, INVALID_COMPANY);
 
}
 
@@ -362,7 +362,7 @@ static void GenerateCompanyName(Company 
 
	Town *t = ClosestTownFromTile(c->last_build_coordinate, UINT_MAX);
 

	
 
	StringID str;
 
	uint32 strp;
 
	uint32_t strp;
 
	std::string name;
 
	if (t->name.empty() && IsInsideMM(t->townnametype, SPECSTR_TOWNNAME_START, SPECSTR_TOWNNAME_LAST + 1)) {
 
		str = t->townnametype - SPECSTR_TOWNNAME_START + SPECSTR_COMPANY_NAME_START;
 
@@ -561,7 +561,7 @@ Company *DoStartupNewCompany(bool is_ai,
 
	_company_colours[c->index] = (Colours)c->colour;
 

	
 
	/* Scale the initial loan based on the inflation rounded down to the loan interval. The maximum loan has already been inflation adjusted. */
 
	c->money = c->current_loan = std::min<int64>((INITIAL_LOAN * _economy.inflation_prices >> 16) / LOAN_INTERVAL * LOAN_INTERVAL, _economy.max_loan);
 
	c->money = c->current_loan = std::min<int64_t>((INITIAL_LOAN * _economy.inflation_prices >> 16) / LOAN_INTERVAL * LOAN_INTERVAL, _economy.max_loan);
 

	
 
	c->avail_railtypes = GetCompanyRailtypes(c->index);
 
	c->avail_roadtypes = GetCompanyRoadTypes(c->index);
 
@@ -684,7 +684,7 @@ static void HandleBankruptcyTakeover(Com
 
	if (c->bankrupt_asked == MAX_UVALUE(CompanyMask)) return;
 

	
 
	Company *best = nullptr;
 
	int32 best_performance = -1;
 
	int32_t best_performance = -1;
 

	
 
	/* Ask the company with the highest performance history first */
 
	for (Company *c2 : Company::Iterate()) {
 
@@ -725,7 +725,7 @@ void OnTick_Companies()
 
	}
 

	
 
	if (_new_competitor_timeout.HasFired() && _game_mode != GM_MENU && AI::CanStartNew()) {
 
		int32 timeout = _settings_game.difficulty.competitors_interval * 60 * TICKS_PER_SECOND;
 
		int32_t timeout = _settings_game.difficulty.competitors_interval * 60 * TICKS_PER_SECOND;
 
		/* If the interval is zero, check every ~10 minutes if a company went bankrupt and needs replacing. */
 
		if (timeout == 0) timeout = 10 * 60 * TICKS_PER_SECOND;
 

	
 
@@ -1149,9 +1149,9 @@ int CompanyServiceInterval(const Company
 
 * Get total sum of all owned road bits.
 
 * @return Combined total road road bits.
 
 */
 
uint32 CompanyInfrastructure::GetRoadTotal() const
 
uint32_t CompanyInfrastructure::GetRoadTotal() const
 
{
 
	uint32 total = 0;
 
	uint32_t total = 0;
 
	for (RoadType rt = ROADTYPE_BEGIN; rt != ROADTYPE_END; rt++) {
 
		if (RoadTypeIsRoad(rt)) total += this->road[rt];
 
	}
 
@@ -1162,9 +1162,9 @@ uint32 CompanyInfrastructure::GetRoadTot
 
 * Get total sum of all owned tram bits.
 
 * @return Combined total of tram road bits.
 
 */
 
uint32 CompanyInfrastructure::GetTramTotal() const
 
uint32_t CompanyInfrastructure::GetTramTotal() const
 
{
 
	uint32 total = 0;
 
	uint32_t total = 0;
 
	for (RoadType rt = ROADTYPE_BEGIN; rt != ROADTYPE_END; rt++) {
 
		if (RoadTypeIsTram(rt)) total += this->road[rt];
 
	}
src/company_cmd.h
Show inline comments
 
@@ -14,7 +14,7 @@
 
#include "company_type.h"
 
#include "livery.h"
 

	
 
enum ClientID : uint32;
 
enum ClientID : uint32_t;
 
enum Colours : byte;
 

	
 
CommandCost CmdCompanyCtrl(DoCommandFlag flags, CompanyCtrlAction cca, CompanyID company_id, CompanyRemoveReason reason, ClientID client_id);
src/company_gui.cpp
Show inline comments
 
@@ -626,7 +626,7 @@ typedef GUIList<const Group*> GUIGroupLi
 
/** Company livery colour scheme window. */
 
struct SelectCompanyLiveryWindow : public Window {
 
private:
 
	uint32 sel;
 
	uint32_t sel;
 
	LiveryClass livery_class;
 
	Dimension square;
 
	uint rows;
 
@@ -635,9 +635,9 @@ private:
 
	std::vector<int> indents;
 
	Scrollbar *vscroll;
 

	
 
	void ShowColourDropDownMenu(uint32 widget)
 
	void ShowColourDropDownMenu(uint32_t widget)
 
	{
 
		uint32 used_colours = 0;
 
		uint32_t used_colours = 0;
 
		const Livery *livery, *default_livery = nullptr;
 
		bool primary = widget == WID_SCL_PRI_COL_DROPDOWN;
 
		byte default_col = 0;
 
@@ -1387,7 +1387,7 @@ class SelectCompanyManagerFaceWindow : p
 
	 * @param val            the value which will be displayed
 
	 * @param is_bool_widget is it a bool button
 
	 */
 
	void SetFaceStringParameters(byte widget_index, uint8 val, bool is_bool_widget) const
 
	void SetFaceStringParameters(byte widget_index, uint8_t val, bool is_bool_widget) const
 
	{
 
		const NWidgetCore *nwi_widget = this->GetWidget<NWidgetCore>(widget_index);
 
		if (nwi_widget->IsDisabled()) {
 
@@ -1881,14 +1881,14 @@ struct CompanyInfrastructureWindow : Win
 
		const Company *c = Company::Get((CompanyID)this->window_number);
 
		Money total;
 

	
 
		uint32 rail_total = c->infrastructure.GetRailTotal();
 
		uint32_t rail_total = c->infrastructure.GetRailTotal();
 
		for (RailType rt = RAILTYPE_BEGIN; rt != RAILTYPE_END; rt++) {
 
			if (HasBit(this->railtypes, rt)) total += RailMaintenanceCost(rt, c->infrastructure.rail[rt], rail_total);
 
		}
 
		total += SignalMaintenanceCost(c->infrastructure.signal);
 

	
 
		uint32 road_total = c->infrastructure.GetRoadTotal();
 
		uint32 tram_total = c->infrastructure.GetTramTotal();
 
		uint32_t road_total = c->infrastructure.GetRoadTotal();
 
		uint32_t tram_total = c->infrastructure.GetTramTotal();
 
		for (RoadType rt = ROADTYPE_BEGIN; rt != ROADTYPE_END; rt++) {
 
			if (HasBit(this->roadtypes, rt)) total += RoadMaintenanceCost(rt, c->infrastructure.road[rt], RoadTypeIsRoad(rt) ? road_total : tram_total);
 
		}
 
@@ -1969,17 +1969,17 @@ struct CompanyInfrastructureWindow : Win
 
			case WID_CI_STATION_COUNT:
 
			case WID_CI_TOTAL: {
 
				/* Find the maximum count that is displayed. */
 
				uint32 max_val = 1000;  // Some random number to reserve enough space.
 
				uint32_t max_val = 1000;  // Some random number to reserve enough space.
 
				Money max_cost = 10000; // Some random number to reserve enough space.
 
				uint32 rail_total = c->infrastructure.GetRailTotal();
 
				uint32_t rail_total = c->infrastructure.GetRailTotal();
 
				for (RailType rt = RAILTYPE_BEGIN; rt < RAILTYPE_END; rt++) {
 
					max_val = std::max(max_val, c->infrastructure.rail[rt]);
 
					max_cost = std::max(max_cost, RailMaintenanceCost(rt, c->infrastructure.rail[rt], rail_total));
 
				}
 
				max_val = std::max(max_val, c->infrastructure.signal);
 
				max_cost = std::max(max_cost, SignalMaintenanceCost(c->infrastructure.signal));
 
				uint32 road_total = c->infrastructure.GetRoadTotal();
 
				uint32 tram_total = c->infrastructure.GetTramTotal();
 
				uint32_t road_total = c->infrastructure.GetRoadTotal();
 
				uint32_t tram_total = c->infrastructure.GetTramTotal();
 
				for (RoadType rt = ROADTYPE_BEGIN; rt < ROADTYPE_END; rt++) {
 
					max_val = std::max(max_val, c->infrastructure.road[rt]);
 
					max_cost = std::max(max_cost, RoadMaintenanceCost(rt, c->infrastructure.road[rt], RoadTypeIsRoad(rt) ? road_total : tram_total));
 
@@ -2062,7 +2062,7 @@ struct CompanyInfrastructureWindow : Win
 

	
 
			case WID_CI_RAIL_COUNT: {
 
				/* Draw infrastructure count for each valid railtype. */
 
				uint32 rail_total = c->infrastructure.GetRailTotal();
 
				uint32_t rail_total = c->infrastructure.GetRailTotal();
 
				for (const auto &rt : _sorted_railtypes) {
 
					if (HasBit(this->railtypes, rt)) {
 
						this->DrawCountLine(r, y, c->infrastructure.rail[rt], RailMaintenanceCost(rt, c->infrastructure.rail[rt], rail_total));
 
@@ -2090,7 +2090,7 @@ struct CompanyInfrastructureWindow : Win
 

	
 
			case WID_CI_ROAD_COUNT:
 
			case WID_CI_TRAM_COUNT: {
 
				uint32 road_tram_total = widget == WID_CI_ROAD_COUNT ? c->infrastructure.GetRoadTotal() : c->infrastructure.GetTramTotal();
 
				uint32_t road_tram_total = widget == WID_CI_ROAD_COUNT ? c->infrastructure.GetRoadTotal() : c->infrastructure.GetTramTotal();
 
				for (const auto &rt : _sorted_roadtypes) {
 
					if (HasBit(this->roadtypes, rt) && RoadTypeIsRoad(rt) == (widget == WID_CI_ROAD_COUNT)) {
 
						this->DrawCountLine(r, y, c->infrastructure.road[rt], RoadMaintenanceCost(rt, c->infrastructure.road[rt], road_tram_total));
src/company_manager_face.h
Show inline comments
 
@@ -127,9 +127,9 @@ static inline void SetCompanyManagerFace
 
 *
 
 * @pre 0 <= val < _cmf_info[cmfv].valid_values[ge]
 
 */
 
static inline void IncreaseCompanyManagerFaceBits(CompanyManagerFace &cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge, int8 amount)
 
static inline void IncreaseCompanyManagerFaceBits(CompanyManagerFace &cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge, int8_t amount)
 
{
 
	int8 val = GetCompanyManagerFaceBits(cmf, cmfv, ge) + amount; // the new value for the cmfv
 
	int8_t val = GetCompanyManagerFaceBits(cmf, cmfv, ge) + amount; // the new value for the cmfv
 

	
 
	/* scales the new value to the correct scope */
 
	if (val >= _cmf_info[cmfv].valid_values[ge]) {
src/company_type.h
Show inline comments
 
@@ -46,13 +46,13 @@ static const uint MAX_COMPETITORS_INTERV
 

	
 
typedef Owner CompanyID;
 

	
 
typedef uint16 CompanyMask;
 
typedef uint16_t CompanyMask;
 

	
 
struct Company;
 
typedef uint32 CompanyManagerFace; ///< Company manager face bits, info see in company_manager_face.h
 
typedef uint32_t CompanyManagerFace; ///< Company manager face bits, info see in company_manager_face.h
 

	
 
/** The reason why the company was removed. */
 
enum CompanyRemoveReason : uint8 {
 
enum CompanyRemoveReason : uint8_t {
 
	CRR_MANUAL,    ///< The company is manually removed.
 
	CRR_AUTOCLEAN, ///< The company is removed due to autoclean.
 
	CRR_BANKRUPT,  ///< The company went belly-up.
 
@@ -63,7 +63,7 @@ enum CompanyRemoveReason : uint8 {
 
};
 

	
 
/** The action to do with CMD_COMPANY_CTRL. */
 
enum CompanyCtrlAction : uint8 {
 
enum CompanyCtrlAction : uint8_t {
 
	CCA_NEW,    ///< Create a new company.
 
	CCA_NEW_AI, ///< Create a new AI company.
 
	CCA_DELETE, ///< Delete a company.
src/console.cpp
Show inline comments
 
@@ -127,7 +127,7 @@ void IConsolePrint(TextColour colour_cod
 
 * @param *arg the string to be converted
 
 * @return Return true on success or false on failure
 
 */
 
bool GetArgumentInteger(uint32 *value, const char *arg)
 
bool GetArgumentInteger(uint32_t *value, const char *arg)
 
{
 
	char *endptr;
 

	
src/console_cmds.cpp
Show inline comments
 
@@ -245,7 +245,7 @@ DEF_CONSOLE_CMD(ConResetTile)
 
	}
 

	
 
	if (argc == 2) {
 
		uint32 result;
 
		uint32_t result;
 
		if (GetArgumentInteger(&result, argv[1])) {
 
			DoClearSquare((TileIndex)result);
 
			return true;
 
@@ -284,7 +284,7 @@ DEF_CONSOLE_CMD(ConZoomToLevel)
 
			return true;
 

	
 
		case 2: {
 
			uint32 level;
 
			uint32_t level;
 
			if (GetArgumentInteger(&level, argv[1])) {
 
				/* In case ZOOM_LVL_MIN is more than 0, the next if statement needs to be amended.
 
				 * A simple check for less than ZOOM_LVL_MIN does not work here because we are
 
@@ -333,7 +333,7 @@ DEF_CONSOLE_CMD(ConScrollToTile)
 
	}
 
	if (argc < 2) return false;
 

	
 
	uint32 arg_index = 1;
 
	uint32_t arg_index = 1;
 
	bool instant = false;
 
	if (strcmp(argv[arg_index], "instant") == 0) {
 
		++arg_index;
 
@@ -342,7 +342,7 @@ DEF_CONSOLE_CMD(ConScrollToTile)
 

	
 
	switch (argc - arg_index) {
 
		case 1: {
 
			uint32 result;
 
			uint32_t result;
 
			if (GetArgumentInteger(&result, argv[arg_index])) {
 
				if (result >= Map::Size()) {
 
					IConsolePrint(CC_ERROR, "Tile does not exist.");
 
@@ -355,7 +355,7 @@ DEF_CONSOLE_CMD(ConScrollToTile)
 
		}
 

	
 
		case 2: {
 
			uint32 x, y;
 
			uint32_t x, y;
 
			if (GetArgumentInteger(&x, argv[arg_index]) && GetArgumentInteger(&y, argv[arg_index + 1])) {
 
				if (x >= Map::SizeX() || y >= Map::SizeY()) {
 
					IConsolePrint(CC_ERROR, "Tile does not exist.");
 
@@ -1499,10 +1499,10 @@ DEF_CONSOLE_CMD(ConScreenShot)
 
	if (argc > 7) return false;
 

	
 
	ScreenshotType type = SC_VIEWPORT;
 
	uint32 width = 0;
 
	uint32 height = 0;
 
	uint32_t width = 0;
 
	uint32_t height = 0;
 
	std::string name{};
 
	uint32 arg_index = 1;
 
	uint32_t arg_index = 1;
 

	
 
	if (argc > arg_index) {
 
		if (strcmp(argv[arg_index], "viewport") == 0) {
 
@@ -1723,7 +1723,7 @@ DEF_CONSOLE_CMD(ConCompanies)
 
		std::string colour = GetString(STR_COLOUR_DARK_BLUE + _company_colours[c->index]);
 
		IConsolePrint(CC_INFO, "#:{}({}) Company Name: '{}'  Year Founded: {}  Money: {}  Loan: {}  Value: {}  (T:{}, R:{}, P:{}, S:{}) {}",
 
			c->index + 1, colour, company_name,
 
			c->inaugurated_year, (int64)c->money, (int64)c->current_loan, (int64)CalculateCompanyValue(c),
 
			c->inaugurated_year, (int64_t)c->money, (int64_t)c->current_loan, (int64_t)CalculateCompanyValue(c),
 
			c->group_all[VEH_TRAIN].num_vehicle,
 
			c->group_all[VEH_ROAD].num_vehicle,
 
			c->group_all[VEH_AIRCRAFT].num_vehicle,
 
@@ -2279,7 +2279,7 @@ DEF_CONSOLE_CMD(ConNewGRFProfile)
 
			IConsolePrint(CC_DEBUG, "Started profiling for GRFID{} {}.", (started > 1) ? "s" : "", grfids);
 

	
 
			if (argc >= 3) {
 
				uint64 ticks = std::max(atoi(argv[2]), 1);
 
				uint64_t ticks = std::max(atoi(argv[2]), 1);
 
				NewGRFProfiler::StartTimer(ticks);
 
				IConsolePrint(CC_DEBUG, "Profiling will automatically stop after {} ticks.", ticks);
 
			}
 
@@ -2358,11 +2358,11 @@ static void ConDumpRoadTypes()
 
	IConsolePrint(CC_DEFAULT, "    h = hidden");
 
	IConsolePrint(CC_DEFAULT, "    T = buildable by towns");
 

	
 
	std::map<uint32, const GRFFile *> grfs;
 
	std::map<uint32_t, const GRFFile *> grfs;
 
	for (RoadType rt = ROADTYPE_BEGIN; rt < ROADTYPE_END; rt++) {
 
		const RoadTypeInfo *rti = GetRoadTypeInfo(rt);
 
		if (rti->label == 0) continue;
 
		uint32 grfid = 0;
 
		uint32_t grfid = 0;
 
		const GRFFile *grf = rti->grffile[ROTSG_GROUND];
 
		if (grf != nullptr) {
 
			grfid = grf->grfid;
 
@@ -2396,11 +2396,11 @@ static void ConDumpRailTypes()
 
	IConsolePrint(CC_DEFAULT, "    a = always allow 90 degree turns");
 
	IConsolePrint(CC_DEFAULT, "    d = always disallow 90 degree turns");
 

	
 
	std::map<uint32, const GRFFile *> grfs;
 
	std::map<uint32_t, const GRFFile *> grfs;
 
	for (RailType rt = RAILTYPE_BEGIN; rt < RAILTYPE_END; rt++) {
 
		const RailtypeInfo *rti = GetRailTypeInfo(rt);
 
		if (rti->label == 0) continue;
 
		uint32 grfid = 0;
 
		uint32_t grfid = 0;
 
		const GRFFile *grf = rti->grffile[RTSG_GROUND];
 
		if (grf != nullptr) {
 
			grfid = grf->grfid;
 
@@ -2439,11 +2439,11 @@ static void ConDumpCargoTypes()
 
	IConsolePrint(CC_DEFAULT, "    c = covered/sheltered");
 
	IConsolePrint(CC_DEFAULT, "    S = special");
 

	
 
	std::map<uint32, const GRFFile *> grfs;
 
	std::map<uint32_t, const GRFFile *> grfs;
 
	for (CargoID i = 0; i < NUM_CARGO; i++) {
 
		const CargoSpec *spec = CargoSpec::Get(i);
 
		if (!spec->IsValid()) continue;
 
		uint32 grfid = 0;
 
		uint32_t grfid = 0;
 
		const GRFFile *grf = spec->grffile;
 
		if (grf != nullptr) {
 
			grfid = grf->grfid;
src/console_gui.cpp
Show inline comments
 
@@ -39,7 +39,7 @@ static const uint ICON_BOTTOM_BORDERWIDT
 
struct IConsoleLine {
 
	std::string buffer;     ///< The data to store.
 
	TextColour colour;      ///< The colour of the line.
 
	uint16 time;            ///< The amount of time the line is in the backlog.
 
	uint16_t time;            ///< The amount of time the line is in the backlog.
 

	
 
	IConsoleLine() : buffer(), colour(TC_BEGIN), time(0)
 
	{
 
@@ -200,7 +200,7 @@ struct IConsoleWindow : Window
 
		if (_iconsole_cmdline.HandleCaret()) this->SetDirty();
 
	}
 

	
 
	EventState OnKeyPress(WChar key, uint16 keycode) override
 
	EventState OnKeyPress(char32_t key, uint16_t keycode) override
 
	{
 
		if (_focused_window != this) return ES_NOT_HANDLED;
 

	
src/console_internal.h
Show inline comments
 
@@ -82,7 +82,7 @@ void IConsoleClearBuffer();
 
void IConsoleStdLibRegister();
 

	
 
/* Supporting functions */
 
bool GetArgumentInteger(uint32 *value, const char *arg);
 
bool GetArgumentInteger(uint32_t *value, const char *arg);
 

	
 
void IConsoleGUIInit();
 
void IConsoleGUIFree();
src/core/bitmath_func.cpp
Show inline comments
 
@@ -12,7 +12,7 @@
 

	
 
#include "../safeguards.h"
 

	
 
const uint8 _ffb_64[64] = {
 
const uint8_t _ffb_64[64] = {
 
	0,  0,  1,  0,  2,  0,  1,  0,
 
	3,  0,  1,  0,  2,  0,  1,  0,
 
	4,  0,  1,  0,  2,  0,  1,  0,
 
@@ -34,13 +34,13 @@ const uint8 _ffb_64[64] = {
 
 * @param x The value to search
 
 * @return The position of the first bit set
 
 */
 
uint8 FindFirstBit(uint64 x)
 
uint8_t FindFirstBit(uint64_t x)
 
{
 
	if (x == 0) return 0;
 
	/* The macro FIND_FIRST_BIT is better to use when your x is
 
	  not more than 128. */
 

	
 
	uint8 pos = 0;
 
	uint8_t pos = 0;
 

	
 
	if ((x & 0xffffffffULL) == 0) { x >>= 32; pos += 32; }
 
	if ((x & 0x0000ffffULL) == 0) { x >>= 16; pos += 16; }
 
@@ -63,11 +63,11 @@ uint8 FindFirstBit(uint64 x)
 
 * @param x The value to search
 
 * @return The position of the last bit set
 
 */
 
uint8 FindLastBit(uint64 x)
 
uint8_t FindLastBit(uint64_t x)
 
{
 
	if (x == 0) return 0;
 

	
 
	uint8 pos = 0;
 
	uint8_t pos = 0;
 

	
 
	if ((x & 0xffffffff00000000ULL) != 0) { x >>= 32; pos += 32; }
 
	if ((x & 0x00000000ffff0000ULL) != 0) { x >>= 16; pos += 16; }
src/core/bitmath_func.hpp
Show inline comments
 
@@ -29,7 +29,7 @@
 
 * @return The selected bits, aligned to a LSB.
 
 */
 
template <typename T>
 
debug_inline constexpr static uint GB(const T x, const uint8 s, const uint8 n)
 
debug_inline constexpr static uint GB(const T x, const uint8_t s, const uint8_t n)
 
{
 
	return (x >> s) & (((T)1U << n) - 1);
 
}
 
@@ -55,7 +55,7 @@ debug_inline constexpr static uint GB(co
 
 * @return The new value of \a x
 
 */
 
template <typename T, typename U>
 
static inline T SB(T &x, const uint8 s, const uint8 n, const U d)
 
static inline T SB(T &x, const uint8_t s, const uint8_t n, const U d)
 
{
 
	x &= (T)(~((((T)1U << n) - 1) << s));
 
	x |= (T)(d << s);
 
@@ -80,7 +80,7 @@ static inline T SB(T &x, const uint8 s, 
 
 * @return The new value of \a x
 
 */
 
template <typename T, typename U>
 
static inline T AB(T &x, const uint8 s, const uint8 n, const U i)
 
static inline T AB(T &x, const uint8_t s, const uint8_t n, const U i)
 
{
 
	const T mask = ((((T)1U << n) - 1) << s);
 
	x = (T)((x & ~mask) | ((x + (i << s)) & mask));
 
@@ -100,7 +100,7 @@ static inline T AB(T &x, const uint8 s, 
 
 * @return True if the bit is set, false else.
 
 */
 
template <typename T>
 
debug_inline static bool HasBit(const T x, const uint8 y)
 
debug_inline static bool HasBit(const T x, const uint8_t y)
 
{
 
	return (x & ((T)1U << y)) != 0;
 
}
 
@@ -118,7 +118,7 @@ debug_inline static bool HasBit(const T 
 
 * @return The new value of the old value with the bit set
 
 */
 
template <typename T>
 
static inline T SetBit(T &x, const uint8 y)
 
static inline T SetBit(T &x, const uint8_t y)
 
{
 
	return x = (T)(x | ((T)1U << y));
 
}
 
@@ -148,7 +148,7 @@ static inline T SetBit(T &x, const uint8
 
 * @return The new value of the old value with the bit cleared
 
 */
 
template <typename T>
 
static inline T ClrBit(T &x, const uint8 y)
 
static inline T ClrBit(T &x, const uint8_t y)
 
{
 
	return x = (T)(x & ~((T)1U << y));
 
}
 
@@ -178,14 +178,14 @@ static inline T ClrBit(T &x, const uint8
 
 * @return The new value of the old value with the bit toggled
 
 */
 
template <typename T>
 
static inline T ToggleBit(T &x, const uint8 y)
 
static inline T ToggleBit(T &x, const uint8_t y)
 
{
 
	return x = (T)(x ^ ((T)1U << y));
 
}
 

	
 

	
 
/** Lookup table to check which bit is set in a 6 bit variable */
 
extern const uint8 _ffb_64[64];
 
extern const uint8_t _ffb_64[64];
 

	
 
/**
 
 * Returns the first non-zero bit in a 6-bit value (from right).
 
@@ -213,7 +213,7 @@ extern const uint8 _ffb_64[64];
 
 * @return The position of the first bit which is set
 
 * @see FIND_FIRST_BIT
 
 */
 
static inline uint8 FindFirstBit2x64(const int value)
 
static inline uint8_t FindFirstBit2x64(const int value)
 
{
 
	if ((value & 0xFF) == 0) {
 
		return FIND_FIRST_BIT((value >> 8) & 0x3F) + 8;
 
@@ -222,8 +222,8 @@ static inline uint8 FindFirstBit2x64(con
 
	}
 
}
 

	
 
uint8 FindFirstBit(uint64 x);
 
uint8 FindLastBit(uint64 x);
 
uint8_t FindFirstBit(uint64_t x);
 
uint8_t FindLastBit(uint64_t x);
 

	
 
/**
 
 * Clear the first bit in an integer.
 
@@ -298,7 +298,7 @@ static inline bool HasAtMostOneBit(T val
 
 * @return A bit rotated number
 
 */
 
template <typename T>
 
static inline T ROL(const T x, const uint8 n)
 
static inline T ROL(const T x, const uint8_t n)
 
{
 
	if (n == 0) return x;
 
	return (T)(x << n | x >> (sizeof(x) * 8 - n));
 
@@ -314,7 +314,7 @@ static inline T ROL(const T x, const uin
 
 * @return A bit rotated number
 
 */
 
template <typename T>
 
static inline T ROR(const T x, const uint8 n)
 
static inline T ROR(const T x, const uint8_t n)
 
{
 
	if (n == 0) return x;
 
	return (T)(x >> n | x << (sizeof(x) * 8 - n));
 
@@ -373,10 +373,10 @@ private:
 
#if defined(__APPLE__)
 
	/* Make endian swapping use Apple's macros to increase speed
 
	 * (since it will use hardware swapping if available).
 
	 * Even though they should return uint16 and uint32, we get
 
	 * Even though they should return uint16_t and uint32_t, we get
 
	 * warnings if we don't cast those (why?) */
 
#	define BSWAP32(x) (static_cast<uint32>(CFSwapInt32(x)))
 
#	define BSWAP16(x) (static_cast<uint16>(CFSwapInt16(x)))
 
#	define BSWAP32(x) (static_cast<uint32_t>(CFSwapInt32(x)))
 
#	define BSWAP16(x) (static_cast<uint16_t>(CFSwapInt16(x)))
 
#elif defined(_MSC_VER)
 
	/* MSVC has intrinsics for swapping, resulting in faster code */
 
#	define BSWAP32(x) (_byteswap_ulong(x))
 
@@ -387,11 +387,11 @@ private:
 
	 * @param x the variable to bitswap
 
	 * @return the bitswapped value.
 
	 */
 
	static inline uint32 BSWAP32(uint32 x)
 
	static inline uint32_t BSWAP32(uint32_t x)
 
	{
 
#if !defined(__ICC) && defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4)  && __GNUC_MINOR__ >= 3))
 
		/* GCC >= 4.3 provides a builtin, resulting in faster code */
 
		return static_cast<uint32>(__builtin_bswap32(static_cast<int32>(x)));
 
		return static_cast<uint32_t>(__builtin_bswap32(static_cast<int32_t>(x)));
 
#else
 
		return ((x >> 24) & 0xFF) | ((x >> 8) & 0xFF00) | ((x << 8) & 0xFF0000) | ((x << 24) & 0xFF000000);
 
#endif /* defined(__GNUC__) */
 
@@ -402,7 +402,7 @@ private:
 
	 * @param x the variable to bitswap
 
	 * @return the bitswapped value.
 
	 */
 
	static inline uint16 BSWAP16(uint16 x)
 
	static inline uint16_t BSWAP16(uint16_t x)
 
	{
 
		return (x >> 8) | (x << 8);
 
	}
src/core/endian_func.hpp
Show inline comments
 
@@ -38,17 +38,17 @@
 
#	define TO_LE32X(x)  (x)
 
#endif /* TTD_ENDIAN == TTD_BIG_ENDIAN */
 

	
 
static inline uint16 ReadLE16Aligned(const void *x)
 
static inline uint16_t ReadLE16Aligned(const void *x)
 
{
 
	return FROM_LE16(*(const uint16*)x);
 
	return FROM_LE16(*(const uint16_t*)x);
 
}
 

	
 
static inline uint16 ReadLE16Unaligned(const void *x)
 
static inline uint16_t ReadLE16Unaligned(const void *x)
 
{
 
#if OTTD_ALIGNMENT == 1
 
	return ((const byte*)x)[0] | ((const byte*)x)[1] << 8;
 
#else
 
	return FROM_LE16(*(const uint16*)x);
 
	return FROM_LE16(*(const uint16_t*)x);
 
#endif /* OTTD_ALIGNMENT == 1 */
 
}
 

	
src/core/geometry_type.hpp
Show inline comments
 
@@ -45,10 +45,10 @@ struct Dimension {
 

	
 
/** Padding dimensions to apply to each side of a Rect. */
 
struct RectPadding {
 
	uint8 left;
 
	uint8 top;
 
	uint8 right;
 
	uint8 bottom;
 
	uint8_t left;
 
	uint8_t top;
 
	uint8_t right;
 
	uint8_t bottom;
 

	
 
	static const RectPadding zero;
 

	
src/core/math_func.cpp
Show inline comments
 
@@ -74,10 +74,10 @@ int DivideApprox(int a, int b)
 
 * @return Rounded integer square root.
 
 * @note Algorithm taken from http://en.wikipedia.org/wiki/Methods_of_computing_square_roots
 
 */
 
uint32 IntSqrt(uint32 num)
 
uint32_t IntSqrt(uint32_t num)
 
{
 
	uint32 res = 0;
 
	uint32 bit = 1UL << 30; // Second to top bit number.
 
	uint32_t res = 0;
 
	uint32_t bit = 1UL << 30; // Second to top bit number.
 

	
 
	/* 'bit' starts at the highest power of four <= the argument. */
 
	while (bit > num) bit >>= 2;
src/core/math_func.hpp
Show inline comments
 
@@ -355,6 +355,6 @@ static inline int DivAwayFromZero(int a,
 
	}
 
}
 

	
 
uint32 IntSqrt(uint32 num);
 
uint32_t IntSqrt(uint32_t num);
 

	
 
#endif /* MATH_FUNC_HPP */
src/core/overflowsafe_type.hpp
Show inline comments
 
@@ -93,11 +93,11 @@ public:
 

	
 
	/* Operators for addition and subtraction. */
 
	inline constexpr OverflowSafeInt  operator +  (const OverflowSafeInt& other) const { OverflowSafeInt result = *this; result += other; return result; }
 
	inline constexpr OverflowSafeInt  operator +  (const int              other) const { OverflowSafeInt result = *this; result += (int64)other; return result; }
 
	inline constexpr OverflowSafeInt  operator +  (const uint             other) const { OverflowSafeInt result = *this; result += (int64)other; return result; }
 
	inline constexpr OverflowSafeInt  operator +  (const int              other) const { OverflowSafeInt result = *this; result += (int64_t)other; return result; }
 
	inline constexpr OverflowSafeInt  operator +  (const uint             other) const { OverflowSafeInt result = *this; result += (int64_t)other; return result; }
 
	inline constexpr OverflowSafeInt  operator -  (const OverflowSafeInt& other) const { OverflowSafeInt result = *this; result -= other; return result; }
 
	inline constexpr OverflowSafeInt  operator -  (const int              other) const { OverflowSafeInt result = *this; result -= (int64)other; return result; }
 
	inline constexpr OverflowSafeInt  operator -  (const uint             other) const { OverflowSafeInt result = *this; result -= (int64)other; return result; }
 
	inline constexpr OverflowSafeInt  operator -  (const int              other) const { OverflowSafeInt result = *this; result -= (int64_t)other; return result; }
 
	inline constexpr OverflowSafeInt  operator -  (const uint             other) const { OverflowSafeInt result = *this; result -= (int64_t)other; return result; }
 

	
 
	inline constexpr OverflowSafeInt& operator ++ () { return *this += 1; }
 
	inline constexpr OverflowSafeInt& operator -- () { return *this += -1; }
 
@@ -136,14 +136,14 @@ public:
 
	}
 

	
 
	/* Operators for multiplication. */
 
	inline constexpr OverflowSafeInt operator * (const int64  factor) const { OverflowSafeInt result = *this; result *= factor; return result; }
 
	inline constexpr OverflowSafeInt operator * (const int    factor) const { OverflowSafeInt result = *this; result *= (int64)factor; return result; }
 
	inline constexpr OverflowSafeInt operator * (const uint   factor) const { OverflowSafeInt result = *this; result *= (int64)factor; return result; }
 
	inline constexpr OverflowSafeInt operator * (const uint16 factor) const { OverflowSafeInt result = *this; result *= (int64)factor; return result; }
 
	inline constexpr OverflowSafeInt operator * (const byte   factor) const { OverflowSafeInt result = *this; result *= (int64)factor; return result; }
 
	inline constexpr OverflowSafeInt operator * (const int64_t  factor) const { OverflowSafeInt result = *this; result *= factor; return result; }
 
	inline constexpr OverflowSafeInt operator * (const int    factor) const { OverflowSafeInt result = *this; result *= (int64_t)factor; return result; }
 
	inline constexpr OverflowSafeInt operator * (const uint   factor) const { OverflowSafeInt result = *this; result *= (int64_t)factor; return result; }
 
	inline constexpr OverflowSafeInt operator * (const uint16_t factor) const { OverflowSafeInt result = *this; result *= (int64_t)factor; return result; }
 
	inline constexpr OverflowSafeInt operator * (const byte   factor) const { OverflowSafeInt result = *this; result *= (int64_t)factor; return result; }
 

	
 
	/* Operators for division. */
 
	inline constexpr OverflowSafeInt& operator /= (const int64            divisor)       { this->m_value /= divisor; return *this; }
 
	inline constexpr OverflowSafeInt& operator /= (const int64_t            divisor)       { this->m_value /= divisor; return *this; }
 
	inline constexpr OverflowSafeInt  operator /  (const OverflowSafeInt& divisor) const { OverflowSafeInt result = *this; result /= divisor.m_value; return result; }
 
	inline constexpr OverflowSafeInt  operator /  (const int              divisor) const { OverflowSafeInt result = *this; result /= divisor; return result; }
 
	inline constexpr OverflowSafeInt  operator /  (const uint             divisor) const { OverflowSafeInt result = *this; result /= (int)divisor; return result; }
 
@@ -181,11 +181,11 @@ public:
 
};
 

	
 

	
 
/* Sometimes we got int64 operator OverflowSafeInt instead of vice versa. Handle that properly. */
 
template <class T> inline constexpr OverflowSafeInt<T> operator + (const int64 a, const OverflowSafeInt<T> b) { return b + a; }
 
template <class T> inline constexpr OverflowSafeInt<T> operator - (const int64 a, const OverflowSafeInt<T> b) { return -b + a; }
 
template <class T> inline constexpr OverflowSafeInt<T> operator * (const int64 a, const OverflowSafeInt<T> b) { return b * a; }
 
template <class T> inline constexpr OverflowSafeInt<T> operator / (const int64 a, const OverflowSafeInt<T> b) { return (OverflowSafeInt<T>)a / (int)b; }
 
/* Sometimes we got int64_t operator OverflowSafeInt instead of vice versa. Handle that properly. */
 
template <class T> inline constexpr OverflowSafeInt<T> operator + (const int64_t a, const OverflowSafeInt<T> b) { return b + a; }
 
template <class T> inline constexpr OverflowSafeInt<T> operator - (const int64_t a, const OverflowSafeInt<T> b) { return -b + a; }
 
template <class T> inline constexpr OverflowSafeInt<T> operator * (const int64_t a, const OverflowSafeInt<T> b) { return b * a; }
 
template <class T> inline constexpr OverflowSafeInt<T> operator / (const int64_t a, const OverflowSafeInt<T> b) { return (OverflowSafeInt<T>)a / (int)b; }
 

	
 
/* Sometimes we got int operator OverflowSafeInt instead of vice versa. Handle that properly. */
 
template <class T> inline constexpr OverflowSafeInt<T> operator + (const int   a, const OverflowSafeInt<T> b) { return b + a; }
 
@@ -205,8 +205,8 @@ template <class T> inline constexpr Over
 
template <class T> inline constexpr OverflowSafeInt<T> operator * (const byte  a, const OverflowSafeInt<T> b) { return b * (uint)a; }
 
template <class T> inline constexpr OverflowSafeInt<T> operator / (const byte  a, const OverflowSafeInt<T> b) { return (OverflowSafeInt<T>)a / (int)b; }
 

	
 
typedef OverflowSafeInt<int64> OverflowSafeInt64;
 
typedef OverflowSafeInt<int32> OverflowSafeInt32;
 
typedef OverflowSafeInt<int64_t> OverflowSafeInt64;
 
typedef OverflowSafeInt<int32_t> OverflowSafeInt32;
 

	
 
/* Some basic "unit tests". Also has the bonus of confirming that constexpr is working. */
 
static_assert(OverflowSafeInt32(INT32_MIN) - 1 == OverflowSafeInt32(INT32_MIN));
src/core/pool_type.hpp
Show inline comments
 
@@ -79,7 +79,7 @@ private:
 
template <class Titem, typename Tindex, size_t Tgrowth_step, size_t Tmax_size, PoolType Tpool_type = PT_NORMAL, bool Tcache = false, bool Tzero = true>
 
struct Pool : PoolBase {
 
	/* Ensure Tmax_size is within the bounds of Tindex. */
 
	static_assert((uint64)(Tmax_size - 1) >> 8 * sizeof(Tindex) == 0);
 
	static_assert((uint64_t)(Tmax_size - 1) >> 8 * sizeof(Tindex) == 0);
 

	
 
	static constexpr size_t MAX_SIZE = Tmax_size; ///< Make template parameter accessible from outside
 

	
src/core/random_func.cpp
Show inline comments
 
@@ -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 *fi
 
	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 */
src/core/random_func.hpp
Show inline comments
 
@@ -20,11 +20,11 @@
 
 */
 
struct Randomizer {
 
	/** The state of the randomizer */
 
	uint32 state[2];
 
	uint32_t state[2];
 

	
 
	uint32 Next();
 
	uint32 Next(uint32 limit);
 
	void SetSeed(uint32 seed);
 
	uint32_t Next();
 
	uint32_t Next(uint32_t limit);
 
	void SetSeed(uint32_t seed);
 
};
 
extern Randomizer _random; ///< Random used in the game state calculations
 
extern Randomizer _interactive_random; ///< Random used everywhere else, where it does not (directly) influence the game state
 
@@ -55,18 +55,18 @@ static inline void RestoreRandomSeeds(co
 
	_interactive_random = storage.interactive_random;
 
}
 

	
 
void SetRandomSeed(uint32 seed);
 
void SetRandomSeed(uint32_t seed);
 
#ifdef RANDOM_DEBUG
 
#	ifdef __APPLE__
 
#		define OTTD_Random() DoRandom(__LINE__, __FILE__)
 
#	else
 
#		define Random() DoRandom(__LINE__, __FILE__)
 
#	endif
 
	uint32 DoRandom(int line, const char *file);
 
	uint32_t DoRandom(int line, const char *file);
 
#	define RandomRange(limit) DoRandomRange(limit, __LINE__, __FILE__)
 
	uint32 DoRandomRange(uint32 limit, int line, const char *file);
 
	uint32_t DoRandomRange(uint32_t limit, int line, const char *file);
 
#else
 
	static inline uint32 Random()
 
	static inline uint32_t Random()
 
	{
 
		return _random.Next();
 
	}
 
@@ -78,18 +78,18 @@ void SetRandomSeed(uint32 seed);
 
	 * @param limit Limit for the range to be picked from.
 
	 * @return A random number in [0,\a limit).
 
	 */
 
	static inline uint32 RandomRange(uint32 limit)
 
	static inline uint32_t RandomRange(uint32_t limit)
 
	{
 
		return _random.Next(limit);
 
	}
 
#endif
 

	
 
static inline uint32 InteractiveRandom()
 
static inline uint32_t InteractiveRandom()
 
{
 
	return _interactive_random.Next();
 
}
 

	
 
static inline uint32 InteractiveRandomRange(uint32 limit)
 
static inline uint32_t InteractiveRandomRange(uint32_t limit)
 
{
 
	return _interactive_random.Next(limit);
 
}
 
@@ -109,10 +109,10 @@ static inline uint32 InteractiveRandomRa
 
 * @param r The given randomize-number
 
 * @return True if the probability given by r is less or equal to (a/b)
 
 */
 
static inline bool Chance16I(const uint a, const uint b, const uint32 r)
 
static inline bool Chance16I(const uint a, const uint b, const uint32_t r)
 
{
 
	assert(b != 0);
 
	return (((uint16)r * b + b / 2) >> 16) < a;
 
	return (((uint16_t)r * b + b / 2) >> 16) < a;
 
}
 

	
 
/**
 
@@ -152,7 +152,7 @@ static inline bool Chance16(const uint a
 
#ifdef RANDOM_DEBUG
 
#	define Chance16R(a, b, r) (r = DoRandom(__LINE__, __FILE__), Chance16I(a, b, r))
 
#else
 
static inline bool Chance16R(const uint a, const uint b, uint32 &r)
 
static inline bool Chance16R(const uint a, const uint b, uint32_t &r)
 
{
 
	r = Random();
 
	return Chance16I(a, b, r);
src/cpu.cpp
Show inline comments
 
@@ -19,7 +19,7 @@
 
#if defined(_MSC_VER) && !defined(RDTSC_AVAILABLE)
 
#include <intrin.h>
 
#include <windows.h>
 
uint64 ottd_rdtsc()
 
uint64_t ottd_rdtsc()
 
{
 
#if defined(_M_ARM)
 
	return __rdpmccntr64();
 
@@ -34,20 +34,20 @@ uint64 ottd_rdtsc()
 

	
 
/* rdtsc for all other *nix-en (hopefully). Use GCC syntax */
 
#if (defined(__i386__) || defined(__x86_64__)) && !defined(RDTSC_AVAILABLE)
 
uint64 ottd_rdtsc()
 
uint64_t ottd_rdtsc()
 
{
 
	uint32 high, low;
 
	uint32_t high, low;
 
	__asm__ __volatile__ ("rdtsc" : "=a" (low), "=d" (high));
 
	return ((uint64)high << 32) | low;
 
	return ((uint64_t)high << 32) | low;
 
}
 
# define RDTSC_AVAILABLE
 
#endif
 

	
 
/* rdtsc for PPC which has this not */
 
#if (defined(__POWERPC__) || defined(__powerpc__)) && !defined(RDTSC_AVAILABLE)
 
uint64 ottd_rdtsc()
 
uint64_t ottd_rdtsc()
 
{
 
	uint32 high = 0, high2 = 0, low;
 
	uint32_t high = 0, high2 = 0, low;
 
	/* PPC does not have rdtsc, so we cheat by reading the two 32-bit time-counters
 
	 * it has, 'Move From Time Base (Upper)'. Since these are two reads, in the
 
	 * very unlikely event that the lower part overflows to the upper part while we
 
@@ -61,14 +61,14 @@ uint64 ottd_rdtsc()
 
				  : "=r" (high), "=r" (low), "=r" (high2)
 
				  : "0" (high), "2" (high2)
 
				  );
 
	return ((uint64)high << 32) | low;
 
	return ((uint64_t)high << 32) | low;
 
}
 
# define RDTSC_AVAILABLE
 
#endif
 

	
 
/* rdtsc for MCST Elbrus 2000 */
 
#if defined(__e2k__) && !defined(RDTSC_AVAILABLE)
 
uint64 ottd_rdtsc()
 
uint64_t ottd_rdtsc()
 
{
 
	uint64_t dst;
 
# pragma asm_inline
 
@@ -80,7 +80,7 @@ uint64 ottd_rdtsc()
 

	
 
#if defined(__EMSCRIPTEN__) && !defined(RDTSC_AVAILABLE)
 
/* On emscripten doing TIC/TOC would be ill-advised */
 
uint64 ottd_rdtsc() {return 0;}
 
uint64_t ottd_rdtsc() {return 0;}
 
# define RDTSC_AVAILABLE
 
#endif
 

	
 
@@ -88,7 +88,7 @@ uint64 ottd_rdtsc() {return 0;}
 
 * you just won't be able to profile your code with TIC()/TOC() */
 
#if !defined(RDTSC_AVAILABLE)
 
#warning "(non-fatal) No support for rdtsc(), you won't be able to profile with TIC/TOC"
 
uint64 ottd_rdtsc() {return 0;}
 
uint64_t ottd_rdtsc() {return 0;}
 
#endif
 

	
 

	
src/cpu.h
Show inline comments
 
@@ -14,7 +14,7 @@
 
 * Get the tick counter from the CPU (high precision timing).
 
 * @return The count.
 
 */
 
uint64 ottd_rdtsc();
 
uint64_t ottd_rdtsc();
 

	
 
/**
 
 * Get the CPUID information from the CPU.
src/currency.cpp
Show inline comments
 
@@ -120,9 +120,9 @@ byte GetNewgrfCurrencyIdConverted(byte g
 
 * get a mask of the allowed currencies depending on the year
 
 * @return mask of currencies
 
 */
 
uint64 GetMaskOfAllowedCurrencies()
 
uint64_t GetMaskOfAllowedCurrencies()
 
{
 
	uint64 mask = 0LL;
 
	uint64_t mask = 0LL;
 
	uint i;
 

	
 
	for (i = 0; i < CURRENCY_END; i++) {
src/currency.h
Show inline comments
 
@@ -70,7 +70,7 @@ enum Currencies {
 

	
 
/** Specification of a currency. */
 
struct CurrencySpec {
 
	uint16 rate;           ///< The conversion rate compared to the base currency.
 
	uint16_t rate;           ///< The conversion rate compared to the base currency.
 
	std::string separator; ///< The thousands separator for this currency.
 
	TimerGameCalendar::Year to_euro; ///< Year of switching to the Euro. May also be #CF_NOEURO or #CF_ISEURO.
 
	std::string prefix;    ///< Prefix to apply when formatting money in this currency.
 
@@ -90,7 +90,7 @@ struct CurrencySpec {
 

	
 
	CurrencySpec() = default;
 

	
 
	CurrencySpec(uint16 rate, const char *separator, TimerGameCalendar::Year to_euro, const char *prefix, const char *suffix, const char *code, byte symbol_pos, StringID name) :
 
	CurrencySpec(uint16_t rate, const char *separator, TimerGameCalendar::Year to_euro, const char *prefix, const char *suffix, const char *code, byte symbol_pos, StringID name) :
 
		rate(rate), separator(separator), to_euro(to_euro), prefix(prefix), suffix(suffix), code(code), symbol_pos(symbol_pos), name(name)
 
	{
 
	}
 
@@ -102,7 +102,7 @@ extern CurrencySpec _currency_specs[CURR
 
#define _custom_currency (_currency_specs[CURRENCY_CUSTOM])
 
#define _currency ((const CurrencySpec*)&_currency_specs[GetGameSettings().locale.currency])
 

	
 
uint64 GetMaskOfAllowedCurrencies();
 
uint64_t GetMaskOfAllowedCurrencies();
 
void ResetCurrencies(bool preserve_custom = true);
 
byte GetNewgrfCurrencyIdConverted(byte grfcurr_id);
 

	
src/date_gui.cpp
Show inline comments
 
@@ -56,7 +56,7 @@ struct SetDateWindow : Window {
 
		this->date.year = Clamp(this->date.year, min_year, max_year);
 
	}
 

	
 
	Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) override
 
	Point OnInitialPosition(int16_t sm_width, int16_t sm_height, int window_number) override
 
	{
 
		Point pt = { this->parent->left + this->parent->width / 2 - sm_width / 2, this->parent->top + this->parent->height / 2 - sm_height / 2 };
 
		return pt;
src/date_type.h
Show inline comments
 
@@ -12,11 +12,11 @@
 

	
 
#include "timer/timer_game_calendar.h"
 

	
 
typedef int32  Ticks;     ///< The type to store ticks in
 
typedef int32_t  Ticks;     ///< The type to store ticks in
 

	
 

	
 
/**
 
 * 1 day is 74 ticks; TimerGameCalendar::date_fract used to be uint16 and incremented by 885. On
 
 * 1 day is 74 ticks; TimerGameCalendar::date_fract used to be uint16_t and incremented by 885. On
 
 *                    an overflow the new day begun and 65535 / 885 = 74.
 
 * 1 tick is approximately 27 ms.
 
 * 1 day is thus about 2 seconds (74 * 27 = 1998) on a machine that can run OpenTTD normally
src/debug.h
Show inline comments
 
@@ -88,9 +88,9 @@ std::string GetDebugString();
 
 *  machines. Mainly useful for local optimisations.
 
 **/
 
#define TIC() {\
 
	uint64 _xxx_ = ottd_rdtsc();\
 
	static uint64 _sum_ = 0;\
 
	static uint32 _i_ = 0;
 
	uint64_t _xxx_ = ottd_rdtsc();\
 
	static uint64_t _sum_ = 0;\
 
	static uint32_t _i_ = 0;
 

	
 
#define TOC(str, count)\
 
	_sum_ += ottd_rdtsc() - _xxx_;\
 
@@ -104,8 +104,8 @@ std::string GetDebugString();
 
/* Chrono based version. The output is in microseconds. */
 
#define TICC() {\
 
	auto _start_ = std::chrono::high_resolution_clock::now();\
 
	static uint64 _sum_ = 0;\
 
	static uint32 _i_ = 0;
 
	static uint64_t _sum_ = 0;\
 
	static uint32_t _i_ = 0;
 

	
 
#define TOCC(str, _count_)\
 
	_sum_ += (std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - _start_)).count();\
src/depot_base.h
Show inline comments
 
@@ -22,7 +22,7 @@ struct Depot : DepotPool::PoolItem<&_dep
 
	std::string name;
 

	
 
	TileIndex xy;
 
	uint16 town_cn; ///< The N-1th depot for this town (consecutive number)
 
	uint16_t town_cn; ///< The N-1th depot for this town (consecutive number)
 
	TimerGameCalendar::Date build_date; ///< Date of construction
 

	
 
	Depot(TileIndex xy = INVALID_TILE) : xy(xy) {}
src/depot_gui.cpp
Show inline comments
 
@@ -360,7 +360,7 @@ struct DepotWindow : Window {
 
			DrawSpriteIgnorePadding((v->vehstatus & VS_STOPPED) ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, PAL_NONE, flag, false, SA_CENTER);
 

	
 
			SetDParam(0, v->unitnumber);
 
			DrawString(text, STR_JUST_COMMA, (uint16)(v->max_age - DAYS_IN_LEAP_YEAR) >= v->age ? TC_BLACK : TC_RED);
 
			DrawString(text, STR_JUST_COMMA, (uint16_t)(v->max_age - DAYS_IN_LEAP_YEAR) >= v->age ? TC_BLACK : TC_RED);
 
		}
 
	}
 

	
 
@@ -399,7 +399,7 @@ struct DepotWindow : Window {
 
			}
 
		}
 

	
 
		uint16 rows_in_display = wid->current_y / wid->resize_y;
 
		uint16_t rows_in_display = wid->current_y / wid->resize_y;
 

	
 
		uint num = this->vscroll->GetPosition() * this->num_columns;
 
		uint maxval = static_cast<uint>(std::min<size_t>(this->vehicle_list.size(), num + (rows_in_display * this->num_columns)));
 
@@ -1120,7 +1120,7 @@ struct DepotWindow : Window {
 
	 * In the case of airports, this is the station ID.
 
	 * @return Depot or station ID of this window.
 
	 */
 
	inline uint16 GetDepotIndex() const
 
	inline uint16_t GetDepotIndex() const
 
	{
 
		return (this->type == VEH_AIRCRAFT) ? ::GetStationIndex(this->window_number) : ::GetDepotIndex(this->window_number);
 
	}
src/depot_type.h
Show inline comments
 
@@ -12,7 +12,7 @@
 

	
 
#include "station_type.h"
 

	
 
typedef uint16 DepotID; ///< Type for the unique identifier of depots.
 
typedef uint16_t DepotID; ///< Type for the unique identifier of depots.
 
struct Depot;
 

	
 
static const DepotID INVALID_DEPOT = (DepotID)INVALID_STATION;
src/disaster_vehicle.cpp
Show inline comments
 
@@ -54,7 +54,7 @@
 
#include "safeguards.h"
 

	
 
/** Delay counter for considering the next disaster. */
 
uint16 _disaster_delay;
 
uint16_t _disaster_delay;
 

	
 
static void DisasterClearSquare(TileIndex tile)
 
{
 
@@ -287,7 +287,7 @@ static bool DisasterTick_Zeppeliner(Disa
 
		v->image_override = SPR_BLIMP_CRASHED;
 
	} else if (v->age <= 300) {
 
		if (GB(v->tick_counter, 0, 3) == 0) {
 
			uint32 r = Random();
 
			uint32_t r = Random();
 

	
 
			CreateEffectVehicleRel(v,
 
				GB(r, 0, 4) - 7,
 
@@ -422,7 +422,7 @@ static void DestructIndustry(Industry *i
 
 * @param news_message The string that's used as news message.
 
 * @param industry_flag Only attack industries that have this flag set.
 
 */
 
static bool DisasterTick_Aircraft(DisasterVehicle *v, uint16 image_override, bool leave_at_top, StringID news_message, IndustryBehaviour industry_flag)
 
static bool DisasterTick_Aircraft(DisasterVehicle *v, uint16_t image_override, bool leave_at_top, StringID news_message, IndustryBehaviour industry_flag)
 
{
 
	v->tick_counter++;
 
	v->image_override = (v->state == 1 && HasBit(v->tick_counter, 2)) ? image_override : 0;
 
@@ -440,7 +440,7 @@ static bool DisasterTick_Aircraft(Disast
 
			Industry *i = Industry::Get(v->dest_tile); // Industry destructor calls ReleaseDisastersTargetingIndustry, so this is valid
 
			int x = TileX(i->location.tile) * TILE_SIZE;
 
			int y = TileY(i->location.tile) * TILE_SIZE;
 
			uint32 r = Random();
 
			uint32_t r = Random();
 

	
 
			CreateEffectVehicleAbove(
 
				GB(r,  0, 6) + x,
 
@@ -640,7 +640,7 @@ static bool DisasterTick_Big_Ufo_Destroy
 
		delete u;
 

	
 
		for (int i = 0; i != 80; i++) {
 
			uint32 r = Random();
 
			uint32_t r = Random();
 
			CreateEffectVehicleAbove(
 
				GB(r, 0, 6) + v->x_pos - 32,
 
				GB(r, 5, 6) + v->y_pos - 32,
 
@@ -838,7 +838,7 @@ static void Disaster_Submarine_Init(Disa
 

	
 
	int y;
 
	Direction dir;
 
	uint32 r = Random();
 
	uint32_t r = Random();
 
	int x = TileX(r) * TILE_SIZE + TILE_SIZE / 2;
 

	
 
	if (HasBit(r, 31)) {
 
@@ -961,7 +961,7 @@ void ReleaseDisastersTargetingIndustry(I
 
		/* primary disaster vehicles that have chosen target */
 
		if (v->subtype == ST_AIRPLANE || v->subtype == ST_HELICOPTER) {
 
			/* if it has chosen target, and it is this industry (yes, dest_tile is IndustryID here), set order to "leaving map peacefully" */
 
			if (v->state > 0 && v->dest_tile == (uint32)i) v->state = 3;
 
			if (v->state > 0 && v->dest_tile == (uint32_t)i) v->state = 3;
 
		}
 
	}
 
}
src/economy.cpp
Show inline comments
 
@@ -76,9 +76,9 @@ INSTANTIATE_POOL_METHODS(CargoPayment)
 
 * @param shift The amount to shift the value to right.
 
 * @return The shifted result
 
 */
 
static inline int32 BigMulS(const int32 a, const int32 b, const uint8 shift)
 
static inline int32_t BigMulS(const int32_t a, const int32_t b, const uint8_t shift)
 
{
 
	return (int32)((int64)a * (int64)b >> shift);
 
	return (int32_t)((int64_t)a * (int64_t)b >> shift);
 
}
 

	
 
typedef std::vector<Industry *> SmallIndustryList;
 
@@ -99,7 +99,7 @@ const ScoreInfo _score_info[] = {
 
	{       0,   0}  // SCORE_TOTAL
 
};
 

	
 
int64 _score_part[MAX_COMPANIES][SCORE_END];
 
int64_t _score_part[MAX_COMPANIES][SCORE_END];
 
Economy _economy;
 
Prices _price;
 
static PriceMultipliers _price_base_multiplier;
 
@@ -304,7 +304,7 @@ int UpdateCompanyRatingAndValue(Company 
 
			/* Skip the total */
 
			if (i == SCORE_TOTAL) continue;
 
			/*  Check the score */
 
			s = Clamp<int64>(_score_part[owner][i], 0, _score_info[i].needed) * _score_info[i].score / _score_info[i].needed;
 
			s = Clamp<int64_t>(_score_part[owner][i], 0, _score_info[i].needed) * _score_info[i].score / _score_info[i].needed;
 
			score += s;
 
			total_score += _score_info[i].score;
 
		}
 
@@ -671,13 +671,13 @@ static void CompaniesGenStatistics()
 
			cur_company.Change(c->index);
 

	
 
			CommandCost cost(EXPENSES_PROPERTY);
 
			uint32 rail_total = c->infrastructure.GetRailTotal();
 
			uint32_t rail_total = c->infrastructure.GetRailTotal();
 
			for (RailType rt = RAILTYPE_BEGIN; rt < RAILTYPE_END; rt++) {
 
				if (c->infrastructure.rail[rt] != 0) cost.AddCost(RailMaintenanceCost(rt, c->infrastructure.rail[rt], rail_total));
 
			}
 
			cost.AddCost(SignalMaintenanceCost(c->infrastructure.signal));
 
			uint32 road_total = c->infrastructure.GetRoadTotal();
 
			uint32 tram_total = c->infrastructure.GetTramTotal();
 
			uint32_t road_total = c->infrastructure.GetRoadTotal();
 
			uint32_t tram_total = c->infrastructure.GetTramTotal();
 
			for (RoadType rt = ROADTYPE_BEGIN; rt < ROADTYPE_END; rt++) {
 
				if (c->infrastructure.road[rt] != 0) cost.AddCost(RoadMaintenanceCost(rt, c->infrastructure.road[rt], RoadTypeIsRoad(rt) ? road_total : tram_total));
 
			}
 
@@ -759,7 +759,7 @@ bool AddInflation(bool check_year)
 
void RecomputePrices()
 
{
 
	/* Setup maximum loan as a rounded down multiple of LOAN_INTERVAL. */
 
	_economy.max_loan = ((uint64)_settings_game.difficulty.max_loan * _economy.inflation_prices >> 16) / LOAN_INTERVAL * LOAN_INTERVAL;
 
	_economy.max_loan = ((uint64_t)_settings_game.difficulty.max_loan * _economy.inflation_prices >> 16) / LOAN_INTERVAL * LOAN_INTERVAL;
 

	
 
	/* Setup price bases */
 
	for (Price i = PR_BEGIN; i < PR_END; i++) {
 
@@ -786,7 +786,7 @@ void RecomputePrices()
 
		}
 

	
 
		/* Apply inflation */
 
		price = (int64)price * _economy.inflation_prices;
 
		price = (int64_t)price * _economy.inflation_prices;
 

	
 
		/* Apply newgrf modifiers, remove fractional part of inflation, and normalise on medium difficulty. */
 
		int shift = _price_base_multiplier[i] - 16 - 3;
 
@@ -812,7 +812,7 @@ void RecomputePrices()
 

	
 
	/* Setup cargo payment */
 
	for (CargoSpec *cs : CargoSpec::Iterate()) {
 
		cs->current_payment = (cs->initial_payment * (int64)_economy.inflation_payment) >> 16;
 
		cs->current_payment = (cs->initial_payment * (int64_t)_economy.inflation_payment) >> 16;
 
	}
 

	
 
	SetWindowClassesDirty(WC_BUILD_VEHICLE);
 
@@ -975,7 +975,7 @@ Money GetPrice(Price index, uint cost_fa
 
	return cost;
 
}
 

	
 
Money GetTransportedGoodsIncome(uint num_pieces, uint dist, uint16 transit_periods, CargoID cargo_type)
 
Money GetTransportedGoodsIncome(uint num_pieces, uint dist, uint16_t transit_periods, CargoID cargo_type)
 
{
 
	const CargoSpec *cs = CargoSpec::Get(cargo_type);
 
	if (!cs->IsValid()) {
 
@@ -985,8 +985,8 @@ Money GetTransportedGoodsIncome(uint num
 

	
 
	/* Use callback to calculate cargo profit, if available */
 
	if (HasBit(cs->callback_mask, CBM_CARGO_PROFIT_CALC)) {
 
		uint32 var18 = ClampTo<uint16_t>(dist) | (ClampTo<uint8_t>(num_pieces) << 16) | (ClampTo<uint8_t>(transit_periods) << 24);
 
		uint16 callback = GetCargoCallback(CBID_CARGO_PROFIT_CALC, 0, var18, cs);
 
		uint32_t var18 = ClampTo<uint16_t>(dist) | (ClampTo<uint8_t>(num_pieces) << 16) | (ClampTo<uint8_t>(transit_periods) << 24);
 
		uint16_t callback = GetCargoCallback(CBID_CARGO_PROFIT_CALC, 0, var18, cs);
 
		if (callback != CALLBACK_FAILED) {
 
			int result = GB(callback, 0, 14);
 

	
 
@@ -1104,7 +1104,7 @@ static uint DeliverGoodsToIndustry(const
 
 * @return Revenue for delivering cargo
 
 * @note The cargo is just added to the stockpile of the industry. It is due to the caller to trigger the industry's production machinery
 
 */
 
static Money DeliverGoods(int num_pieces, CargoID cargo_type, StationID dest, TileIndex source_tile, uint16 periods_in_transit, Company *company, SourceType src_type, SourceID src)
 
static Money DeliverGoods(int num_pieces, CargoID cargo_type, StationID dest, TileIndex source_tile, uint16_t periods_in_transit, Company *company, SourceType src_type, SourceID src)
 
{
 
	assert(num_pieces > 0);
 

	
 
@@ -1157,7 +1157,7 @@ static Money DeliverGoods(int num_pieces
 
static void TriggerIndustryProduction(Industry *i)
 
{
 
	const IndustrySpec *indspec = GetIndustrySpec(i->type);
 
	uint16 callback = indspec->callback_mask;
 
	uint16_t callback = indspec->callback_mask;
 

	
 
	i->was_cargo_delivered = true;
 

	
 
@@ -1317,7 +1317,7 @@ static uint GetLoadAmount(Vehicle *v)
 
	if (air_mail) load_amount = CeilDiv(load_amount, 4);
 

	
 
	if (_settings_game.order.gradual_loading) {
 
		uint16 cb_load_amount = CALLBACK_FAILED;
 
		uint16_t cb_load_amount = CALLBACK_FAILED;
 
		if (e->GetGRF() != nullptr && e->GetGRF()->grf_version >= 8) {
 
			/* Use callback 36 */
 
			cb_load_amount = GetVehicleProperty(v, PROP_VEHICLE_LOAD_AMOUNT, CALLBACK_FAILED);
src/economy_func.h
Show inline comments
 
@@ -20,7 +20,7 @@ void ResetPriceBaseMultipliers();
 
void SetPriceBaseMultiplier(Price price, int factor);
 

	
 
extern const ScoreInfo _score_info[];
 
extern int64 _score_part[MAX_COMPANIES][SCORE_END];
 
extern int64_t _score_part[MAX_COMPANIES][SCORE_END];
 
extern Economy _economy;
 
/* Prices and also the fractional part. */
 
extern Prices _price;
 
@@ -28,7 +28,7 @@ extern Prices _price;
 
int UpdateCompanyRatingAndValue(Company *c, bool update);
 
void StartupIndustryDailyChanges(bool init_counter);
 

	
 
Money GetTransportedGoodsIncome(uint num_pieces, uint dist, uint16 transit_periods, CargoID cargo_type);
 
Money GetTransportedGoodsIncome(uint num_pieces, uint dist, uint16_t transit_periods, CargoID cargo_type);
 
uint MoveGoodsToStation(CargoID type, uint amount, SourceType source_type, SourceID source_id, const StationList *all_stations, Owner exclusivity = INVALID_OWNER);
 

	
 
void PrepareUnload(Vehicle *front_v);
src/economy_type.h
Show inline comments
 
@@ -16,7 +16,7 @@
 
typedef OverflowSafeInt64 Money;
 

	
 
/** Type of the game economy. */
 
enum EconomyType : uint8 {
 
enum EconomyType : uint8_t {
 
	ET_BEGIN = 0,
 
	ET_ORIGINAL = 0,
 
	ET_SMOOTH = 1,
 
@@ -27,18 +27,18 @@ enum EconomyType : uint8 {
 
/** Data of the economy. */
 
struct Economy {
 
	Money max_loan;                       ///< NOSAVE: Maximum possible loan
 
	int16 fluct;                          ///< Economy fluctuation status
 
	int16_t fluct;                          ///< Economy fluctuation status
 
	byte interest_rate;                   ///< Interest
 
	byte infl_amount;                     ///< inflation amount
 
	byte infl_amount_pr;                  ///< inflation rate for payment rates
 
	uint32 industry_daily_change_counter; ///< Bits 31-16 are number of industry to be performed, 15-0 are fractional collected daily
 
	uint32 industry_daily_increment;      ///< The value which will increment industry_daily_change_counter. Computed value. NOSAVE
 
	uint64 inflation_prices;              ///< Cumulated inflation of prices since game start; 16 bit fractional part
 
	uint64 inflation_payment;             ///< Cumulated inflation of cargo payment since game start; 16 bit fractional part
 
	uint32_t industry_daily_change_counter; ///< Bits 31-16 are number of industry to be performed, 15-0 are fractional collected daily
 
	uint32_t industry_daily_increment;      ///< The value which will increment industry_daily_change_counter. Computed value. NOSAVE
 
	uint64_t inflation_prices;              ///< Cumulated inflation of prices since game start; 16 bit fractional part
 
	uint64_t inflation_payment;             ///< Cumulated inflation of cargo payment since game start; 16 bit fractional part
 

	
 
	/* Old stuff for savegame conversion only */
 
	Money old_max_loan_unround;           ///< Old: Unrounded max loan
 
	uint16 old_max_loan_unround_fract;    ///< Old: Fraction of the unrounded max loan
 
	uint16_t old_max_loan_unround_fract;    ///< Old: Fraction of the unrounded max loan
 
};
 

	
 
/** Score categories in the detailed performance rating. */
 
@@ -151,7 +151,7 @@ enum Price {
 
DECLARE_POSTFIX_INCREMENT(Price)
 

	
 
typedef Money Prices[PR_END]; ///< Prices of everything. @see Price
 
typedef int8 PriceMultipliers[PR_END];
 
typedef int8_t PriceMultipliers[PR_END];
 

	
 
/** Types of expenses. */
 
enum ExpensesType : byte {
 
@@ -194,17 +194,17 @@ struct PriceBaseSpec {
 
/** The "steps" in loan size, in British Pounds! */
 
static const int LOAN_INTERVAL = 10000;
 
/** The size of loan for a new company, in British Pounds! */
 
static const int64 INITIAL_LOAN = 100000;
 
static const int64_t INITIAL_LOAN = 100000;
 

	
 
/**
 
 * Maximum inflation (including fractional part) without causing overflows in int64 price computations.
 
 * Maximum inflation (including fractional part) without causing overflows in int64_t price computations.
 
 * This allows for 32 bit base prices (21 are currently needed).
 
 * Considering the sign bit and 16 fractional bits, there are 15 bits left.
 
 * 170 years of 4% inflation result in a inflation of about 822, so 10 bits are actually enough.
 
 * Note that NewGRF multipliers share the 16 fractional bits.
 
 * @see MAX_PRICE_MODIFIER
 
 */
 
static const uint64 MAX_INFLATION = (1ull << (63 - 32)) - 1;
 
static const uint64_t MAX_INFLATION = (1ull << (63 - 32)) - 1;
 

	
 
/**
 
 * Maximum NewGRF price modifiers.
 
@@ -227,6 +227,6 @@ static const uint ROAD_STOP_TRACKBIT_FAC
 
static const uint LOCK_DEPOT_TILE_FACTOR = 2;
 

	
 
struct CargoPayment;
 
typedef uint32 CargoPaymentID;
 
typedef uint32_t CargoPaymentID;
 

	
 
#endif /* ECONOMY_TYPE_H */
src/effectvehicle.cpp
Show inline comments
 
@@ -38,7 +38,7 @@ static bool IncrementSprite(EffectVehicl
 

	
 
static void ChimneySmokeInit(EffectVehicle *v)
 
{
 
	uint32 r = Random();
 
	uint32_t r = Random();
 
	v->sprite_cache.sprite_seq.Set(SPR_CHIMNEY_SMOKE_0 + GB(r, 0, 3));
 
	v->progress = GB(r, 16, 3);
 
}
 
@@ -274,8 +274,8 @@ static const BulldozerMovement _bulldoze
 
};
 

	
 
static const struct {
 
	int8 x;
 
	int8 y;
 
	int8_t x;
 
	int8_t y;
 
} _inc_by_dir[] = {
 
	{ -1,  0 },
 
	{  0,  1 },
 
@@ -317,9 +317,9 @@ static void BubbleInit(EffectVehicle *v)
 
}
 

	
 
struct BubbleMovement {
 
	int8 x:4;
 
	int8 y:4;
 
	int8 z:4;
 
	int8_t x:4;
 
	int8_t y:4;
 
	int8_t z:4;
 
	byte image:4;
 
};
 

	
src/effectvehicle_base.h
Show inline comments
 
@@ -22,7 +22,7 @@
 
 *  - bubbles (industry)
 
 */
 
struct EffectVehicle FINAL : public SpecializedVehicle<EffectVehicle, VEH_EFFECT> {
 
	uint16 animation_state;  ///< State primarily used to change the graphics/behaviour.
 
	uint16_t animation_state;  ///< State primarily used to change the graphics/behaviour.
 
	byte animation_substate; ///< Sub state to time the change of the graphics/behaviour.
 

	
 
	/** We don't want GCC to zero our struct! It already is zeroed and has an index! */
src/elrail.cpp
Show inline comments
 
@@ -232,8 +232,8 @@ static int GetPCPElevation(TileIndex til
 
	 * Also note that the result of GetSlopePixelZ() is very special on bridge-ramps.
 
	 */
 

	
 
	int z = GetSlopePixelZ(TileX(tile) * TILE_SIZE + std::min<int8>(x_pcp_offsets[PCPpos], TILE_SIZE - 1),
 
	                       TileY(tile) * TILE_SIZE + std::min<int8>(y_pcp_offsets[PCPpos], TILE_SIZE - 1), true);
 
	int z = GetSlopePixelZ(TileX(tile) * TILE_SIZE + std::min<int8_t>(x_pcp_offsets[PCPpos], TILE_SIZE - 1),
 
	                       TileY(tile) * TILE_SIZE + std::min<int8_t>(y_pcp_offsets[PCPpos], TILE_SIZE - 1), true);
 
	/* Round the Z to the nearest half tile height. */
 
	static const uint HALF_TILE_HEIGHT = TILE_HEIGHT / 2;
 
	return (z + HALF_TILE_HEIGHT / 2) / HALF_TILE_HEIGHT * HALF_TILE_HEIGHT;
 
@@ -595,7 +595,7 @@ void DrawRailCatenary(const TileInfo *ti
 
	DrawRailCatenaryRailway(ti);
 
}
 

	
 
void SettingsDisableElrail(int32 new_value)
 
void SettingsDisableElrail(int32_t new_value)
 
{
 
	bool disable = (new_value != 0);
 

	
src/elrail_func.h
Show inline comments
 
@@ -36,6 +36,6 @@ void DrawRailCatenary(const TileInfo *ti
 
void DrawRailCatenaryOnTunnel(const TileInfo *ti);
 
void DrawRailCatenaryOnBridge(const TileInfo *ti);
 

	
 
void SettingsDisableElrail(int32 new_value); ///< _settings_game.disable_elrail callback
 
void SettingsDisableElrail(int32_t new_value); ///< _settings_game.disable_elrail callback
 

	
 
#endif /* ELRAIL_FUNC_H */
src/engine.cpp
Show inline comments
 
@@ -49,7 +49,7 @@ EngineOverrideManager _engine_mngr;
 
static TimerGameCalendar::Year _year_engine_aging_stops;
 

	
 
/** Number of engines of each vehicle type in original engine data */
 
const uint8 _engine_counts[4] = {
 
const uint8_t _engine_counts[4] = {
 
	lengthof(_orig_rail_vehicle_info),
 
	lengthof(_orig_road_vehicle_info),
 
	lengthof(_orig_ship_vehicle_info),
 
@@ -57,7 +57,7 @@ const uint8 _engine_counts[4] = {
 
};
 

	
 
/** Offset of the first engine of each vehicle type in original engine data */
 
const uint8 _engine_offsets[4] = {
 
const uint8_t _engine_offsets[4] = {
 
	0,
 
	lengthof(_orig_rail_vehicle_info),
 
	lengthof(_orig_rail_vehicle_info) + lengthof(_orig_road_vehicle_info),
 
@@ -151,7 +151,7 @@ bool Engine::IsEnabled() const
 
 * This is the GRF providing the Action 3.
 
 * @return GRF ID of the associated NewGRF.
 
 */
 
uint32 Engine::GetGRFID() const
 
uint32_t Engine::GetGRFID() const
 
{
 
	const GRFFile *file = this->GetGRF();
 
	return file == nullptr ? 0 : file->grfid;
 
@@ -195,7 +195,7 @@ bool Engine::CanCarryCargo() const
 
 * @param mail_capacity returns secondary cargo (mail) capacity of aircraft
 
 * @return Capacity
 
 */
 
uint Engine::DetermineCapacity(const Vehicle *v, uint16 *mail_capacity) const
 
uint Engine::DetermineCapacity(const Vehicle *v, uint16_t *mail_capacity) const
 
{
 
	assert(v == nullptr || this->index == v->engine_type);
 
	if (mail_capacity != nullptr) *mail_capacity = 0;
 
@@ -213,7 +213,7 @@ uint Engine::DetermineCapacity(const Veh
 
	/* Check the refit capacity callback if we are not in the default configuration, or if we are using the new multiplier algorithm. */
 
	if (HasBit(this->info.callback_mask, CBM_VEHICLE_REFIT_CAPACITY) &&
 
			(new_multipliers || default_cargo != cargo_type || (v != nullptr && v->cargo_subtype != 0))) {
 
		uint16 callback = GetVehicleCallback(CBID_VEHICLE_REFIT_CAPACITY, 0, 0, this->index, v);
 
		uint16_t callback = GetVehicleCallback(CBID_VEHICLE_REFIT_CAPACITY, 0, 0, this->index, v);
 
		if (callback != CALLBACK_FAILED) return callback;
 
	}
 

	
 
@@ -256,8 +256,8 @@ uint Engine::DetermineCapacity(const Veh
 

	
 
	/* Apply multipliers depending on cargo- and vehicletype. */
 
	if (new_multipliers || (this->type != VEH_SHIP && default_cargo != cargo_type)) {
 
		uint16 default_multiplier = new_multipliers ? 0x100 : CargoSpec::Get(default_cargo)->multiplier;
 
		uint16 cargo_multiplier = CargoSpec::Get(cargo_type)->multiplier;
 
		uint16_t default_multiplier = new_multipliers ? 0x100 : CargoSpec::Get(default_cargo)->multiplier;
 
		uint16_t cargo_multiplier = CargoSpec::Get(cargo_type)->multiplier;
 
		capacity *= cargo_multiplier;
 
		if (extra_mail_cap > 0) {
 
			uint mail_multiplier = CargoSpec::Get(CT_MAIL)->multiplier;
 
@@ -445,7 +445,7 @@ TimerGameCalendar::Date Engine::GetLifeL
 
 * Get the range of an aircraft type.
 
 * @return Range of the aircraft type in tiles or 0 if unlimited range.
 
 */
 
uint16 Engine::GetRange() const
 
uint16_t Engine::GetRange() const
 
{
 
	switch (this->type) {
 
		case VEH_AIRCRAFT:
 
@@ -524,7 +524,7 @@ void EngineOverrideManager::ResetToDefau
 
 *              If dynnamic_engines is disabled, all newgrf share the same ID scope identified by INVALID_GRFID.
 
 * @return The engine ID if present, or INVALID_ENGINE if not.
 
 */
 
EngineID EngineOverrideManager::GetID(VehicleType type, uint16 grf_local_id, uint32 grfid)
 
EngineID EngineOverrideManager::GetID(VehicleType type, uint16_t grf_local_id, uint32_t grfid)
 
{
 
	EngineID index = 0;
 
	for (const EngineIDMapping &eid : *this) {
 
@@ -611,7 +611,7 @@ void CalcEngineReliability(Engine *e, bo
 
		re = Engine::Get(re->info.variant_id);
 
	}
 

	
 
	uint32 age = re->age;
 
	uint32_t age = re->age;
 
	if (new_month && re->index > e->index && age != INT32_MAX) age++; /* parent variant's age has not yet updated. */
 

	
 
	/* Check for early retirement */
 
@@ -675,7 +675,7 @@ void SetYearEngineAgingStops()
 
 * @param aging_date The date used for age calculations.
 
 * @param seed Random seed.
 
 */
 
void StartupOneEngine(Engine *e, TimerGameCalendar::Date aging_date, uint32 seed)
 
void StartupOneEngine(Engine *e, TimerGameCalendar::Date aging_date, uint32_t seed)
 
{
 
	const EngineInfo *ei = &e->info;
 

	
 
@@ -692,7 +692,7 @@ void StartupOneEngine(Engine *e, TimerGa
 
	              ei->base_intro ^
 
	              e->type ^
 
	              e->GetGRFID());
 
	uint32 r = Random();
 
	uint32_t r = Random();
 

	
 
	/* Don't randomise the start-date in the first two years after gamestart to ensure availability
 
	 * of engines in early starting games.
 
@@ -745,7 +745,7 @@ void StartupEngines()
 
{
 
	/* Aging of vehicles stops, so account for that when starting late */
 
	const TimerGameCalendar::Date aging_date = std::min(TimerGameCalendar::date, TimerGameCalendar::ConvertYMDToDate(_year_engine_aging_stops, 0, 1));
 
	uint32 seed = Random();
 
	uint32_t seed = Random();
 

	
 
	for (Engine *e : Engine::Iterate()) {
 
		StartupOneEngine(e, aging_date, seed);
 
@@ -863,7 +863,7 @@ static CompanyID GetPreviewCompany(Engin
 
	/* For trains the cargomask has no useful meaning, since you can attach other wagons */
 
	CargoTypes cargomask = e->type != VEH_TRAIN ? GetUnionOfArticulatedRefitMasks(e->index, true) : ALL_CARGOTYPES;
 

	
 
	int32 best_hist = -1;
 
	int32_t best_hist = -1;
 
	for (const Company *c : Company::Iterate()) {
 
		if (c->block_preview == 0 && !HasBit(e->preview_asked, c->index) &&
 
				c->old_economy[0].performance_history > best_hist) {
src/engine_base.h
Show inline comments
 
@@ -37,22 +37,22 @@ extern EnginePool _engine_pool;
 
struct Engine : EnginePool::PoolItem<&_engine_pool> {
 
	std::string name;           ///< Custom name of engine.
 
	TimerGameCalendar::Date intro_date; ///< Date of introduction of the engine.
 
	int32 age;                  ///< Age of the engine in months.
 
	uint16 reliability;         ///< Current reliability of the engine.
 
	uint16 reliability_spd_dec; ///< Speed of reliability decay between services (per day).
 
	uint16 reliability_start;   ///< Initial reliability of the engine.
 
	uint16 reliability_max;     ///< Maximal reliability of the engine.
 
	uint16 reliability_final;   ///< Final reliability of the engine.
 
	uint16 duration_phase_1;    ///< First reliability phase in months, increasing reliability from #reliability_start to #reliability_max.
 
	uint16 duration_phase_2;    ///< Second reliability phase in months, keeping #reliability_max.
 
	uint16 duration_phase_3;    ///< Third reliability phase in months, decaying to #reliability_final.
 
	int32_t age;                  ///< Age of the engine in months.
 
	uint16_t reliability;         ///< Current reliability of the engine.
 
	uint16_t reliability_spd_dec; ///< Speed of reliability decay between services (per day).
 
	uint16_t reliability_start;   ///< Initial reliability of the engine.
 
	uint16_t reliability_max;     ///< Maximal reliability of the engine.
 
	uint16_t reliability_final;   ///< Final reliability of the engine.
 
	uint16_t duration_phase_1;    ///< First reliability phase in months, increasing reliability from #reliability_start to #reliability_max.
 
	uint16_t duration_phase_2;    ///< Second reliability phase in months, keeping #reliability_max.
 
	uint16_t duration_phase_3;    ///< Third reliability phase in months, decaying to #reliability_final.
 
	byte flags;                 ///< Flags of the engine. @see EngineFlags
 
	CompanyMask preview_asked;  ///< Bit for each company which has already been offered a preview.
 
	CompanyID preview_company;  ///< Company which is currently being offered a preview \c INVALID_COMPANY means no company.
 
	byte preview_wait;          ///< Daily countdown timer for timeout of offering the engine to the #preview_company company.
 
	CompanyMask company_avail;  ///< Bit for each company whether the engine is available for that company.
 
	CompanyMask company_hidden; ///< Bit for each company whether the engine is normally hidden in the build gui for that company.
 
	uint8 original_image_index; ///< Original vehicle image index, thus the image index of the overridden vehicle
 
	uint8_t original_image_index; ///< Original vehicle image index, thus the image index of the overridden vehicle
 
	VehicleType type;           ///< %Vehicle type, ie #VEH_ROAD, #VEH_TRAIN, etc.
 

	
 
	EngineDisplayFlags display_flags; ///< NOSAVE client-side-only display flags for build engine list.
 
@@ -76,7 +76,7 @@ struct Engine : EnginePool::PoolItem<&_e
 
	 */
 
	GRFFilePropsBase<NUM_CARGO + 2> grf_prop;
 
	std::vector<WagonOverride> overrides;
 
	uint16 list_position;
 
	uint16_t list_position;
 

	
 
	Engine() {}
 
	Engine(VehicleType type, EngineID base);
 
@@ -98,7 +98,7 @@ struct Engine : EnginePool::PoolItem<&_e
 
		return this->info.cargo_type;
 
	}
 

	
 
	uint DetermineCapacity(const Vehicle *v, uint16 *mail_capacity = nullptr) const;
 
	uint DetermineCapacity(const Vehicle *v, uint16_t *mail_capacity = nullptr) const;
 

	
 
	bool CanCarryCargo() const;
 

	
 
@@ -113,7 +113,7 @@ struct Engine : EnginePool::PoolItem<&_e
 
	 * @return The default capacity
 
	 * @see GetDefaultCargoType
 
	 */
 
	uint GetDisplayDefaultCapacity(uint16 *mail_capacity = nullptr) const
 
	uint GetDisplayDefaultCapacity(uint16_t *mail_capacity = nullptr) const
 
	{
 
		return this->DetermineCapacity(nullptr, mail_capacity);
 
	}
 
@@ -125,7 +125,7 @@ struct Engine : EnginePool::PoolItem<&_e
 
	uint GetDisplayWeight() const;
 
	uint GetDisplayMaxTractiveEffort() const;
 
	TimerGameCalendar::Date GetLifeLengthInDays() const;
 
	uint16 GetRange() const;
 
	uint16_t GetRange() const;
 
	StringID GetAircraftTypeText() const;
 

	
 
	/**
 
@@ -169,7 +169,7 @@ struct Engine : EnginePool::PoolItem<&_e
 
		return this->grf_prop.grffile;
 
	}
 

	
 
	uint32 GetGRFID() const;
 
	uint32_t GetGRFID() const;
 

	
 
	struct EngineTypeFilter {
 
		VehicleType vt;
 
@@ -190,10 +190,10 @@ struct Engine : EnginePool::PoolItem<&_e
 
};
 

	
 
struct EngineIDMapping {
 
	uint32 grfid;          ///< The GRF ID of the file the entity belongs to
 
	uint16 internal_id;    ///< The internal ID within the GRF file
 
	uint32_t grfid;          ///< The GRF ID of the file the entity belongs to
 
	uint16_t internal_id;    ///< The internal ID within the GRF file
 
	VehicleType type;      ///< The engine type
 
	uint8  substitute_id;  ///< The (original) entity ID to use if this GRF is not available (currently not used)
 
	uint8_t  substitute_id;  ///< The (original) entity ID to use if this GRF is not available (currently not used)
 
};
 

	
 
/**
 
@@ -204,7 +204,7 @@ struct EngineOverrideManager : std::vect
 
	static const uint NUM_DEFAULT_ENGINES; ///< Number of default entries
 

	
 
	void ResetToDefaultMapping();
 
	EngineID GetID(VehicleType type, uint16 grf_local_id, uint32 grfid);
 
	EngineID GetID(VehicleType type, uint16_t grf_local_id, uint32_t grfid);
 

	
 
	static bool ResetToCurrentNewGRFConfig();
 
};
src/engine_func.h
Show inline comments
 
@@ -20,14 +20,14 @@ void StartupEngines();
 
void CheckEngines();
 

	
 
/* Original engine data counts and offsets */
 
extern const uint8 _engine_counts[4];
 
extern const uint8 _engine_offsets[4];
 
extern const uint8_t _engine_counts[4];
 
extern const uint8_t _engine_offsets[4];
 

	
 
bool IsEngineBuildable(EngineID engine, VehicleType type, CompanyID company);
 
bool IsEngineRefittable(EngineID engine);
 
void SetYearEngineAgingStops();
 
void CalcEngineReliability(Engine *e, bool new_month);
 
void StartupOneEngine(Engine *e, TimerGameCalendar::Date aging_date, uint32 seed);
 
void StartupOneEngine(Engine *e, TimerGameCalendar::Date aging_date, uint32_t seed);
 

	
 
uint GetTotalCapacityOfArticulatedParts(EngineID engine);
 

	
src/engine_gui.cpp
Show inline comments
 
@@ -190,9 +190,9 @@ static StringID GetTrainEngineInfoString
 
static StringID GetAircraftEngineInfoString(const Engine *e)
 
{
 
	CargoID cargo = e->GetDefaultCargoType();
 
	uint16 mail_capacity;
 
	uint16_t mail_capacity;
 
	uint capacity = e->GetDisplayDefaultCapacity(&mail_capacity);
 
	uint16 range = e->GetRange();
 
	uint16_t range = e->GetRange();
 

	
 
	uint i = 0;
 
	SetDParam(i++, e->GetCost());
src/engine_gui.h
Show inline comments
 
@@ -20,7 +20,7 @@ struct GUIEngineListItem {
 
	EngineID engine_id;       ///< Engine to display in build purchase list
 
	EngineID variant_id;      ///< Variant group of the engine.
 
	EngineDisplayFlags flags; ///< Flags for toggling/drawing (un)folded status and controlling indentation.
 
	int8 indent;              ///< Display indentation level.
 
	int8_t indent;              ///< Display indentation level.
 

	
 
	GUIEngineListItem(EngineID engine_id, EngineID variant_id, EngineDisplayFlags flags, int indent) : engine_id(engine_id), variant_id(variant_id), flags(flags), indent(indent) {}
 

	
src/engine_type.h
Show inline comments
 
@@ -18,7 +18,7 @@
 
#include "sound_type.h"
 
#include "strings_type.h"
 

	
 
typedef uint16 EngineID; ///< Unique identification number of an engine.
 
typedef uint16_t EngineID; ///< Unique identification number of an engine.
 

	
 
struct Engine;
 

	
 
@@ -45,30 +45,30 @@ struct RailVehicleInfo {
 
	byte cost_factor;               ///< Purchase cost factor;      For multiheaded engines the sum of both engine prices.
 
	RailType railtype;              ///< Railtype, mangled if elrail is disabled.
 
	RailType intended_railtype;     ///< Intended railtype, regardless of elrail being enabled or disabled.
 
	uint16 max_speed;               ///< Maximum speed (1 unit = 1/1.6 mph = 1 km-ish/h)
 
	uint16 power;                   ///< Power of engine (hp);      For multiheaded engines the sum of both engine powers.
 
	uint16 weight;                  ///< Weight of vehicle (tons);  For multiheaded engines the weight of each single engine.
 
	uint16_t max_speed;               ///< Maximum speed (1 unit = 1/1.6 mph = 1 km-ish/h)
 
	uint16_t power;                   ///< Power of engine (hp);      For multiheaded engines the sum of both engine powers.
 
	uint16_t weight;                  ///< Weight of vehicle (tons);  For multiheaded engines the weight of each single engine.
 
	byte running_cost;              ///< Running cost of engine;    For multiheaded engines the sum of both running costs.
 
	Price running_cost_class;
 
	EngineClass engclass;           ///< Class of engine for this vehicle
 
	byte capacity;                  ///< Cargo capacity of vehicle; For multiheaded engines the capacity of each single engine.
 
	byte ai_passenger_only;         ///< Bit value to tell AI that this engine is for passenger use only
 
	uint16 pow_wag_power;           ///< Extra power applied to consist if wagon should be powered
 
	uint16_t pow_wag_power;           ///< Extra power applied to consist if wagon should be powered
 
	byte pow_wag_weight;            ///< Extra weight applied to consist if wagon should be powered
 
	byte visual_effect;             ///< Bitstuffed NewGRF visual effect data
 
	byte shorten_factor;            ///< length on main map for this type is 8 - shorten_factor
 
	byte tractive_effort;           ///< Tractive effort coefficient
 
	byte air_drag;                  ///< Coefficient of air drag
 
	byte user_def_data;             ///< Property 0x25: "User-defined bit mask" Used only for (very few) NewGRF vehicles
 
	int16 curve_speed_mod;          ///< Modifier to maximum speed in curves (fixed-point binary with 8 fractional bits)
 
	int16_t curve_speed_mod;          ///< Modifier to maximum speed in curves (fixed-point binary with 8 fractional bits)
 
};
 

	
 
/** Information about a ship vehicle. */
 
struct ShipVehicleInfo {
 
	byte image_index;
 
	byte cost_factor;
 
	uint16 max_speed;      ///< Maximum speed (1 unit = 1/3.2 mph = 0.5 km-ish/h)
 
	uint16 capacity;
 
	uint16_t max_speed;      ///< Maximum speed (1 unit = 1/3.2 mph = 0.5 km-ish/h)
 
	uint16_t capacity;
 
	byte running_cost;
 
	SoundID sfx;
 
	bool old_refittable;   ///< Is ship refittable; only used during initialisation. Later use EngineInfo::refit_mask.
 
@@ -103,10 +103,10 @@ struct AircraftVehicleInfo {
 
	byte subtype;               ///< Type of aircraft. @see AircraftSubTypeBits
 
	SoundID sfx;
 
	byte acceleration;
 
	uint16 max_speed;           ///< Maximum speed (1 unit = 8 mph = 12.8 km-ish/h)
 
	uint16_t max_speed;           ///< Maximum speed (1 unit = 8 mph = 12.8 km-ish/h)
 
	byte mail_capacity;         ///< Mail capacity (bags).
 
	uint16 passenger_capacity;  ///< Passenger capacity (persons).
 
	uint16 max_range;           ///< Maximum range of this aircraft.
 
	uint16_t passenger_capacity;  ///< Passenger capacity (persons).
 
	uint16_t max_range;           ///< Maximum range of this aircraft.
 
};
 

	
 
/** Information about a road vehicle. */
 
@@ -116,18 +116,18 @@ struct RoadVehicleInfo {
 
	byte running_cost;
 
	Price running_cost_class;
 
	SoundID sfx;
 
	uint16 max_speed;        ///< Maximum speed (1 unit = 1/3.2 mph = 0.5 km-ish/h)
 
	uint16_t max_speed;        ///< Maximum speed (1 unit = 1/3.2 mph = 0.5 km-ish/h)
 
	byte capacity;
 
	uint8 weight;            ///< Weight in 1/4t units
 
	uint8 power;             ///< Power in 10hp units
 
	uint8 tractive_effort;   ///< Coefficient of tractive effort
 
	uint8 air_drag;          ///< Coefficient of air drag
 
	uint8_t weight;            ///< Weight in 1/4t units
 
	uint8_t power;             ///< Power in 10hp units
 
	uint8_t tractive_effort;   ///< Coefficient of tractive effort
 
	uint8_t air_drag;          ///< Coefficient of air drag
 
	byte visual_effect;      ///< Bitstuffed NewGRF visual effect data
 
	byte shorten_factor;     ///< length on main map for this type is 8 - shorten_factor
 
	RoadType roadtype;       ///< Road type
 
};
 

	
 
enum class ExtraEngineFlags : uint32 {
 
enum class ExtraEngineFlags : uint32_t {
 
	None = 0,
 
	NoNews          = (1U << 0), ///< No 'new vehicle' news will be generated.
 
	NoPreview       = (1U << 1), ///< No exclusive preview will be offered.
 
@@ -151,10 +151,10 @@ struct EngineInfo {
 
	CargoTypes refit_mask;
 
	byte refit_cost;
 
	byte misc_flags;         ///< Miscellaneous flags. @see EngineMiscFlags
 
	uint16 callback_mask;    ///< Bitmask of vehicle callbacks that have to be called
 
	int8 retire_early;       ///< Number of years early to retire vehicle
 
	uint16_t callback_mask;    ///< Bitmask of vehicle callbacks that have to be called
 
	int8_t retire_early;       ///< Number of years early to retire vehicle
 
	StringID string_id;      ///< Default name of engine
 
	uint16 cargo_age_period; ///< Number of ticks before carried cargo is aged.
 
	uint16_t cargo_age_period; ///< Number of ticks before carried cargo is aged.
 
	EngineID variant_id;     ///< Engine variant ID. If set, will be treated specially in purchase lists.
 
	ExtraEngineFlags extra_flags;
 
};
 
@@ -185,7 +185,7 @@ enum EngineFlags {
 
/**
 
 * Contexts an engine name can be shown in.
 
 */
 
enum EngineNameContext : uint8 {
 
enum EngineNameContext : uint8_t {
 
	Generic                 = 0x00, ///< No specific context available.
 
	VehicleDetails          = 0x11, ///< Name is shown in the vehicle details GUI.
 
	PurchaseList            = 0x20, ///< Name is shown in the purchase list (including autoreplace window 'Available vehicles' panel).
 
@@ -194,9 +194,9 @@ enum EngineNameContext : uint8 {
 
};
 

	
 
/** Combine an engine ID and a name context to an engine name dparam. */
 
inline uint64 PackEngineNameDParam(EngineID engine_id, EngineNameContext context, uint32 extra_data = 0)
 
inline uint64_t PackEngineNameDParam(EngineID engine_id, EngineNameContext context, uint32_t extra_data = 0)
 
{
 
	return engine_id | (static_cast<uint64>(context) << 32) | (static_cast<uint64>(extra_data) << 40);
 
	return engine_id | (static_cast<uint64_t>(context) << 32) | (static_cast<uint64_t>(extra_data) << 40);
 
}
 

	
 
static const uint MAX_LENGTH_ENGINE_NAME_CHARS = 32; ///< The maximum length of an engine name in characters including '\0'
src/error.h
Show inline comments
 
@@ -33,8 +33,8 @@ protected:
 
	bool is_critical;               ///< Whether the error message is critical.
 
	std::vector<StringParameterBackup> params; ///< Backup of parameters of the message strings.
 
	const GRFFile *textref_stack_grffile; ///< NewGRF that filled the #TextRefStack for the error message.
 
	uint textref_stack_size;        ///< Number of uint32 values to put on the #TextRefStack for the error message.
 
	uint32 textref_stack[16];       ///< Values to put on the #TextRefStack for the error message.
 
	uint textref_stack_size;        ///< Number of uint32_t values to put on the #TextRefStack for the error message.
 
	uint32_t textref_stack[16];       ///< Values to put on the #TextRefStack for the error message.
 
	StringID summary_msg;           ///< General error message showed in first line. Must be valid.
 
	StringID detailed_msg;          ///< Detailed error message showed in second line. Can be #INVALID_STRING_ID.
 
	StringID extra_msg;             ///< Extra error message shown in third line. Can be #INVALID_STRING_ID.
 
@@ -43,7 +43,7 @@ protected:
 

	
 
public:
 
	ErrorMessageData(const ErrorMessageData &data);
 
	ErrorMessageData(StringID summary_msg, StringID detailed_msg, bool is_critical = false, int x = 0, int y = 0, const GRFFile *textref_stack_grffile = nullptr, uint textref_stack_size = 0, const uint32 *textref_stack = nullptr, StringID extra_msg = INVALID_STRING_ID);
 
	ErrorMessageData(StringID summary_msg, StringID detailed_msg, bool is_critical = false, int x = 0, int y = 0, const GRFFile *textref_stack_grffile = nullptr, uint textref_stack_size = 0, const uint32_t *textref_stack = nullptr, StringID extra_msg = INVALID_STRING_ID);
 

	
 
	/* Remove the copy assignment, as the default implementation will not do the right thing. */
 
	ErrorMessageData &operator=(ErrorMessageData &rhs) = delete;
 
@@ -51,7 +51,7 @@ public:
 
	/** Check whether error window shall display a company manager face */
 
	bool HasFace() const { return face != INVALID_COMPANY; }
 

	
 
	void SetDParam(uint n, uint64 v);
 
	void SetDParam(uint n, uint64_t v);
 
	void SetDParamStr(uint n, const char *str);
 
	void SetDParamStr(uint n, const std::string &str);
 

	
 
@@ -65,7 +65,7 @@ void ScheduleErrorMessage(ErrorList &dat
 
void ScheduleErrorMessage(const ErrorMessageData &data);
 

	
 
void ShowErrorMessage(StringID summary_msg, int x, int y, CommandCost cc);
 
void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x = 0, int y = 0, const GRFFile *textref_stack_grffile = nullptr, uint textref_stack_size = 0, const uint32 *textref_stack = nullptr, StringID extra_msg = INVALID_STRING_ID);
 
void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x = 0, int y = 0, const GRFFile *textref_stack_grffile = nullptr, uint textref_stack_size = 0, const uint32_t *textref_stack = nullptr, StringID extra_msg = INVALID_STRING_ID);
 
bool HideActiveErrorMessage();
 

	
 
void ClearErrorMessages();
src/error_gui.cpp
Show inline comments
 
@@ -88,11 +88,11 @@ ErrorMessageData::ErrorMessageData(const
 
 * @param x            World X position (TileVirtX) of the error location. Set both x and y to 0 to just center the message when there is no related error tile.
 
 * @param y            World Y position (TileVirtY) of the error location. Set both x and y to 0 to just center the message when there is no related error tile.
 
 * @param textref_stack_grffile NewGRF that provides the #TextRefStack for the error message.
 
 * @param textref_stack_size Number of uint32 values to put on the #TextRefStack for the error message; 0 if the #TextRefStack shall not be used.
 
 * @param textref_stack_size Number of uint32_t values to put on the #TextRefStack for the error message; 0 if the #TextRefStack shall not be used.
 
 * @param textref_stack Values to put on the #TextRefStack.
 
 * @param extra_msg    Extra error message showed in third line. Can be INVALID_STRING_ID.
 
 */
 
ErrorMessageData::ErrorMessageData(StringID summary_msg, StringID detailed_msg, bool is_critical, int x, int y, const GRFFile *textref_stack_grffile, uint textref_stack_size, const uint32 *textref_stack, StringID extra_msg) :
 
ErrorMessageData::ErrorMessageData(StringID summary_msg, StringID detailed_msg, bool is_critical, int x, int y, const GRFFile *textref_stack_grffile, uint textref_stack_size, const uint32_t *textref_stack, StringID extra_msg) :
 
	is_critical(is_critical),
 
	textref_stack_grffile(textref_stack_grffile),
 
	textref_stack_size(textref_stack_size),
 
@@ -131,7 +131,7 @@ void ErrorMessageData::CopyOutDParams()
 
 * @param n Parameter index
 
 * @param v Parameter value
 
 */
 
void ErrorMessageData::SetDParam(uint n, uint64 v)
 
void ErrorMessageData::SetDParam(uint n, uint64_t v)
 
{
 
	if (n >= this->params.size()) this->params.resize(n + 1);
 
	this->params[n] = v;
 
@@ -217,7 +217,7 @@ public:
 
		}
 
	}
 

	
 
	Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) override
 
	Point OnInitialPosition(int16_t sm_width, int16_t sm_height, int window_number) override
 
	{
 
		/* Position (0, 0) given, center the window. */
 
		if (this->position.x == 0 && this->position.y == 0) {
 
@@ -385,11 +385,11 @@ void ShowErrorMessage(StringID summary_m
 
 * @param x            World X position (TileVirtX) of the error location. Set both x and y to 0 to just center the message when there is no related error tile.
 
 * @param y            World Y position (TileVirtY) of the error location. Set both x and y to 0 to just center the message when there is no related error tile.
 
 * @param textref_stack_grffile NewGRF providing the #TextRefStack for the error message.
 
 * @param textref_stack_size Number of uint32 values to put on the #TextRefStack for the error message; 0 if the #TextRefStack shall not be used.
 
 * @param textref_stack_size Number of uint32_t values to put on the #TextRefStack for the error message; 0 if the #TextRefStack shall not be used.
 
 * @param textref_stack Values to put on the #TextRefStack.
 
 * @param extra_msg    Extra error message shown in third line. Can be INVALID_STRING_ID.
 
 */
 
void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x, int y, const GRFFile *textref_stack_grffile, uint textref_stack_size, const uint32 *textref_stack, StringID extra_msg)
 
void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x, int y, const GRFFile *textref_stack_grffile, uint textref_stack_size, const uint32_t *textref_stack, StringID extra_msg)
 
{
 
	assert(textref_stack_size == 0 || (textref_stack_grffile != nullptr && textref_stack != nullptr));
 
	if (summary_msg == STR_NULL) summary_msg = STR_EMPTY;
src/fios.cpp
Show inline comments
 
@@ -604,7 +604,7 @@ const char *FiosGetScreenshotDir()
 

	
 
/** Basic data to distinguish a scenario. Used in the server list window */
 
struct ScenarioIdentifier {
 
	uint32 scenid;           ///< ID for the scenario (generated by content).
 
	uint32_t scenid;           ///< ID for the scenario (generated by content).
 
	MD5Hash md5sum;          ///< MD5 checksum of file.
 
	std::string filename;    ///< filename of the file.
 

	
 
@@ -652,7 +652,7 @@ public:
 
		id.filename = filename;
 

	
 
		Md5 checksum;
 
		uint8 buffer[1024];
 
		uint8_t buffer[1024];
 
		size_t len, size;
 

	
 
		/* open the scenario file, but first get the name.
src/fios.h
Show inline comments
 
@@ -35,7 +35,7 @@ struct LoadCheckData {
 
	StringID error;     ///< Error message from loading. INVALID_STRING_ID if no error.
 
	std::string error_msg; ///< Data to pass to SetDParamStr when displaying #error.
 

	
 
	uint32 map_size_x, map_size_y;
 
	uint32_t map_size_x, map_size_y;
 
	TimerGameCalendar::Date current_date;
 

	
 
	GameSettings settings;
 
@@ -78,7 +78,7 @@ extern LoadCheckData _load_check_data;
 
/** Deals with finding savegames */
 
struct FiosItem {
 
	FiosType type;
 
	uint64 mtime;
 
	uint64_t mtime;
 
	std::string title;
 
	std::string name;
 
	bool operator< (const FiosItem &other) const;
src/fios_gui.cpp
Show inline comments
 
@@ -735,7 +735,7 @@ public:
 
		}
 
	}
 

	
 
	EventState OnKeyPress(WChar key, uint16 keycode) override
 
	EventState OnKeyPress(char32_t key, uint16_t keycode) override
 
	{
 
		if (keycode == WKC_ESC) {
 
			this->Close();
src/fontcache.h
Show inline comments
 
@@ -14,7 +14,7 @@
 
#include "spritecache.h"
 

	
 
/** Glyphs are characters from a font. */
 
typedef uint32 GlyphID;
 
typedef uint32_t GlyphID;
 
static const GlyphID SPRITE_GLYPH = 1U << 30;
 

	
 
/** Font cache for basic fonts. */
 
@@ -78,7 +78,7 @@ public:
 
	 * @param key The key to map to.
 
	 * @param sprite The sprite that is being mapped.
 
	 */
 
	virtual void SetUnicodeGlyph(WChar key, SpriteID sprite) = 0;
 
	virtual void SetUnicodeGlyph(char32_t key, SpriteID sprite) = 0;
 

	
 
	/** Initialize the glyph map */
 
	virtual void InitializeUnicodeGlyphMap() = 0;
 
@@ -111,7 +111,7 @@ public:
 
	 * @param key The character.
 
	 * @return The glyph ID used to draw the character.
 
	 */
 
	virtual GlyphID MapCharToGlyph(WChar key) = 0;
 
	virtual GlyphID MapCharToGlyph(char32_t key) = 0;
 

	
 
	/**
 
	 * Read a font table from the font.
 
@@ -119,7 +119,7 @@ public:
 
	 * @param length The length of the read data.
 
	 * @return The loaded table data.
 
	 */
 
	virtual const void *GetFontTable(uint32 tag, size_t &length) = 0;
 
	virtual const void *GetFontTable(uint32_t tag, size_t &length) = 0;
 

	
 
	/**
 
	 * Get the native OS font handle, if there is one.
 
@@ -164,7 +164,7 @@ public:
 
};
 

	
 
/** Map a SpriteID to the font size and key */
 
static inline void SetUnicodeGlyph(FontSize size, WChar key, SpriteID sprite)
 
static inline void SetUnicodeGlyph(FontSize size, char32_t key, SpriteID sprite)
 
{
 
	FontCache::Get(size)->SetUnicodeGlyph(key, sprite);
 
}
 
@@ -185,14 +185,14 @@ static inline void ClearFontCache()
 
}
 

	
 
/** Get the Sprite for a glyph */
 
static inline const Sprite *GetGlyph(FontSize size, WChar key)
 
static inline const Sprite *GetGlyph(FontSize size, char32_t key)
 
{
 
	FontCache *fc = FontCache::Get(size);
 
	return fc->GetGlyph(fc->MapCharToGlyph(key));
 
}
 

	
 
/** Get the width of a glyph */
 
static inline uint GetGlyphWidth(FontSize size, WChar key)
 
static inline uint GetGlyphWidth(FontSize size, char32_t key)
 
{
 
	FontCache *fc = FontCache::Get(size);
 
	return fc->GetGlyphWidth(fc->MapCharToGlyph(key));
src/fontcache/freetypefontcache.cpp
Show inline comments
 
@@ -34,14 +34,14 @@ private:
 
	FT_Face face;  ///< The font face associated with this font.
 

	
 
	void SetFontSize(FontSize fs, FT_Face face, int pixels);
 
	const void *InternalGetFontTable(uint32 tag, size_t &length) override;
 
	const void *InternalGetFontTable(uint32_t tag, size_t &length) override;
 
	const Sprite *InternalGetGlyph(GlyphID key, bool aa) override;
 

	
 
public:
 
	FreeTypeFontCache(FontSize fs, FT_Face face, int pixels);
 
	~FreeTypeFontCache();
 
	void ClearFontCache() override;
 
	GlyphID MapCharToGlyph(WChar key) override;
 
	GlyphID MapCharToGlyph(char32_t key) override;
 
	std::string GetFontName() override { return fmt::format("{}, {}", face->family_name, face->style_name); }
 
	bool IsBuiltInFont() override { return false; }
 
	const void *GetOSHandle() override { return &face; }
 
@@ -275,7 +275,7 @@ const Sprite *FreeTypeFontCache::Interna
 
}
 

	
 

	
 
GlyphID FreeTypeFontCache::MapCharToGlyph(WChar key)
 
GlyphID FreeTypeFontCache::MapCharToGlyph(char32_t key)
 
{
 
	assert(IsPrintable(key));
 

	
 
@@ -286,7 +286,7 @@ GlyphID FreeTypeFontCache::MapCharToGlyp
 
	return FT_Get_Char_Index(this->face, key);
 
}
 

	
 
const void *FreeTypeFontCache::InternalGetFontTable(uint32 tag, size_t &length)
 
const void *FreeTypeFontCache::InternalGetFontTable(uint32_t tag, size_t &length)
 
{
 
	FT_ULong len = 0;
 
	FT_Byte *result = nullptr;
src/fontcache/spritefontcache.cpp
Show inline comments
 
@@ -50,13 +50,13 @@ SpriteFontCache::~SpriteFontCache()
 
	this->ClearGlyphToSpriteMap();
 
}
 

	
 
SpriteID SpriteFontCache::GetUnicodeGlyph(WChar key)
 
SpriteID SpriteFontCache::GetUnicodeGlyph(char32_t key)
 
{
 
	if (this->glyph_to_spriteid_map[GB(key, 8, 8)] == nullptr) return 0;
 
	return this->glyph_to_spriteid_map[GB(key, 8, 8)][GB(key, 0, 8)];
 
}
 

	
 
void SpriteFontCache::SetUnicodeGlyph(WChar key, SpriteID sprite)
 
void SpriteFontCache::SetUnicodeGlyph(char32_t key, SpriteID sprite)
 
{
 
	if (this->glyph_to_spriteid_map == nullptr) this->glyph_to_spriteid_map = CallocT<SpriteID*>(256);
 
	if (this->glyph_to_spriteid_map[GB(key, 8, 8)] == nullptr) this->glyph_to_spriteid_map[GB(key, 8, 8)] = CallocT<SpriteID>(256);
src/fontcache/spritefontcache.h
Show inline comments
 
@@ -17,20 +17,20 @@
 
class SpriteFontCache : public FontCache {
 
private:
 
	SpriteID **glyph_to_spriteid_map; ///< Mapping of glyphs to sprite IDs.
 
	SpriteID GetUnicodeGlyph(WChar key);
 
	SpriteID GetUnicodeGlyph(char32_t key);
 

	
 
	void ClearGlyphToSpriteMap();
 
public:
 
	SpriteFontCache(FontSize fs);
 
	~SpriteFontCache();
 
	virtual void SetUnicodeGlyph(WChar key, SpriteID sprite);
 
	virtual void SetUnicodeGlyph(char32_t key, SpriteID sprite);
 
	virtual void InitializeUnicodeGlyphMap();
 
	virtual void ClearFontCache();
 
	virtual const Sprite *GetGlyph(GlyphID key);
 
	virtual uint GetGlyphWidth(GlyphID key);
 
	virtual bool GetDrawGlyphShadow();
 
	virtual GlyphID MapCharToGlyph(WChar key) { assert(IsPrintable(key)); return SPRITE_GLYPH | key; }
 
	virtual const void *GetFontTable(uint32 tag, size_t &length) { length = 0; return nullptr; }
 
	virtual GlyphID MapCharToGlyph(char32_t key) { assert(IsPrintable(key)); return SPRITE_GLYPH | key; }
 
	virtual const void *GetFontTable(uint32_t tag, size_t &length) { length = 0; return nullptr; }
 
	virtual std::string GetFontName() { return "sprite"; }
 
	virtual bool IsBuiltInFont() { return true; }
 
};
src/fontcache/truetypefontcache.cpp
Show inline comments
 
@@ -165,7 +165,7 @@ const Sprite *TrueTypeFontCache::GetGlyp
 
	return this->InternalGetGlyph(key, GetFontAAState(this->fs));
 
}
 

	
 
const void *TrueTypeFontCache::GetFontTable(uint32 tag, size_t &length)
 
const void *TrueTypeFontCache::GetFontTable(uint32_t tag, size_t &length)
 
{
 
	const auto iter = this->font_tables.find(tag);
 
	if (iter != this->font_tables.end()) {
src/fontcache/truetypefontcache.h
Show inline comments
 
@@ -55,17 +55,17 @@ protected:
 
	GlyphEntry *GetGlyphPtr(GlyphID key);
 
	void SetGlyphPtr(GlyphID key, const GlyphEntry *glyph, bool duplicate = false);
 

	
 
	virtual const void *InternalGetFontTable(uint32 tag, size_t &length) = 0;
 
	virtual const void *InternalGetFontTable(uint32_t tag, size_t &length) = 0;
 
	virtual const Sprite *InternalGetGlyph(GlyphID key, bool aa) = 0;
 

	
 
public:
 
	TrueTypeFontCache(FontSize fs, int pixels);
 
	virtual ~TrueTypeFontCache();
 
	int GetFontSize() const override { return this->used_size; }
 
	void SetUnicodeGlyph(WChar key, SpriteID sprite) override { this->parent->SetUnicodeGlyph(key, sprite); }
 
	void SetUnicodeGlyph(char32_t key, SpriteID sprite) override { this->parent->SetUnicodeGlyph(key, sprite); }
 
	void InitializeUnicodeGlyphMap() override { this->parent->InitializeUnicodeGlyphMap(); }
 
	const Sprite *GetGlyph(GlyphID key) override;
 
	const void *GetFontTable(uint32 tag, size_t &length) override;
 
	const void *GetFontTable(uint32_t tag, size_t &length) override;
 
	void ClearFontCache() override;
 
	uint GetGlyphWidth(GlyphID key) override;
 
	bool GetDrawGlyphShadow() override;
src/framerate_gui.cpp
Show inline comments
 
@@ -415,13 +415,13 @@ struct FramerateWindow : Window {
 

	
 
	struct CachedDecimal {
 
		StringID strid;
 
		uint32 value;
 
		uint32_t value;
 

	
 
		inline void SetRate(double value, double target)
 
		{
 
			const double threshold_good = target * 0.95;
 
			const double threshold_bad = target * 2 / 3;
 
			this->value = (uint32)(value * 100);
 
			this->value = (uint32_t)(value * 100);
 
			this->strid = (value > threshold_good) ? STR_FRAMERATE_FPS_GOOD : (value < threshold_bad) ? STR_FRAMERATE_FPS_BAD : STR_FRAMERATE_FPS_WARN;
 
		}
 

	
 
@@ -429,7 +429,7 @@ struct FramerateWindow : Window {
 
		{
 
			const double threshold_good = target / 3;
 
			const double threshold_bad = target;
 
			this->value = (uint32)(value * 100);
 
			this->value = (uint32_t)(value * 100);
 
			this->strid = (value < threshold_good) ? STR_FRAMERATE_MS_GOOD : (value > threshold_bad) ? STR_FRAMERATE_MS_BAD : STR_FRAMERATE_MS_WARN;
 
		}
 

	
 
@@ -601,7 +601,7 @@ struct FramerateWindow : Window {
 
	void DrawElementTimesColumn(const Rect &r, StringID heading_str, const CachedDecimal *values) const
 
	{
 
		const Scrollbar *sb = this->GetScrollbar(WID_FRW_SCROLLBAR);
 
		uint16 skip = sb->GetPosition();
 
		uint16_t skip = sb->GetPosition();
 
		int drawable = this->num_displayed;
 
		int y = r.top;
 
		DrawString(r.left, r.right, y, heading_str, TC_FROMSTRING, SA_CENTER, true);
 
@@ -623,7 +623,7 @@ struct FramerateWindow : Window {
 
	void DrawElementAllocationsColumn(const Rect &r) const
 
	{
 
		const Scrollbar *sb = this->GetScrollbar(WID_FRW_SCROLLBAR);
 
		uint16 skip = sb->GetPosition();
 
		uint16_t skip = sb->GetPosition();
 
		int drawable = this->num_displayed;
 
		int y = r.top;
 
		DrawString(r.left, r.right, y, STR_FRAMERATE_MEMORYUSE, TC_FROMSTRING, SA_CENTER, true);
 
@@ -657,7 +657,7 @@ struct FramerateWindow : Window {
 
			case WID_FRW_TIMES_NAMES: {
 
				/* Render a column of titles for performance element names */
 
				const Scrollbar *sb = this->GetScrollbar(WID_FRW_SCROLLBAR);
 
				uint16 skip = sb->GetPosition();
 
				uint16_t skip = sb->GetPosition();
 
				int drawable = this->num_displayed;
 
				int y = r.top + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal; // first line contains headings in the value columns
 
				for (PerformanceElement e : DISPLAY_ORDER_PFE) {
 
@@ -949,7 +949,7 @@ struct FrametimeGraphWindow : Window {
 
			/* Position of last rendered data point */
 
			Point lastpoint = {
 
				x_max,
 
				(int)Scinterlate<int64>(y_zero, y_max, 0, this->vertical_scale, durations[point])
 
				(int)Scinterlate<int64_t>(y_zero, y_max, 0, this->vertical_scale, durations[point])
 
			};
 
			/* Timestamp of last rendered data point */
 
			TimingMeasurement lastts = timestamps[point];
 
@@ -979,8 +979,8 @@ struct FrametimeGraphWindow : Window {
 

	
 
				/* Draw line from previous point to new point */
 
				Point newpoint = {
 
					(int)Scinterlate<int64>(x_zero, x_max, 0, (int64)draw_horz_scale, (int64)draw_horz_scale - (int64)time_sum),
 
					(int)Scinterlate<int64>(y_zero, y_max, 0, (int64)draw_vert_scale, (int64)value)
 
					(int)Scinterlate<int64_t>(x_zero, x_max, 0, (int64_t)draw_horz_scale, (int64_t)draw_horz_scale - (int64_t)time_sum),
 
					(int)Scinterlate<int64_t>(y_zero, y_max, 0, (int64_t)draw_vert_scale, (int64_t)value)
 
				};
 
				if (newpoint.x > lastpoint.x) continue; // don't draw backwards
 
				GfxDrawLine(lastpoint.x, lastpoint.y, newpoint.x, newpoint.y, c_lines);
src/framerate_type.h
Show inline comments
 
@@ -80,7 +80,7 @@ enum PerformanceElement {
 
DECLARE_POSTFIX_INCREMENT(PerformanceElement)
 

	
 
/** Type used to hold a performance timing measurement */
 
typedef uint64 TimingMeasurement;
 
typedef uint64_t TimingMeasurement;
 

	
 
/**
 
 * RAII class for measuring simple elements of performance.
src/game/game_gui.cpp
Show inline comments
 
@@ -361,7 +361,7 @@ struct GSConfigWindow : public Window {
 
	void OnQueryTextFinished(char *str) override
 
	{
 
		if (StrEmpty(str)) return;
 
		int32 value = atoi(str);
 
		int32_t value = atoi(str);
 
		SetValue(value);
 
	}
 

	
src/game/game_text.hpp
Show inline comments
 
@@ -18,9 +18,9 @@ struct StringParam {
 
	};
 

	
 
	ParamType type;
 
	uint8 consumes;
 
	uint8_t consumes;
 

	
 
	StringParam(ParamType type, uint8 consumes) : type(type), consumes(consumes) {}
 
	StringParam(ParamType type, uint8_t consumes) : type(type), consumes(consumes) {}
 
};
 
using StringParams = std::vector<StringParam>;
 
using StringParamsList = std::vector<StringParams>;
src/gamelog.cpp
Show inline comments
 
@@ -24,7 +24,7 @@ extern const SaveLoadVersion SAVEGAME_VE
 

	
 
extern SavegameType _savegame_type; ///< type of savegame we are loading
 

	
 
extern uint32 _ttdp_version;        ///< version of TTDP savegame (if applicable)
 
extern uint32_t _ttdp_version;        ///< version of TTDP savegame (if applicable)
 
extern SaveLoadVersion _sl_version; ///< the major savegame version identifier
 
extern byte   _sl_minor_version;    ///< the minor savegame version, DO NOT USE!
 

	
 
@@ -406,7 +406,7 @@ void Gamelog::Oldver()
 
 * @param oldval old setting value
 
 * @param newval new setting value
 
 */
 
void Gamelog::Setting(const std::string &name, int32 oldval, int32 newval)
 
void Gamelog::Setting(const std::string &name, int32_t oldval, int32_t newval)
 
{
 
	assert(this->action_type == GLAT_SETTING);
 

	
 
@@ -459,7 +459,7 @@ void Gamelog::TestMode()
 
 * @param bug type of bug, @see enum GRFBugs
 
 * @param data additional data
 
 */
 
void Gamelog::GRFBug(uint32 grfid, byte bug, uint64 data)
 
void Gamelog::GRFBug(uint32_t grfid, byte bug, uint64_t data)
 
{
 
	assert(this->action_type == GLAT_GRFBUG);
 

	
 
@@ -475,7 +475,7 @@ void Gamelog::GRFBug(uint32 grfid, byte 
 
 * @param internal_id the internal ID of whatever's broken in the NewGRF
 
 * @return true iff a unique record was done
 
 */
 
bool Gamelog::GRFBugReverse(uint32 grfid, uint16 internal_id)
 
bool Gamelog::GRFBugReverse(uint32_t grfid, uint16_t internal_id)
 
{
 
	for (const LoggedAction &la : this->data->action) {
 
		for (const auto &lc : la.change) {
 
@@ -510,7 +510,7 @@ static inline bool IsLoggableGrfConfig(c
 
 * Logs removal of a GRF
 
 * @param grfid ID of removed GRF
 
 */
 
void Gamelog::GRFRemove(uint32 grfid)
 
void Gamelog::GRFRemove(uint32_t grfid)
 
{
 
	assert(this->action_type == GLAT_LOAD || this->action_type == GLAT_GRF);
 

	
 
@@ -547,7 +547,7 @@ void Gamelog::GRFCompatible(const GRFIde
 
 * @param grfid GRF that is moved
 
 * @param offset how far it is moved, positive = moved down
 
 */
 
void Gamelog::GRFMove(uint32 grfid, int32 offset)
 
void Gamelog::GRFMove(uint32_t grfid, int32_t offset)
 
{
 
	assert(this->action_type == GLAT_GRF);
 

	
 
@@ -559,7 +559,7 @@ void Gamelog::GRFMove(uint32 grfid, int3
 
 * Details about parameters changed are not stored
 
 * @param grfid ID of GRF to store
 
 */
 
void Gamelog::GRFParameters(uint32 grfid)
 
void Gamelog::GRFParameters(uint32_t grfid)
 
{
 
	assert(this->action_type == GLAT_GRF);
 

	
 
@@ -678,7 +678,7 @@ void Gamelog::GRFUpdate(const GRFConfig 
 
 * @param[out] ever_modified Max value of 'modified' from all binaries that ever saved this savegame.
 
 * @param[out] removed_newgrfs Set to true if any NewGRFs have been removed.
 
 */
 
void Gamelog::Info(uint32 *last_ottd_rev, byte *ever_modified, bool *removed_newgrfs)
 
void Gamelog::Info(uint32_t *last_ottd_rev, byte *ever_modified, bool *removed_newgrfs)
 
{
 
	for (const LoggedAction &la : this->data->action) {
 
		for (const auto &lc : la.change) {
src/gamelog.h
Show inline comments
 
@@ -13,7 +13,7 @@
 
#include "newgrf_config.h"
 

	
 
/** The actions we log. */
 
enum GamelogActionType : uint8 {
 
enum GamelogActionType : uint8_t {
 
	GLAT_START,        ///< Game created
 
	GLAT_LOAD,         ///< Game loaded
 
	GLAT_GRF,          ///< GRF changed
 
@@ -26,7 +26,7 @@ enum GamelogActionType : uint8 {
 
};
 

	
 
/** Type of logged change */
 
enum GamelogChangeType : uint8 {
 
enum GamelogChangeType : uint8_t {
 
	GLCT_MODE,        ///< Scenario editor x Game, different landscape
 
	GLCT_REVISION,    ///< Changed game revision string
 
	GLCT_OLDVER,      ///< Loaded from savegame without logged data
 
@@ -74,22 +74,22 @@ public:
 
	void Revision();
 
	void Mode();
 
	void Oldver();
 
	void Setting(const std::string &name, int32 oldval, int32 newval);
 
	void Setting(const std::string &name, int32_t oldval, int32_t newval);
 

	
 
	void GRFUpdate(const GRFConfig *oldg, const GRFConfig *newg);
 
	void GRFAddList(const GRFConfig *newg);
 
	void GRFRemove(uint32 grfid);
 
	void GRFRemove(uint32_t grfid);
 
	void GRFAdd(const GRFConfig *newg);
 
	void GRFBug(uint32 grfid, byte bug, uint64 data);
 
	bool GRFBugReverse(uint32 grfid, uint16 internal_id);
 
	void GRFBug(uint32_t grfid, byte bug, uint64_t data);
 
	bool GRFBugReverse(uint32_t grfid, uint16_t internal_id);
 
	void GRFCompatible(const GRFIdentifier *newg);
 
	void GRFMove(uint32 grfid, int32 offset);
 
	void GRFParameters(uint32 grfid);
 
	void GRFMove(uint32_t grfid, int32_t offset);
 
	void GRFParameters(uint32_t grfid);
 

	
 
	void TestRevision();
 
	void TestMode();
 

	
 
	void Info(uint32 *last_ottd_rev, byte *ever_modified, bool *removed_newgrfs);
 
	void Info(uint32_t *last_ottd_rev, byte *ever_modified, bool *removed_newgrfs);
 
	const GRFIdentifier *GetOverriddenIdentifier(const GRFConfig *c);
 

	
 
	/* Saveload handler for gamelog needs access to internal data. */
src/genworld.h
Show inline comments
 
@@ -21,7 +21,7 @@ enum LandscapeGenerator {
 
	LG_TERRAGENESIS = 1,  ///< TerraGenesis Perlin landscape generator
 
};
 

	
 
static const uint32 GENERATE_NEW_SEED = UINT32_MAX; ///< Create a new random seed
 
static const uint32_t GENERATE_NEW_SEED = UINT32_MAX; ///< Create a new random seed
 

	
 
/** Modes for GenerateWorld */
 
enum GenWorldMode {
 
@@ -96,7 +96,7 @@ void SetGeneratingWorldProgress(GenWorld
 
void IncreaseGeneratingWorldProgress(GenWorldProgress cls);
 
void PrepareGenerateWorldProgress();
 
void ShowGenerateWorldProgress();
 
void StartNewGameWithoutGUI(uint32 seed);
 
void StartNewGameWithoutGUI(uint32_t seed);
 
void ShowCreateScenario();
 
void StartScenarioEditor();
 

	
src/genworld_gui.cpp
Show inline comments
 
@@ -821,7 +821,7 @@ struct GenerateLandscapeWindow : public 
 
				break;
 

	
 
			case WID_GL_WATER_PULLDOWN: { // Water quantity
 
				uint32 hidden_mask = 0;
 
				uint32_t hidden_mask = 0;
 
				/* Disable custom water level when the original map generator is active. */
 
				if (_settings_newgame.game_creation.land_generator == LG_ORIGINAL) {
 
					SetBit(hidden_mask, CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY);
 
@@ -961,7 +961,7 @@ struct GenerateLandscapeWindow : public 
 
		/* Was 'cancel' pressed? */
 
		if (str == nullptr) return;
 

	
 
		int32 value;
 
		int32_t value;
 
		if (!StrEmpty(str)) {
 
			value = atoi(str);
 
		} else {
 
@@ -1084,7 +1084,7 @@ void StartScenarioEditor()
 
 * Start a normal game without the GUI.
 
 * @param seed The seed of the new game.
 
 */
 
void StartNewGameWithoutGUI(uint32 seed)
 
void StartNewGameWithoutGUI(uint32_t seed)
 
{
 
	/* GenerateWorld takes care of the possible GENERATE_NEW_SEED value in 'seed' */
 
	_settings_newgame.game_creation.generation_seed = seed;
 
@@ -1253,7 +1253,7 @@ struct CreateScenarioWindow : public Win
 
	void OnQueryTextFinished(char *str) override
 
	{
 
		if (!StrEmpty(str)) {
 
			int32 value = atoi(str);
 
			int32_t value = atoi(str);
 

	
 
			switch (this->widget_id) {
 
				case WID_CS_START_DATE_TEXT:
src/gfx.cpp
Show inline comments
 
@@ -38,7 +38,7 @@ byte _support8bpp;
 
CursorVars _cursor;
 
bool _ctrl_pressed;   ///< Is Ctrl pressed?
 
bool _shift_pressed;  ///< Is Shift pressed?
 
uint16 _game_speed = 100; ///< Current game-speed; 100 is 1x, 0 is infinite.
 
uint16_t _game_speed = 100; ///< Current game-speed; 100 is 1x, 0 is infinite.
 
bool _left_button_down;     ///< Is left mouse button pressed?
 
bool _left_button_clicked;  ///< Is left mouse button clicked?
 
bool _right_button_down;    ///< Is right mouse button pressed?
 
@@ -61,7 +61,7 @@ static std::recursive_mutex _palette_mut
 
static void GfxMainBlitterViewport(const Sprite *sprite, int x, int y, BlitterMode mode, const SubSprite *sub = nullptr, SpriteID sprite_id = SPR_CURSOR_MOUSE);
 
static void GfxMainBlitter(const Sprite *sprite, int x, int y, BlitterMode mode, const SubSprite *sub = nullptr, SpriteID sprite_id = SPR_CURSOR_MOUSE, ZoomLevel zoom = ZOOM_LVL_NORMAL);
 

	
 
static ReusableBuffer<uint8> _cursor_backup;
 
static ReusableBuffer<uint8_t> _cursor_backup;
 

	
 
ZoomLevel _gui_zoom  = ZOOM_LVL_OUT_4X;     ///< GUI Zoom level
 
ZoomLevel _font_zoom = _gui_zoom;           ///< Sprite font Zoom level (not clamped)
 
@@ -145,7 +145,7 @@ void GfxFillRect(int left, int top, int 
 

	
 
	switch (mode) {
 
		default: // FILLRECT_OPAQUE
 
			blitter->DrawRect(dst, right, bottom, (uint8)colour);
 
			blitter->DrawRect(dst, right, bottom, (uint8_t)colour);
 
			break;
 

	
 
		case FILLRECT_RECOLOUR:
 
@@ -155,7 +155,7 @@ void GfxFillRect(int left, int top, int 
 
		case FILLRECT_CHECKER: {
 
			byte bo = (oleft - left + dpi->left + otop - top + dpi->top) & 1;
 
			do {
 
				for (int i = (bo ^= 1); i < right; i += 2) blitter->SetPixel(dst, i, 0, (uint8)colour);
 
				for (int i = (bo ^= 1); i < right; i += 2) blitter->SetPixel(dst, i, 0, (uint8_t)colour);
 
				dst = blitter->MoveTo(dst, 0, 1);
 
			} while (--bottom > 0);
 
			break;
 
@@ -281,7 +281,7 @@ void GfxFillPolygon(const std::vector<Po
 
			void *dst = blitter->MoveTo(dpi->dst_ptr, x1, y);
 
			switch (mode) {
 
				default: // FILLRECT_OPAQUE
 
					blitter->DrawRect(dst, x2 - x1, 1, (uint8)colour);
 
					blitter->DrawRect(dst, x2 - x1, 1, (uint8_t)colour);
 
					break;
 
				case FILLRECT_RECOLOUR:
 
					blitter->DrawColourMappingRect(dst, x2 - x1, 1, GB(colour, 0, PALETTE_WIDTH));
 
@@ -290,7 +290,7 @@ void GfxFillPolygon(const std::vector<Po
 
					/* Fill every other pixel, offset such that the sum of filled pixels' X and Y coordinates is odd.
 
					 * This creates a checkerboard effect. */
 
					for (int x = (x1 + y) & 1; x < x2 - x1; x += 2) {
 
						blitter->SetPixel(dst, x, 0, (uint8)colour);
 
						blitter->SetPixel(dst, x, 0, (uint8_t)colour);
 
					}
 
					break;
 
			}
 
@@ -315,7 +315,7 @@ void GfxFillPolygon(const std::vector<Po
 
 * @param width Width of the line.
 
 * @param dash Length of dashes for dashed lines. 0 means solid line.
 
 */
 
static inline void GfxDoDrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash = 0)
 
static inline void GfxDoDrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8_t colour, int width, int dash = 0)
 
{
 
	Blitter *blitter = BlitterFactory::GetCurrentBlitter();
 

	
 
@@ -909,7 +909,7 @@ ptrdiff_t GetCharAtPosition(std::string_
 
 * @param colour      Colour to use, for details see _string_colourmap in
 
 *                    table/palettes.h or docs/ottd-colourtext-palette.png or the enum TextColour in gfx_type.h
 
 */
 
void DrawCharCentered(WChar c, const Rect &r, TextColour colour)
 
void DrawCharCentered(char32_t c, const Rect &r, TextColour colour)
 
{
 
	SetColourRemap(colour);
 
	GfxMainBlitter(GetGlyph(FS_NORMAL, c),
 
@@ -1146,7 +1146,7 @@ static void GfxBlitter(const Sprite * co
 
 * @param zoom The zoom level at which to draw the sprites.
 
 * @return Pixel buffer, or nullptr if an 8bpp blitter is being used.
 
 */
 
std::unique_ptr<uint32[]> DrawSpriteToRgbaBuffer(SpriteID spriteId, ZoomLevel zoom)
 
std::unique_ptr<uint32_t[]> DrawSpriteToRgbaBuffer(SpriteID spriteId, ZoomLevel zoom)
 
{
 
	/* Invalid zoom level requested? */
 
	if (zoom < _settings_client.gui.zoom_min || zoom > _settings_client.gui.zoom_max) return nullptr;
 
@@ -1159,7 +1159,7 @@ std::unique_ptr<uint32[]> DrawSpriteToRg
 
	const Sprite *sprite = GetSprite(real_sprite, SpriteType::Normal);
 
	Dimension dim = GetSpriteSize(real_sprite, nullptr, zoom);
 
	size_t dim_size = static_cast<size_t>(dim.width) * dim.height;
 
	std::unique_ptr<uint32[]> result(new uint32[dim_size]);
 
	std::unique_ptr<uint32_t[]> result(new uint32_t[dim_size]);
 
	/* Set buffer to fully transparent. */
 
	MemSetT(result.get(), 0, dim_size);
 

	
 
@@ -1192,7 +1192,7 @@ std::unique_ptr<uint32[]> DrawSpriteToRg
 

	
 
	if (blitter->GetScreenDepth() == 8) {
 
		/* Resolve palette. */
 
		uint32 *dst = result.get();
 
		uint32_t *dst = result.get();
 
		const byte *src = pal_buffer.get();
 
		for (size_t i = 0; i < dim_size; ++i) {
 
			*dst++ = _cur_palette.palette[*src++].data;
 
@@ -1247,8 +1247,8 @@ bool CopyPalette(Palette &local_palette,
 
	return true;
 
}
 

	
 
#define EXTR(p, q) (((uint16)(palette_animation_counter * (p)) * (q)) >> 16)
 
#define EXTR2(p, q) (((uint16)(~palette_animation_counter * (p)) * (q)) >> 16)
 
#define EXTR(p, q) (((uint16_t)(palette_animation_counter * (p)) * (q)) >> 16)
 
#define EXTR2(p, q) (((uint16_t)(~palette_animation_counter * (p)) * (q)) >> 16)
 

	
 
void DoPaletteAnimations()
 
{
 
@@ -1367,7 +1367,7 @@ void DoPaletteAnimations()
 
 * @param threshold Background colour brightness threshold below which the background is considered dark and TC_WHITE is returned, range: 0 - 255, default 128.
 
 * @return TC_BLACK or TC_WHITE depending on what gives a better contrast.
 
 */
 
TextColour GetContrastColour(uint8 background, uint8 threshold)
 
TextColour GetContrastColour(uint8_t background, uint8_t threshold)
 
{
 
	Colour c = _cur_palette.palette[background];
 
	/* Compute brightness according to http://www.w3.org/TR/AERT#color-contrast.
 
@@ -1400,7 +1400,7 @@ void LoadStringWidthTable(bool monospace
 
 * @param key   Character code glyph
 
 * @return Width of the character glyph
 
 */
 
byte GetCharacterWidth(FontSize size, WChar key)
 
byte GetCharacterWidth(FontSize size, char32_t key)
 
{
 
	/* Use _stringwidth_table cache if possible */
 
	if (key >= 32 && key < 256) return _stringwidth_table[size][key - 32];
 
@@ -1517,7 +1517,7 @@ void DrawMouseCursor()
 
	_cursor.draw_size.x = width;
 
	_cursor.draw_size.y = height;
 

	
 
	uint8 *buffer = _cursor_backup.Allocate(blitter->BufferSize(_cursor.draw_size.x, _cursor.draw_size.y));
 
	uint8_t *buffer = _cursor_backup.Allocate(blitter->BufferSize(_cursor.draw_size.x, _cursor.draw_size.y));
 

	
 
	/* Make backup of stuff below cursor */
 
	blitter->CopyToBuffer(blitter->MoveTo(_screen.dst_ptr, _cursor.draw_pos.x, _cursor.draw_pos.y), buffer, _cursor.draw_size.x, _cursor.draw_size.y);
 
@@ -1946,7 +1946,7 @@ void UpdateGUIZoom()
 
		_gui_scale = Clamp(_gui_scale_cfg, MIN_INTERFACE_SCALE, MAX_INTERFACE_SCALE);
 
	}
 

	
 
	int8 new_zoom = ScaleGUITrad(1) <= 1 ? ZOOM_LVL_OUT_4X : ScaleGUITrad(1) >= 4 ? ZOOM_LVL_MIN : ZOOM_LVL_OUT_2X;
 
	int8_t new_zoom = ScaleGUITrad(1) <= 1 ? ZOOM_LVL_OUT_4X : ScaleGUITrad(1) >= 4 ? ZOOM_LVL_MIN : ZOOM_LVL_OUT_2X;
 
	/* Font glyphs should not be clamped to min/max zoom. */
 
	_font_zoom = static_cast<ZoomLevel>(new_zoom);
 
	/* Ensure the gui_zoom is clamped between min/max. */

Changeset was too big and was cut off... Show full diff anyway

0 comments (0 inline, 0 general)