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
pull/603/merge
Rubidium 12 months ago committed by rubidium42
parent 4f4810dc28
commit eaae0bb5e7

@ -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 /*[64]*/)
void Md5::Append(const void *data, const size_t nbytes)
{
const uint8 *p = (const uint8 *)data;
const uint8_t *p = (const uint8_t *)data;
size_t left = nbytes;
const size_t offset = (this->count[0] >> 3) & 63;
const uint32 nbits = (uint32)(nbytes << 3);
const uint32_t nbits = (uint32_t)(nbytes << 3);
if (nbytes <= 0) return;
/* Update the message length. */
this->count[1] += (uint32)(nbytes >> 29);
this->count[1] += (uint32_t)(nbytes >> 29);
this->count[0] += nbits;
if (this->count[0] < nbits) this->count[1]++;
@ -299,17 +299,17 @@ void Md5::Append(const void *data, const size_t nbytes)
void Md5::Finish(MD5Hash &digest)
{
static const uint8 pad[64] = {
static const uint8_t pad[64] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
uint8 data[8];
uint8_t data[8];
/* Save the length before padding. */
for (uint i = 0; i < 8; ++i) {
data[i] = (uint8)(this->count[i >> 2] >> ((i & 3) << 3));
data[i] = (uint8_t)(this->count[i >> 2] >> ((i & 3) << 3));
}
/* Pad to 56 bytes mod 64. */
@ -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));
}
}

