Codechange: rename byte to uint8_t (#12308)

This commit is contained in:
Patric Stout 2024-03-16 23:59:32 +01:00 committed by GitHub
parent bd7120bae4
commit a3cfd23cf9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
355 changed files with 1654 additions and 1656 deletions

View File

@ -248,7 +248,7 @@ Templates are a very powerful C++ tool, but they can easily confuse beginners. T
* Templates are to be documented in a very clear and verbose manner. Never assume anything in the documentation.
* the template keyword and the template layout get a separate line. typenames are either "T" or preceded by a "T", integers get a single capital letter or a descriptive name preceded by "T".
```c++
template <typename T, typename Tsomething, int N, byte Tnumber_of_something>
template <typename T, typename Tsomething, int N, uint8_t Tnumber_of_something>
int Func();
```

View File

@ -57,8 +57,8 @@
static const size_t MD5_HASH_BYTES = 16;
/** Container for storing a MD5 hash/checksum/digest. */
struct MD5Hash : std::array<byte, MD5_HASH_BYTES> {
MD5Hash() : std::array<byte, MD5_HASH_BYTES>{} {}
struct MD5Hash : std::array<uint8_t, MD5_HASH_BYTES> {
MD5Hash() : std::array<uint8_t, MD5_HASH_BYTES>{} {}
/**
* Exclusively-or the given hash into this hash.

View File

@ -73,14 +73,14 @@ struct AircraftCache {
*/
struct Aircraft final : public SpecializedVehicle<Aircraft, VEH_AIRCRAFT> {
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.
uint8_t pos; ///< Next desired position of the aircraft.
uint8_t previous_pos; ///< Previous desired position of the aircraft.
StationID targetairport; ///< Airport to go to next.
byte state; ///< State of the airport. @see AirportMovementStates
uint8_t state; ///< State of the airport. @see AirportMovementStates
Direction last_direction;
byte number_consecutive_turns; ///< Protection to prevent the aircraft of making a lot of turns in order to reach a specific point.
byte turn_counter; ///< Ticks between each turn to prevent > 45 degree turns.
byte flags; ///< Aircraft flags. @see AirVehicleFlags
uint8_t number_consecutive_turns; ///< Protection to prevent the aircraft of making a lot of turns in order to reach a specific point.
uint8_t turn_counter; ///< Ticks between each turn to prevent > 45 degree turns.
uint8_t flags; ///< Aircraft flags. @see AirVehicleFlags
AircraftCache acache;

View File

@ -655,7 +655,7 @@ static int UpdateAircraftSpeed(Aircraft *v, uint speed_limit = SPEED_LIMIT_NONE,
* ~ acceleration * 77 (km-ish/h / 256)
*/
uint spd = v->acceleration * 77;
byte t;
uint8_t t;
/* Adjust speed limits by plane speed factor to prevent taxiing
* and take-off speeds being too low. */
@ -672,7 +672,7 @@ static int UpdateAircraftSpeed(Aircraft *v, uint speed_limit = SPEED_LIMIT_NONE,
speed_limit = v->vcache.cached_max_speed;
}
v->subspeed = (t = v->subspeed) + (byte)spd;
v->subspeed = (t = v->subspeed) + (uint8_t)spd;
/* Aircraft's current speed is used twice so that very fast planes are
* forced to slow down rapidly in the short distance needed. The magic
@ -699,7 +699,7 @@ static int UpdateAircraftSpeed(Aircraft *v, uint speed_limit = SPEED_LIMIT_NONE,
spd = v->GetOldAdvanceSpeed(spd);
spd += v->progress;
v->progress = (byte)spd;
v->progress = (uint8_t)spd;
return spd >> 8;
}
@ -825,7 +825,7 @@ template int GetAircraftFlightLevel(Aircraft *v, bool takeoff);
* @param rotation The rotation of the airport.
* @return The index of the entry point
*/
static byte AircraftGetEntryPoint(const Aircraft *v, const AirportFTAClass *apc, Direction rotation)
static uint8_t AircraftGetEntryPoint(const Aircraft *v, const AirportFTAClass *apc, Direction rotation)
{
assert(v != nullptr);
assert(apc != nullptr);
@ -1666,7 +1666,7 @@ static void AircraftEventHandler_Flying(Aircraft *v, const AirportFTAClass *apc)
/* {32,FLYING,NOTHING_block,37}, {32,LANDING,N,33}, {32,HELILANDING,N,41},
* if it is an airplane, look for LANDING, for helicopter HELILANDING
* it is possible to choose from multiple landing runways, so loop until a free one is found */
byte landingtype = (v->subtype == AIR_HELICOPTER) ? HELILANDING : LANDING;
uint8_t landingtype = (v->subtype == AIR_HELICOPTER) ? HELILANDING : LANDING;
const AirportFTA *current = apc->layout[v->pos].next;
while (current != nullptr) {
if (current->heading == landingtype) {
@ -1813,8 +1813,8 @@ static bool AirportMove(Aircraft *v, const AirportFTAClass *apc)
const AirportFTA *current = &apc->layout[v->pos];
/* we have arrived in an important state (eg terminal, hangar, etc.) */
if (current->heading == v->state) {
byte prev_pos = v->pos; // location could be changed in state, so save it before-hand
byte prev_state = v->state;
uint8_t prev_pos = v->pos; // location could be changed in state, so save it before-hand
uint8_t prev_state = v->state;
_aircraft_state_handlers[v->state](v, apc);
if (v->state != FLYING) v->previous_pos = prev_pos;
if (v->state != prev_state || v->pos != prev_pos) UpdateAircraftCache(v);
@ -1950,7 +1950,7 @@ static const MovementTerminalMapping _airport_terminal_mapping[] = {
* @param last_terminal Terminal number to stop examining.
* @return A terminal or helipad has been found, and has been assigned to the aircraft.
*/
static bool FreeTerminal(Aircraft *v, byte i, byte last_terminal)
static bool FreeTerminal(Aircraft *v, uint8_t i, uint8_t last_terminal)
{
assert(last_terminal <= lengthof(_airport_terminal_mapping));
Station *st = Station::Get(v->targetairport);

View File

@ -110,12 +110,12 @@ AirportMovingData RotateAirportMovingData(const AirportMovingData *orig, Directi
AirportFTAClass::AirportFTAClass(
const AirportMovingData *moving_data_,
const byte *terminals_,
const byte num_helipads_,
const byte *entry_points_,
const uint8_t *terminals_,
const uint8_t num_helipads_,
const uint8_t *entry_points_,
Flags flags_,
const AirportFTAbuildup *apFA,
byte delta_z_
uint8_t delta_z_
) :
moving_data(moving_data_),
terminals(terminals_),
@ -204,7 +204,7 @@ static AirportFTA *AirportBuildAutomata(uint nofelements, const AirportFTAbuildu
* @param airport_type %Airport type to query FTA from. @see AirportTypes
* @return Finite state machine of the airport.
*/
const AirportFTAClass *GetAirport(const byte airport_type)
const AirportFTAClass *GetAirport(const uint8_t airport_type)
{
if (airport_type == AT_DUMMY) return &_airportfta_dummy;
return AirportSpec::Get(airport_type)->fsm;
@ -215,7 +215,7 @@ const AirportFTAClass *GetAirport(const byte airport_type)
* @param hangar_tile The tile on which the vehicle is build
* @return The position (index in airport node array) where the aircraft ends up
*/
byte GetVehiclePosOnBuild(TileIndex hangar_tile)
uint8_t GetVehiclePosOnBuild(TileIndex hangar_tile)
{
const Station *st = Station::GetByTile(hangar_tile);
const AirportFTAClass *apc = st->airport.GetFTA();

View File

@ -152,12 +152,12 @@ public:
AirportFTAClass(
const AirportMovingData *moving_data,
const byte *terminals,
const byte num_helipads,
const byte *entry_points,
const uint8_t *terminals,
const uint8_t num_helipads,
const uint8_t *entry_points,
Flags flags,
const AirportFTAbuildup *apFA,
byte delta_z
uint8_t delta_z
);
~AirportFTAClass();
@ -167,7 +167,7 @@ public:
* @param position Element number to get movement data about.
* @return Pointer to the movement data.
*/
const AirportMovingData *MovingData(byte position) const
const AirportMovingData *MovingData(uint8_t position) const
{
assert(position < nofelements);
return &moving_data[position];
@ -175,12 +175,12 @@ public:
const AirportMovingData *moving_data; ///< Movement data.
struct AirportFTA *layout; ///< state machine for airport
const byte *terminals; ///< %Array with the number of terminal groups, followed by the number of terminals in each group.
const byte num_helipads; ///< Number of helipads on this airport. When 0 helicopters will go to normal terminals.
const uint8_t *terminals; ///< %Array with the number of terminal groups, followed by the number of terminals in each group.
const uint8_t num_helipads; ///< Number of helipads on this airport. When 0 helicopters will go to normal terminals.
Flags flags; ///< Flags for this airport type.
byte nofelements; ///< number of positions the airport consists of
const byte *entry_points; ///< when an airplane arrives at this airport, enter it at position entry_point, index depends on direction
byte delta_z; ///< Z adjustment for helicopter pads
uint8_t nofelements; ///< number of positions the airport consists of
const uint8_t *entry_points; ///< when an airplane arrives at this airport, enter it at position entry_point, index depends on direction
uint8_t delta_z; ///< Z adjustment for helicopter pads
};
DECLARE_ENUM_AS_BIT_SET(AirportFTAClass::Flags)
@ -190,12 +190,12 @@ DECLARE_ENUM_AS_BIT_SET(AirportFTAClass::Flags)
struct AirportFTA {
AirportFTA *next; ///< possible extra movement choices from this position
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
uint8_t position; ///< the position that an airplane is at
uint8_t next_position; ///< next position from this position
uint8_t heading; ///< heading (current orders), guiding an airplane to its target on an airport
};
const AirportFTAClass *GetAirport(const byte airport_type);
byte GetVehiclePosOnBuild(TileIndex hangar_tile);
const AirportFTAClass *GetAirport(const uint8_t airport_type);
uint8_t GetVehiclePosOnBuild(TileIndex hangar_tile);
#endif /* AIRPORT_H */

View File

@ -41,11 +41,11 @@
static AirportClassID _selected_airport_class; ///< the currently visible airport class
static int _selected_airport_index; ///< the index of the selected airport in the current class or -1
static byte _selected_airport_layout; ///< selected airport layout number.
static uint8_t _selected_airport_layout; ///< selected airport layout number.
static void ShowBuildAirportPicker(Window *parent);
SpriteID GetCustomAirportSprite(const AirportSpec *as, byte layout);
SpriteID GetCustomAirportSprite(const AirportSpec *as, uint8_t layout);
void CcBuildAirport(Commands, const CommandCost &result, TileIndex tile)
{
@ -63,8 +63,8 @@ static void PlaceAirport(TileIndex tile)
{
if (_selected_airport_index == -1) return;
byte airport_type = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index)->GetIndex();
byte layout = _selected_airport_layout;
uint8_t airport_type = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index)->GetIndex();
uint8_t layout = _selected_airport_layout;
bool adjacent = _ctrl_pressed;
auto proc = [=](bool test, StationID to_join) -> bool {
@ -347,7 +347,7 @@ public:
for (int i = 0; i < NUM_AIRPORTS; i++) {
const AirportSpec *as = AirportSpec::Get(i);
if (!as->enabled) continue;
for (byte layout = 0; layout < as->num_table; layout++) {
for (uint8_t layout = 0; layout < as->num_table; layout++) {
SpriteID sprite = GetCustomAirportSprite(as, layout);
if (sprite != 0) {
Dimension d = GetSpriteSize(sprite);
@ -363,7 +363,7 @@ public:
for (int i = NEW_AIRPORT_OFFSET; i < NUM_AIRPORTS; i++) {
const AirportSpec *as = AirportSpec::Get(i);
if (!as->enabled) continue;
for (byte layout = 0; layout < as->num_table; layout++) {
for (uint8_t layout = 0; layout < as->num_table; layout++) {
StringID string = GetAirportTextCallback(as, layout, CBID_AIRPORT_ADDITIONAL_TEXT);
if (string == STR_UNDEFINED) continue;

View File

@ -362,7 +362,7 @@ static CommandCost BuildReplacementVehicle(Vehicle *old_veh, Vehicle **new_vehic
/* Refit the vehicle if needed */
if (refit_cargo != CARGO_NO_REFIT) {
byte subtype = GetBestFittingSubType(old_veh, new_veh, refit_cargo);
uint8_t subtype = GetBestFittingSubType(old_veh, new_veh, refit_cargo);
cost.AddCost(std::get<0>(Command<CMD_REFIT_VEHICLE>::Do(DC_EXEC, new_veh->index, refit_cargo, subtype, false, false, 0)));
assert(cost.Succeeded()); // This should be ensured by GetNewCargoTypeForReplace()

View File

@ -85,7 +85,7 @@ class ReplaceVehicleWindow : public Window {
bool reset_sel_engine; ///< Also reset #sel_engine while updating left and/or right and no valid engine selected.
GroupID sel_group; ///< Group selected to replace.
int details_height; ///< Minimal needed height of the details panels, in text lines (found so far).
byte sort_criteria; ///< Criteria of sorting vehicles.
uint8_t sort_criteria; ///< Criteria of sorting vehicles.
bool descending_sort_order; ///< Order of sorting vehicles.
bool show_hidden_engines; ///< Whether to show the hidden engines.
RailType sel_railtype; ///< Type of rail tracks selected. #INVALID_RAILTYPE to show all.
@ -143,7 +143,7 @@ class ReplaceVehicleWindow : public Window {
std::vector<EngineID> variants;
EngineID selected_engine = INVALID_ENGINE;
VehicleType type = (VehicleType)this->window_number;
byte side = draw_left ? 0 : 1;
uint8_t side = draw_left ? 0 : 1;
GUIEngineList list;
@ -607,7 +607,7 @@ public:
case WID_RV_LEFT_MATRIX:
case WID_RV_RIGHT_MATRIX: {
byte click_side;
uint8_t click_side;
if (widget == WID_RV_LEFT_MATRIX) {
click_side = 0;
} else {

View File

@ -314,7 +314,7 @@ static const uint NUM_SONGS_PLAYLIST = 32;
/* Functions to read DOS music CAT files, similar to but not quite the same as sound effect CAT files */
char *GetMusicCatEntryName(const std::string &filename, size_t entrynum);
byte *GetMusicCatEntryData(const std::string &filename, size_t entrynum, size_t &entrylen);
uint8_t *GetMusicCatEntryData(const std::string &filename, size_t entrynum, size_t &entrylen);
enum MusicTrackType {
MTT_STANDARDMIDI, ///< Standard MIDI file
@ -324,7 +324,7 @@ enum MusicTrackType {
/** Metadata about a music track. */
struct MusicSongInfo {
std::string songname; ///< name of song displayed in UI
byte tracknr; ///< track number of song displayed in UI
uint8_t tracknr; ///< track number of song displayed in UI
std::string filename; ///< file on disk containing song (when used in MusicSet class)
MusicTrackType filetype; ///< decoder required for song file
int cat_index; ///< entry index in CAT file, for filetype==MTT_MPSMIDI
@ -338,7 +338,7 @@ struct MusicSet : BaseSet<MusicSet, NUM_SONGS_AVAILABLE, false> {
/** Data about individual songs in set. */
MusicSongInfo songinfo[NUM_SONGS_AVAILABLE];
/** Number of valid songs in set. */
byte num_available;
uint8_t num_available;
bool FillSetDetails(const IniFile &ini, const std::string &path, const std::string &full_filename);
};

View File

@ -59,7 +59,7 @@ struct StationRect : public Rect {
struct BaseStation : StationPool::PoolItem<&_station_pool> {
TileIndex xy; ///< Base tile of the station
TrackedViewportSign sign; ///< NOSAVE: Dimensions of sign
byte delete_ctr; ///< Delete counter. If greater than 0 then it is decremented until it reaches 0; the waypoint is then is deleted.
uint8_t delete_ctr; ///< Delete counter. If greater than 0 then it is decremented until it reaches 0; the waypoint is then is deleted.
std::string name; ///< Custom name
StringID string_id; ///< Default name (town area) of station
@ -75,7 +75,7 @@ struct BaseStation : StationPool::PoolItem<&_station_pool> {
TimerGameCalendar::Date build_date; ///< Date of construction
uint16_t random_bits; ///< Random bits assigned to this station
byte waiting_triggers; ///< Waiting triggers (NewGRF) for this station
uint8_t waiting_triggers; ///< Waiting triggers (NewGRF) for this station
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
@ -113,7 +113,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_t GetNewGRFVariable(const struct ResolverObject &object, byte variable, byte parameter, bool *available) const = 0;
virtual uint32_t GetNewGRFVariable(const struct ResolverObject &object, uint8_t variable, uint8_t parameter, bool *available) const = 0;
/**
* Update the coordinated of the sign (as shown in the viewport).
@ -179,7 +179,7 @@ struct BaseStation : StationPool::PoolItem<&_station_pool> {
return (this->facilities & ~FACIL_WAYPOINT) != 0;
}
inline byte GetRoadStopRandomBits(TileIndex tile) const
inline uint8_t GetRoadStopRandomBits(TileIndex tile) const
{
for (const RoadStopTileData &tile_data : this->custom_roadstop_tile_data) {
if (tile_data.tile == tile) return tile_data.random_bits;
@ -187,7 +187,7 @@ struct BaseStation : StationPool::PoolItem<&_station_pool> {
return 0;
}
inline byte GetRoadStopAnimationFrame(TileIndex tile) const
inline uint8_t GetRoadStopAnimationFrame(TileIndex tile) const
{
for (const RoadStopTileData &tile_data : this->custom_roadstop_tile_data) {
if (tile_data.tile == tile) return tile_data.animation_frame;
@ -196,11 +196,11 @@ struct BaseStation : StationPool::PoolItem<&_station_pool> {
}
private:
void SetRoadStopTileData(TileIndex tile, byte data, bool animation);
void SetRoadStopTileData(TileIndex tile, uint8_t data, bool animation);
public:
inline void SetRoadStopRandomBits(TileIndex tile, byte random_bits) { this->SetRoadStopTileData(tile, random_bits, false); }
inline void SetRoadStopAnimationFrame(TileIndex tile, byte frame) { this->SetRoadStopTileData(tile, frame, true); }
inline void SetRoadStopRandomBits(TileIndex tile, uint8_t random_bits) { this->SetRoadStopTileData(tile, random_bits, false); }
inline void SetRoadStopAnimationFrame(TileIndex tile, uint8_t frame) { this->SetRoadStopTileData(tile, frame, true); }
void RemoveRoadStopTileData(TileIndex tile);
static void PostDestructor(size_t index);

View File

@ -34,23 +34,23 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
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_t *)src_px);
src_n = (const uint16_t *)((const byte *)src_n + *(const uint32_t *)src_n);
src_px = (const Colour *)((const uint8_t *)src_px + *(const uint32_t *)src_px);
src_n = (const uint16_t *)((const uint8_t *)src_n + *(const uint32_t *)src_n);
}
Colour *dst = (Colour *)bp->dst + bp->top * bp->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
const uint8_t *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_t *anim_ln = anim + this->anim_buf_pitch;
const Colour *src_px_ln = (const Colour *)((const byte *)src_px + *(const uint32_t *)src_px);
const Colour *src_px_ln = (const Colour *)((const uint8_t *)src_px + *(const uint32_t *)src_px);
src_px++;
const uint16_t *src_n_ln = (const uint16_t *)((const byte *)src_n + *(const uint32_t *)src_n);
const uint16_t *src_n_ln = (const uint16_t *)((const uint8_t *)src_n + *(const uint32_t *)src_n);
src_n += 2;
Colour *dst_end = dst + bp->skip_left;

View File

@ -33,7 +33,7 @@ template <BlitterMode mode, Blitter_32bppSSE2::ReadMode read_mode, Blitter_32bpp
GNU_TARGET("sse4.1")
inline void Blitter_32bppSSE4_Anim::Draw(const BlitterParams *bp, ZoomLevel zoom)
{
const byte * const remap = bp->remap;
const uint8_t * const remap = bp->remap;
Colour *dst_line = (Colour *) bp->dst + bp->top * bp->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;
@ -42,7 +42,7 @@ inline void Blitter_32bppSSE4_Anim::Draw(const BlitterParams *bp, ZoomLevel zoom
const Blitter_32bppSSE_Base::SpriteData * const sd = (const Blitter_32bppSSE_Base::SpriteData *) bp->sprite;
const SpriteInfo * const si = &sd->infos[zoom];
const MapValue *src_mv_line = (const MapValue *) &sd->data[si->mv_offset] + bp->skip_top * si->sprite_width;
const Colour *src_rgba_line = (const Colour *) ((const byte *) &sd->data[si->sprite_offset] + bp->skip_top * si->sprite_line_size);
const Colour *src_rgba_line = (const Colour *) ((const uint8_t *) &sd->data[si->sprite_offset] + bp->skip_top * si->sprite_line_size);
if (read_mode != RM_WITH_MARGIN) {
src_rgba_line += bp->skip_left;
@ -104,20 +104,20 @@ inline void Blitter_32bppSSE4_Anim::Draw(const BlitterParams *bp, ZoomLevel zoom
if (animated) {
/* Remap colours. */
const byte m0 = mvX2;
const uint8_t m0 = mvX2;
if (m0 >= PALETTE_ANIM_START) {
const Colour c0 = (this->LookupColourInPalette(m0).data & 0x00FFFFFF) | (src[0].data & 0xFF000000);
InsertFirstUint32(AdjustBrightneSSE(c0, (byte) (mvX2 >> 8)).data, srcABCD);
InsertFirstUint32(AdjustBrightneSSE(c0, (uint8_t) (mvX2 >> 8)).data, srcABCD);
}
const byte m1 = mvX2 >> 16;
const uint8_t m1 = mvX2 >> 16;
if (m1 >= PALETTE_ANIM_START) {
const Colour c1 = (this->LookupColourInPalette(m1).data & 0x00FFFFFF) | (src[1].data & 0xFF000000);
InsertSecondUint32(AdjustBrightneSSE(c1, (byte) (mvX2 >> 24)).data, srcABCD);
InsertSecondUint32(AdjustBrightneSSE(c1, (uint8_t) (mvX2 >> 24)).data, srcABCD);
}
/* Update anim buffer. */
const byte a0 = src[0].a;
const byte a1 = src[1].a;
const uint8_t a0 = src[0].a;
const uint8_t a1 = src[1].a;
uint32_t anim01 = 0;
if (a0 == 255) {
if (a1 == 255) {
@ -185,9 +185,9 @@ bmno_full_transparency:
__m128i dstABCD = _mm_loadl_epi64((__m128i*) dst);
/* Remap colours. */
const uint m0 = (byte) mvX2;
const uint m0 = (uint8_t) mvX2;
const uint r0 = remap[m0];
const uint m1 = (byte) (mvX2 >> 16);
const uint m1 = (uint8_t) (mvX2 >> 16);
const uint r1 = remap[m1];
if (mvX2 & 0x00FF00FF) {
#define CMOV_REMAP(m_colour, m_colour_init, m_src, m_m) \
@ -195,7 +195,7 @@ bmno_full_transparency:
Colour m_colour = m_colour_init; \
{ \
const Colour srcm = (Colour) (m_src); \
const uint m = (byte) (m_m); \
const uint m = (uint8_t) (m_m); \
const uint r = remap[m]; \
const Colour cmap = (this->LookupColourInPalette(r).data & 0x00FFFFFF) | (srcm.data & 0xFF000000); \
m_colour = r == 0 ? m_colour : cmap; \
@ -225,8 +225,8 @@ bmno_full_transparency:
/* Update anim buffer. */
if (animated) {
const byte a0 = src[0].a;
const byte a1 = src[1].a;
const uint8_t a0 = src[0].a;
const uint8_t a1 = src[1].a;
uint32_t anim01 = mvX2 & 0xFF00FF00;
if (a0 == 255) {
anim01 |= r0;
@ -368,7 +368,7 @@ bmcr_alpha_blend_single:
next_line:
if (mode != BM_TRANSPARENT && mode != BM_TRANSPARENT_REMAP) src_mv_line += si->sprite_width;
src_rgba_line = (const Colour*) ((const byte*) src_rgba_line + si->sprite_line_size);
src_rgba_line = (const Colour*) ((const uint8_t*) src_rgba_line + si->sprite_line_size);
dst_line += bp->pitch;
anim_line += this->anim_buf_pitch;
}

View File

@ -40,26 +40,26 @@ inline void Blitter_32bppOptimized::Draw(const Blitter::BlitterParams *bp, ZoomL
/* 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_t *)src_px);
src_n = (const uint16_t *)((const byte *)src_n + *(const uint32_t *)src_n);
src_px = (const Colour *)((const uint8_t *)src_px + *(const uint32_t *)src_px);
src_n = (const uint16_t *)((const uint8_t *)src_n + *(const uint32_t *)src_n);
}
/* skip lines in dst */
Colour *dst = (Colour *)bp->dst + bp->top * bp->pitch + bp->left;
/* store so we don't have to access it via bp every time (compiler assumes pointer aliasing) */
const byte *remap = bp->remap;
const uint8_t *remap = bp->remap;
for (int y = 0; y < bp->height; y++) {
/* next dst line begins here */
Colour *dst_ln = dst + bp->pitch;
/* next src line begins here */
const Colour *src_px_ln = (const Colour *)((const byte *)src_px + *(const uint32_t *)src_px);
const Colour *src_px_ln = (const Colour *)((const uint8_t *)src_px + *(const uint32_t *)src_px);
src_px++;
/* next src_n line begins here */
const uint16_t *src_n_ln = (const uint16_t *)((const byte *)src_n + *(const uint32_t *)src_n);
const uint16_t *src_n_ln = (const uint16_t *)((const uint8_t *)src_n + *(const uint32_t *)src_n);
src_n += 2;
/* we will end this line when we reach this point */
@ -405,8 +405,8 @@ template <bool Tpal_to_rgb> Sprite *Blitter_32bppOptimized::EncodeInternal(const
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
lengths[z][1] = (byte *)dst_n_ln - (byte *)dst_n_orig[z];
lengths[z][0] = (uint8_t *)dst_px_ln - (uint8_t *)dst_px_orig[z]; // all are aligned to 4B boundary
lengths[z][1] = (uint8_t *)dst_n_ln - (uint8_t *)dst_n_orig[z];
}
uint len = 0; // total length of data

View File

@ -18,7 +18,7 @@ public:
/** Data stored about a (single) sprite. */
struct SpriteData {
uint32_t offset[ZOOM_LVL_END][2]; ///< Offsets (from .data) to streams for different zoom levels, and the normal and remap image information.
byte data[]; ///< Data, all zoomlevels.
uint8_t data[]; ///< Data, all zoomlevels.
};
void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override;

View File

@ -114,7 +114,7 @@ Sprite *Blitter_32bppSSE_Base::Encode(const SpriteLoader::SpriteCollection &spri
(*dst_rgba_line).data = nb_pix_transp;
Colour *nb_right = dst_rgba_line + 1;
dst_rgba_line = (Colour*) ((byte*) dst_rgba_line + sd.infos[z].sprite_line_size);
dst_rgba_line = (Colour*) ((uint8_t*) dst_rgba_line + sd.infos[z].sprite_line_size);
/* Count the number of transparent pixels from the right. */
dst_rgba = dst_rgba_line - 1;

View File

@ -73,7 +73,7 @@ public:
struct SpriteData {
SpriteFlags flags;
SpriteInfo infos[ZOOM_LVL_END];
byte data[]; ///< Data, all zoomlevels.
uint8_t data[]; ///< Data, all zoomlevels.
};
Sprite *Encode(const SpriteLoader::SpriteCollection &sprite, AllocatorProc *allocator);

View File

@ -214,7 +214,7 @@ inline void Blitter_32bppSSSE3::Draw(const Blitter::BlitterParams *bp, ZoomLevel
inline void Blitter_32bppSSE4::Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom)
#endif
{
const byte * const remap = bp->remap;
const uint8_t * const remap = bp->remap;
Colour *dst_line = (Colour *) bp->dst + bp->top * bp->pitch + bp->left;
int effective_width = bp->width;
@ -222,7 +222,7 @@ inline void Blitter_32bppSSE4::Draw(const Blitter::BlitterParams *bp, ZoomLevel
const SpriteData * const sd = (const SpriteData *) bp->sprite;
const SpriteInfo * const si = &sd->infos[zoom];
const MapValue *src_mv_line = (const MapValue *) &sd->data[si->mv_offset] + bp->skip_top * si->sprite_width;
const Colour *src_rgba_line = (const Colour *) ((const byte *) &sd->data[si->sprite_offset] + bp->skip_top * si->sprite_line_size);
const Colour *src_rgba_line = (const Colour *) ((const uint8_t *) &sd->data[si->sprite_offset] + bp->skip_top * si->sprite_line_size);
if (read_mode != RM_WITH_MARGIN) {
src_rgba_line += bp->skip_left;
@ -307,7 +307,7 @@ inline void Blitter_32bppSSE4::Draw(const Blitter::BlitterParams *bp, ZoomLevel
Colour m_colour = m_colour_init; \
{ \
const Colour srcm = (Colour) (m_src); \
const uint m = (byte) (m_m); \
const uint m = (uint8_t) (m_m); \
const uint r = remap[m]; \
const Colour cmap = (this->LookupColourInPalette(r).data & 0x00FFFFFF) | (srcm.data & 0xFF000000); \
m_colour = r == 0 ? m_colour : cmap; \
@ -435,7 +435,7 @@ bmcr_alpha_blend_single:
next_line:
if (mode == BM_COLOUR_REMAP || mode == BM_CRASH_REMAP) src_mv_line += si->sprite_width;
src_rgba_line = (const Colour*) ((const byte*) src_rgba_line + si->sprite_line_size);
src_rgba_line = (const Colour*) ((const uint8_t*) src_rgba_line + si->sprite_line_size);
dst_line += bp->pitch;
}
}

View File

@ -104,8 +104,8 @@ inline void Blitter_40bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
/* 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_t *)src_px);
src_n = (const uint16_t *)((const byte *)src_n + *(const uint32_t *)src_n);
src_px = (const Colour *)((const uint8_t *)src_px + *(const uint32_t *)src_px);
src_n = (const uint16_t *)((const uint8_t *)src_n + *(const uint32_t *)src_n);
}
/* skip lines in dst */
@ -114,7 +114,7 @@ inline void Blitter_40bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
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;
const uint8_t *remap = bp->remap;
for (int y = 0; y < bp->height; y++) {
/* next dst line begins here */
@ -122,11 +122,11 @@ inline void Blitter_40bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
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_t *)src_px);
const Colour *src_px_ln = (const Colour *)((const uint8_t *)src_px + *(const uint32_t *)src_px);
src_px++;
/* next src_n line begins here */
const uint16_t *src_n_ln = (const uint16_t *)((const byte *)src_n + *(const uint32_t *)src_n);
const uint16_t *src_n_ln = (const uint16_t *)((const uint8_t *)src_n + *(const uint32_t *)src_n);
src_n += 2;
/* we will end this line when we reach this point */

View File

@ -147,10 +147,10 @@ Sprite *Blitter_8bppOptimized::Encode(const SpriteLoader::SpriteCollection &spri
/* Don't allocate memory each time, but just keep some
* memory around as this function is called quite often
* and the memory usage is quite low. */
static ReusableBuffer<byte> temp_buffer;
static ReusableBuffer<uint8_t> temp_buffer;
SpriteData *temp_dst = (SpriteData *)temp_buffer.Allocate(memory);
memset(temp_dst, 0, sizeof(*temp_dst));
byte *dst = temp_dst->data;
uint8_t *dst = temp_dst->data;
/* Make the sprites per zoom-level */
for (ZoomLevel i = zoom_min; i <= zoom_max; i++) {
@ -166,7 +166,7 @@ Sprite *Blitter_8bppOptimized::Encode(const SpriteLoader::SpriteCollection &spri
uint trans = 0;
uint pixels = 0;
uint last_colour = 0;
byte *count_dst = nullptr;
uint8_t *count_dst = nullptr;
/* Store the scaled image */
const SpriteLoader::CommonPixel *src = &sprite[i].data[y * sprite[i].width];
@ -213,7 +213,7 @@ Sprite *Blitter_8bppOptimized::Encode(const SpriteLoader::SpriteCollection &spri
}
}
uint size = dst - (byte *)temp_dst;
uint size = dst - (uint8_t *)temp_dst;
/* Safety check, to make sure we guessed the size correctly */
assert(size < memory);

View File

@ -19,7 +19,7 @@ public:
/** Data stored about a (single) sprite. */
struct SpriteData {
uint32_t offset[ZOOM_LVL_END]; ///< Offsets (from .data) to streams for different zoom levels.
byte data[]; ///< Data, all zoomlevels.
uint8_t data[]; ///< Data, all zoomlevels.
};
void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override;

View File

@ -31,7 +31,7 @@ public:
/** Parameters related to blitting. */
struct BlitterParams {
const void *sprite; ///< Pointer to the sprite how ever the encoder stored it
const byte *remap; ///< XXX -- Temporary storage for remap array
const uint8_t *remap; ///< XXX -- Temporary storage for remap array
int skip_left; ///< How much pixels of the source to skip on the left (based on zoom of dst)
int skip_top; ///< How much pixels of the source to skip on the top (based on zoom of dst)

View File

@ -39,7 +39,7 @@ static inline bool EndOfBuffer(BmpBuffer *buffer)
return buffer->pos == buffer->read;
}
static inline byte ReadByte(BmpBuffer *buffer)
static inline uint8_t ReadByte(BmpBuffer *buffer)
{
if (buffer->read < 0) return 0;
@ -83,9 +83,9 @@ static inline void SetStreamOffset(BmpBuffer *buffer, int offset)
static inline bool BmpRead1(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
{
uint x, y, i;
byte pad = GB(4 - info->width / 8, 0, 2);
byte *pixel_row;
byte b;
uint8_t pad = GB(4 - info->width / 8, 0, 2);
uint8_t *pixel_row;
uint8_t b;
for (y = info->height; y > 0; y--) {
x = 0;
pixel_row = &data->bitmap[(y - 1) * info->width];
@ -110,9 +110,9 @@ static inline bool BmpRead1(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
static inline bool BmpRead4(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
{
uint x, y;
byte pad = GB(4 - info->width / 2, 0, 2);
byte *pixel_row;
byte b;
uint8_t pad = GB(4 - info->width / 2, 0, 2);
uint8_t *pixel_row;
uint8_t b;
for (y = info->height; y > 0; y--) {
x = 0;
pixel_row = &data->bitmap[(y - 1) * info->width];
@ -140,12 +140,12 @@ static inline bool BmpRead4Rle(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
{
uint x = 0;
uint y = info->height - 1;
byte *pixel = &data->bitmap[y * info->width];
uint8_t *pixel = &data->bitmap[y * info->width];
while (y != 0 || x < info->width) {
if (EndOfBuffer(buffer)) return false; // the file is shorter than expected
byte n = ReadByte(buffer);
byte c = ReadByte(buffer);
uint8_t n = ReadByte(buffer);
uint8_t c = ReadByte(buffer);
if (n == 0) {
switch (c) {
case 0: // end of line
@ -159,8 +159,8 @@ static inline bool BmpRead4Rle(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
case 2: { // delta
if (EndOfBuffer(buffer)) return false;
byte dx = ReadByte(buffer);
byte dy = ReadByte(buffer);
uint8_t dx = ReadByte(buffer);
uint8_t dy = ReadByte(buffer);
/* Check for over- and underflow. */
if (x + dx >= info->width || x + dx < x || dy > y) return false;
@ -175,7 +175,7 @@ static inline bool BmpRead4Rle(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
uint i = 0;
while (i++ < c) {
if (EndOfBuffer(buffer) || x >= info->width) return false;
byte b = ReadByte(buffer);
uint8_t b = ReadByte(buffer);
*pixel++ = GB(b, 4, 4);
x++;
if (i++ < c) {
@ -214,8 +214,8 @@ static inline bool BmpRead8(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
{
uint i;
uint y;
byte pad = GB(4 - info->width, 0, 2);
byte *pixel;
uint8_t pad = GB(4 - info->width, 0, 2);
uint8_t *pixel;
for (y = info->height; y > 0; y--) {
if (EndOfBuffer(buffer)) return false; // the file is shorter than expected
pixel = &data->bitmap[(y - 1) * info->width];
@ -233,12 +233,12 @@ static inline bool BmpRead8Rle(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
{
uint x = 0;
uint y = info->height - 1;
byte *pixel = &data->bitmap[y * info->width];
uint8_t *pixel = &data->bitmap[y * info->width];
while (y != 0 || x < info->width) {
if (EndOfBuffer(buffer)) return false; // the file is shorter than expected
byte n = ReadByte(buffer);
byte c = ReadByte(buffer);
uint8_t n = ReadByte(buffer);
uint8_t c = ReadByte(buffer);
if (n == 0) {
switch (c) {
case 0: // end of line
@ -252,8 +252,8 @@ static inline bool BmpRead8Rle(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
case 2: { // delta
if (EndOfBuffer(buffer)) return false;
byte dx = ReadByte(buffer);
byte dy = ReadByte(buffer);
uint8_t dx = ReadByte(buffer);
uint8_t dy = ReadByte(buffer);
/* Check for over- and underflow. */
if (x + dx >= info->width || x + dx < x || dy > y) return false;
@ -294,8 +294,8 @@ static inline bool BmpRead8Rle(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
static inline bool BmpRead24(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
{
uint x, y;
byte pad = GB(4 - info->width * 3, 0, 2);
byte *pixel_row;
uint8_t pad = GB(4 - info->width * 3, 0, 2);
uint8_t *pixel_row;
for (y = info->height; y > 0; y--) {
pixel_row = &data->bitmap[(y - 1) * info->width * 3];
for (x = 0; x < info->width; x++) {
@ -395,7 +395,7 @@ bool BmpReadBitmap(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
{
assert(info != nullptr && data != nullptr);
data->bitmap = CallocT<byte>(static_cast<size_t>(info->width) * info->height * ((info->bpp == 24) ? 3 : 1));
data->bitmap = CallocT<uint8_t>(static_cast<size_t>(info->width) * info->height * ((info->bpp == 24) ? 3 : 1));
/* Load image */
SetStreamOffset(buffer, info->offset);

View File

@ -24,13 +24,13 @@ struct BmpInfo {
struct BmpData {
Colour *palette;
byte *bitmap;
uint8_t *bitmap;
};
#define BMP_BUFFER_SIZE 1024
struct BmpBuffer {
byte data[BMP_BUFFER_SIZE];
uint8_t data[BMP_BUFFER_SIZE];
int pos;
int read;
FILE *file;

View File

@ -41,7 +41,7 @@ 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)
uint8_t min_length; ///< the minimum length (not counting start and end tile)
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)
@ -50,7 +50,7 @@ struct BridgeSpec {
StringID material; ///< the string that contains the bridge description
StringID transport_name[2]; ///< description of the bridge, when built for road or rail
PalSpriteID **sprite_table; ///< table of sprites for drawing the bridge
byte flags; ///< bit 0 set: disable drawing of far pillars.
uint8_t flags; ///< bit 0 set: disable drawing of far pillars.
};
extern BridgeSpec _bridge[MAX_BRIDGES];

View File

@ -54,7 +54,7 @@ typedef GUIList<BuildBridgeData> GUIBridgeList; ///< List of bridges, used in #B
* @param tile_start start tile
* @param transport_type transport type.
*/
void CcBuildBridge(Commands, const CommandCost &result, TileIndex end_tile, TileIndex tile_start, TransportType transport_type, BridgeType, byte)
void CcBuildBridge(Commands, const CommandCost &result, TileIndex end_tile, TileIndex tile_start, TransportType transport_type, BridgeType, uint8_t)
{
if (result.Failed()) return;
if (_settings_client.sound.confirm) SndPlayTileFx(SND_27_CONSTRUCTION_BRIDGE, end_tile);
@ -82,7 +82,7 @@ private:
TileIndex start_tile;
TileIndex end_tile;
TransportType transport_type;
byte road_rail_type;
uint8_t road_rail_type;
GUIBridgeList bridges;
int icon_width; ///< Scaled width of the the bridge icon sprite.
Scrollbar *vscroll;
@ -147,7 +147,7 @@ private:
}
public:
BuildBridgeWindow(WindowDesc *desc, TileIndex start, TileIndex end, TransportType transport_type, byte road_rail_type, GUIBridgeList &&bl) : Window(desc),
BuildBridgeWindow(WindowDesc *desc, TileIndex start, TileIndex end, TransportType transport_type, uint8_t road_rail_type, GUIBridgeList &&bl) : Window(desc),
start_tile(start),
end_tile(end),
transport_type(transport_type),
@ -358,7 +358,7 @@ static WindowDesc _build_bridge_desc(
* @param transport_type The transport type
* @param road_rail_type The road/rail type
*/
void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transport_type, byte road_rail_type)
void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transport_type, uint8_t road_rail_type)
{
CloseWindowByClass(WC_BUILD_BRIDGE);

View File

@ -95,7 +95,7 @@ static constexpr NWidgetPart _nested_build_vehicle_widgets[] = {
bool _engine_sort_direction; ///< \c false = descending, \c true = ascending.
byte _engine_sort_last_criteria[] = {0, 0, 0, 0}; ///< Last set sort criteria, for each vehicle type.
uint8_t _engine_sort_last_criteria[] = {0, 0, 0, 0}; ///< Last set sort criteria, for each vehicle type.
bool _engine_sort_last_order[] = {false, false, false, false}; ///< Last set direction of the sort order, for each vehicle type.
bool _engine_sort_show_hidden_engines[] = {false, false, false, false}; ///< Last set 'show hidden engines' setting for each vehicle type.
static CargoID _engine_sort_last_cargo_criteria[] = {CargoFilterCriteria::CF_ANY, CargoFilterCriteria::CF_ANY, CargoFilterCriteria::CF_ANY, CargoFilterCriteria::CF_ANY}; ///< Last set filter criteria, for each vehicle type.
@ -1126,7 +1126,7 @@ struct BuildVehicleWindow : Window {
RoadType roadtype; ///< Road type to show, or #INVALID_ROADTYPE.
} filter; ///< Filter to apply.
bool descending_sort_order; ///< Sort direction, @see _engine_sort_direction
byte sort_criteria; ///< Current sort criterium.
uint8_t sort_criteria; ///< Current sort criterium.
bool show_hidden_engines; ///< State of the 'show hidden engines' button.
bool listview_mode; ///< If set, only display the available vehicles and do not show a 'build' button.
EngineID sel_engine; ///< Currently selected engine, or #INVALID_ENGINE

View File

@ -19,7 +19,7 @@ using CargoLabel = StrongType::Typedef<uint32_t, struct CargoLabelTag, StrongTyp
/**
* Cargo slots to indicate a cargo type within a game.
*/
using CargoID = byte;
using CargoID = uint8_t;
/**
* Available types of cargo
@ -134,7 +134,7 @@ struct CargoArray : std::array<uint, NUM_CARGO> {
/** Types of cargo source and destination */
enum class SourceType : byte {
enum class SourceType : uint8_t {
Industry, ///< Source/destination is an industry
Town, ///< Source/destination is a town
Headquarters, ///< Source/destination are company headquarters

View File

@ -18,7 +18,7 @@
#include "core/bitmath_func.hpp"
/** Town growth effect when delivering cargo. */
enum TownAcceptanceEffect : byte {
enum TownAcceptanceEffect : uint8_t {
TAE_BEGIN = 0,
TAE_NONE = TAE_BEGIN, ///< Cargo has no effect.
TAE_PASSENGERS, ///< Cargo behaves passenger-like.
@ -31,7 +31,7 @@ enum TownAcceptanceEffect : byte {
};
/** Town effect when producing cargo. */
enum TownProductionEffect : byte {
enum TownProductionEffect : uint8_t {
TPE_NONE, ///< Town will not produce this cargo type.
TPE_PASSENGERS, ///< Cargo behaves passenger-like for production.
TPE_MAIL, ///< Cargo behaves mail-like for production.
@ -60,7 +60,7 @@ enum CargoClass {
CC_SPECIAL = 1 << 15, ///< Special bit used for livery refit tricks instead of normal cargoes.
};
static const byte INVALID_CARGO_BITNUM = 0xFF; ///< Constant representing invalid cargo
static const uint8_t INVALID_CARGO_BITNUM = 0xFF; ///< Constant representing invalid cargo
static const uint TOWN_PRODUCTION_DIVISOR = 256;

View File

@ -44,7 +44,7 @@ static CommandCost ClearTile_Clear(TileIndex tile, DoCommandFlag flags)
return price;
}
void DrawClearLandTile(const TileInfo *ti, byte set)
void DrawClearLandTile(const TileInfo *ti, uint8_t set)
{
DrawGroundSprite(SPR_FLAT_BARE_LAND + SlopeToSpriteOffset(ti->tileh) + set * 19, PAL_NONE);
}

View File

@ -13,6 +13,6 @@
#include "tile_cmd.h"
void DrawHillyLandTile(const TileInfo *ti);
void DrawClearLandTile(const TileInfo *ti, byte set);
void DrawClearLandTile(const TileInfo *ti, uint8_t set);
#endif /* CLEAR_FUNC_H */

View File

@ -462,7 +462,7 @@ template <Commands Tcmd> struct CommandTraits;
};
/** Storage buffer for serialized command data. */
typedef std::vector<byte> CommandDataBuffer;
typedef std::vector<uint8_t> CommandDataBuffer;
/**
* Define a callback function for the client, after the command is finished.

View File

@ -78,20 +78,20 @@ struct CompanyProperties {
CompanyManagerFace face; ///< Face description of the president.
Money money; ///< Money owned by the company.
byte money_fraction; ///< Fraction of money of the company, too small to represent in #money.
uint8_t money_fraction; ///< Fraction of money of the company, too small to represent in #money.
Money current_loan; ///< Amount of money borrowed from the bank.
Money max_loan; ///< Max allowed amount of the loan or COMPANY_MAX_LOAN_DEFAULT.
Colours colour; ///< Company colour.
byte block_preview; ///< Number of quarters that the company is not allowed to get new exclusive engine previews (see CompaniesGenStatistics).
uint8_t block_preview; ///< Number of quarters that the company is not allowed to get new exclusive engine previews (see CompaniesGenStatistics).
TileIndex location_of_HQ; ///< Northern tile of HQ; #INVALID_TILE when there is none.
TileIndex last_build_coordinate; ///< Coordinate of the last build thing by this company.
TimerGameEconomy::Year inaugurated_year; ///< Economy year of starting the company.
byte months_of_bankruptcy; ///< Number of months that the company is unable to pay its debts
uint8_t 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_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;
@ -110,7 +110,7 @@ struct CompanyProperties {
std::array<Expenses, 3> yearly_expenses{}; ///< Expenses of the company for the last three years.
CompanyEconomyEntry cur_economy; ///< Economic data of the company of this quarter.
CompanyEconomyEntry old_economy[MAX_HISTORY_QUARTERS]; ///< Economic data of the company of the last #MAX_HISTORY_QUARTERS quarters.
byte num_valid_stat_ent; ///< Number of valid statistical entries in #old_economy.
uint8_t num_valid_stat_ent; ///< Number of valid statistical entries in #old_economy.
Livery livery[LS_END];

View File

@ -298,10 +298,10 @@ void SubtractMoneyFromCompany(const CommandCost &cost)
void SubtractMoneyFromCompanyFract(CompanyID company, const CommandCost &cst)
{
Company *c = Company::Get(company);
byte m = c->money_fraction;
uint8_t m = c->money_fraction;
Money cost = cst.GetCost();
c->money_fraction = m - (byte)cost;
c->money_fraction = m - (uint8_t)cost;
cost >>= 8;
if (c->money_fraction > m) cost++;
if (cost != 0) SubtractMoneyFromAnyCompany(c, CommandCost(cst.GetExpensesType(), cost));
@ -447,7 +447,7 @@ bad_town_name:;
}
/** Sorting weights for the company colours. */
static const byte _colour_sort[COLOUR_END] = {2, 2, 3, 2, 3, 2, 3, 2, 3, 2, 2, 2, 3, 1, 1, 1};
static const uint8_t _colour_sort[COLOUR_END] = {2, 2, 3, 2, 3, 2, 3, 2, 3, 2, 2, 2, 3, 1, 1, 1};
/** Similar colours, so we can try to prevent same coloured companies. */
static const Colours _similar_colour[COLOUR_END][2] = {
{ COLOUR_BLUE, COLOUR_LIGHT_BLUE }, // COLOUR_DARK_BLUE

View File

@ -15,7 +15,7 @@
#include "livery.h"
enum ClientID : uint32_t;
enum Colours : byte;
enum Colours : uint8_t;
CommandCost CmdCompanyCtrl(DoCommandFlag flags, CompanyCtrlAction cca, CompanyID company_id, CompanyRemoveReason reason, ClientID client_id);
CommandCost CmdGiveMoney(DoCommandFlag flags, Money money, CompanyID dest_company);

View File

@ -610,7 +610,7 @@ private:
uint32_t used_colours = 0;
const Livery *livery, *default_livery = nullptr;
bool primary = widget == WID_SCL_PRI_COL_DROPDOWN;
byte default_col = 0;
uint8_t default_col = 0;
/* Disallow other company colours for the primary colour */
if (this->livery_class < LC_GROUP_RAIL && HasBit(this->sel, LS_DEFAULT) && primary) {
@ -651,7 +651,7 @@ private:
list.push_back(std::make_unique<DropDownListColourItem<>>(i, HasBit(used_colours, i)));
}
byte sel;
uint8_t sel;
if (default_livery == nullptr || HasBit(livery->in_use, primary ? 0 : 1)) {
sel = primary ? livery->colour1 : livery->colour2;
} else {
@ -2524,7 +2524,7 @@ struct CompanyWindow : Window
}
case WID_C_BUILD_HQ:
if ((byte)this->window_number != _local_company) return;
if ((uint8_t)this->window_number != _local_company) return;
if (this->IsWidgetLowered(WID_C_BUILD_HQ)) {
ResetObjectToPlace();
this->RaiseButtons();

View File

@ -54,9 +54,9 @@ DECLARE_POSTFIX_INCREMENT(CompanyManagerFaceVariable)
/** Information about the valid values of CompanyManagerFace bitgroups as well as the sprites to draw */
struct CompanyManagerFaceBitsInfo {
byte offset; ///< Offset in bits into the CompanyManagerFace
byte length; ///< Number of bits used in the CompanyManagerFace
byte valid_values[GE_END]; ///< The number of valid values per gender/ethnicity
uint8_t offset; ///< Offset in bits into the CompanyManagerFace
uint8_t length; ///< Number of bits used in the CompanyManagerFace
uint8_t valid_values[GE_END]; ///< The number of valid values per gender/ethnicity
SpriteID first_sprite[GE_END]; ///< The first sprite per gender/ethnicity
};

View File

@ -15,7 +15,7 @@
/**
* Enum for all companies/owners.
*/
enum Owner : byte {
enum Owner : uint8_t {
/* All companies below MAX_COMPANIES are playable
* companies, above, they are special, computer controlled 'companies' */
OWNER_BEGIN = 0x00, ///< First owner

View File

@ -206,7 +206,7 @@ static std::string RemoveUnderscores(std::string name)
* @param tokencount the number of parameters passed
* @param *tokens are the parameters given to the original command (0 is the first param)
*/
static void IConsoleAliasExec(const IConsoleAlias *alias, byte tokencount, char *tokens[ICON_TOKEN_COUNT], const uint recurse_count)
static void IConsoleAliasExec(const IConsoleAlias *alias, uint8_t tokencount, char *tokens[ICON_TOKEN_COUNT], const uint recurse_count)
{
std::string alias_buffer;

View File

@ -89,7 +89,7 @@ static ConsoleFileList _console_file_list_scenario{FT_SCENARIO, false}; ///< Fil
static ConsoleFileList _console_file_list_heightmap{FT_HEIGHTMAP, false}; ///< File storage cache for heightmaps.
/* console command defines */
#define DEF_CONSOLE_CMD(function) static bool function([[maybe_unused]] byte argc, [[maybe_unused]] char *argv[])
#define DEF_CONSOLE_CMD(function) static bool function([[maybe_unused]] uint8_t argc, [[maybe_unused]] char *argv[])
#define DEF_CONSOLE_HOOK(function) static ConsoleHookResult function(bool echo)
@ -2113,7 +2113,7 @@ DEF_CONSOLE_CMD(ConFont)
uint size = setting->size;
bool aa = setting->aa;
byte arg_index = 2;
uint8_t arg_index = 2;
/* We may encounter "aa" or "noaa" but it must be the last argument. */
if (StrEqualsIgnoreCase(argv[arg_index], "aa") || StrEqualsIgnoreCase(argv[arg_index], "noaa")) {
aa = !StrStartsWithIgnoreCase(argv[arg_index++], "no");

View File

@ -30,7 +30,7 @@ enum ConsoleHookResult {
* If you want to handle multiple words as one, enclose them in double-quotes
* eg. 'say "hello everybody"'
*/
typedef bool IConsoleCmdProc(byte argc, char *argv[]);
typedef bool IConsoleCmdProc(uint8_t argc, char *argv[]);
typedef ConsoleHookResult IConsoleHook(bool echo);
struct IConsoleCmd {
IConsoleCmd(const std::string &name, IConsoleCmdProc *proc, IConsoleHook *hook) : name(name), proc(proc), hook(hook) {}

View File

@ -93,14 +93,14 @@ public:
* @param size the amount of bytes to allocate.
* @return the given amounts of bytes zeroed.
*/
inline void *operator new(size_t size) { return CallocT<byte>(size); }
inline void *operator new(size_t size) { return CallocT<uint8_t>(size); }
/**
* Memory allocator for an array of class instances.
* @param size the amount of bytes to allocate.
* @return the given amounts of bytes zeroed.
*/
inline void *operator new[](size_t size) { return CallocT<byte>(size); }
inline void *operator new[](size_t size) { return CallocT<uint8_t>(size); }
/**
* Memory release for a single class instance.

View File

@ -46,7 +46,7 @@ inline void MemMoveT(T *destination, const T *source, size_t num = 1)
* @param num number of items to be set (!not number of bytes!)
*/
template <typename T>
inline void MemSetT(T *ptr, byte value, size_t num = 1)
inline void MemSetT(T *ptr, uint8_t value, size_t num = 1)
{
memset(ptr, value, num * sizeof(T));
}

View File

@ -140,7 +140,7 @@ public:
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; }
inline constexpr OverflowSafeInt operator * (const uint8_t factor) const { OverflowSafeInt result = *this; result *= (int64_t)factor; return result; }
/* Operators for division. */
inline constexpr OverflowSafeInt& operator /= (const int64_t divisor) { this->m_value /= divisor; return *this; }
@ -200,10 +200,10 @@ template <class T> inline constexpr OverflowSafeInt<T> operator * (const uint a
template <class T> inline constexpr OverflowSafeInt<T> operator / (const uint a, const OverflowSafeInt<T> b) { return (OverflowSafeInt<T>)a / (int)b; }
/* Sometimes we got byte operator OverflowSafeInt instead of vice versa. Handle that properly. */
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 -b + (uint)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; }
template <class T> inline constexpr OverflowSafeInt<T> operator + (const uint8_t a, const OverflowSafeInt<T> b) { return b + (uint)a; }
template <class T> inline constexpr OverflowSafeInt<T> operator - (const uint8_t a, const OverflowSafeInt<T> b) { return -b + (uint)a; }
template <class T> inline constexpr OverflowSafeInt<T> operator * (const uint8_t a, const OverflowSafeInt<T> b) { return b * (uint)a; }
template <class T> inline constexpr OverflowSafeInt<T> operator / (const uint8_t a, const OverflowSafeInt<T> b) { return (OverflowSafeInt<T>)a / (int)b; }
typedef OverflowSafeInt<int64_t> OverflowSafeInt64;
typedef OverflowSafeInt<int32_t> OverflowSafeInt32;

View File

@ -123,9 +123,9 @@ DEFINE_POOL_METHOD(inline void *)::AllocateItem(size_t size, size_t index)
memset((void *)item, 0, sizeof(Titem));
}
} else if (Tzero) {
item = (Titem *)CallocT<byte>(size);
item = (Titem *)CallocT<uint8_t>(size);
} else {
item = (Titem *)MallocT<byte>(size);
item = (Titem *)MallocT<uint8_t>(size);
}
this->data[index] = item;
SetBit(this->used_bitmap[index / BITMAP_SIZE], index % BITMAP_SIZE);

View File

@ -73,7 +73,7 @@ void SetRandomSeed(uint32_t seed)
uint32_t Random(const std::source_location location)
{
if (_networking && (!_network_server || (NetworkClientSocket::IsValidID(0) && NetworkClientSocket::Get(0)->status != NetworkClientSocket::STATUS_INACTIVE))) {
Debug(random, 0, "{:08x}; {:02x}; {:04x}; {:02x}; {}:{}", TimerGameEconomy::date, TimerGameEconomy::date_fract, _frame_counter, (byte)_current_company, location.file_name(), location.line());
Debug(random, 0, "{:08x}; {:02x}; {:04x}; {:02x}; {}:{}", TimerGameEconomy::date, TimerGameEconomy::date_fract, _frame_counter, (uint8_t)_current_company, location.file_name(), location.line());
}
return _random.Next();

View File

@ -82,7 +82,7 @@ CurrencySpec _currency_specs[CURRENCY_END];
* When a grf sends currencies, they are based on the order defined by TTDPatch.
* So, we must reindex them to our own order.
*/
const byte TTDPatch_To_OTTDIndex[] =
const uint8_t TTDPatch_To_OTTDIndex[] =
{
CURRENCY_GBP,
CURRENCY_USD,
@ -113,7 +113,7 @@ const byte TTDPatch_To_OTTDIndex[] =
* @param grfcurr_id currency id coming from newgrf
* @return the corrected index
*/
byte GetNewgrfCurrencyIdConverted(byte grfcurr_id)
uint8_t GetNewgrfCurrencyIdConverted(uint8_t grfcurr_id)
{
return (grfcurr_id >= lengthof(TTDPatch_To_OTTDIndex)) ? grfcurr_id : TTDPatch_To_OTTDIndex[grfcurr_id];
}

View File

@ -88,12 +88,12 @@ struct CurrencySpec {
* It is not a spec from Newgrf,
* rather a way to let users do what they want with custom currency
*/
byte symbol_pos;
uint8_t symbol_pos;
StringID name;
CurrencySpec() = default;
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) :
CurrencySpec(uint16_t rate, const char *separator, TimerGameCalendar::Year to_euro, const char *prefix, const char *suffix, const char *code, uint8_t symbol_pos, StringID name) :
rate(rate), separator(separator), to_euro(to_euro), prefix(prefix), suffix(suffix), code(code), symbol_pos(symbol_pos), name(name)
{
}
@ -107,6 +107,6 @@ extern CurrencySpec _currency_specs[CURRENCY_END];
uint64_t GetMaskOfAllowedCurrencies();
void ResetCurrencies(bool preserve_custom = true);
byte GetNewgrfCurrencyIdConverted(byte grfcurr_id);
uint8_t GetNewgrfCurrencyIdConverted(uint8_t grfcurr_id);
#endif /* CURRENCY_H */

View File

@ -21,7 +21,7 @@
* your viewport and not rotated by 45 degrees left or right to get
* a "north" used in you games.
*/
enum Direction : byte {
enum Direction : uint8_t {
DIR_BEGIN = 0, ///< Used to iterate
DIR_N = 0, ///< North
DIR_NE = 1, ///< Northeast
@ -70,7 +70,7 @@ enum DirDiff {
*
* This enumeration is used for the 4 direction of the tile-edges.
*/
enum DiagDirection : byte {
enum DiagDirection : uint8_t {
DIAGDIR_BEGIN = 0, ///< Used for iterations
DIAGDIR_NE = 0, ///< Northeast, upper right on your monitor
DIAGDIR_SE = 1, ///< Southeast
@ -113,7 +113,7 @@ DECLARE_POSTFIX_INCREMENT(DiagDirDiff)
* (and south-east edge). The Y axis must be so the one which goes
* align the north-east edge (and south-west) edge.
*/
enum Axis : byte {
enum Axis : uint8_t {
AXIS_X = 0, ///< The X axis
AXIS_Y = 1, ///< The y axis
AXIS_END, ///< Used for iterations

View File

@ -925,11 +925,11 @@ static const Disaster _disasters[] = {
static void DoDisaster()
{
byte buf[lengthof(_disasters)];
uint8_t buf[lengthof(_disasters)];
byte j = 0;
uint8_t j = 0;
for (size_t i = 0; i != lengthof(_disasters); i++) {
if (TimerGameCalendar::year >= _disasters[i].min_year && TimerGameCalendar::year < _disasters[i].max_year) buf[j++] = (byte)i;
if (TimerGameCalendar::year >= _disasters[i].min_year && TimerGameCalendar::year < _disasters[i].max_year) buf[j++] = (uint8_t)i;
}
if (j == 0) return;

View File

@ -37,7 +37,7 @@ enum DisasterSubType {
struct DisasterVehicle final : public SpecializedVehicle<DisasterVehicle, VEH_DISASTER> {
SpriteID image_override; ///< Override for the default disaster vehicle sprite.
VehicleID big_ufo_destroyer_target; ///< The big UFO that this destroyer is supposed to bomb.
byte flags; ///< Flags about the state of the vehicle, @see AirVehicleFlags
uint8_t flags; ///< Flags about the state of the vehicle, @see AirVehicleFlags
uint16_t state; ///< Action stage of the disaster vehicle.
/** For use by saveload. */

View File

@ -118,7 +118,7 @@ static Money CalculateCompanyAssetValue(const Company *c)
uint num = 0;
for (const Station *st : Station::Iterate()) {
if (st->owner == owner) num += CountBits((byte)st->facilities);
if (st->owner == owner) num += CountBits((uint8_t)st->facilities);
}
Money value = num * _price[PR_STATION_VALUE] * 25;
@ -239,7 +239,7 @@ int UpdateCompanyRatingAndValue(Company *c, bool update)
uint num = 0;
for (const Station *st : Station::Iterate()) {
/* Only count stations that are actually serviced */
if (st->owner == owner && (st->time_since_load <= 20 || st->time_since_unload <= 20)) num += CountBits((byte)st->facilities);
if (st->owner == owner && (st->time_since_load <= 20 || st->time_since_unload <= 20)) num += CountBits((uint8_t)st->facilities);
}
_score_part[owner][SCORE_STATIONS] = num;
}

View File

@ -43,9 +43,9 @@ static const int DEF_CARGO_SCALE = 100;
struct Economy {
Money max_loan; ///< NOSAVE: Maximum possible loan
int16_t fluct; ///< Economy fluctuation status
byte interest_rate; ///< Interest
byte infl_amount; ///< inflation amount
byte infl_amount_pr; ///< inflation rate for payment rates
uint8_t interest_rate; ///< Interest
uint8_t infl_amount; ///< inflation amount
uint8_t infl_amount_pr; ///< inflation rate for payment rates
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
@ -169,7 +169,7 @@ typedef Money Prices[PR_END]; ///< Prices of everything. @see Price
typedef int8_t PriceMultipliers[PR_END];
/** Types of expenses. */
enum ExpensesType : byte {
enum ExpensesType : uint8_t {
EXPENSES_CONSTRUCTION = 0, ///< Construction costs.
EXPENSES_NEW_VEHICLES, ///< New vehicles.
EXPENSES_TRAIN_RUN, ///< Running costs trains.

View File

@ -245,9 +245,9 @@ static void BulldozerInit(EffectVehicle *v)
}
struct BulldozerMovement {
byte direction:2;
byte image:2;
byte duration:3;
uint8_t direction:2;
uint8_t image:2;
uint8_t duration:3;
};
static const BulldozerMovement _bulldozer_movement[] = {
@ -320,7 +320,7 @@ struct BubbleMovement {
int8_t x:4;
int8_t y:4;
int8_t z:4;
byte image:4;
uint8_t image:4;
};
#define MK(x, y, z, i) { x, y, z, i }

View File

@ -23,7 +23,7 @@
*/
struct EffectVehicle final : public SpecializedVehicle<EffectVehicle, VEH_EFFECT> {
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.
uint8_t 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! */
EffectVehicle() : SpecializedVehicleBase() {}

View File

@ -83,7 +83,7 @@ static inline TLG GetTLG(TileIndex t)
* @param override pointer to PCP override, can be nullptr
* @return trackbits of tile if it is electrified
*/
static TrackBits GetRailTrackBitsUniversal(TileIndex t, byte *override)
static TrackBits GetRailTrackBitsUniversal(TileIndex t, uint8_t *override)
{
switch (GetTileType(t)) {
case MP_RAILWAY:
@ -295,10 +295,10 @@ static void DrawRailCatenaryRailway(const TileInfo *ti)
}
TLG tlg = GetTLG(ti->tile);
byte PCPstatus = 0;
byte OverridePCP = 0;
byte PPPpreferred[DIAGDIR_END];
byte PPPallowed[DIAGDIR_END];
uint8_t PCPstatus = 0;
uint8_t OverridePCP = 0;
uint8_t PPPpreferred[DIAGDIR_END];
uint8_t PPPallowed[DIAGDIR_END];
/* Find which rail bits are present, and select the override points.
* We don't draw a pylon:
@ -425,7 +425,7 @@ static void DrawRailCatenaryRailway(const TileInfo *ti)
if (PPPallowed[i] != 0 && HasBit(PCPstatus, i) && !HasBit(OverridePCP, i) &&
(!IsRailStationTile(ti->tile) || CanStationTileHavePylons(ti->tile))) {
for (Direction k = DIR_BEGIN; k < DIR_END; k++) {
byte temp = PPPorder[i][GetTLG(ti->tile)][k];
uint8_t temp = PPPorder[i][GetTLG(ti->tile)][k];
if (HasBit(PPPallowed[i], temp)) {
uint x = ti->x + x_pcp_offsets[i] + x_ppp_offsets[temp];
@ -474,7 +474,7 @@ static void DrawRailCatenaryRailway(const TileInfo *ti)
/* Drawing of pylons is finished, now draw the wires */
for (Track t : SetTrackBitIterator(wireconfig[TS_HOME])) {
SpriteID wire_base = (t == halftile_track) ? wire_halftile : wire_normal;
byte PCPconfig = HasBit(PCPstatus, PCPpositions[t][0]) +
uint8_t PCPconfig = HasBit(PCPstatus, PCPpositions[t][0]) +
(HasBit(PCPstatus, PCPpositions[t][1]) << 1);
const SortableSpriteStruct *sss;

View File

@ -23,7 +23,7 @@ struct WagonOverride {
};
/** Flags used client-side in the purchase/autorenew engine list. */
enum class EngineDisplayFlags : byte {
enum class EngineDisplayFlags : uint8_t {
None = 0, ///< No flag set.
HasVariants = (1U << 0), ///< Set if engine has variants.
IsFolded = (1U << 1), ///< Set if display of variants should be folded (hidden).
@ -46,10 +46,10 @@ struct Engine : EnginePool::PoolItem<&_engine_pool> {
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
uint8_t 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.
uint8_t 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_t original_image_index; ///< Original vehicle image index, thus the image index of the overridden vehicle

View File

@ -44,7 +44,7 @@ void DrawShipEngine(int left, int right, int preferred_x, int y, EngineID engine
void DrawAircraftEngine(int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal, EngineImageType image_type);
extern bool _engine_sort_direction;
extern byte _engine_sort_last_criteria[];
extern uint8_t _engine_sort_last_criteria[];
extern bool _engine_sort_last_order[];
extern bool _engine_sort_show_hidden_engines[];
extern const StringID _engine_sort_listing[][12];

View File

@ -40,42 +40,42 @@ enum EngineClass {
/** Information about a rail vehicle. */
struct RailVehicleInfo {
byte image_index;
uint8_t image_index;
RailVehicleTypes railveh_type;
byte cost_factor; ///< Purchase cost factor; For multiheaded engines the sum of both engine prices.
uint8_t cost_factor; ///< Purchase cost factor; For multiheaded engines the sum of both engine prices.
RailType railtype; ///< Railtype, mangled if elrail is disabled.
RailType intended_railtype; ///< Intended railtype, regardless of elrail being enabled or disabled.
uint16_t max_speed; ///< Maximum speed (1 unit = 1/1.6 mph = 1 km-ish/h)
uint16_t power; ///< Power of engine (hp); For multiheaded engines the sum of both engine powers.
uint16_t weight; ///< Weight of vehicle (tons); For multiheaded engines the weight of each single engine.
byte running_cost; ///< Running cost of engine; For multiheaded engines the sum of both running costs.
uint8_t running_cost; ///< Running cost of engine; For multiheaded engines the sum of both running costs.
Price running_cost_class;
EngineClass engclass; ///< Class of engine for this vehicle
byte capacity; ///< Cargo capacity of vehicle; For multiheaded engines the capacity of each single engine.
byte ai_passenger_only; ///< Bit value to tell AI that this engine is for passenger use only
uint8_t capacity; ///< Cargo capacity of vehicle; For multiheaded engines the capacity of each single engine.
uint8_t ai_passenger_only; ///< Bit value to tell AI that this engine is for passenger use only
uint16_t pow_wag_power; ///< Extra power applied to consist if wagon should be powered
byte pow_wag_weight; ///< Extra weight applied to consist if wagon should be powered
byte visual_effect; ///< Bitstuffed NewGRF visual effect data
byte shorten_factor; ///< length on main map for this type is 8 - shorten_factor
byte tractive_effort; ///< Tractive effort coefficient
byte air_drag; ///< Coefficient of air drag
byte user_def_data; ///< Property 0x25: "User-defined bit mask" Used only for (very few) NewGRF vehicles
uint8_t pow_wag_weight; ///< Extra weight applied to consist if wagon should be powered
uint8_t visual_effect; ///< Bitstuffed NewGRF visual effect data
uint8_t shorten_factor; ///< length on main map for this type is 8 - shorten_factor
uint8_t tractive_effort; ///< Tractive effort coefficient
uint8_t air_drag; ///< Coefficient of air drag
uint8_t user_def_data; ///< Property 0x25: "User-defined bit mask" Used only for (very few) NewGRF vehicles
int16_t curve_speed_mod; ///< Modifier to maximum speed in curves (fixed-point binary with 8 fractional bits)
};
/** Information about a ship vehicle. */
struct ShipVehicleInfo {
byte image_index;
byte cost_factor;
uint8_t image_index;
uint8_t cost_factor;
uint8_t acceleration; ///< Acceleration (1 unit = 1/3.2 mph per tick = 0.5 km-ish/h per tick)
uint16_t max_speed; ///< Maximum speed (1 unit = 1/3.2 mph = 0.5 km-ish/h)
uint16_t capacity;
byte running_cost;
uint8_t running_cost;
SoundID sfx;
bool old_refittable; ///< Is ship refittable; only used during initialisation. Later use EngineInfo::refit_mask.
byte visual_effect; ///< Bitstuffed NewGRF visual effect data
byte ocean_speed_frac; ///< Fraction of maximum speed for ocean tiles.
byte canal_speed_frac; ///< Fraction of maximum speed for canal/river tiles.
uint8_t visual_effect; ///< Bitstuffed NewGRF visual effect data
uint8_t ocean_speed_frac; ///< Fraction of maximum speed for ocean tiles.
uint8_t canal_speed_frac; ///< Fraction of maximum speed for canal/river tiles.
/** Apply ocean/canal speed fraction to a velocity */
uint ApplyWaterClassSpeedFrac(uint raw_speed, bool is_ocean) const
@ -98,33 +98,33 @@ enum AircraftSubTypeBits {
/** Information about a aircraft vehicle. */
struct AircraftVehicleInfo {
byte image_index;
byte cost_factor;
byte running_cost;
byte subtype; ///< Type of aircraft. @see AircraftSubTypeBits
uint8_t image_index;
uint8_t cost_factor;
uint8_t running_cost;
uint8_t subtype; ///< Type of aircraft. @see AircraftSubTypeBits
SoundID sfx;
byte acceleration;
uint8_t acceleration;
uint16_t max_speed; ///< Maximum speed (1 unit = 8 mph = 12.8 km-ish/h)
byte mail_capacity; ///< Mail capacity (bags).
uint8_t mail_capacity; ///< Mail capacity (bags).
uint16_t passenger_capacity; ///< Passenger capacity (persons).
uint16_t max_range; ///< Maximum range of this aircraft.
};
/** Information about a road vehicle. */
struct RoadVehicleInfo {
byte image_index;
byte cost_factor;
byte running_cost;
uint8_t image_index;
uint8_t cost_factor;
uint8_t running_cost;
Price running_cost_class;
SoundID sfx;
uint16_t max_speed; ///< Maximum speed (1 unit = 1/3.2 mph = 0.5 km-ish/h)
byte capacity;
uint8_t capacity;
uint8_t weight; ///< Weight in 1/4t units
uint8_t power; ///< Power in 10hp units
uint8_t tractive_effort; ///< Coefficient of tractive effort
uint8_t air_drag; ///< Coefficient of air drag
byte visual_effect; ///< Bitstuffed NewGRF visual effect data
byte shorten_factor; ///< length on main map for this type is 8 - shorten_factor
uint8_t visual_effect; ///< Bitstuffed NewGRF visual effect data
uint8_t shorten_factor; ///< length on main map for this type is 8 - shorten_factor
RoadType roadtype; ///< Road type
};
@ -145,14 +145,14 @@ struct EngineInfo {
TimerGameCalendar::Date base_intro; ///< Basic date of engine introduction (without random parts).
TimerGameCalendar::Year lifelength; ///< Lifetime of a single vehicle
TimerGameCalendar::Year base_life; ///< Basic duration of engine availability (without random parts). \c 0xFF means infinite life.
byte decay_speed;
byte load_amount;
byte climates; ///< Climates supported by the engine.
uint8_t decay_speed;
uint8_t load_amount;
uint8_t climates; ///< Climates supported by the engine.
CargoID cargo_type;
std::variant<CargoLabel, MixedCargoType> cargo_label;
CargoTypes refit_mask;
byte refit_cost;
byte misc_flags; ///< Miscellaneous flags. @see EngineMiscFlags
uint8_t refit_cost;
uint8_t misc_flags; ///< Miscellaneous flags. @see EngineMiscFlags
uint16_t callback_mask; ///< Bitmask of vehicle callbacks that have to be called
int8_t retire_early; ///< Number of years early to retire vehicle
StringID string_id; ///< Default name of engine

View File

@ -498,7 +498,7 @@ public:
if (tr.top > tr.bottom) return;
/* Climate */
byte landscape = _load_check_data.settings.game_creation.landscape;
uint8_t landscape = _load_check_data.settings.game_creation.landscape;
if (landscape < NUM_LANDSCAPE) {
SetDParam(0, STR_CLIMATE_TEMPERATE_LANDSCAPE + landscape);
DrawString(tr, STR_NETWORK_SERVER_LIST_LANDSCAPE);

View File

@ -85,7 +85,7 @@ void SpriteFontCache::InitializeUnicodeGlyphMap()
}
for (uint i = 0; i < lengthof(_default_unicode_map); i++) {
byte key = _default_unicode_map[i].key;
uint8_t key = _default_unicode_map[i].key;
if (key == CLRA) {
/* Clear the glyph. This happens if the glyph at this code point
* is non-standard and should be accessed by an SCC_xxx enum

View File

@ -15,8 +15,8 @@
static const int MAX_FONT_SIZE = 72; ///< Maximum font size.
static const byte FACE_COLOUR = 1;
static const byte SHADOW_COLOUR = 2;
static const uint8_t FACE_COLOUR = 1;
static const uint8_t SHADOW_COLOUR = 2;
/** Font cache for fonts that are based on a TrueType font. */
class TrueTypeFontCache : public FontCache {
@ -33,7 +33,7 @@ protected:
/** Container for information about a glyph. */
struct GlyphEntry {
Sprite *sprite; ///< The loaded sprite.
byte width; ///< The width of the glyph.
uint8_t width; ///< The width of the glyph.
bool duplicate; ///< Whether this glyph entry is a duplicate, i.e. may this be freed?
};

View File

@ -136,7 +136,7 @@ struct TranslationWriter : LanguageWriter {
/* We don't write the length. */
}
void Write(const byte *buffer, size_t length) override
void Write(const uint8_t *buffer, size_t length) override
{
this->strings.emplace_back((const char *)buffer, length);
}

View File

@ -26,7 +26,7 @@ extern SavegameType _savegame_type; ///< type of savegame we are loading
extern uint32_t _ttdp_version; ///< version of TTDP savegame (if applicable)
extern SaveLoadVersion _sl_version; ///< the major savegame version identifier
extern byte _sl_minor_version; ///< the minor savegame version, DO NOT USE!
extern uint8_t _sl_minor_version; ///< the minor savegame version, DO NOT USE!
Gamelog _gamelog; ///< Gamelog instance
@ -463,7 +463,7 @@ void Gamelog::TestMode()
* @param bug type of bug, @see enum GRFBugs
* @param data additional data
*/
void Gamelog::GRFBug(uint32_t grfid, byte bug, uint64_t data)
void Gamelog::GRFBug(uint32_t grfid, uint8_t bug, uint64_t data)
{
assert(this->action_type == GLAT_GRFBUG);
@ -682,7 +682,7 @@ void Gamelog::GRFUpdate(const GRFConfig *oldc, const GRFConfig *newc)
* @param[out] ever_modified Max value of 'modified' from all binaries that ever saved this savegame.
* @param[out] removed_newgrfs Set to true if any NewGRFs have been removed.
*/
void Gamelog::Info(uint32_t *last_ottd_rev, byte *ever_modified, bool *removed_newgrfs)
void Gamelog::Info(uint32_t *last_ottd_rev, uint8_t *ever_modified, bool *removed_newgrfs)
{
for (const LoggedAction &la : this->data->action) {
for (const auto &lc : la.change) {

View File

@ -80,7 +80,7 @@ public:
void GRFAddList(const GRFConfig *newg);
void GRFRemove(uint32_t grfid);
void GRFAdd(const GRFConfig *newg);
void GRFBug(uint32_t grfid, byte bug, uint64_t data);
void GRFBug(uint32_t grfid, uint8_t bug, uint64_t data);
bool GRFBugReverse(uint32_t grfid, uint16_t internal_id);
void GRFCompatible(const GRFIdentifier *newg);
void GRFMove(uint32_t grfid, int32_t offset);
@ -89,7 +89,7 @@ public:
void TestRevision();
void TestMode();
void Info(uint32_t *last_ottd_rev, byte *ever_modified, bool *removed_newgrfs);
void Info(uint32_t *last_ottd_rev, uint8_t *ever_modified, bool *removed_newgrfs);
const GRFIdentifier *GetOverriddenIdentifier(const GRFConfig *c);
/* Saveload handler for gamelog needs access to internal data. */

View File

@ -38,24 +38,24 @@ struct LoggedChange {
struct LoggedChangeMode : LoggedChange {
LoggedChangeMode() : LoggedChange(GLCT_MODE) {}
LoggedChangeMode(byte mode, byte landscape) :
LoggedChangeMode(uint8_t mode, uint8_t landscape) :
LoggedChange(GLCT_MODE), mode(mode), landscape(landscape) {}
void FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override;
byte mode; ///< new game mode - Editor x Game
byte landscape; ///< landscape (temperate, arctic, ...)
uint8_t mode; ///< new game mode - Editor x Game
uint8_t landscape; ///< landscape (temperate, arctic, ...)
};
struct LoggedChangeRevision : LoggedChange {
LoggedChangeRevision() : LoggedChange(GLCT_REVISION) {}
LoggedChangeRevision(const std::string &text, uint32_t newgrf, uint16_t slver, byte modified) :
LoggedChangeRevision(const std::string &text, uint32_t newgrf, uint16_t slver, uint8_t modified) :
LoggedChange(GLCT_REVISION), text(text), newgrf(newgrf), slver(slver), modified(modified) {}
void FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override;
std::string text; ///< revision string, _openttd_revision
uint32_t newgrf; ///< _openttd_newgrf_version
uint16_t slver; ///< _sl_version
byte modified; //< _openttd_revision_modified
uint8_t modified; //< _openttd_revision_modified
};
struct LoggedChangeOldVersion : LoggedChange {
@ -123,13 +123,13 @@ struct LoggedChangeSettingChanged : LoggedChange {
struct LoggedChangeGRFBug : LoggedChange {
LoggedChangeGRFBug() : LoggedChange(GLCT_GRFBUG) {}
LoggedChangeGRFBug(uint64_t data, uint32_t grfid, byte bug) :
LoggedChangeGRFBug(uint64_t data, uint32_t grfid, uint8_t bug) :
LoggedChange(GLCT_GRFBUG), data(data), grfid(grfid), bug(bug) {}
void FormatTo(std::back_insert_iterator<std::string> &output_iterator, GrfIDMapping &grf_names, GamelogActionType action_type) override;
uint64_t data; ///< additional data
uint32_t grfid; ///< ID of problematic GRF
byte bug; ///< type of bug, @see enum GRFBugs
uint8_t bug; ///< type of bug, @see enum GRFBugs
};
struct LoggedChangeEmergencySave : LoggedChange {

View File

@ -91,7 +91,7 @@ bool IsGeneratingWorldAborted();
void HandleGeneratingWorldAbortion();
/* genworld_gui.cpp */
void SetNewLandscapeType(byte landscape);
void SetNewLandscapeType(uint8_t landscape);
void SetGeneratingWorldProgress(GenWorldProgress cls, uint total);
void IncreaseGeneratingWorldProgress(GenWorldProgress cls);
void PrepareGenerateWorldProgress();

View File

@ -61,7 +61,7 @@ static uint GetMapHeightLimit()
* Changes landscape type and sets genworld window dirty
* @param landscape new landscape type
*/
void SetNewLandscapeType(byte landscape)
void SetNewLandscapeType(uint8_t landscape)
{
_settings_newgame.game_creation.landscape = landscape;
InvalidateWindowClassesData(WC_SELECT_GAME);

View File

@ -30,9 +30,9 @@
#include "safeguards.h"
byte _dirkeys; ///< 1 = left, 2 = up, 4 = right, 8 = down
uint8_t _dirkeys; ///< 1 = left, 2 = up, 4 = right, 8 = down
bool _fullscreen;
byte _support8bpp;
uint8_t _support8bpp;
CursorVars _cursor;
bool _ctrl_pressed; ///< Is Ctrl pressed?
bool _shift_pressed; ///< Is Shift pressed?
@ -49,7 +49,7 @@ SwitchMode _switch_mode; ///< The next mainloop command.
PauseMode _pause_mode;
GameSessionStats _game_session_stats; ///< Statistics about the current session.
static byte _stringwidth_table[FS_END][224]; ///< Cache containing width of often used characters. @see GetCharacterWidth()
static uint8_t _stringwidth_table[FS_END][224]; ///< Cache containing width of often used characters. @see GetCharacterWidth()
DrawPixelInfo *_cur_dpi;
static void GfxMainBlitterViewport(const Sprite *sprite, int x, int y, BlitterMode mode, const SubSprite *sub = nullptr, SpriteID sprite_id = SPR_CURSOR_MOUSE);
@ -70,14 +70,14 @@ int _gui_scale_cfg; ///< GUI scale in config.
* @ingroup dirty
*/
static Rect _invalid_rect;
static const byte *_colour_remap_ptr;
static byte _string_colourremap[3]; ///< Recoloursprite for stringdrawing. The grf loader ensures that #SpriteType::Font sprites only use colours 0 to 2.
static const uint8_t *_colour_remap_ptr;
static uint8_t _string_colourremap[3]; ///< Recoloursprite for stringdrawing. The grf loader ensures that #SpriteType::Font sprites only use colours 0 to 2.
static const uint DIRTY_BLOCK_HEIGHT = 8;
static const uint DIRTY_BLOCK_WIDTH = 64;
static uint _dirty_bytes_per_line = 0;
static byte *_dirty_blocks = nullptr;
static uint8_t *_dirty_blocks = nullptr;
extern uint _dirty_block_colour;
void GfxScroll(int left, int top, int width, int height, int xo, int yo)
@ -147,7 +147,7 @@ void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectM
break;
case FILLRECT_CHECKER: {
byte bo = (oleft - left + dpi->left + otop - top + dpi->top) & 1;
uint8_t bo = (oleft - left + dpi->left + otop - top + dpi->top) & 1;
do {
for (int i = (bo ^= 1); i < right; i += 2) blitter->SetPixel(dst, i, 0, (uint8_t)colour);
dst = blitter->MoveTo(dst, 0, 1);
@ -431,7 +431,7 @@ void DrawBox(int x, int y, int dx1, int dy1, int dx2, int dy2, int dx3, int dy3)
* ....V.
*/
static const byte colour = PC_WHITE;
static const uint8_t colour = PC_WHITE;
GfxDrawLineUnscaled(x, y, x + dx1, y + dy1, colour);
GfxDrawLineUnscaled(x, y, x + dx2, y + dy2, colour);
@ -474,7 +474,7 @@ static void SetColourRemap(TextColour colour)
bool raw_colour = (colour & TC_IS_PALETTE_COLOUR) != 0;
colour &= ~(TC_NO_SHADE | TC_IS_PALETTE_COLOUR | TC_FORCED);
_string_colourremap[1] = raw_colour ? (byte)colour : _string_colourmap[colour];
_string_colourremap[1] = raw_colour ? (uint8_t)colour : _string_colourmap[colour];
_string_colourremap[2] = no_shade ? 0 : 1;
_colour_remap_ptr = _string_colourremap;
}
@ -1185,9 +1185,9 @@ std::unique_ptr<uint32_t[]> DrawSpriteToRgbaBuffer(SpriteID spriteId, ZoomLevel
dim_size = static_cast<size_t>(dim.width) * dim.height;
/* If the current blitter is a paletted blitter, we have to render to an extra buffer and resolve the palette later. */
std::unique_ptr<byte[]> pal_buffer{};
std::unique_ptr<uint8_t[]> pal_buffer{};
if (blitter->GetScreenDepth() == 8) {
pal_buffer = std::make_unique<byte[]>(dim_size);
pal_buffer = std::make_unique<uint8_t[]>(dim_size);
dpi.dst_ptr = pal_buffer.get();
}
@ -1199,7 +1199,7 @@ std::unique_ptr<uint32_t[]> DrawSpriteToRgbaBuffer(SpriteID spriteId, ZoomLevel
if (blitter->GetScreenDepth() == 8) {
/* Resolve palette. */
uint32_t *dst = result.get();
const byte *src = pal_buffer.get();
const uint8_t *src = pal_buffer.get();
for (size_t i = 0; i < dim_size; ++i) {
*dst++ = _cur_palette.palette[*src++].data;
}
@ -1239,7 +1239,7 @@ void LoadStringWidthTable(bool monospace)
* @param key Character code glyph
* @return Width of the character glyph
*/
byte GetCharacterWidth(FontSize size, char32_t key)
uint8_t GetCharacterWidth(FontSize size, char32_t key)
{
/* Use _stringwidth_table cache if possible */
if (key >= 32 && key < 256) return _stringwidth_table[size][key - 32];
@ -1252,9 +1252,9 @@ byte GetCharacterWidth(FontSize size, char32_t key)
* @param size Font of the digit
* @return Width of the digit.
*/
byte GetDigitWidth(FontSize size)
uint8_t GetDigitWidth(FontSize size)
{
byte width = 0;
uint8_t width = 0;
for (char c = '0'; c <= '9'; c++) {
width = std::max(GetCharacterWidth(size, c), width);
}
@ -1283,7 +1283,7 @@ void GetBroadestDigit(uint *front, uint *next, FontSize size)
void ScreenSizeChanged()
{
_dirty_bytes_per_line = CeilDiv(_screen.width, DIRTY_BLOCK_WIDTH);
_dirty_blocks = ReallocT<byte>(_dirty_blocks, static_cast<size_t>(_dirty_bytes_per_line) * CeilDiv(_screen.height, DIRTY_BLOCK_HEIGHT));
_dirty_blocks = ReallocT<uint8_t>(_dirty_blocks, static_cast<size_t>(_dirty_bytes_per_line) * CeilDiv(_screen.height, DIRTY_BLOCK_HEIGHT));
/* check the dirty rect */
if (_invalid_rect.right >= _screen.width) _invalid_rect.right = _screen.width;
@ -1411,7 +1411,7 @@ void RedrawScreenRect(int left, int top, int right, int bottom)
*/
void DrawDirtyBlocks()
{
byte *b = _dirty_blocks;
uint8_t *b = _dirty_blocks;
const int w = Align(_screen.width, DIRTY_BLOCK_WIDTH);
const int h = Align(_screen.height, DIRTY_BLOCK_HEIGHT);
int x;
@ -1426,7 +1426,7 @@ void DrawDirtyBlocks()
int top;
int right = x + DIRTY_BLOCK_WIDTH;
int bottom = y;
byte *p = b;
uint8_t *p = b;
int h2;
/* First try coalescing downwards */
@ -1442,7 +1442,7 @@ void DrawDirtyBlocks()
p = b;
while (right != w) {
byte *p2 = ++p;
uint8_t *p2 = ++p;
int i = h2;
/* Check if a full line of dirty flags is set. */
do {
@ -1500,7 +1500,7 @@ void DrawDirtyBlocks()
*/
void AddDirtyBlock(int left, int top, int right, int bottom)
{
byte *b;
uint8_t *b;
int width;
int height;

View File

@ -48,9 +48,9 @@ void GameLoop();
void CreateConsole();
extern byte _dirkeys; ///< 1 = left, 2 = up, 4 = right, 8 = down
extern uint8_t _dirkeys; ///< 1 = left, 2 = up, 4 = right, 8 = down
extern bool _fullscreen;
extern byte _support8bpp;
extern uint8_t _support8bpp;
extern CursorVars _cursor;
extern bool _ctrl_pressed; ///< Is Ctrl pressed?
extern bool _shift_pressed; ///< Is Shift pressed?
@ -181,8 +181,8 @@ void SortResolutions();
bool ToggleFullScreen(bool fs);
/* gfx.cpp */
byte GetCharacterWidth(FontSize size, char32_t key);
byte GetDigitWidth(FontSize size = FS_NORMAL);
uint8_t GetCharacterWidth(FontSize size, char32_t key);
uint8_t GetDigitWidth(FontSize size = FS_NORMAL);
void GetBroadestDigit(uint *front, uint *next, FontSize size = FS_NORMAL);
int GetCharacterHeight(FontSize size);

View File

@ -109,7 +109,7 @@ enum WindowKeyCodes {
struct AnimCursor {
static const CursorID LAST = MAX_UVALUE(CursorID);
CursorID sprite; ///< Must be set to LAST_ANIM when it is the last sprite of the loop
byte display_time; ///< Amount of ticks this sprite will be shown
uint8_t display_time; ///< Amount of ticks this sprite will be shown
};
/** Collection of variables for cursor-display and -animation */
@ -227,7 +227,7 @@ struct SubSprite {
int left, top, right, bottom;
};
enum Colours : byte {
enum Colours : uint8_t {
COLOUR_BEGIN,
COLOUR_DARK_BLUE = COLOUR_BEGIN,
COLOUR_PALE_GREEN,
@ -306,7 +306,7 @@ enum PaletteType {
};
/** Types of sprites that might be loaded */
enum class SpriteType : byte {
enum class SpriteType : uint8_t {
Normal = 0, ///< The most basic (normal) sprite
MapGen = 1, ///< Special sprite for the map generator
Font = 2, ///< A sprite used for fonts

View File

@ -52,12 +52,12 @@ static uint LoadGrfFile(const std::string &filename, uint load_index, bool needs
Debug(sprite, 2, "Reading grf-file '{}'", filename);
byte container_ver = file.GetContainerVersion();
uint8_t container_ver = file.GetContainerVersion();
if (container_ver == 0) UserError("Base grf '{}' is corrupt", filename);
ReadGRFSpriteOffsets(file);
if (container_ver >= 2) {
/* Read compression. */
byte compression = file.ReadByte();
uint8_t compression = file.ReadByte();
if (compression != 0) UserError("Unsupported compression format");
}
@ -89,12 +89,12 @@ static void LoadGrfFileIndexed(const std::string &filename, const SpriteID *inde
Debug(sprite, 2, "Reading indexed grf-file '{}'", filename);
byte container_ver = file.GetContainerVersion();
uint8_t container_ver = file.GetContainerVersion();
if (container_ver == 0) UserError("Base grf '{}' is corrupt", filename);
ReadGRFSpriteOffsets(file);
if (container_ver >= 2) {
/* Read compression. */
byte compression = file.ReadByte();
uint8_t compression = file.ReadByte();
if (compression != 0) UserError("Unsupported compression format");
}

View File

@ -306,7 +306,7 @@ CommandCost CmdGoalQuestionAnswer(DoCommandFlag flags, uint16_t uniqueid, uint8_
}
if (flags & DC_EXEC) {
Game::NewEvent(new ScriptEventGoalQuestionAnswer(uniqueid, (ScriptCompany::CompanyID)(byte)_current_company, (ScriptGoal::QuestionButton)(1 << button)));
Game::NewEvent(new ScriptEventGoalQuestionAnswer(uniqueid, (ScriptCompany::CompanyID)(uint8_t)_current_company, (ScriptGoal::QuestionButton)(1 << button)));
}
return CommandCost();

View File

@ -479,7 +479,7 @@ static WindowDesc _goal_question_list_desc[] = {
* @param button_mask Buttons to display.
* @param question Question to ask.
*/
void ShowGoalQuestion(uint16_t id, byte type, uint32_t button_mask, const std::string &question)
void ShowGoalQuestion(uint16_t id, uint8_t type, uint32_t button_mask, const std::string &question)
{
assert(type < GQT_END);
new GoalQuestionWindow(&_goal_question_list_desc[type], id, type == 3 ? TC_WHITE : TC_BLACK, button_mask, question);

View File

@ -14,7 +14,7 @@
static const uint32_t GOAL_QUESTION_BUTTON_COUNT = 18; ///< Amount of buttons available.
enum GoalQuestionType : byte {
enum GoalQuestionType : uint8_t {
GQT_QUESTION = 0,
GQT_INFORMATION = 1,
GQT_WARNING = 2,
@ -23,7 +23,7 @@ enum GoalQuestionType : byte {
};
/** Types of goal destinations */
enum GoalType : byte {
enum GoalType : uint8_t {
GT_NONE, ///< Destination is not linked
GT_TILE, ///< Destination is a tile
GT_INDUSTRY, ///< Destination is an industry

View File

@ -183,9 +183,9 @@ protected:
static const int MIN_GRID_PIXEL_SIZE = 20; ///< Minimum distance between graph lines.
uint64_t excluded_data; ///< bitmask of the datasets that shouldn't be displayed.
byte num_dataset;
byte num_on_x_axis;
byte num_vert_lines;
uint8_t num_dataset;
uint8_t num_on_x_axis;
uint8_t num_vert_lines;
/* The starting month and year that values are plotted against. */
TimerGameEconomy::Month month;
@ -199,7 +199,7 @@ protected:
uint16_t x_values_increment;
StringID format_str_y_axis;
byte colours[GRAPH_MAX_DATASETS];
uint8_t colours[GRAPH_MAX_DATASETS];
OverflowSafeInt64 cost[GRAPH_MAX_DATASETS][GRAPH_NUM_MONTHS]; ///< Stored costs for the last #GRAPH_NUM_MONTHS months
/**
@ -443,7 +443,7 @@ protected:
/* Centre the dot between the grid lines. */
x = r.left + (x_sep / 2);
byte colour = this->colours[i];
uint8_t colour = this->colours[i];
uint prev_x = INVALID_DATAPOINT_POS;
uint prev_y = INVALID_DATAPOINT_POS;
@ -600,7 +600,7 @@ public:
if (!Company::IsValidID(c)) SetBit(excluded_companies, c);
}
byte nums = 0;
uint8_t nums = 0;
for (const Company *c : Company::Iterate()) {
nums = std::min(this->num_vert_lines, std::max(nums, c->num_valid_stat_ent));
}

View File

@ -41,8 +41,8 @@ void GroundVehicle<T, Type>::PowerChanged()
if (track_speed > 0) max_track_speed = std::min(max_track_speed, track_speed);
}
byte air_drag;
byte air_drag_value = v->GetAirDrag();
uint8_t air_drag;
uint8_t air_drag_value = v->GetAirDrag();
/* If air drag is set to zero (default), the resulting air drag coefficient is dependent on max speed. */
if (air_drag_value == 0) {

View File

@ -63,9 +63,9 @@ enum GroundVehicleFlags {
* virtual uint16_t GetPower() const = 0;
* virtual uint16_t GetPoweredPartPower(const T *head) const = 0;
* virtual uint16_t GetWeight() const = 0;
* virtual byte GetTractiveEffort() const = 0;
* virtual byte GetAirDrag() const = 0;
* virtual byte GetAirDragArea() const = 0;
* virtual uint8_t GetTractiveEffort() const = 0;
* virtual uint8_t GetAirDrag() const = 0;
* virtual uint8_t GetAirDragArea() const = 0;
* virtual AccelStatus GetAccelerationStatus() const = 0;
* virtual uint16_t GetCurrentSpeed() const = 0;
* virtual uint32_t GetRollingFriction() const = 0;
@ -362,7 +362,7 @@ protected:
inline uint DoUpdateSpeed(uint accel, int min_speed, int max_speed)
{
uint spd = this->subspeed + accel;
this->subspeed = (byte)spd;
this->subspeed = (uint8_t)spd;
/* When we are going faster than the maximum speed, reduce the speed
* somewhat gradually. But never lower than the maximum speed. */

View File

@ -16,11 +16,11 @@
#include "vehiclelist.h"
#include "vehiclelist_cmd.h"
enum Colours : byte;
enum Colours : uint8_t;
enum GroupFlags : uint8_t;
/** Action for \c CmdAlterGroup. */
enum class AlterGroupMode : byte {
enum class AlterGroupMode : uint8_t {
Rename, ///< Change group name.
SetParent, ///< Change group parent.
};

View File

@ -62,7 +62,7 @@ void ShowSubsidiesList();
/* goal_gui.cpp */
void ShowGoalsList(CompanyID company);
void ShowGoalQuestion(uint16_t id, byte type, uint32_t button_mask, const std::string &question);
void ShowGoalQuestion(uint16_t id, uint8_t type, uint32_t button_mask, const std::string &question);
/* story_gui.cpp */
void ShowStoryBook(CompanyID company, uint16_t page_id = INVALID_STORY_PAGE, bool centered = false);
@ -72,7 +72,7 @@ void ShowExtraViewportWindow(TileIndex tile = INVALID_TILE);
void ShowExtraViewportWindowForTileUnderCursor();
/* bridge_gui.cpp */
void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transport_type, byte bridge_type);
void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transport_type, uint8_t bridge_type);
/* music_gui.cpp */
void ShowMusicWindow();

View File

@ -60,7 +60,7 @@ static inline bool IsValidHeightmapDimension(size_t width, size_t height)
* Convert RGB colours to Grayscale using 29.9% Red, 58.7% Green, 11.4% Blue
* (average luminosity formula, NTSC Colour Space)
*/
static inline byte RGBToGrayscale(byte red, byte green, byte blue)
static inline uint8_t RGBToGrayscale(uint8_t red, uint8_t green, uint8_t blue)
{
/* To avoid doubles and stuff, multiply it with a total of 65536 (16bits), then
* divide by it to normalize the value to a byte again. */
@ -75,10 +75,10 @@ static inline byte RGBToGrayscale(byte red, byte green, byte blue)
/**
* The PNG Heightmap loader.
*/
static void ReadHeightmapPNGImageData(byte *map, png_structp png_ptr, png_infop info_ptr)
static void ReadHeightmapPNGImageData(uint8_t *map, png_structp png_ptr, png_infop info_ptr)
{
uint x, y;
byte gray_palette[256];
uint8_t gray_palette[256];
png_bytep *row_pointers = nullptr;
bool has_palette = png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_PALETTE;
uint channels = png_get_channels(png_ptr, info_ptr);
@ -114,7 +114,7 @@ static void ReadHeightmapPNGImageData(byte *map, png_structp png_ptr, png_infop
/* Read the raw image data and convert in 8-bit grayscale */
for (x = 0; x < png_get_image_width(png_ptr, info_ptr); x++) {
for (y = 0; y < png_get_image_height(png_ptr, info_ptr); y++) {
byte *pixel = &map[y * png_get_image_width(png_ptr, info_ptr) + x];
uint8_t *pixel = &map[y * png_get_image_width(png_ptr, info_ptr) + x];
uint x_offset = x * channels;
if (has_palette) {
@ -134,7 +134,7 @@ static void ReadHeightmapPNGImageData(byte *map, png_structp png_ptr, png_infop
* If map == nullptr only the size of the PNG is read, otherwise a map
* with grayscale pixels is allocated and assigned to *map.
*/
static bool ReadHeightmapPNG(const char *filename, uint *x, uint *y, byte **map)
static bool ReadHeightmapPNG(const char *filename, uint *x, uint *y, uint8_t **map)
{
FILE *fp;
png_structp png_ptr = nullptr;
@ -188,7 +188,7 @@ static bool ReadHeightmapPNG(const char *filename, uint *x, uint *y, byte **map)
}
if (map != nullptr) {
*map = MallocT<byte>(static_cast<size_t>(width) * height);
*map = MallocT<uint8_t>(static_cast<size_t>(width) * height);
ReadHeightmapPNGImageData(*map, png_ptr, info_ptr);
}
@ -206,10 +206,10 @@ static bool ReadHeightmapPNG(const char *filename, uint *x, uint *y, byte **map)
/**
* The BMP Heightmap loader.
*/
static void ReadHeightmapBMPImageData(byte *map, BmpInfo *info, BmpData *data)
static void ReadHeightmapBMPImageData(uint8_t *map, BmpInfo *info, BmpData *data)
{
uint x, y;
byte gray_palette[256];
uint8_t gray_palette[256];
if (data->palette != nullptr) {
uint i;
@ -244,8 +244,8 @@ static void ReadHeightmapBMPImageData(byte *map, BmpInfo *info, BmpData *data)
/* Read the raw image data and convert in 8-bit grayscale */
for (y = 0; y < info->height; y++) {
byte *pixel = &map[y * info->width];
byte *bitmap = &data->bitmap[y * info->width * (info->bpp == 24 ? 3 : 1)];
uint8_t *pixel = &map[y * info->width];
uint8_t *bitmap = &data->bitmap[y * info->width * (info->bpp == 24 ? 3 : 1)];
for (x = 0; x < info->width; x++) {
if (info->bpp != 24) {
@ -263,7 +263,7 @@ static void ReadHeightmapBMPImageData(byte *map, BmpInfo *info, BmpData *data)
* If map == nullptr only the size of the BMP is read, otherwise a map
* with grayscale pixels is allocated and assigned to *map.
*/
static bool ReadHeightmapBMP(const char *filename, uint *x, uint *y, byte **map)
static bool ReadHeightmapBMP(const char *filename, uint *x, uint *y, uint8_t **map)
{
FILE *f;
BmpInfo info;
@ -303,7 +303,7 @@ static bool ReadHeightmapBMP(const char *filename, uint *x, uint *y, byte **map)
return false;
}
*map = MallocT<byte>(static_cast<size_t>(info.width) * info.height);
*map = MallocT<uint8_t>(static_cast<size_t>(info.width) * info.height);
ReadHeightmapBMPImageData(*map, &info, &data);
}
@ -323,7 +323,7 @@ static bool ReadHeightmapBMP(const char *filename, uint *x, uint *y, byte **map)
* @param img_height the height of the image in pixels/tiles
* @param map the input map
*/
static void GrayscaleToMapHeights(uint img_width, uint img_height, byte *map)
static void GrayscaleToMapHeights(uint img_width, uint img_height, uint8_t *map)
{
/* Defines the detail of the aspect ratio (to avoid doubles) */
const uint num_div = 16384;
@ -423,7 +423,7 @@ void FixSlopes()
{
uint width, height;
int row, col;
byte current_tile;
uint8_t current_tile;
/* Adjust height difference to maximum one horizontal/vertical change. */
width = Map::SizeX();
@ -484,7 +484,7 @@ void FixSlopes()
* @param[in,out] map If not \c nullptr, destination to store the loaded block of image data.
* @return Whether loading was successful.
*/
static bool ReadHeightMap(DetailedFileType dft, const char *filename, uint *x, uint *y, byte **map)
static bool ReadHeightMap(DetailedFileType dft, const char *filename, uint *x, uint *y, uint8_t **map)
{
switch (dft) {
default:
@ -523,7 +523,7 @@ bool GetHeightmapDimensions(DetailedFileType dft, const char *filename, uint *x,
bool LoadHeightmap(DetailedFileType dft, const char *filename)
{
uint x, y;
byte *map = nullptr;
uint8_t *map = nullptr;
if (!ReadHeightMap(dft, filename, &x, &y, &map)) {
free(map);
@ -543,7 +543,7 @@ bool LoadHeightmap(DetailedFileType dft, const char *filename)
* Make an empty world where all tiles are of height 'tile_height'.
* @param tile_height of the desired new empty world
*/
void FlatEmptyWorld(byte tile_height)
void FlatEmptyWorld(uint8_t tile_height)
{
int edge_distance = _settings_game.construction.freeform_edges ? 0 : 2;
for (uint row = edge_distance; row < Map::SizeY() - edge_distance; row++) {

View File

@ -23,7 +23,7 @@ enum HeightmapRotation {
bool GetHeightmapDimensions(DetailedFileType dft, const char *filename, uint *x, uint *y);
bool LoadHeightmap(DetailedFileType dft, const char *filename);
void FlatEmptyWorld(byte tile_height);
void FlatEmptyWorld(uint8_t tile_height);
void FixSlopes();
#endif /* HEIGHTMAP_H */

View File

@ -129,7 +129,7 @@ void SaveToHighScore()
for (int i = 0; i < SP_SAVED_HIGHSCORE_END; i++) {
for (HighScore &hs : _highscore_table[i]) {
/* This code is weird and old fashioned to keep compatibility with the old high score files. */
byte name_length = ClampTo<byte>(hs.name.size());
uint8_t name_length = ClampTo<uint8_t>(hs.name.size());
if (fwrite(&name_length, sizeof(name_length), 1, fp.get()) != 1 || // Write the string length of the name
fwrite(hs.name.data(), name_length, 1, fp.get()) > 1 || // Yes... could be 0 bytes too
fwrite(&hs.score, sizeof(hs.score), 1, fp.get()) != 1 ||
@ -153,7 +153,7 @@ void LoadFromHighScore()
for (int i = 0; i < SP_SAVED_HIGHSCORE_END; i++) {
for (HighScore &hs : _highscore_table[i]) {
/* This code is weird and old fashioned to keep compatibility with the old high score files. */
byte name_length;
uint8_t name_length;
char buffer[std::numeric_limits<decltype(name_length)>::max() + 1];
if (fread(&name_length, sizeof(name_length), 1, fp.get()) != 1 ||

View File

@ -20,7 +20,7 @@
* Simple value that indicates the house has reached the final stage of
* construction.
*/
static const byte TOWN_HOUSE_COMPLETED = 3;
static const uint8_t TOWN_HOUSE_COMPLETED = 3;
static const HouseID NUM_HOUSES_PER_GRF = 255; ///< Number of supported houses per NewGRF; limited to 255 to allow extending Action3 with an extended byte later on.
@ -99,12 +99,12 @@ struct HouseSpec {
/* Standard properties */
TimerGameCalendar::Year min_year; ///< introduction year of the house
TimerGameCalendar::Year max_year; ///< last year it can be built
byte population; ///< population (Zero on other tiles in multi tile house.)
byte removal_cost; ///< cost multiplier for removing it
uint8_t population; ///< population (Zero on other tiles in multi tile house.)
uint8_t removal_cost; ///< cost multiplier for removing it
StringID building_name; ///< building name
uint16_t remove_rating_decrease; ///< rating decrease if removed
byte mail_generation; ///< mail generation multiplier (tile based, as the acceptances below)
byte cargo_acceptance[HOUSE_NUM_ACCEPTS]; ///< acceptance level for the cargo slots
uint8_t mail_generation; ///< mail generation multiplier (tile based, as the acceptances below)
uint8_t cargo_acceptance[HOUSE_NUM_ACCEPTS]; ///< acceptance level for the cargo slots
CargoID accepts_cargo[HOUSE_NUM_ACCEPTS]; ///< input cargo slots
CargoLabel accepts_cargo_label[HOUSE_NUM_ACCEPTS]; ///< input landscape cargo slots
BuildingFlags building_flags; ///< some flags that describe the house (size, stadium etc...)
@ -115,12 +115,12 @@ struct HouseSpec {
GRFFileProps grf_prop; ///< Properties related the the grf file
uint16_t callback_mask; ///< Bitmask of house callbacks that have to be called
Colours random_colour[4]; ///< 4 "random" colours
byte probability; ///< Relative probability of appearing (16 is the standard value)
uint8_t probability; ///< Relative probability of appearing (16 is the standard value)
HouseExtraFlags extra_flags; ///< some more flags
HouseClassID class_id; ///< defines the class this house has (not grf file based)
AnimationInfo animation; ///< information about the animation.
byte processing_time; ///< Periodic refresh multiplier
byte minimum_life; ///< The minimum number of years this house will survive before the town rebuilds it
uint8_t processing_time; ///< Periodic refresh multiplier
uint8_t minimum_life; ///< The minimum number of years this house will survive before the town rebuilds it
CargoTypes watched_cargoes; ///< Cargo types watched for acceptance.
Money GetRemovalCost() const;

View File

@ -41,7 +41,7 @@ enum ProductionLevels {
* Flags to control/override the behaviour of an industry.
* These flags are controlled by game scripts.
*/
enum IndustryControlFlags : byte {
enum IndustryControlFlags : uint8_t {
/** No flags in effect */
INDCTL_NONE = 0,
/** When industry production change is evaluated, rolls to decrease are ignored. */
@ -98,14 +98,14 @@ struct Industry : IndustryPool::PoolItem<&_industry_pool> {
Station *neutral_station; ///< Associated neutral station
ProducedCargoArray produced; ///< INDUSTRY_NUM_OUTPUTS production cargo slots
AcceptedCargoArray accepted; ///< INDUSTRY_NUM_INPUTS input cargo slots
byte prod_level; ///< general production level
uint8_t prod_level; ///< general production level
uint16_t counter; ///< used for animation and/or production (if available cargo)
IndustryType type; ///< type of industry.
Owner owner; ///< owner of the industry. Which SHOULD always be (imho) OWNER_NONE
Colours random_colour; ///< randomized colour of the industry, for display purpose
TimerGameEconomy::Year last_prod_year; ///< last economy year of production
byte was_cargo_delivered; ///< flag that indicate this has been the closest industry chosen for cargo delivery by a station. see DeliverGoodsToIndustry
uint8_t was_cargo_delivered; ///< flag that indicate this has been the closest industry chosen for cargo delivery by a station. see DeliverGoodsToIndustry
IndustryControlFlags ctlflags; ///< flags overriding standard behaviours
PartOfSubsidy part_of_subsidy; ///< NOSAVE: is this industry a source/destination of a subsidy?
@ -115,7 +115,7 @@ struct Industry : IndustryPool::PoolItem<&_industry_pool> {
Owner founder; ///< Founder of the industry
TimerGameCalendar::Date construction_date; ///< Date of the construction of the industry
uint8_t construction_type; ///< Way the industry was constructed (@see IndustryConstructionType)
byte selected_layout; ///< Which tile layout was used when creating the industry
uint8_t selected_layout; ///< Which tile layout was used when creating the industry
Owner exclusive_supplier; ///< Which company has exclusive rights to deliver cargo (INVALID_OWNER = anyone)
Owner exclusive_consumer; ///< Which company has exclusive rights to take cargo (INVALID_OWNER = anyone)
std::string text; ///< General text with additional information.
@ -275,7 +275,7 @@ bool IsTileForestIndustry(TileIndex tile);
/** Data for managing the number of industries of a single industry type. */
struct IndustryTypeBuildData {
uint32_t probability; ///< Relative probability of building this industry.
byte min_number; ///< Smallest number of industries that should exist (either \c 0 or \c 1).
uint8_t min_number; ///< Smallest number of industries that should exist (either \c 0 or \c 1).
uint16_t target_count; ///< Desired number of industries of this type.
uint16_t max_wait; ///< Starting number of turns to wait (copied to #wait_count).
uint16_t wait_count; ///< Number of turns to wait before trying to build again.

View File

@ -60,7 +60,7 @@ INSTANTIATE_POOL_METHODS(Industry)
void ShowIndustryViewWindow(int industry);
void BuildOilRig(TileIndex tile);
static byte _industry_sound_ctr;
static uint8_t _industry_sound_ctr;
static TileIndex _industry_sound_tile;
uint16_t Industry::counts[NUM_INDUSTRYTYPES];
@ -451,7 +451,7 @@ static void AddAcceptedCargo_Industry(TileIndex tile, CargoArray &acceptance, Ca
}
}
for (byte i = 0; i < std::size(itspec->accepts_cargo); i++) {
for (uint8_t i = 0; i < std::size(itspec->accepts_cargo); i++) {
CargoID a = accepts_cargo[i];
if (!IsValidCargoID(a) || cargo_acceptance[i] <= 0) continue; // work only with valid cargoes
@ -547,7 +547,7 @@ static bool TransportIndustryGoods(TileIndex tile)
static void AnimateSugarSieve(TileIndex tile)
{
byte m = GetAnimationFrame(tile) + 1;
uint8_t m = GetAnimationFrame(tile) + 1;
if (_settings_client.sound.ambient) {
switch (m & 7) {
@ -567,7 +567,7 @@ static void AnimateSugarSieve(TileIndex tile)
static void AnimateToffeeQuarry(TileIndex tile)
{
byte m = GetAnimationFrame(tile);
uint8_t m = GetAnimationFrame(tile);
if (_industry_anim_offs_toffee[m] == 0xFF && _settings_client.sound.ambient) {
SndPlayTileFx(SND_30_TOFFEE_QUARRY, tile);
@ -584,7 +584,7 @@ static void AnimateToffeeQuarry(TileIndex tile)
static void AnimateBubbleCatcher(TileIndex tile)
{
byte m = GetAnimationFrame(tile);
uint8_t m = GetAnimationFrame(tile);
if (++m >= 40) {
m = 0;
@ -597,7 +597,7 @@ static void AnimateBubbleCatcher(TileIndex tile)
static void AnimatePowerPlantSparks(TileIndex tile)
{
byte m = GetAnimationFrame(tile);
uint8_t m = GetAnimationFrame(tile);
if (m == 6) {
SetAnimationFrame(tile, 0);
DeleteAnimatedTile(tile);
@ -609,7 +609,7 @@ static void AnimatePowerPlantSparks(TileIndex tile)
static void AnimateToyFactory(TileIndex tile)
{
byte m = GetAnimationFrame(tile) + 1;
uint8_t m = GetAnimationFrame(tile) + 1;
switch (m) {
case 1: if (_settings_client.sound.ambient) SndPlayTileFx(SND_2C_TOY_FACTORY_1, tile); break;
@ -641,7 +641,7 @@ static void AnimatePlasticFountain(TileIndex tile, IndustryGfx gfx)
static void AnimateOilWell(TileIndex tile, IndustryGfx gfx)
{
bool b = Chance16(1, 7);
byte m = GetAnimationFrame(tile) + 1;
uint8_t m = GetAnimationFrame(tile) + 1;
if (m == 4 && (m = 0, ++gfx) == GFX_OILWELL_ANIMATED_3 + 1 && (gfx = GFX_OILWELL_ANIMATED_1, b)) {
SetIndustryGfx(tile, GFX_OILWELL_NOT_ANIMATED);
SetIndustryConstructionStage(tile, 3);
@ -661,7 +661,7 @@ static void AnimateMineTower(TileIndex tile)
if (state < 0x1A0) {
if (state < 0x20 || state >= 0x180) {
byte m = GetAnimationFrame(tile);
uint8_t m = GetAnimationFrame(tile);
if (!(m & 0x40)) {
SetAnimationFrame(tile, m | 0x40);
if (_settings_client.sound.ambient) SndPlayTileFx(SND_0B_MINE, tile);
@ -670,7 +670,7 @@ static void AnimateMineTower(TileIndex tile)
} else {
if (state & 3) return;
}
byte m = (GetAnimationFrame(tile) + 1) | 0x40;
uint8_t m = (GetAnimationFrame(tile) + 1) | 0x40;
if (m > 0xC2) m = 0xC0;
SetAnimationFrame(tile, m);
MarkTileDirtyByTile(tile);
@ -678,7 +678,7 @@ static void AnimateMineTower(TileIndex tile)
int i = (state < 0x220 || state >= 0x380) ? 7 : 3;
if (state & i) return;
byte m = (GetAnimationFrame(tile) & 0xBF) - 1;
uint8_t m = (GetAnimationFrame(tile) & 0xBF) - 1;
if (m < 0x80) m = 0x82;
SetAnimationFrame(tile, m);
MarkTileDirtyByTile(tile);
@ -747,13 +747,13 @@ static void CreateChimneySmoke(TileIndex tile)
static void MakeIndustryTileBigger(TileIndex tile)
{
byte cnt = GetIndustryConstructionCounter(tile) + 1;
uint8_t cnt = GetIndustryConstructionCounter(tile) + 1;
if (cnt != 4) {
SetIndustryConstructionCounter(tile, cnt);
return;
}
byte stage = GetIndustryConstructionStage(tile) + 1;
uint8_t stage = GetIndustryConstructionStage(tile) + 1;
SetIndustryConstructionCounter(tile, 0);
SetIndustryConstructionStage(tile, stage);
StartStopIndustryTileAnimation(tile, IAT_CONSTRUCTION_STATE_CHANGE);
@ -985,7 +985,7 @@ bool IsTileForestIndustry(TileIndex tile)
return std::any_of(std::begin(ind->produced), std::end(ind->produced), [](const auto &p) { return IsValidCargoID(p.cargo) && CargoSpec::Get(p.cargo)->label == CT_WOOD; });
}
static const byte _plantfarmfield_type[] = {1, 1, 1, 1, 1, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6};
static const uint8_t _plantfarmfield_type[] = {1, 1, 1, 1, 1, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6};
/**
* Check whether the tile can be replaced by a farm field.
@ -1010,7 +1010,7 @@ static bool IsSuitableForFarmField(TileIndex tile, bool allow_fields)
* @param type type of fence to set
* @param side the side of the tile to attempt placement
*/
static void SetupFarmFieldFence(TileIndex tile, int size, byte type, DiagDirection side)
static void SetupFarmFieldFence(TileIndex tile, int size, uint8_t type, DiagDirection side)
{
TileIndexDiff diff = (DiagDirToAxis(side) == AXIS_Y ? TileDiffXY(1, 0) : TileDiffXY(0, 1));
TileIndexDiff neighbour_diff = TileOffsByDiagDir(side);
@ -1022,7 +1022,7 @@ static void SetupFarmFieldFence(TileIndex tile, int size, byte type, DiagDirecti
TileIndex neighbour = tile + neighbour_diff;
if (!IsTileType(neighbour, MP_CLEAR) || !IsClearGround(neighbour, CLEAR_FIELDS) || GetFence(neighbour, ReverseDiagDir(side)) == 0) {
/* Add fence as long as neighbouring tile does not already have a fence in the same position. */
byte or_ = type;
uint8_t or_ = type;
if (or_ == 1 && Chance16(1, 7)) or_ = 2;
@ -1433,7 +1433,7 @@ static CommandCost FindTownForIndustry(TileIndex tile, int type, Town **t)
if (_settings_game.economy.multiple_industry_per_town) return CommandCost();
for (const Industry *i : Industry::Iterate()) {
if (i->type == (byte)type && i->town == *t) {
if (i->type == (uint8_t)type && i->town == *t) {
*t = nullptr;
return_cmd_error(STR_ERROR_ONLY_ONE_ALLOWED_PER_TOWN);
}
@ -1801,7 +1801,7 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type,
/* Randomize inital production if non-original economy is used and there are no production related callbacks. */
if (!indspec->UsesOriginalEconomy()) {
for (auto &p : i->produced) {
p.rate = ClampTo<byte>((RandomRange(256) + 128) * p.rate >> 8);
p.rate = ClampTo<uint8_t>((RandomRange(256) + 128) * p.rate >> 8);
}
}
@ -1824,7 +1824,7 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type,
/* Adding 1 here makes it conform to specs of var44 of varaction2 for industries
* 0 = created prior of newindustries
* else, chosen layout + 1 */
i->selected_layout = (byte)(layout_index + 1);
i->selected_layout = (uint8_t)(layout_index + 1);
i->exclusive_supplier = INVALID_OWNER;
i->exclusive_consumer = INVALID_OWNER;
@ -2157,7 +2157,7 @@ CommandCost CmdIndustrySetFlags(DoCommandFlag flags, IndustryID ind_id, Industry
* @param custom_news Custom news message text.
* @return Empty cost or an error.
*/
CommandCost CmdIndustrySetProduction(DoCommandFlag flags, IndustryID ind_id, byte prod_level, bool show_news, const std::string &custom_news)
CommandCost CmdIndustrySetProduction(DoCommandFlag flags, IndustryID ind_id, uint8_t prod_level, bool show_news, const std::string &custom_news)
{
if (_current_company != OWNER_DEITY) return CMD_ERROR;
if (prod_level < PRODLEVEL_MINIMUM || prod_level > PRODLEVEL_MAXIMUM) return CMD_ERROR;
@ -2313,7 +2313,7 @@ static uint32_t GetScaledIndustryGenerationProbability(IndustryType it, bool *fo
* @param[out] min_number Minimal number of industries that should exist at the map.
* @return Relative probability for the industry to appear.
*/
static uint16_t GetIndustryGamePlayProbability(IndustryType it, byte *min_number)
static uint16_t GetIndustryGamePlayProbability(IndustryType it, uint8_t *min_number)
{
if (_settings_game.difficulty.industry_density == ID_FUND_ONLY) {
*min_number = 0;
@ -2321,7 +2321,7 @@ static uint16_t GetIndustryGamePlayProbability(IndustryType it, byte *min_number
}
const IndustrySpec *ind_spc = GetIndustrySpec(it);
byte chance = ind_spc->appear_ingame[_settings_game.game_creation.landscape];
uint8_t chance = ind_spc->appear_ingame[_settings_game.game_creation.landscape];
if (!ind_spc->enabled || ind_spc->layouts.empty() ||
((ind_spc->behaviour & INDUSTRYBEH_BEFORE_1950) && TimerGameCalendar::year > 1950) ||
((ind_spc->behaviour & INDUSTRYBEH_AFTER_1960) && TimerGameCalendar::year < 1960) ||
@ -2541,7 +2541,7 @@ void ClearAllIndustryCachedNames()
*/
bool IndustryTypeBuildData::GetIndustryTypeData(IndustryType it)
{
byte min_number;
uint8_t min_number;
uint32_t probability = GetIndustryGamePlayProbability(it, &min_number);
bool changed = min_number != this->min_number || probability != this->probability;
this->min_number = min_number;
@ -2801,8 +2801,8 @@ static void ChangeIndustryProduction(Industry *i, bool monthly)
bool recalculate_multipliers = false; ///< reinitialize production_rate to match prod_level
/* use original economy for industries using production related callbacks */
bool original_economy = indspec->UsesOriginalEconomy();
byte div = 0;
byte mul = 0;
uint8_t div = 0;
uint8_t mul = 0;
int8_t increment = 0;
bool callback_enabled = HasBit(indspec->callback_mask, monthly ? CBM_IND_MONTHLYPROD_CHANGE : CBM_IND_PRODUCTION_CHANGE);

View File

@ -14,13 +14,13 @@
#include "company_type.h"
#include "industry_type.h"
enum IndustryControlFlags : byte;
enum IndustryControlFlags : uint8_t;
CommandCost CmdBuildIndustry(DoCommandFlag flags, TileIndex tile, IndustryType it, uint32_t first_layout, bool fund, uint32_t seed);
CommandCost CmdIndustrySetFlags(DoCommandFlag flags, IndustryID ind_id, IndustryControlFlags ctlflags);
CommandCost CmdIndustrySetExclusivity(DoCommandFlag flags, IndustryID ind_id, Owner company_id, bool consumer);
CommandCost CmdIndustrySetText(DoCommandFlag flags, IndustryID ind_id, const std::string &text);
CommandCost CmdIndustrySetProduction(DoCommandFlag flags, IndustryID ind_id, byte prod_level, bool show_news, const std::string &text);
CommandCost CmdIndustrySetProduction(DoCommandFlag flags, IndustryID ind_id, uint8_t prod_level, bool show_news, const std::string &text);
DEF_CMD_TRAIT(CMD_BUILD_INDUSTRY, CmdBuildIndustry, CMD_DEITY, CMDT_LANDSCAPE_CONSTRUCTION)
DEF_CMD_TRAIT(CMD_INDUSTRY_SET_FLAGS, CmdIndustrySetFlags, CMD_DEITY, CMDT_OTHER_MANAGEMENT)

View File

@ -160,7 +160,7 @@ static inline void GetAllCargoSuffixes(CargoSuffixInOut use_input, CargoSuffixTy
/* Reworked behaviour with new many-in-many-out scheme */
for (uint j = 0; j < lengthof(suffixes); j++) {
if (IsValidCargoID(cargoes[j])) {
byte local_id = indspec->grf_prop.grffile->cargo_map[cargoes[j]]; // should we check the value for valid?
uint8_t local_id = indspec->grf_prop.grffile->cargo_map[cargoes[j]]; // should we check the value for valid?
uint cargotype = local_id << 16 | use_input;
GetCargoSuffix(cargotype, cst, ind, ind_type, indspec, suffixes[j]);
} else {
@ -207,7 +207,7 @@ void GetCargoSuffix(CargoSuffixInOut use_input, CargoSuffixType cst, const Indus
suffix.display = CSD_CARGO;
if (!IsValidCargoID(cargo)) return;
if (indspec->behaviour & INDUSTRYBEH_CARGOTYPES_UNLIMITED) {
byte local_id = indspec->grf_prop.grffile->cargo_map[cargo]; // should we check the value for valid?
uint8_t local_id = indspec->grf_prop.grffile->cargo_map[cargo]; // should we check the value for valid?
uint cargotype = local_id << 16 | use_input;
GetCargoSuffix(cargotype, cst, ind, ind_type, indspec, suffix);
} else if (use_input == CARGOSUFFIX_IN) {
@ -805,7 +805,7 @@ class IndustryViewWindow : public Window
Editability editable; ///< Mode for changing production
InfoLine editbox_line; ///< The line clicked to open the edit box
InfoLine clicked_line; ///< The line of the button that has been clicked
byte clicked_button; ///< The button that has been clicked (to raise)
uint8_t clicked_button; ///< The button that has been clicked (to raise)
int production_offset_y; ///< The offset of the production texts/buttons
int info_height; ///< Height needed for the #WID_IV_INFO panel
int cheat_line_height; ///< Height of each line for the #WID_IV_INFO panel
@ -1048,10 +1048,10 @@ public:
case EA_MULTIPLIER:
if (decrease) {
if (i->prod_level <= PRODLEVEL_MINIMUM) return;
i->prod_level = static_cast<byte>(std::max<uint>(i->prod_level / 2, PRODLEVEL_MINIMUM));
i->prod_level = static_cast<uint8_t>(std::max<uint>(i->prod_level / 2, PRODLEVEL_MINIMUM));
} else {
if (i->prod_level >= PRODLEVEL_MAXIMUM) return;
i->prod_level = static_cast<byte>(std::min<uint>(i->prod_level * 2, PRODLEVEL_MAXIMUM));
i->prod_level = static_cast<uint8_t>(std::min<uint>(i->prod_level * 2, PRODLEVEL_MAXIMUM));
}
break;
@ -1063,7 +1063,7 @@ public:
if (i->produced[line - IL_RATE1].rate >= 255) return;
/* a zero production industry is unlikely to give anything but zero, so push it a little bit */
int new_prod = i->produced[line - IL_RATE1].rate == 0 ? 1 : i->produced[line - IL_RATE1].rate * 2;
i->produced[line - IL_RATE1].rate = ClampTo<byte>(new_prod);
i->produced[line - IL_RATE1].rate = ClampTo<uint8_t>(new_prod);
}
break;
@ -1551,7 +1551,7 @@ protected:
StringID GetIndustryString(const Industry *i) const
{
const IndustrySpec *indsp = GetIndustrySpec(i->type);
byte p = 0;
uint8_t p = 0;
/* Industry name */
SetDParam(p++, i->index);

View File

@ -97,10 +97,10 @@ inline void SetIndustryCompleted(Tile tile)
* @pre IsTileType(tile, MP_INDUSTRY)
* @return the construction stage
*/
inline byte GetIndustryConstructionStage(Tile tile)
inline uint8_t GetIndustryConstructionStage(Tile tile)
{
assert(IsTileType(tile, MP_INDUSTRY));
return IsIndustryCompleted(tile) ? (byte)INDUSTRY_COMPLETED : GB(tile.m1(), 0, 2);
return IsIndustryCompleted(tile) ? (uint8_t)INDUSTRY_COMPLETED : GB(tile.m1(), 0, 2);
}
/**
@ -109,7 +109,7 @@ inline byte GetIndustryConstructionStage(Tile tile)
* @param value the new construction stage
* @pre IsTileType(tile, MP_INDUSTRY)
*/
inline void SetIndustryConstructionStage(Tile tile, byte value)
inline void SetIndustryConstructionStage(Tile tile, uint8_t value)
{
assert(IsTileType(tile, MP_INDUSTRY));
SB(tile.m1(), 0, 2, value);
@ -159,7 +159,7 @@ inline void SetIndustryGfx(Tile t, IndustryGfx gfx)
* @pre IsTileType(tile, MP_INDUSTRY)
* @return the construction counter
*/
inline byte GetIndustryConstructionCounter(Tile tile)
inline uint8_t GetIndustryConstructionCounter(Tile tile)
{
assert(IsTileType(tile, MP_INDUSTRY));
return GB(tile.m1(), 2, 2);
@ -171,7 +171,7 @@ inline byte GetIndustryConstructionCounter(Tile tile)
* @param value the new value for the construction counter
* @pre IsTileType(tile, MP_INDUSTRY)
*/
inline void SetIndustryConstructionCounter(Tile tile, byte value)
inline void SetIndustryConstructionCounter(Tile tile, uint8_t value)
{
assert(IsTileType(tile, MP_INDUSTRY));
SB(tile.m1(), 2, 2, value);
@ -196,7 +196,7 @@ inline void ResetIndustryConstructionStage(Tile tile)
* @param tile the tile to get the animation loop number of
* @pre IsTileType(tile, MP_INDUSTRY)
*/
inline byte GetIndustryAnimationLoop(Tile tile)
inline uint8_t GetIndustryAnimationLoop(Tile tile)
{
assert(IsTileType(tile, MP_INDUSTRY));
return tile.m4();
@ -208,7 +208,7 @@ inline byte GetIndustryAnimationLoop(Tile tile)
* @param count the new animation frame number
* @pre IsTileType(tile, MP_INDUSTRY)
*/
inline void SetIndustryAnimationLoop(Tile tile, byte count)
inline void SetIndustryAnimationLoop(Tile tile, uint8_t count)
{
assert(IsTileType(tile, MP_INDUSTRY));
tile.m4() = count;
@ -221,7 +221,7 @@ inline void SetIndustryAnimationLoop(Tile tile, byte count)
* @pre IsTileType(tile, MP_INDUSTRY)
* @return requested bits
*/
inline byte GetIndustryRandomBits(Tile tile)
inline uint8_t GetIndustryRandomBits(Tile tile)
{
assert(IsTileType(tile, MP_INDUSTRY));
return tile.m3();
@ -234,7 +234,7 @@ inline byte GetIndustryRandomBits(Tile tile)
* @param bits the random bits
* @pre IsTileType(tile, MP_INDUSTRY)
*/
inline void SetIndustryRandomBits(Tile tile, byte bits)
inline void SetIndustryRandomBits(Tile tile, uint8_t bits)
{
assert(IsTileType(tile, MP_INDUSTRY));
tile.m3() = bits;
@ -247,7 +247,7 @@ inline void SetIndustryRandomBits(Tile tile, byte bits)
* @pre IsTileType(tile, MP_INDUSTRY)
* @return requested triggers
*/
inline byte GetIndustryTriggers(Tile tile)
inline uint8_t GetIndustryTriggers(Tile tile)
{
assert(IsTileType(tile, MP_INDUSTRY));
return GB(tile.m6(), 3, 3);
@ -261,7 +261,7 @@ inline byte GetIndustryTriggers(Tile tile)
* @param triggers the triggers to set
* @pre IsTileType(tile, MP_INDUSTRY)
*/
inline void SetIndustryTriggers(Tile tile, byte triggers)
inline void SetIndustryTriggers(Tile tile, uint8_t triggers)
{
assert(IsTileType(tile, MP_INDUSTRY));
SB(tile.m6(), 3, 3, triggers);

View File

@ -108,30 +108,30 @@ struct IndustrySpec {
uint32_t removal_cost_multiplier; ///< Base removal cost multiplier.
uint32_t prospecting_chance; ///< Chance prospecting succeeds
IndustryType conflicting[3]; ///< Industries this industry cannot be close to
byte check_proc; ///< Index to a procedure to check for conflicting circumstances
uint8_t check_proc; ///< Index to a procedure to check for conflicting circumstances
CargoID produced_cargo[INDUSTRY_NUM_OUTPUTS];
std::variant<CargoLabel, MixedCargoType> produced_cargo_label[INDUSTRY_NUM_OUTPUTS];
byte production_rate[INDUSTRY_NUM_OUTPUTS];
uint8_t production_rate[INDUSTRY_NUM_OUTPUTS];
/**
* minimum amount of cargo transported to the stations.
* If the waiting cargo is less than this number, no cargo is moved to it.
*/
byte minimal_cargo;
uint8_t minimal_cargo;
CargoID accepts_cargo[INDUSTRY_NUM_INPUTS]; ///< 16 accepted cargoes.
std::variant<CargoLabel, MixedCargoType> accepts_cargo_label[INDUSTRY_NUM_INPUTS];
uint16_t input_cargo_multiplier[INDUSTRY_NUM_INPUTS][INDUSTRY_NUM_OUTPUTS]; ///< Input cargo multipliers (multiply amount of incoming cargo for the produced cargoes)
IndustryLifeType life_type; ///< This is also known as Industry production flag, in newgrf specs
byte climate_availability; ///< Bitmask, giving landscape enums as bit position
uint8_t climate_availability; ///< Bitmask, giving landscape enums as bit position
IndustryBehaviour behaviour; ///< How this industry will behave, and how others entities can use it
byte map_colour; ///< colour used for the small map
uint8_t map_colour; ///< colour used for the small map
StringID name; ///< Displayed name of the industry
StringID new_industry_text; ///< Message appearing when the industry is built
StringID closure_text; ///< Message appearing when the industry closes
StringID production_up_text; ///< Message appearing when the industry's production is increasing
StringID production_down_text; ///< Message appearing when the industry's production is decreasing
StringID station_name; ///< Default name for nearby station
byte appear_ingame[NUM_LANDSCAPE]; ///< Probability of appearance in game
byte appear_creation[NUM_LANDSCAPE]; ///< Probability of appearance during map creation
uint8_t appear_ingame[NUM_LANDSCAPE]; ///< Probability of appearance in game
uint8_t appear_creation[NUM_LANDSCAPE]; ///< Probability of appearance during map creation
uint8_t number_of_sounds; ///< Number of sounds available in the sounds array
const uint8_t *random_sounds; ///< array of random sounds.
/* Newgrf data */
@ -158,8 +158,8 @@ struct IndustryTileSpec {
std::array<std::variant<CargoLabel, MixedCargoType>, INDUSTRY_NUM_INPUTS> accepts_cargo_label;
std::array<int8_t, INDUSTRY_NUM_INPUTS> acceptance; ///< Level of acceptance per cargo type (signed, may be negative!)
Slope slopes_refused; ///< slope pattern on which this tile cannot be built
byte anim_production; ///< Animation frame to start when goods are produced
byte anim_next; ///< Next frame in an animation
uint8_t anim_production; ///< Animation frame to start when goods are produced
uint8_t anim_next; ///< Next frame in an animation
/**
* When true, the tile has to be drawn using the animation
* state instead of the construction state

View File

@ -48,13 +48,13 @@
*/
struct IntroGameViewportCommand {
/** Horizontal alignment value. */
enum AlignmentH : byte {
enum AlignmentH : uint8_t {
LEFT,
CENTRE,
RIGHT,
};
/** Vertical alignment value. */
enum AlignmentV : byte {
enum AlignmentV : uint8_t {
TOP,
MIDDLE,
BOTTOM,

View File

@ -76,7 +76,7 @@ const TileTypeProcs * const _tile_type_procs[16] = {
};
/** landscape slope => sprite */
extern const byte _slope_to_sprite_offset[32] = {
extern const uint8_t _slope_to_sprite_offset[32] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0,
0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 17, 0, 15, 18, 0,
};
@ -455,7 +455,7 @@ void DrawFoundation(TileInfo *ti, Foundation f)
if (IsInclinedFoundation(f)) {
/* inclined foundation */
byte inclined = highest_corner * 2 + (f == FOUNDATION_INCLINED_Y ? 1 : 0);
uint8_t inclined = highest_corner * 2 + (f == FOUNDATION_INCLINED_Y ? 1 : 0);
AddSortableSpriteToDraw(inclined_base + inclined, PAL_NONE, ti->x, ti->y,
f == FOUNDATION_INCLINED_X ? TILE_SIZE : 1,
@ -510,7 +510,7 @@ void DrawFoundation(TileInfo *ti, Foundation f)
OffsetGroundSprite(0, 0);
} else {
/* inclined foundation */
byte inclined = GetHighestSlopeCorner(ti->tileh) * 2 + (f == FOUNDATION_INCLINED_Y ? 1 : 0);
uint8_t inclined = GetHighestSlopeCorner(ti->tileh) * 2 + (f == FOUNDATION_INCLINED_Y ? 1 : 0);
AddSortableSpriteToDraw(inclined_base + inclined, PAL_NONE, ti->x, ti->y,
f == FOUNDATION_INCLINED_X ? TILE_SIZE : 1,
@ -582,7 +582,7 @@ bool IsSnowLineSet()
* @param table the 12 * 32 byte table containing the snowline for each day
* @ingroup SnowLineGroup
*/
void SetSnowLine(byte table[SNOW_LINE_MONTHS][SNOW_LINE_DAYS])
void SetSnowLine(uint8_t table[SNOW_LINE_MONTHS][SNOW_LINE_DAYS])
{
_snow_line = CallocT<SnowLine>(1);
_snow_line->lowest_value = 0xFF;
@ -601,7 +601,7 @@ void SetSnowLine(byte table[SNOW_LINE_MONTHS][SNOW_LINE_DAYS])
* @return the snow line height.
* @ingroup SnowLineGroup
*/
byte GetSnowLine()
uint8_t GetSnowLine()
{
if (_snow_line == nullptr) return _settings_game.game_creation.snow_line_height;
@ -614,7 +614,7 @@ byte GetSnowLine()
* @return the highest snow line height.
* @ingroup SnowLineGroup
*/
byte HighestSnowLine()
uint8_t HighestSnowLine()
{
return _snow_line == nullptr ? _settings_game.game_creation.snow_line_height : _snow_line->highest_value;
}
@ -624,7 +624,7 @@ byte HighestSnowLine()
* @return the lowest snow line height.
* @ingroup SnowLineGroup
*/
byte LowestSnowLine()
uint8_t LowestSnowLine()
{
return _snow_line == nullptr ? _settings_game.game_creation.snow_line_height : _snow_line->lowest_value;
}
@ -805,8 +805,8 @@ void InitializeLandscape()
for (uint y = 0; y < Map::SizeY(); y++) MakeVoid(TileXY(Map::MaxX(), y));
}
static const byte _genterrain_tbl_1[5] = { 10, 22, 33, 37, 4 };
static const byte _genterrain_tbl_2[5] = { 0, 0, 0, 0, 33 };
static const uint8_t _genterrain_tbl_1[5] = { 10, 22, 33, 37, 4 };
static const uint8_t _genterrain_tbl_2[5] = { 0, 0, 0, 0, 33 };
static void GenerateTerrain(int type, uint flag)
{
@ -830,7 +830,7 @@ static void GenerateTerrain(int type, uint flag)
if (DiagDirToAxis(direction) == AXIS_Y) Swap(w, h);
const byte *p = templ->data;
const uint8_t *p = templ->data;
if ((flag & 4) != 0) {
/* This is only executed in secondary/tertiary loops to generate the terrain for arctic and tropic.
@ -1550,7 +1550,7 @@ static uint8_t CalculateDesertLine()
return CalculateCoverageLine(100 - _settings_game.game_creation.desert_coverage, 4);
}
bool GenerateLandscape(byte mode)
bool GenerateLandscape(uint8_t mode)
{
/** Number of steps of landscape generation */
enum GenLandscapeSteps {

View File

@ -21,16 +21,16 @@ static const uint SNOW_LINE_DAYS = 32; ///< Number of days in each month in th
* @ingroup SnowLineGroup
*/
struct SnowLine {
byte table[SNOW_LINE_MONTHS][SNOW_LINE_DAYS]; ///< Height of the snow line each day of the year
byte highest_value; ///< Highest snow line of the year
byte lowest_value; ///< Lowest snow line of the year
uint8_t table[SNOW_LINE_MONTHS][SNOW_LINE_DAYS]; ///< Height of the snow line each day of the year
uint8_t highest_value; ///< Highest snow line of the year
uint8_t lowest_value; ///< Lowest snow line of the year
};
bool IsSnowLineSet();
void SetSnowLine(byte table[SNOW_LINE_MONTHS][SNOW_LINE_DAYS]);
byte GetSnowLine();
byte HighestSnowLine();
byte LowestSnowLine();
void SetSnowLine(uint8_t table[SNOW_LINE_MONTHS][SNOW_LINE_DAYS]);
uint8_t GetSnowLine();
uint8_t HighestSnowLine();
uint8_t LowestSnowLine();
void ClearSnowLine();
int GetSlopeZInCorner(Slope tileh, Corner corner);
@ -136,6 +136,6 @@ void DoClearSquare(TileIndex tile);
void RunTileLoop();
void InitializeLandscape();
bool GenerateLandscape(byte mode);
bool GenerateLandscape(uint8_t mode);
#endif /* LANDSCAPE_H */

View File

@ -10,7 +10,7 @@
#ifndef LANDSCAPE_TYPE_H
#define LANDSCAPE_TYPE_H
typedef byte LandscapeID; ///< Landscape type. @see LandscapeType
typedef uint8_t LandscapeID; ///< Landscape type. @see LandscapeType
/** Landscape types */
enum LandscapeType {

View File

@ -38,8 +38,8 @@ struct LanguagePackHeader {
/** Decimal separator */
char digit_decimal_separator[8];
uint16_t missing; ///< number of missing strings.
byte plural_form; ///< plural form index
byte text_dir; ///< default direction of the text
uint8_t plural_form; ///< plural form index
uint8_t text_dir; ///< default direction of the text
/**
* Windows language ID:
* Windows cannot and will not convert isocodes to something it can use to
@ -52,7 +52,7 @@ struct LanguagePackHeader {
uint8_t newgrflangid; ///< newgrf language id
uint8_t num_genders; ///< the number of genders of this language
uint8_t num_cases; ///< the number of cases of this language
byte pad[3]; ///< pad header to be a multiple of 4
uint8_t pad[3]; ///< pad header to be a multiple of 4
char genders[MAX_NUM_GENDERS][CASE_GENDER_LEN]; ///< the genders used by this translation
char cases[MAX_NUM_CASES][CASE_GENDER_LEN]; ///< the cases used by this translation
@ -108,6 +108,6 @@ extern std::unique_ptr<icu::Collator> _current_collator;
#endif /* WITH_ICU_I18N */
bool ReadLanguagePack(const LanguageMetadata *lang);
const LanguageMetadata *GetLanguage(byte newgrflangid);
const LanguageMetadata *GetLanguage(uint8_t newgrflangid);
#endif /* LANGUAGE_H */

View File

@ -11,7 +11,7 @@
#define LEAGUE_TYPE_H
/** Types of the possible link targets. */
enum LinkType : byte {
enum LinkType : uint8_t {
LT_NONE = 0, ///< No link
LT_TILE = 1, ///< Link a tile
LT_INDUSTRY = 2, ///< Link an industry

View File

@ -19,7 +19,7 @@ static const LinkGraphJobID INVALID_LINK_GRAPH_JOB = UINT16_MAX;
typedef uint16_t NodeID;
static const NodeID INVALID_NODE = UINT16_MAX;
enum DistributionType : byte {
enum DistributionType : uint8_t {
DT_BEGIN = 0,
DT_MIN = 0,
DT_MANUAL = 0, ///< Manual distribution. No link graph calculations are run.

View File

@ -102,7 +102,7 @@ bool LinkRefresher::HandleRefit(CargoID refit_cargo)
/* Back up the vehicle's cargo type */
CargoID temp_cid = v->cargo_type;
byte temp_subtype = v->cargo_subtype;
uint8_t temp_subtype = v->cargo_subtype;
v->cargo_type = this->cargo;
v->cargo_subtype = GetBestFittingSubType(v, v, this->cargo);

View File

@ -13,12 +13,12 @@
#include "company_type.h"
#include "gfx_type.h"
static const byte LIT_NONE = 0; ///< Don't show the liveries at all
static const byte LIT_COMPANY = 1; ///< Show the liveries of your own company
static const byte LIT_ALL = 2; ///< Show the liveries of all companies
static const uint8_t LIT_NONE = 0; ///< Don't show the liveries at all
static const uint8_t LIT_COMPANY = 1; ///< Show the liveries of your own company
static const uint8_t LIT_ALL = 2; ///< Show the liveries of all companies
/** List of different livery schemes. */
enum LiveryScheme : byte {
enum LiveryScheme : uint8_t {
LS_BEGIN = 0,
LS_DEFAULT = 0,
@ -60,7 +60,7 @@ enum LiveryScheme : byte {
DECLARE_POSTFIX_INCREMENT(LiveryScheme)
/** List of different livery classes, used only by the livery GUI. */
enum LiveryClass : byte {
enum LiveryClass : uint8_t {
LC_OTHER,
LC_RAIL,
LC_ROAD,
@ -76,7 +76,7 @@ DECLARE_ENUM_AS_ADDABLE(LiveryClass)
/** Information about a particular livery. */
struct Livery {
byte in_use; ///< Bit 0 set if this livery should override the default livery first colour, Bit 1 for the second colour.
uint8_t in_use; ///< Bit 0 set if this livery should override the default livery first colour, Bit 1 for the second colour.
Colours colour1; ///< First colour, for all vehicles.
Colours colour2; ///< Second colour, for vehicles with 2CC support.
};

View File

@ -335,7 +335,7 @@ struct MainWindow : Window
case GHK_REFRESH_SCREEN: MarkWholeScreenDirty(); break;
case GHK_CRASH: // Crash the game
*(volatile byte *)nullptr = 0;
*(volatile uint8_t *)nullptr = 0;
break;
case GHK_MONEY: // Gimme money
@ -541,7 +541,7 @@ void ShowSelectGameWindow();
void SetupColoursAndInitialWindow()
{
for (Colours i = COLOUR_BEGIN; i != COLOUR_END; i++) {
const byte *b = GetNonSprite(GENERAL_SPRITE_COLOUR(i), SpriteType::Recolour) + 1;
const uint8_t *b = GetNonSprite(GENERAL_SPRITE_COLOUR(i), SpriteType::Recolour) + 1;
assert(b != nullptr);
for (ColourShade j = SHADE_BEGIN; j < SHADE_END; j++) {
SetColourGradient(i, j, b[0xC6 + j]);

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