@ -74,11 +74,11 @@ struct MD5Hash : std::array<byte, MD5_HASH_BYTES> {
struct Md5 {
private:
uint32 count[2]; ///< message length in bits, lsw first
uint32 abcd[4]; ///< digest buffer
uint8 buf[64]; ///< accumulate block
uint32_t count[2]; ///< message length in bits, lsw first
uint32_t abcd[4]; ///< digest buffer
uint8_t buf[64]; ///< accumulate block
void Process(const uint8 *data);
void Process(const uint8_t *data);
public:
Md5();

@ -179,7 +179,7 @@ typedef void (*SQPRINTFUNCTION)(HSQUIRRELVM,const std::string &);
typedef SQInteger (*SQWRITEFUNC)(SQUserPointer,SQUserPointer,SQInteger);
typedef SQInteger (*SQREADFUNC)(SQUserPointer,SQUserPointer,SQInteger);
typedef WChar (*SQLEXREADFUNC)(SQUserPointer);
typedef char32_t (*SQLEXREADFUNC)(SQUserPointer);
typedef struct tagSQRegFunction{
const SQChar *name;

@ -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;

@ -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 SQChar *err)
void SQLexer::Next()
{
WChar t = _readf(_up);
char32_t t = _readf(_up);
if(t > MAX_CHAR) Error("Invalid character");
if(t != 0) {
_currdata = t;
@ -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();

@ -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;

@ -64,15 +64,15 @@ int GetAircraftFlightLevel(T *v, bool takeoff = false);
/** Variables that are cached to improve performance and such. */
struct AircraftCache {
uint32 cached_max_range_sqr; ///< Cached squared maximum range.
uint16 cached_max_range; ///< Cached maximum range.
uint32_t cached_max_range_sqr; ///< Cached squared maximum range.
uint16_t cached_max_range; ///< Cached maximum range.
};
/**
* Aircraft, helicopters, rotors and their shadows belong to this class.
*/
struct Aircraft FINAL : public SpecializedVehicle<Aircraft, VEH_AIRCRAFT> {
uint16 crashed_counter; ///< Timer for handling crash animations.
uint16_t crashed_counter; ///< Timer for handling crash animations.
byte pos; ///< Next desired position of the aircraft.
byte previous_pos; ///< Previous desired position of the aircraft.
StationID targetairport; ///< Airport to go to next.
@ -130,7 +130,7 @@ struct Aircraft FINAL : public SpecializedVehicle<Aircraft, VEH_AIRCRAFT> {
* Get the range of this aircraft.
* @return Range in tiles or 0 if unlimited range.
*/
uint16 GetRange() const
uint16_t GetRange() const
{
return this->acache.cached_max_range;
}

@ -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 Aircraft *v)
void Aircraft::GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const
{
uint8 spritenum = this->spritenum;
uint8_t spritenum = this->spritenum;
if (is_custom_sprite(spritenum)) {
GetCustomVehicleSprite(this, direction, image_type, result);
@ -202,7 +202,7 @@ void GetRotorImage(const Aircraft *v, EngineImageType image_type, VehicleSpriteS
static void GetAircraftIcon(EngineID engine, EngineImageType image_type, VehicleSpriteSeq *result)
{
const Engine *e = Engine::Get(engine);
uint8 spritenum = e->u.air.image_index;
uint8_t spritenum = e->u.air.image_index;
if (is_custom_sprite(spritenum)) {
GetCustomVehicleIcon(engine, DIR_W, image_type, result);
@ -1174,7 +1174,7 @@ static bool HandleCrashedAircraft(Aircraft *v)
}
if (v->crashed_counter < 650) {
uint32 r;
uint32_t r;
if (Chance16R(1, 32, r)) {
static const DirDiff delta[] = {
DIRDIFF_45LEFT, DIRDIFF_SAME, DIRDIFF_SAME, DIRDIFF_45RIGHT
@ -1218,8 +1218,8 @@ static bool HandleCrashedAircraft(Aircraft *v)
static void HandleAircraftSmoke(Aircraft *v, bool mode)
{
static const struct {
int8 x;
int8 y;
int8_t x;
int8_t y;
} smoke_pos[] = {
{ 5, 5 },
{ 6, 0 },
@ -1358,7 +1358,7 @@ static void MaybeCrashAirplane(Aircraft *v)
Station *st = Station::Get(v->targetairport);
uint32 prob;
uint32_t prob;
if ((st->airport.GetFTA()->flags & AirportFTAClass::SHORT_STRIP) &&
(AircraftVehInfo(v->engine_type)->subtype & AIR_FAST) &&
!_cheats.no_jetcrash.value) {
@ -1655,8 +1655,8 @@ static void AircraftEventHandler_Flying(Aircraft *v, const AirportFTAClass *apc)
/* save speed before, since if AirportHasBlock is false, it resets them to 0
* we don't want that for plane in air
* hack for speed thingie */
uint16 tcur_speed = v->cur_speed;
uint16 tsubspeed = v->subspeed;
uint16_t tcur_speed = v->cur_speed;
uint16_t tsubspeed = v->subspeed;
if (!AirportHasBlock(v, current, apc)) {
v->state = landingtype; // LANDING / HELILANDING
if (v->state == HELILANDING) SetBit(v->flags, VAF_HELI_DIRECT_DESCENT);
@ -1840,7 +1840,7 @@ static bool AirportHasBlock(Aircraft *v, const AirportFTA *current_pos, const Ai
/* same block, then of course we can move */
if (apc->layout[current_pos->position].block != next->block) {
const Station *st = Station::Get(v->targetairport);
uint64 airport_flags = next->block;
uint64_t airport_flags = next->block;
/* check additional possible extra blocks */
if (current_pos != reference && current_pos->block != NOTHING_block) {
@ -1870,7 +1870,7 @@ static bool AirportSetBlocks(Aircraft *v, const AirportFTA *current_pos, const A
/* if the next position is in another block, check it and wait until it is free */
if ((apc->layout[current_pos->position].block & next->block) != next->block) {
uint64 airport_flags = next->block;
uint64_t airport_flags = next->block;
/* search for all all elements in the list with the same state, and blocks != N
* this means more blocks should be checked/set */
const AirportFTA *current = current_pos;
@ -1907,7 +1907,7 @@ static bool AirportSetBlocks(Aircraft *v, const AirportFTA *current_pos, const A
*/
struct MovementTerminalMapping {
AirportMovementStates state; ///< Aircraft movement state when going to this terminal.
uint64 airport_flag; ///< Bitmask in the airport flags that need to be free for this terminal.
uint64_t airport_flag; ///< Bitmask in the airport flags that need to be free for this terminal.
};
/** A list of all valid terminals and their associated blocks. */

@ -65,7 +65,7 @@ AIRPORT_GENERIC(dummy, nullptr, 0, AirportFTAClass::ALL, 0)
#include "table/airport_defaults.h"
static uint16 AirportGetNofElements(const AirportFTAbuildup *apFA);
static uint16_t AirportGetNofElements(const AirportFTAbuildup *apFA);
static AirportFTA *AirportBuildAutomata(uint nofelements, const AirportFTAbuildup *apFA);
@ -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(const AirportFTAbuildup *apFA)
static AirportFTA *AirportBuildAutomata(uint nofelements, const AirportFTAbuildup *apFA)
{
AirportFTA *FAutomata = MallocT<AirportFTA>(nofelements);
uint16 internalcounter = 0;
uint16_t internalcounter = 0;
for (uint i = 0; i < nofelements; i++) {
AirportFTA *current = &FAutomata[i];

@ -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::Flags)
/** 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

@ -36,7 +36,7 @@ static EngineID GetNextArticulatedPart(uint index, EngineID front_type, Vehicle
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 engine_type, bool purchase_window)
* @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(EngineID engine)
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;

@ -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

@ -498,7 +498,7 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlag flags, bool wagon
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++;

@ -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)
{

@ -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;

@ -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

@ -59,7 +59,7 @@ bool BaseSet<T, Tnum_files, Tsearch_in_tars>::FillSetDetails(IniFile *ini, const
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");

@ -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::PoolItem<&_station_pool> {
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::PoolItem<&_station_pool> {
* @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).

@ -30,26 +30,26 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
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(const Blitter::BlitterParams *bp, ZoomLevel
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(const Blitter::BlitterParams *bp, ZoomLevel
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::DrawColourMappingRect(void *dst, int width, int height,
}
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::DrawColourMappingRect(void *dst, int width, int height,
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 *video, int x, int y, int x2, int y2, int
*((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 *video, int x, int y, int x2, int y2, int
}
}
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 *video, int width, int height, uint8 colou
}
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 *video, int width, int height, uint8 colou
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 *video, int width, int height, uint8 colou
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(void *video, const void *src, int width,
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(const void *video, void *dst, int width, in
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(void *video, int &left, int &top, int &widt
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(void *video, int &left, int &top, int &widt
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(void *video, int &left, int &top, int &widt
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(const Palette &palette)
* 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(const Palette &palette)
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));
}
}

@ -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;

@ -30,7 +30,7 @@ void Blitter_32bppSSE2_Anim::PaletteAnimate(const Palette &palette)
* 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::PaletteAnimate(const Palette &palette)
__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::PaletteAnimate(const Palette &palette)
/* 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));

@ -34,7 +34,7 @@ inline void Blitter_32bppSSE4_Anim::Draw(const Blitter::BlitterParams *bp, ZoomL
{
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(const Blitter::BlitterParams *bp, ZoomL
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(const Blitter::BlitterParams *bp, ZoomL
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(const Blitter::BlitterParams *bp, ZoomL
}
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(const Blitter::BlitterParams *bp, ZoomL
/* 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;
}

@ -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 *video, int x, int y, int x2, int y2, int
});
}
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 *video, int width, int height, uint8 colou
*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(void *video, const void *src, int width,
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(const void *video, void *dst, int width, in
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::CopyImageToBuffer(const void *video, void *dst, int widt
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(void *video, int &left, int &top, int &widt
}
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(void *video, int &left, int &top, int &widt
/* 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(void *video, int &left, int &top, int &widt
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(const Palette &palette)
/* 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;

@ -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;

@ -29,18 +29,18 @@ inline void Blitter_32bppOptimized::Draw(const Blitter::BlitterParams *bp, ZoomL
{
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(const Blitter::BlitterParams *bp, ZoomL
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(const Blitter::BlitterParams *bp, ZoomL
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(const Blitter::BlitterParams *bp, ZoomL
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 *Blitter_32bppOptimized::EncodeInternal(const
*
* 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 *Blitter_32bppOptimized::EncodeInternal(const
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 *Blitter_32bppOptimized::EncodeInternal(const
*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 *Blitter_32bppOptimized::EncodeInternal(const
}
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

@ -17,7 +17,7 @@ class Blitter_32bppOptimized : public Blitter_32bppSimple {
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.
};

@ -48,7 +48,7 @@ void Blitter_32bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Zoo
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(const SpriteLoader::Sprite *sprite, Allocato
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;

@ -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;

@ -22,8 +22,8 @@ static FBlitter_32bppSSE2 iFBlitter_32bppSSE2;
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(const SpriteLoader::Sprite *sprite, Alloca
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(const SpriteLoader::Sprite *sprite, Alloca
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(const SpriteLoader::Sprite *sprite, Alloca
}
} 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(const SpriteLoader::Sprite *sprite, Alloca
/* 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;

@ -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;

@ -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(const uint32 value, __m128i &into)
}
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(const uint32 value, __m128i &into)
}
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(const __m128i from, const __m128i &mask)
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(__m128i src, __m128i dst, const __m128i &d
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(Colour colour, uint8 brightness)
}
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(const Blitter::BlitterParams *bp, ZoomLevel
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(const Blitter::BlitterParams *bp, ZoomLevel
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 {

@ -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)

@ -26,7 +26,7 @@ static FBlitter_40bppAnim iFBlitter_40bppAnim;
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 *video, int x, int y, uint8 colour)
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 *video, int width, int height, uint8 colou
}
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 *video, int width, int height, uint8 colou
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 *video, int x, int y, int x2, int y2, int
}
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(const Blitter::BlitterParams *bp, ZoomLevel
{
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(const Blitter::BlitterParams *bp, ZoomLevel
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(const Blitter::BlitterParams *bp, ZoomLevel
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(const Blitter::BlitterParams *bp, ZoomLevel
} 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(const Blitter::BlitterParams *bp, ZoomLevel
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::DrawColourMappingRect(void *dst, int width, int height,
}
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::DrawColourMappingRect(void *dst, int width, int height,
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::DrawColourMappingRect(void *dst, int width, int height,
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 SpriteLoader::Sprite *sprite, AllocatorP
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(void *video, const void *src, int width,
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::CopyImageToBuffer(const void *video, void *dst, int widt
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(void *video, int &left, int &top, int &widt
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(void *video, int &left, int &top, int &widt
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(void *video, int &left, int &top, int &widt
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()

@ -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;
}

@ -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(void *video, const void *src, int width, i
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(const void *video, void *dst, int width, int
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(const void *video, void *dst, int width
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 *video, int &left, int &top, int &width
}
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 *video, int &left, int &top, int &width
/* 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;
}

@ -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;

@ -26,8 +26,8 @@ void Blitter_8bppOptimized::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Z
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::BlitterParams *bp, BlitterMode mode, Z
}
}
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::BlitterParams *bp, BlitterMode mode, Z
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::BlitterParams *bp, BlitterMode mode, Z
break;
case BM_TRANSPARENT: {
const uint8 *remap = bp->remap;
const uint8_t *remap = bp->remap;
src += pixels;
do {
*dst = remap[*dst];

@ -18,7 +18,7 @@ class Blitter_8bppOptimized FINAL : public Blitter_8bppBase {
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.
};

@ -18,12 +18,12 @@ static FBlitter_8bppSimple iFBlitter_8bppSimple;
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;

@ -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.

@ -50,11 +50,11 @@ void Blitter::DrawLineGeneric(int x1, int y1, int x2, int y2, int screen_width,
/* 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, int y1, int x2, int y2, int screen_width,
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, int y1, int x2, int y2, int screen_width,
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;

@ -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 {};

@ -48,15 +48,15 @@ static inline byte ReadByte(BmpBuffer *buffer)
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 *buffer, BmpInfo *info, BmpData *data)
*/
bool BmpReadHeader(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
{
uint32 header_size;
uint32_t header_size;
assert(info != nullptr);
MemSetT(info, 0);

@ -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 {

@ -42,9 +42,9 @@ typedef uint BridgeType; ///< Bridge spec number.
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

@ -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 start, TileIndex end, TransportType transpo
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;
}
}

@ -401,7 +401,7 @@ static bool AircraftEngineCargoSorter(const GUIEngineListItem &a, const GUIEngin
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(const GUIEngineListItem &a, const GUIEngin
*/
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 left, int right, int y, EngineID engine_n
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 left, int right, int y, EngineID engine_
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 left, int right, int y, EngineID engine_
*/
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, int right, int y, EngineID engine_number,
* @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, const Rect &r, const GUIEngineList &eng_li
*/
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

@ -74,7 +74,7 @@ inline bool IsValidCargoType(CargoType t) { return t != CT_INVALID; }
/** 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 */

@ -66,17 +66,17 @@ void ClearCargoDeliveryMonitoring(CompanyID company)
* @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 &monitor_map, CargoMonitorID monitor, boo
* @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 monitor, bool keep_monitoring)
* @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 monitor, bool keep_monitoring)
* @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;

@ -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 EncodeCargoIndustryMonitor(CompanyID company, Cargo
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 EncodeCargoTownMonitor(CompanyID company, CargoID c
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(CargoMonitorID num)
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 */

@ -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 source, TileIndex source_xy, uint16 count, So
* @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::SetTransferLoadPlace(TileIndex xy)
* @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);

@ -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> class CargoList;
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

@ -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);

@ -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; ///< Constant representing invalid cargo
/** 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();

@ -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 = 10000000;
* @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_value, int32 change_direction)
* @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(int32 new_value, int32 change_direction)
* @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 new_value, int32 change_direction)
* @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();
}

@ -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);

@ -428,7 +428,7 @@ void CommandCost::AddCost(const CommandCost &ret)
* 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;

@ -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

@ -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.

@ -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 *c)
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, CompanyID company = INVALID_COMPANY)
_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(Company *c)
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 *c, VehicleType type)
* 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::GetRoadTotal() const
* 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];
}

@ -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);

@ -626,7 +626,7 @@ typedef GUIList<const Group*> GUIGroupList;
/** 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 : public Window
* @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 : Window
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 : Window
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 : Window
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 : Window
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));

@ -127,9 +127,9 @@ static inline void SetCompanyManagerFaceBits(CompanyManagerFace &cmf, CompanyMan
*
* @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]) {

@ -46,13 +46,13 @@ static const uint MAX_COMPETITORS_INTERVAL = 500; ///< The maximum interval (in
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.

@ -127,7 +127,7 @@ void IConsolePrint(TextColour colour_code, const std::string &string)
* @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;

@ -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;

@ -39,7 +39,7 @@ static const uint ICON_BOTTOM_BORDERWIDTH = 12;
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;

@ -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();

@ -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; }

@ -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(const T x, const uint8 s, const uint8 n)
* @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, const uint8 n, const U d)
* @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, const uint8 n, const U i)
* @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 x, const uint8 y)
* @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 y)
* @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 y)
* @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(const int value)
}
}
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 value)
* @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 uint8 n)
* @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);
}

@ -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 */
}

@ -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;

@ -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;

@ -355,6 +355,6 @@ static inline int DivAwayFromZero(int a, uint b)
}
}
uint32 IntSqrt(uint32 num);
uint32_t IntSqrt(uint32_t num);
#endif /* MATH_FUNC_HPP */

@ -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 OverflowSafeInt<T> operator - (const byte a
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));

@ -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

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

@ -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(const SavedRandomSeeds &storage)
_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 InteractiveRandomRange(uint32 limit)
* @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, const uint b)
#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);

@ -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

@ -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.

@ -120,9 +120,9 @@ byte GetNewgrfCurrencyIdConverted(byte grfcurr_id)
* 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++) {

@ -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[CURRENCY_END];
#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);

@ -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;

@ -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

@ -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();\

@ -22,7 +22,7 @@ struct Depot : DepotPool::PoolItem<&_depot_pool> {
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) {}

@ -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);
}

@ -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;

@ -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(DisasterVehicle *v)
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(DisasterVehicle *v, uint16 image_override, boo
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_Destroyer(DisasterVehicle *v)
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(DisasterSubType subtype)
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(IndustryID 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;
}
}
}

@ -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 *c, bool update)
/* 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_factor, const GRFFile *grf_file, int shift
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_pieces, uint dist, uint16 transit_perio
/* 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 Station *st, CargoID cargo_type, uint n
* @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, CargoID cargo_type, StationID dest, Ti
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);

@ -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);

@ -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_FACTOR = 2;
static const uint LOCK_DEPOT_TILE_FACTOR = 2;
struct CargoPayment;
typedef uint32 CargoPaymentID;
typedef uint32_t CargoPaymentID;
#endif /* ECONOMY_TYPE_H */

@ -38,7 +38,7 @@ static bool IncrementSprite(EffectVehicle *v, SpriteID last)
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 _bulldozer_movement[] = {
};
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;
};

@ -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! */

@ -232,8 +232,8 @@ static int GetPCPElevation(TileIndex tile, DiagDirection PCPpos)
* 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);

@ -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 */

@ -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 Vehicle *v, uint16 *mail_capacity) const
/* 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 Vehicle *v, uint16 *mail_capacity) const
/* 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::GetLifeLengthInDays() const
* 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::ResetToDefaultMapping()
* 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, bool new_month)
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, TimerGameCalendar::Date aging_date, uint32 seed
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(Engine *e)
/* 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) {

@ -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<&_engine_pool> {
*/
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<&_engine_pool> {
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<&_engine_pool> {
* @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<&_engine_pool> {
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<&_engine_pool> {
return this->grf_prop.grffile;
}
uint32 GetGRFID() const;
uint32_t GetGRFID() const;
struct EngineTypeFilter {
VehicleType vt;
@ -190,10 +190,10 @@ struct Engine : EnginePool::PoolItem<&_engine_pool> {
};
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::vector<EngineIDMapping> {
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();
};

@ -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);

@ -190,9 +190,9 @@ static StringID GetTrainEngineInfoString(const Engine *e)
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());

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save