Merge branch 'master' into jgrpp
Remove 'byte' typedef
This commit is contained in:
@@ -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();
|
||||
```
|
||||
|
||||
|
4
src/3rdparty/md5/md5.h
vendored
4
src/3rdparty/md5/md5.h
vendored
@@ -59,8 +59,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.
|
||||
|
@@ -67,7 +67,7 @@ int GetAircraftFlightLevel(T *v, bool takeoff = false);
|
||||
struct AircraftCache {
|
||||
uint32_t cached_max_range_sqr; ///< Cached squared maximum range.
|
||||
uint16_t cached_max_range; ///< Cached maximum range.
|
||||
byte image_movement_state; ///< Cached image aircraft movement state
|
||||
uint8_t image_movement_state; ///< Cached image aircraft movement state
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -75,14 +75,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;
|
||||
|
||||
@@ -146,6 +146,6 @@ void GetRotorImage(const Aircraft *v, EngineImageType image_type, VehicleSpriteS
|
||||
Station *GetTargetAirportIfValid(const Aircraft *v);
|
||||
void HandleMissingAircraftOrders(Aircraft *v);
|
||||
|
||||
const char *AirportMovementStateToString(byte state);
|
||||
const char *AirportMovementStateToString(uint8_t state);
|
||||
|
||||
#endif /* AIRCRAFT_H */
|
||||
|
@@ -692,7 +692,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. */
|
||||
@@ -710,7 +710,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
|
||||
@@ -737,7 +737,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;
|
||||
}
|
||||
|
||||
@@ -861,7 +861,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);
|
||||
@@ -1775,7 +1775,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) {
|
||||
@@ -1922,8 +1922,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);
|
||||
@@ -2059,7 +2059,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);
|
||||
@@ -2259,8 +2259,8 @@ bool Aircraft::Tick()
|
||||
}
|
||||
|
||||
if (HasBit(this->vcache.cached_veh_flags, VCF_REDRAW_ON_SPEED_CHANGE)) {
|
||||
extern byte MapAircraftMovementState(const Aircraft *v);
|
||||
byte state = MapAircraftMovementState(this);
|
||||
extern uint8_t MapAircraftMovementState(const Aircraft *v);
|
||||
uint8_t state = MapAircraftMovementState(this);
|
||||
if (state != this->acache.image_movement_state) {
|
||||
this->InvalidateImageCacheOfChain();
|
||||
this->acache.image_movement_state = state;
|
||||
@@ -2317,7 +2317,7 @@ void UpdateAirplanesOnNewStation(const Station *st)
|
||||
if (!st->airport.HasHangar()) RemoveOrderFromAllVehicles(OT_GOTO_DEPOT, st->index, true);
|
||||
}
|
||||
|
||||
const char *AirportMovementStateToString(byte state)
|
||||
const char *AirportMovementStateToString(uint8_t state)
|
||||
{
|
||||
#define AMS(s) case s: return #s;
|
||||
switch (state) {
|
||||
|
@@ -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();
|
||||
|
@@ -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 */
|
||||
|
@@ -36,11 +36,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(const CommandCost &result, TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd)
|
||||
{
|
||||
@@ -339,7 +339,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);
|
||||
@@ -355,7 +355,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;
|
||||
|
||||
|
@@ -343,7 +343,7 @@ static CommandCost BuildReplacementMultiPartShipSimple(EngineID e, const Vehicle
|
||||
for (; v != nullptr && old != nullptr; v = v->Next(), old = old->Next()) {
|
||||
if (old->cargo_type == INVALID_CARGO) continue;
|
||||
|
||||
byte subtype = GetBestFittingSubType(old, v, old->cargo_type);
|
||||
uint8_t subtype = GetBestFittingSubType(old, v, old->cargo_type);
|
||||
CommandCost refit_cost = DoCommand(0, v->index, old->cargo_type | (subtype << 8) | (1 << 16), DC_EXEC, GetCmdRefitVeh(v));
|
||||
if (refit_cost.Succeeded()) cost.AddCost(refit_cost);
|
||||
}
|
||||
@@ -396,7 +396,7 @@ static CommandCost BuildReplacementMultiPartShip(EngineID e, const Vehicle *old_
|
||||
CargoID c = FindFirstBit(available);
|
||||
assert(old_cargo_vehs[c] != nullptr);
|
||||
|
||||
byte subtype = GetBestFittingSubType(old_cargo_vehs[c], v, c);
|
||||
uint8_t subtype = GetBestFittingSubType(old_cargo_vehs[c], v, c);
|
||||
CommandCost refit_cost = DoCommand(0, v->index, c | (subtype << 8) | (1 << 16), DC_EXEC, GetCmdRefitVeh(v));
|
||||
if (refit_cost.Succeeded()) cost.AddCost(refit_cost);
|
||||
}
|
||||
@@ -453,7 +453,7 @@ static CommandCost BuildReplacementMultiPartShip(EngineID e, const Vehicle *old_
|
||||
if (c == INVALID_CARGO) continue;
|
||||
|
||||
assert(old_cargo_vehs[c] != nullptr);
|
||||
byte subtype = GetBestFittingSubType(old_cargo_vehs[c], v, c);
|
||||
uint8_t subtype = GetBestFittingSubType(old_cargo_vehs[c], v, c);
|
||||
CommandCost refit_cost = DoCommand(0, v->index, c | (subtype << 8) | (1 << 16), DC_EXEC, GetCmdRefitVeh(v));
|
||||
if (refit_cost.Succeeded()) cost.AddCost(refit_cost);
|
||||
}
|
||||
@@ -514,7 +514,7 @@ static CommandCost BuildReplacementVehicle(const Vehicle *old_veh, Vehicle **new
|
||||
|
||||
/* 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(DoCommand(0, new_veh->index, refit_cargo | (subtype << 8), DC_EXEC, GetCmdRefitVeh(new_veh)));
|
||||
assert(cost.Succeeded()); // This should be ensured by GetNewCargoTypeForReplace()
|
||||
|
@@ -83,7 +83,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.
|
||||
@@ -141,7 +141,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;
|
||||
|
||||
@@ -606,7 +606,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 {
|
||||
|
@@ -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);
|
||||
};
|
||||
|
@@ -80,8 +80,8 @@ struct BaseStation : StationPool::PoolItem<&_station_pool> {
|
||||
std::vector<RoadStopSpecList> roadstop_speclist; ///< List of road stop specs of this station
|
||||
|
||||
uint16_t random_bits; ///< Random bits assigned to this station
|
||||
byte waiting_triggers; ///< Waiting triggers (NewGRF) for this station
|
||||
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 waiting_triggers; ///< Waiting triggers (NewGRF) for this station
|
||||
uint8_t delete_ctr; ///< Delete counter. If greater than 0 then it is decremented until it reaches 0; the waypoint is then is deleted.
|
||||
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
|
||||
@@ -119,7 +119,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, uint16_t variable, byte parameter, bool *available) const = 0;
|
||||
virtual uint32_t GetNewGRFVariable(const struct ResolverObject &object, uint16_t variable, uint8_t parameter, bool *available) const = 0;
|
||||
|
||||
/**
|
||||
* Update the coordinated of the sign (as shown in the viewport).
|
||||
@@ -195,7 +195,7 @@ struct BaseStation : StationPool::PoolItem<&_station_pool> {
|
||||
return (this->facilities & facilities) != 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;
|
||||
@@ -203,7 +203,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;
|
||||
@@ -212,11 +212,11 @@ struct BaseStation : StationPool::PoolItem<&_station_pool> {
|
||||
}
|
||||
|
||||
private:
|
||||
bool SetRoadStopTileData(TileIndex tile, byte data, bool animation);
|
||||
bool SetRoadStopTileData(TileIndex tile, uint8_t data, bool animation);
|
||||
|
||||
public:
|
||||
inline void SetRoadStopRandomBits(TileIndex tile, byte random_bits) { this->SetRoadStopTileData(tile, random_bits, false); }
|
||||
inline bool SetRoadStopAnimationFrame(TileIndex tile, byte frame) { return this->SetRoadStopTileData(tile, frame, true); }
|
||||
inline void SetRoadStopRandomBits(TileIndex tile, uint8_t random_bits) { this->SetRoadStopTileData(tile, random_bits, false); }
|
||||
inline bool SetRoadStopAnimationFrame(TileIndex tile, uint8_t frame) { return this->SetRoadStopTileData(tile, frame, true); }
|
||||
void RemoveRoadStopTileData(TileIndex tile);
|
||||
|
||||
static void PostDestructor(size_t index);
|
||||
|
@@ -36,14 +36,14 @@ 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
|
||||
const int width = bp->width;
|
||||
const int pitch = bp->pitch;
|
||||
const int anim_pitch = this->anim_buf_pitch;
|
||||
@@ -54,10 +54,10 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
|
||||
Colour *dst_ln = dst + pitch;
|
||||
uint16_t *anim_ln = anim + anim_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;
|
||||
|
@@ -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;
|
||||
@@ -437,7 +437,7 @@ bmcr_alpha_blend_single_brightness:
|
||||
|
||||
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;
|
||||
}
|
||||
|
@@ -41,26 +41,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 */
|
||||
@@ -459,8 +459,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];
|
||||
|
||||
px_buffer_next = (Colour *)dst_px_ln;
|
||||
n_buffer_next = (uint16_t *)dst_n_ln;
|
||||
|
@@ -19,7 +19,7 @@ public:
|
||||
struct SpriteData {
|
||||
BlitterSpriteFlags flags;
|
||||
uint32_t offset[ZOOM_LVL_SPR_COUNT][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.
|
||||
};
|
||||
|
||||
Blitter_32bppOptimized()
|
||||
|
@@ -142,7 +142,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;
|
||||
|
@@ -61,7 +61,7 @@ public:
|
||||
struct SpriteData {
|
||||
BlitterSpriteFlags flags;
|
||||
SpriteInfo infos[ZOOM_LVL_SPR_COUNT];
|
||||
byte data[]; ///< Data, all zoomlevels.
|
||||
uint8_t data[]; ///< Data, all zoomlevels.
|
||||
};
|
||||
|
||||
Sprite *Encode(const SpriteLoader::SpriteCollection &sprite, AllocatorProc *allocator);
|
||||
|
@@ -10,10 +10,17 @@
|
||||
#ifndef BLITTER_32BPP_SSE_FUNC_HPP
|
||||
#define BLITTER_32BPP_SSE_FUNC_HPP
|
||||
|
||||
/* ATTENTION
|
||||
* This file is compiled multiple times with different defines for SSE_VERSION and MARGIN_NORMAL_THRESHOLD.
|
||||
* Be careful when declaring things with external linkage.
|
||||
* Use internal linkage instead, i.e. "static".
|
||||
*/
|
||||
#define INTERNAL_LINKAGE static
|
||||
|
||||
#ifdef WITH_SSE
|
||||
|
||||
GNU_TARGET(SSE_TARGET)
|
||||
inline void InsertFirstUint32(const uint32_t value, __m128i &into)
|
||||
INTERNAL_LINKAGE inline void InsertFirstUint32(const uint32_t value, __m128i &into)
|
||||
{
|
||||
#if (SSE_VERSION >= 4)
|
||||
into = _mm_insert_epi32(into, value, 0);
|
||||
@@ -24,7 +31,7 @@ inline void InsertFirstUint32(const uint32_t value, __m128i &into)
|
||||
}
|
||||
|
||||
GNU_TARGET(SSE_TARGET)
|
||||
inline void InsertSecondUint32(const uint32_t value, __m128i &into)
|
||||
INTERNAL_LINKAGE inline void InsertSecondUint32(const uint32_t value, __m128i &into)
|
||||
{
|
||||
#if (SSE_VERSION >= 4)
|
||||
into = _mm_insert_epi32(into, value, 1);
|
||||
@@ -35,7 +42,7 @@ inline void InsertSecondUint32(const uint32_t value, __m128i &into)
|
||||
}
|
||||
|
||||
GNU_TARGET(SSE_TARGET)
|
||||
inline void LoadUint64(const uint64_t value, __m128i &into)
|
||||
INTERNAL_LINKAGE inline void LoadUint64(const uint64_t value, __m128i &into)
|
||||
{
|
||||
#ifdef POINTER_IS_64BIT
|
||||
into = _mm_cvtsi64_si128(value);
|
||||
@@ -50,7 +57,7 @@ inline void LoadUint64(const uint64_t value, __m128i &into)
|
||||
}
|
||||
|
||||
GNU_TARGET(SSE_TARGET)
|
||||
inline __m128i PackUnsaturated(__m128i from, const __m128i &mask)
|
||||
INTERNAL_LINKAGE inline __m128i PackUnsaturated(__m128i from, const __m128i &mask)
|
||||
{
|
||||
#if (SSE_VERSION == 2)
|
||||
from = _mm_and_si128(from, mask); // PAND, wipe high bytes to keep low bytes when packing
|
||||
@@ -61,7 +68,7 @@ inline __m128i PackUnsaturated(__m128i from, const __m128i &mask)
|
||||
}
|
||||
|
||||
GNU_TARGET(SSE_TARGET)
|
||||
inline __m128i DistributeAlpha(const __m128i from, const __m128i &mask)
|
||||
INTERNAL_LINKAGE inline __m128i DistributeAlpha(const __m128i from, const __m128i &mask)
|
||||
{
|
||||
#if (SSE_VERSION == 2)
|
||||
__m128i alphaAB = _mm_shufflelo_epi16(from, 0x3F); // PSHUFLW, put alpha1 in front of each rgb1
|
||||
@@ -73,7 +80,7 @@ inline __m128i DistributeAlpha(const __m128i from, const __m128i &mask)
|
||||
}
|
||||
|
||||
GNU_TARGET(SSE_TARGET)
|
||||
inline __m128i AlphaBlendTwoPixels(__m128i src, __m128i dst, const __m128i &distribution_mask, const __m128i &pack_mask, const __m128i &alpha_mask)
|
||||
INTERNAL_LINKAGE inline __m128i AlphaBlendTwoPixels(__m128i src, __m128i dst, const __m128i &distribution_mask, const __m128i &pack_mask, const __m128i &alpha_mask)
|
||||
{
|
||||
__m128i srcAB = _mm_unpacklo_epi8(src, _mm_setzero_si128()); // PUNPCKLBW, expand each uint8_t into uint16
|
||||
__m128i dstAB = _mm_unpacklo_epi8(dst, _mm_setzero_si128());
|
||||
@@ -97,7 +104,7 @@ inline __m128i AlphaBlendTwoPixels(__m128i src, __m128i dst, const __m128i &dist
|
||||
* rgb = rgb * ((256/4) * 4 - (alpha/4)) / ((256/4) * 4)
|
||||
*/
|
||||
GNU_TARGET(SSE_TARGET)
|
||||
inline __m128i DarkenTwoPixels(__m128i src, __m128i dst, const __m128i &distribution_mask, const __m128i &tr_nom_base)
|
||||
INTERNAL_LINKAGE inline __m128i DarkenTwoPixels(__m128i src, __m128i dst, const __m128i &distribution_mask, const __m128i &tr_nom_base)
|
||||
{
|
||||
__m128i srcAB = _mm_unpacklo_epi8(src, _mm_setzero_si128());
|
||||
__m128i dstAB = _mm_unpacklo_epi8(dst, _mm_setzero_si128());
|
||||
@@ -111,7 +118,7 @@ inline __m128i DarkenTwoPixels(__m128i src, __m128i dst, const __m128i &distribu
|
||||
|
||||
IGNORE_UNINITIALIZED_WARNING_START
|
||||
GNU_TARGET(SSE_TARGET)
|
||||
static Colour ReallyAdjustBrightness(Colour colour, uint8_t brightness)
|
||||
INTERNAL_LINKAGE Colour ReallyAdjustBrightness(Colour colour, uint8_t brightness)
|
||||
{
|
||||
uint64_t c16 = colour.b | (uint64_t) colour.g << 16 | (uint64_t) colour.r << 32;
|
||||
c16 *= brightness;
|
||||
@@ -145,7 +152,7 @@ IGNORE_UNINITIALIZED_WARNING_STOP
|
||||
/** ReallyAdjustBrightness() is not called that often.
|
||||
* Inlining this function implies a far jump, which has a huge latency.
|
||||
*/
|
||||
inline Colour AdjustBrightneSSE(Colour colour, uint8_t brightness)
|
||||
INTERNAL_LINKAGE inline Colour AdjustBrightneSSE(Colour colour, uint8_t brightness)
|
||||
{
|
||||
/* Shortcut for normal brightness. */
|
||||
if (likely(brightness == Blitter_32bppBase::DEFAULT_BRIGHTNESS)) return colour;
|
||||
@@ -154,7 +161,7 @@ inline Colour AdjustBrightneSSE(Colour colour, uint8_t brightness)
|
||||
}
|
||||
|
||||
GNU_TARGET(SSE_TARGET)
|
||||
inline __m128i AdjustBrightnessOfTwoPixels([[maybe_unused]] __m128i from, [[maybe_unused]] uint32_t brightness)
|
||||
INTERNAL_LINKAGE inline __m128i AdjustBrightnessOfTwoPixels([[maybe_unused]] __m128i from, [[maybe_unused]] uint32_t brightness)
|
||||
{
|
||||
#if (SSE_VERSION < 3)
|
||||
NOT_REACHED();
|
||||
@@ -214,7 +221,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 +229,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);
|
||||
|
||||
uint32_t bm_normal_brightness = 0;
|
||||
if (mode == BM_NORMAL_WITH_BRIGHTNESS) {
|
||||
@@ -313,7 +320,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; \
|
||||
@@ -496,7 +503,7 @@ bmcr_alpha_blend_single_brightness:
|
||||
|
||||
next_line:
|
||||
if (mode == BM_COLOUR_REMAP || mode == BM_CRASH_REMAP || mode == BM_COLOUR_REMAP_WITH_BRIGHTNESS) 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;
|
||||
}
|
||||
}
|
||||
|
@@ -10,6 +10,12 @@
|
||||
#ifndef BLITTER_32BPP_SSE_TYPE_H
|
||||
#define BLITTER_32BPP_SSE_TYPE_H
|
||||
|
||||
/* ATTENTION
|
||||
* This file is compiled multiple times with different defines for SSE_VERSION.
|
||||
* Be careful when declaring things with external linkage.
|
||||
* Use internal linkage instead, i.e. "static".
|
||||
*/
|
||||
|
||||
#ifdef WITH_SSE
|
||||
|
||||
#include "32bpp_simple.hpp"
|
||||
|
@@ -167,8 +167,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 */
|
||||
@@ -177,7 +177,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 */
|
||||
@@ -185,11 +185,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 */
|
||||
|
@@ -148,10 +148,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++) {
|
||||
@@ -167,7 +167,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];
|
||||
@@ -214,7 +214,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);
|
||||
|
@@ -19,7 +19,7 @@ public:
|
||||
/** Data stored about a (single) sprite. */
|
||||
struct SpriteData {
|
||||
uint32_t offset[ZOOM_LVL_SPR_COUNT]; ///< 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;
|
||||
|
@@ -58,7 +58,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 brightness_adjust; ///< Brightness adjustment
|
||||
|
||||
int skip_left; ///< How much pixels of the source to skip on the left (based on zoom of dst)
|
||||
|
46
src/bmp.cpp
46
src/bmp.cpp
@@ -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);
|
||||
|
@@ -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;
|
||||
|
@@ -63,7 +63,7 @@ enum BridgeSpecCtrlFlags {
|
||||
*/
|
||||
struct BridgeSpec {
|
||||
CalTime::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)
|
||||
@@ -72,9 +72,9 @@ 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.
|
||||
byte ctrl_flags; ///< control flags
|
||||
byte pillar_flags[12]; ///< bridge pillar flags: 6 x pairs of x and y flags
|
||||
uint8_t flags; ///< bit 0 set: disable drawing of far pillars.
|
||||
uint8_t ctrl_flags; ///< control flags
|
||||
uint8_t pillar_flags[12]; ///< bridge pillar flags: 6 x pairs of x and y flags
|
||||
};
|
||||
|
||||
extern BridgeSpec _bridge[MAX_BRIDGES];
|
||||
|
@@ -373,7 +373,7 @@ static WindowDesc _build_bridge_desc(__FILE__, __LINE__,
|
||||
* @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);
|
||||
|
||||
|
@@ -360,7 +360,7 @@ inline bool IsCustomBridgeHeadTile(TileIndex t)
|
||||
inline TrackBits GetBridgeReservationTrackBits(TileIndex t)
|
||||
{
|
||||
assert_tile(IsRailBridgeHeadTile(t), t);
|
||||
byte track_b = GB(_m[t].m2, 0, 3);
|
||||
uint8_t track_b = GB(_m[t].m2, 0, 3);
|
||||
Track track = (Track)(track_b - 1); // map array saves Track+1
|
||||
if (track_b == 0) return TRACK_BIT_NONE;
|
||||
return (TrackBits)(TrackToTrackBits(track) | (HasBit(_m[t].m2, 3) ? TrackToTrackBits(TrackToOppositeTrack(track)) : 0));
|
||||
@@ -378,7 +378,7 @@ inline void SetBridgeReservationTrackBits(TileIndex t, TrackBits b)
|
||||
assert(!TracksOverlap(b));
|
||||
Track track = RemoveFirstTrack(&b);
|
||||
SB(_m[t].m2, 0, 3, track == INVALID_TRACK ? 0 : track + 1);
|
||||
SB(_m[t].m2, 3, 1, (byte)(b != TRACK_BIT_NONE));
|
||||
SB(_m[t].m2, 3, 1, (uint8_t)(b != TRACK_BIT_NONE));
|
||||
}
|
||||
|
||||
|
||||
|
@@ -199,7 +199,7 @@ static constexpr NWidgetPart _nested_build_vehicle_widgets_train_advanced[] = {
|
||||
};
|
||||
|
||||
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.
|
||||
bool _engine_sort_show_hidden_locos = false; ///< Last set 'show hidden locos' setting.
|
||||
@@ -229,11 +229,11 @@ struct EngineCapacityCache {
|
||||
};
|
||||
static EngineCapacityCache *_engine_sort_capacity_cache = nullptr;
|
||||
|
||||
static byte _last_sort_criteria_loco = 0;
|
||||
static uint8_t _last_sort_criteria_loco = 0;
|
||||
static bool _last_sort_order_loco = false;
|
||||
static CargoID _last_filter_criteria_loco = CargoFilterCriteria::CF_ANY;
|
||||
|
||||
static byte _last_sort_criteria_wagon = 0;
|
||||
static uint8_t _last_sort_criteria_wagon = 0;
|
||||
static bool _last_sort_order_wagon = false;
|
||||
static CargoID _last_filter_criteria_wagon = CargoFilterCriteria::CF_ANY;
|
||||
|
||||
@@ -1528,7 +1528,7 @@ struct BuildVehicleWindow : BuildVehicleWindowBase {
|
||||
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.
|
||||
EngineID sel_engine; ///< Currently selected engine, or #INVALID_ENGINE
|
||||
EngineID rename_engine; ///< Engine being renamed.
|
||||
@@ -2349,7 +2349,7 @@ struct BuildVehicleWindowTrainAdvanced final : BuildVehicleWindowBase {
|
||||
|
||||
struct PanelState {
|
||||
bool descending_sort_order; ///< Sort direction, @see _engine_sort_direction
|
||||
byte sort_criteria; ///< Current sort criterium.
|
||||
uint8_t sort_criteria; ///< Current sort criterium.
|
||||
EngineID sel_engine; ///< Currently selected engine, or #INVALID_ENGINE
|
||||
EngineID rename_engine {}; ///< Engine being renamed.
|
||||
GUIEngineList eng_list;
|
||||
@@ -3151,7 +3151,7 @@ struct BuildVehicleWindowTrainAdvanced final : BuildVehicleWindowBase {
|
||||
switch (widget) {
|
||||
case WID_BV_SORT_DROPDOWN_LOCO: {
|
||||
if (this->loco.sort_criteria != index) {
|
||||
this->loco.sort_criteria = static_cast<byte>(index);
|
||||
this->loco.sort_criteria = static_cast<uint8_t>(index);
|
||||
_last_sort_criteria_loco = this->loco.sort_criteria;
|
||||
this->loco.eng_list.ForceRebuild();
|
||||
}
|
||||
@@ -3160,7 +3160,7 @@ struct BuildVehicleWindowTrainAdvanced final : BuildVehicleWindowBase {
|
||||
|
||||
case WID_BV_CARGO_FILTER_DROPDOWN_LOCO: { // Select a cargo filter criteria
|
||||
if (this->loco.cargo_filter_criteria != index) {
|
||||
this->loco.cargo_filter_criteria = static_cast<byte>(index);
|
||||
this->loco.cargo_filter_criteria = static_cast<uint8_t>(index);
|
||||
_last_filter_criteria_loco = this->loco.cargo_filter_criteria;
|
||||
/* deactivate filter if criteria is 'Show All', activate it otherwise */
|
||||
this->loco.eng_list.SetFilterState(this->loco.cargo_filter_criteria != CargoFilterCriteria::CF_ANY);
|
||||
@@ -3171,7 +3171,7 @@ struct BuildVehicleWindowTrainAdvanced final : BuildVehicleWindowBase {
|
||||
|
||||
case WID_BV_SORT_DROPDOWN_WAGON: {
|
||||
if (this->wagon.sort_criteria != index) {
|
||||
this->wagon.sort_criteria = static_cast<byte>(index);
|
||||
this->wagon.sort_criteria = static_cast<uint8_t>(index);
|
||||
_last_sort_criteria_wagon = this->wagon.sort_criteria;
|
||||
this->wagon.eng_list.ForceRebuild();
|
||||
}
|
||||
@@ -3180,7 +3180,7 @@ struct BuildVehicleWindowTrainAdvanced final : BuildVehicleWindowBase {
|
||||
|
||||
case WID_BV_CARGO_FILTER_DROPDOWN_WAGON: { // Select a cargo filter criteria
|
||||
if (this->wagon.cargo_filter_criteria != index) {
|
||||
this->wagon.cargo_filter_criteria = static_cast<byte>(index);
|
||||
this->wagon.cargo_filter_criteria = static_cast<uint8_t>(index);
|
||||
_last_filter_criteria_wagon = this->wagon.cargo_filter_criteria;
|
||||
/* deactivate filter if criteria is 'Show All', activate it otherwise */
|
||||
this->wagon.eng_list.SetFilterState(this->wagon.cargo_filter_criteria != CargoFilterCriteria::CF_ANY);
|
||||
|
@@ -22,7 +22,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
|
||||
@@ -149,7 +149,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
|
||||
|
@@ -19,7 +19,7 @@
|
||||
#include <vector>
|
||||
|
||||
/** 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.
|
||||
@@ -32,7 +32,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.
|
||||
@@ -61,7 +61,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;
|
||||
|
||||
|
@@ -46,12 +46,12 @@ static CommandCost ClearTile_Clear(TileIndex tile, DoCommandFlag flags)
|
||||
return price;
|
||||
}
|
||||
|
||||
SpriteID GetSpriteIDForClearLand(const Slope slope, byte set)
|
||||
SpriteID GetSpriteIDForClearLand(const Slope slope, uint8_t set)
|
||||
{
|
||||
return SPR_FLAT_BARE_LAND + SlopeToSpriteOffset(slope) + set * 19;
|
||||
}
|
||||
|
||||
void DrawClearLandTile(const TileInfo *ti, byte set)
|
||||
void DrawClearLandTile(const TileInfo *ti, uint8_t set)
|
||||
{
|
||||
DrawGroundSprite(GetSpriteIDForClearLand(ti->tileh, set), PAL_NONE);
|
||||
}
|
||||
|
@@ -13,9 +13,9 @@
|
||||
#include "tile_cmd.h"
|
||||
|
||||
void DrawHillyLandTile(const TileInfo *ti);
|
||||
void DrawClearLandTile(const TileInfo *ti, byte set);
|
||||
void DrawClearLandTile(const TileInfo *ti, uint8_t set);
|
||||
|
||||
SpriteID GetSpriteIDForClearLand(const Slope slope, byte set);
|
||||
SpriteID GetSpriteIDForClearLand(const Slope slope, uint8_t set);
|
||||
SpriteID GetSpriteIDForHillyLand(const Slope slope, const uint rough_index);
|
||||
SpriteID GetSpriteIDForRocks(const Slope slope, const uint tile_hash);
|
||||
SpriteID GetSpriteIDForFields(const Slope slope, const uint field_type);
|
||||
|
@@ -1119,7 +1119,7 @@ CommandCost DoCommandPInternal(TileIndex tile, uint32_t p1, uint32_t p2, uint64_
|
||||
_additional_cash_required = 0;
|
||||
|
||||
/* Get pointer to command handler */
|
||||
byte cmd_id = cmd & CMD_ID_MASK;
|
||||
uint cmd_id = cmd & CMD_ID_MASK;
|
||||
assert(cmd_id < lengthof(_command_proc_table));
|
||||
|
||||
const Command &command = _command_proc_table[cmd_id];
|
||||
@@ -1177,7 +1177,7 @@ CommandCost DoCommandPInternal(TileIndex tile, uint32_t p1, uint32_t p2, uint64_
|
||||
if (_debug_desync_level >= 1) {
|
||||
std::string aux_str;
|
||||
if (aux_data != nullptr) {
|
||||
std::vector<byte> buffer;
|
||||
std::vector<uint8_t> buffer;
|
||||
CommandSerialisationBuffer serialiser(buffer, SHRT_MAX);
|
||||
aux_data->Serialise(serialiser);
|
||||
aux_str = FormatArrayAsHex(buffer);
|
||||
|
@@ -25,7 +25,7 @@ struct CommandDeserialisationBuffer : public BufferDeserialisationHelper<Command
|
||||
|
||||
CommandDeserialisationBuffer(const uint8_t *buffer, size_t size) : buffer(buffer), size(size) {}
|
||||
|
||||
const byte *GetDeserialisationBuffer() const { return this->buffer; }
|
||||
const uint8_t *GetDeserialisationBuffer() const { return this->buffer; }
|
||||
size_t GetDeserialisationBufferSize() const { return this->size; }
|
||||
size_t &GetDeserialisationPosition() { return this->pos; }
|
||||
|
||||
@@ -44,17 +44,17 @@ struct CommandDeserialisationBuffer : public BufferDeserialisationHelper<Command
|
||||
};
|
||||
|
||||
struct CommandSerialisationBuffer : public BufferSerialisationHelper<CommandSerialisationBuffer> {
|
||||
std::vector<byte> &buffer;
|
||||
std::vector<uint8_t> &buffer;
|
||||
size_t limit;
|
||||
|
||||
CommandSerialisationBuffer(std::vector<byte> &buffer, size_t limit) : buffer(buffer), limit(limit) {}
|
||||
CommandSerialisationBuffer(std::vector<uint8_t> &buffer, size_t limit) : buffer(buffer), limit(limit) {}
|
||||
|
||||
std::vector<byte> &GetSerialisationBuffer() { return this->buffer; }
|
||||
std::vector<uint8_t> &GetSerialisationBuffer() { return this->buffer; }
|
||||
size_t GetSerialisationLimit() const { return this->limit; }
|
||||
};
|
||||
|
||||
struct CommandAuxiliarySerialised : public CommandAuxiliaryBase {
|
||||
std::vector<byte> serialised_data;
|
||||
std::vector<uint8_t> serialised_data;
|
||||
|
||||
CommandAuxiliaryBase *Clone() const override
|
||||
{
|
||||
|
@@ -65,7 +65,7 @@ private:
|
||||
std::vector<BitmapStorage> used_bitmap;
|
||||
};
|
||||
|
||||
enum CompanyBankruptcyFlags : byte {
|
||||
enum CompanyBankruptcyFlags : uint8_t {
|
||||
CBRF_NONE = 0x0,
|
||||
CBRF_SALE = 0x1, ///< the company has been marked for sale
|
||||
CBRF_SALE_ONLY = 0x2, ///< the company has been marked for sale without being in a bankruptcy state first
|
||||
@@ -88,13 +88,13 @@ 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.
|
||||
@@ -105,7 +105,7 @@ struct CompanyProperties {
|
||||
int32_t display_inaugurated_period;///< Wallclock display period of starting the company.
|
||||
YearDelta age_years; ///< Number of economy years that the company has been operational.
|
||||
|
||||
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
|
||||
CompanyID bankrupt_last_asked; ///< Which company was most recently asked about buying it?
|
||||
CompanyBankruptcyFlags bankrupt_flags; ///< bankruptcy flags
|
||||
CompanyMask bankrupt_asked; ///< which companies were asked about buying it?
|
||||
@@ -127,7 +127,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];
|
||||
|
||||
|
@@ -323,10 +323,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));
|
||||
@@ -473,7 +473,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
|
||||
|
@@ -651,7 +651,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) {
|
||||
@@ -692,7 +692,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 {
|
||||
@@ -2636,7 +2636,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();
|
||||
|
@@ -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
|
||||
};
|
||||
|
||||
|
@@ -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
|
||||
@@ -47,7 +47,7 @@ static const uint MIN_COMPETITORS_INTERVAL = 0; ///< The minimum interval (in
|
||||
static const uint MAX_COMPETITORS_INTERVAL = 500; ///< The maximum interval (in minutes) between competitors.
|
||||
|
||||
/** Define basic enum properties */
|
||||
template <> struct EnumPropsT<Owner> : MakeEnumPropsT<Owner, byte, OWNER_BEGIN, OWNER_END, INVALID_OWNER> {};
|
||||
template <> struct EnumPropsT<Owner> : MakeEnumPropsT<Owner, uint8_t, OWNER_BEGIN, OWNER_END, INVALID_OWNER> {};
|
||||
|
||||
typedef Owner CompanyID;
|
||||
|
||||
|
@@ -249,7 +249,7 @@ 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;
|
||||
|
||||
|
@@ -111,7 +111,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)
|
||||
|
||||
/****************
|
||||
@@ -2367,7 +2367,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");
|
||||
@@ -3810,7 +3810,7 @@ DEF_CONSOLE_CMD(ConSwitchBaseset)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static bool ConConditionalCommon(byte argc, char *argv[], int value, const char *value_name, const char *name)
|
||||
static bool ConConditionalCommon(uint8_t argc, char *argv[], int value, const char *value_name, const char *name)
|
||||
{
|
||||
if (argc < 4) {
|
||||
IConsolePrintF(CC_WARNING, "- Execute command if %s is within the specified range. Usage: '%s <minimum> <maximum> <command...>'", value_name, name);
|
||||
|
@@ -31,7 +31,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, bool unlisted) : name(name), proc(proc), hook(hook), unlisted(unlisted) {}
|
||||
|
@@ -94,14 +94,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.
|
||||
|
@@ -49,7 +49,7 @@ inline bool ShouldLogUpdateStateChecksum()
|
||||
return _networking && (!_network_server || (NetworkClientSocket::IsValidID(0) && NetworkClientSocket::Get(0)->status != NetworkClientSocket::STATUS_INACTIVE));
|
||||
}
|
||||
# define DEBUG_UPDATESTATECHECKSUM(str, ...) if (ShouldLogUpdateStateChecksum()) DEBUG(statecsum, 0, "%s; %04x; %02x; " OTTD_PRINTFHEX64PAD "; %s:%d " str, \
|
||||
debug_date_dumper().HexDate(), _frame_counter, (byte)_current_company, _state_checksum.state, __FILE__, __LINE__, __VA_ARGS__);
|
||||
debug_date_dumper().HexDate(), _frame_counter, (uint8_t)_current_company, _state_checksum.state, __FILE__, __LINE__, __VA_ARGS__);
|
||||
#else
|
||||
# define DEBUG_UPDATESTATECHECKSUM(str, ...)
|
||||
#endif /* RANDOM_DEBUG */
|
||||
|
@@ -49,7 +49,7 @@
|
||||
* other templates below. Here we have only forward declaration. For each enum type
|
||||
* we will create specialization derived from MakeEnumPropsT<>.
|
||||
* i.e.:
|
||||
* template <> struct EnumPropsT<Track> : MakeEnumPropsT<Track, byte, TRACK_BEGIN, TRACK_END, INVALID_TRACK> {};
|
||||
* template <> struct EnumPropsT<Track> : MakeEnumPropsT<Track, uint8_t, TRACK_BEGIN, TRACK_END, INVALID_TRACK> {};
|
||||
*/
|
||||
template <typename Tenum_t> struct EnumPropsT;
|
||||
|
||||
@@ -58,7 +58,7 @@ template <typename Tenum_t> struct EnumPropsT;
|
||||
* from outsize. It is used as base class of several EnumPropsT specializations each
|
||||
* dedicated to one of commonly used enumeration types.
|
||||
* @param Tenum_t enumeration type that you want to describe
|
||||
* @param Tstorage_t what storage type would be sufficient (i.e. byte)
|
||||
* @param Tstorage_t what storage type would be sufficient (i.e. uint8_t)
|
||||
* @param Tbegin first valid value from the contiguous range (i.e. TRACK_BEGIN)
|
||||
* @param Tend one past the last valid value from the contiguous range (i.e. TRACK_END)
|
||||
* @param Tinvalid value used as invalid value marker (i.e. INVALID_TRACK)
|
||||
@@ -67,7 +67,7 @@ template <typename Tenum_t> struct EnumPropsT;
|
||||
template <typename Tenum_t, typename Tstorage_t, Tenum_t Tbegin, Tenum_t Tend, Tenum_t Tinvalid, uint Tnum_bits = 8 * sizeof(Tstorage_t)>
|
||||
struct MakeEnumPropsT {
|
||||
typedef Tenum_t type; ///< enum type (i.e. Trackdir)
|
||||
typedef Tstorage_t storage; ///< storage type (i.e. byte)
|
||||
typedef Tstorage_t storage; ///< storage type (i.e. uint8_t)
|
||||
static const Tenum_t begin = Tbegin; ///< lowest valid value (i.e. TRACKDIR_BEGIN)
|
||||
static const Tenum_t end = Tend; ///< one after the last valid value (i.e. TRACKDIR_END)
|
||||
static const Tenum_t invalid = Tinvalid; ///< what value is used as invalid value (i.e. INVALID_TRACKDIR)
|
||||
|
@@ -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));
|
||||
}
|
||||
|
@@ -138,7 +138,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; }
|
||||
@@ -197,11 +197,11 @@ 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 b * 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; }
|
||||
/* Sometimes we got uint8_t operator OverflowSafeInt instead of vice versa. Handle that properly. */
|
||||
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;
|
||||
|
@@ -125,9 +125,9 @@ DEFINE_POOL_METHOD(inline void *)::AllocateItem(size_t size, size_t index, Pool:
|
||||
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] = Tops::PutPtr(item, param);
|
||||
SetBit(this->free_bitmap[index / 64], index % 64);
|
||||
|
@@ -87,7 +87,7 @@ void SetRandomSeed(uint32_t seed)
|
||||
uint32_t DoRandom(int line, const char *file)
|
||||
{
|
||||
if (_networking && (!_network_server || (NetworkClientSocket::IsValidID(0) && NetworkClientSocket::Get(0)->status != NetworkClientSocket::STATUS_INACTIVE))) {
|
||||
DEBUG(random, 0, "%s; %04x; %02x; %s:%d", debug_date_dumper().HexDate(), _frame_counter, (byte)_current_company, file, line);
|
||||
DEBUG(random, 0, "%s; %04x; %02x; %s:%d", debug_date_dumper().HexDate(), _frame_counter, (uint8_t)_current_company, file, line);
|
||||
}
|
||||
|
||||
return _random.Next();
|
||||
|
@@ -25,7 +25,7 @@
|
||||
template <class T>
|
||||
class ring_buffer
|
||||
{
|
||||
std::unique_ptr<byte, FreeDeleter> data;
|
||||
std::unique_ptr<uint8_t, FreeDeleter> data;
|
||||
uint32_t head = 0;
|
||||
uint32_t count = 0;
|
||||
uint32_t mask = (uint32_t)-1;
|
||||
@@ -219,11 +219,11 @@ public:
|
||||
void construct_from(const U &other)
|
||||
{
|
||||
uint32_t cap = round_up_size((uint32_t)other.size());
|
||||
this->data.reset(MallocT<byte>(cap * sizeof(T)));
|
||||
this->data.reset(MallocT<uint8_t>(cap * sizeof(T)));
|
||||
this->mask = cap - 1;
|
||||
this->head = 0;
|
||||
this->count = (uint32_t)other.size();
|
||||
byte *ptr = this->data.get();
|
||||
uint8_t *ptr = this->data.get();
|
||||
for (const T &item : other) {
|
||||
new (ptr) T(item);
|
||||
ptr += sizeof(T);
|
||||
@@ -259,12 +259,12 @@ public:
|
||||
if (!other.empty()) {
|
||||
if (other.size() > this->capacity()) {
|
||||
uint32_t cap = round_up_size(other.count);
|
||||
this->data.reset(MallocT<byte>(cap * sizeof(T)));
|
||||
this->data.reset(MallocT<uint8_t>(cap * sizeof(T)));
|
||||
this->mask = cap - 1;
|
||||
}
|
||||
this->head = 0;
|
||||
this->count = other.count;
|
||||
byte *ptr = this->data.get();
|
||||
uint8_t *ptr = this->data.get();
|
||||
for (const T &item : other) {
|
||||
new (ptr) T(item);
|
||||
ptr += sizeof(T);
|
||||
@@ -341,8 +341,8 @@ private:
|
||||
void reallocate(uint32_t new_cap)
|
||||
{
|
||||
const uint32_t cap = round_up_size(new_cap);
|
||||
byte *new_buf = MallocT<byte>(cap * sizeof(T));
|
||||
byte *pos = new_buf;
|
||||
uint8_t *new_buf = MallocT<uint8_t>(cap * sizeof(T));
|
||||
uint8_t *pos = new_buf;
|
||||
for (T &item : *this) {
|
||||
new (pos) T(std::move(item));
|
||||
item.~T();
|
||||
@@ -522,8 +522,8 @@ private:
|
||||
if (this->count + num > (uint32_t)this->capacity()) {
|
||||
/* grow container */
|
||||
const uint32_t cap = round_up_size(this->count + num);
|
||||
byte *new_buf = MallocT<byte>(cap * sizeof(T));
|
||||
byte *write_to = new_buf;
|
||||
uint8_t *new_buf = MallocT<uint8_t>(cap * sizeof(T));
|
||||
uint8_t *write_to = new_buf;
|
||||
const uint32_t end = this->head + this->count;
|
||||
for (uint32_t idx = this->head; idx != end; idx++) {
|
||||
if (idx == pos) {
|
||||
|
@@ -16,7 +16,7 @@
|
||||
* @param bytes_to_write The amount of bytes we want to try to write.
|
||||
* @return True iff the given amount of bytes can be written to the packet.
|
||||
*/
|
||||
[[maybe_unused]] static bool BufferCanWriteToPacket(const std::vector<byte> &buffer, size_t limit, size_t bytes_to_write)
|
||||
[[maybe_unused]] static bool BufferCanWriteToPacket(const std::vector<uint8_t> &buffer, size_t limit, size_t bytes_to_write)
|
||||
{
|
||||
return buffer.size() + bytes_to_write <= limit;
|
||||
}
|
||||
@@ -37,7 +37,7 @@
|
||||
* Package a boolean in the packet.
|
||||
* @param data The data to send.
|
||||
*/
|
||||
void BufferSend_bool(std::vector<byte> &buffer, size_t limit, bool data)
|
||||
void BufferSend_bool(std::vector<uint8_t> &buffer, size_t limit, bool data)
|
||||
{
|
||||
BufferSend_uint8(buffer, limit, data ? 1 : 0);
|
||||
}
|
||||
@@ -46,7 +46,7 @@ void BufferSend_bool(std::vector<byte> &buffer, size_t limit, bool data)
|
||||
* Package a 8 bits integer in the packet.
|
||||
* @param data The data to send.
|
||||
*/
|
||||
void BufferSend_uint8(std::vector<byte> &buffer, size_t limit, uint8_t data)
|
||||
void BufferSend_uint8(std::vector<uint8_t> &buffer, size_t limit, uint8_t data)
|
||||
{
|
||||
assert(BufferCanWriteToPacket(buffer, limit, sizeof(data)));
|
||||
buffer.emplace_back(data);
|
||||
@@ -56,7 +56,7 @@ void BufferSend_uint8(std::vector<byte> &buffer, size_t limit, uint8_t data)
|
||||
* Package a 16 bits integer in the packet.
|
||||
* @param data The data to send.
|
||||
*/
|
||||
void BufferSend_uint16(std::vector<byte> &buffer, size_t limit, uint16_t data)
|
||||
void BufferSend_uint16(std::vector<uint8_t> &buffer, size_t limit, uint16_t data)
|
||||
{
|
||||
assert(BufferCanWriteToPacket(buffer, limit, sizeof(data)));
|
||||
buffer.insert(buffer.end(), {
|
||||
@@ -69,7 +69,7 @@ void BufferSend_uint16(std::vector<byte> &buffer, size_t limit, uint16_t data)
|
||||
* Package a 32 bits integer in the packet.
|
||||
* @param data The data to send.
|
||||
*/
|
||||
void BufferSend_uint32(std::vector<byte> &buffer, size_t limit, uint32_t data)
|
||||
void BufferSend_uint32(std::vector<uint8_t> &buffer, size_t limit, uint32_t data)
|
||||
{
|
||||
assert(BufferCanWriteToPacket(buffer, limit, sizeof(data)));
|
||||
buffer.insert(buffer.end(), {
|
||||
@@ -84,7 +84,7 @@ void BufferSend_uint32(std::vector<byte> &buffer, size_t limit, uint32_t data)
|
||||
* Package a 64 bits integer in the packet.
|
||||
* @param data The data to send.
|
||||
*/
|
||||
void BufferSend_uint64(std::vector<byte> &buffer, size_t limit, uint64_t data)
|
||||
void BufferSend_uint64(std::vector<uint8_t> &buffer, size_t limit, uint64_t data)
|
||||
{
|
||||
assert(BufferCanWriteToPacket(buffer, limit, sizeof(data)));
|
||||
buffer.insert(buffer.end(), {
|
||||
@@ -104,7 +104,7 @@ void BufferSend_uint64(std::vector<byte> &buffer, size_t limit, uint64_t data)
|
||||
* the string + '\0'. No size-byte or something.
|
||||
* @param data The string to send
|
||||
*/
|
||||
void BufferSend_string(std::vector<byte> &buffer, size_t limit, const std::string_view data)
|
||||
void BufferSend_string(std::vector<uint8_t> &buffer, size_t limit, const std::string_view data)
|
||||
{
|
||||
assert(BufferCanWriteToPacket(buffer, limit, data.size() + 1));
|
||||
buffer.insert(buffer.end(), data.begin(), data.end());
|
||||
@@ -119,7 +119,7 @@ void BufferSend_string(std::vector<byte> &buffer, size_t limit, const std::strin
|
||||
* @param end The end of the buffer to send.
|
||||
* @return The number of bytes that were added to this packet.
|
||||
*/
|
||||
size_t BufferSend_binary_until_full(std::vector<byte> &buffer, size_t limit, const byte *begin, const byte *end)
|
||||
size_t BufferSend_binary_until_full(std::vector<uint8_t> &buffer, size_t limit, const uint8_t *begin, const uint8_t *end)
|
||||
{
|
||||
size_t amount = std::min<size_t>(end - begin, limit - buffer.size());
|
||||
buffer.insert(buffer.end(), begin, begin + amount);
|
||||
@@ -130,7 +130,7 @@ size_t BufferSend_binary_until_full(std::vector<byte> &buffer, size_t limit, con
|
||||
* Sends a binary data over the network.
|
||||
* @param data The data to send
|
||||
*/
|
||||
void BufferSend_binary(std::vector<byte> &buffer, size_t limit, const byte *data, const size_t size)
|
||||
void BufferSend_binary(std::vector<uint8_t> &buffer, size_t limit, const uint8_t *data, const size_t size)
|
||||
{
|
||||
assert(data != nullptr);
|
||||
assert(BufferCanWriteToPacket(buffer, limit, size));
|
||||
@@ -142,7 +142,7 @@ void BufferSend_binary(std::vector<byte> &buffer, size_t limit, const byte *data
|
||||
* The data is length prefixed with a uint16.
|
||||
* @param data The string to send
|
||||
*/
|
||||
void BufferSend_buffer(std::vector<byte> &buffer, size_t limit, const byte *data, const size_t size)
|
||||
void BufferSend_buffer(std::vector<uint8_t> &buffer, size_t limit, const uint8_t *data, const size_t size)
|
||||
{
|
||||
assert(size <= UINT16_MAX);
|
||||
assert(BufferCanWriteToPacket(buffer, limit, size + 2));
|
||||
|
@@ -18,15 +18,15 @@
|
||||
#include <string>
|
||||
#include <limits>
|
||||
|
||||
void BufferSend_bool (std::vector<byte> &buffer, size_t limit, bool data);
|
||||
void BufferSend_uint8 (std::vector<byte> &buffer, size_t limit, uint8_t data);
|
||||
void BufferSend_uint16(std::vector<byte> &buffer, size_t limit, uint16_t data);
|
||||
void BufferSend_uint32(std::vector<byte> &buffer, size_t limit, uint32_t data);
|
||||
void BufferSend_uint64(std::vector<byte> &buffer, size_t limit, uint64_t data);
|
||||
void BufferSend_string(std::vector<byte> &buffer, size_t limit, const std::string_view data);
|
||||
size_t BufferSend_binary_until_full(std::vector<byte> &buffer, size_t limit, const byte *begin, const byte *end);
|
||||
void BufferSend_binary(std::vector<byte> &buffer, size_t limit, const byte *data, const size_t size);
|
||||
void BufferSend_buffer(std::vector<byte> &buffer, size_t limit, const byte *data, const size_t size);
|
||||
void BufferSend_bool (std::vector<uint8_t> &buffer, size_t limit, bool data);
|
||||
void BufferSend_uint8 (std::vector<uint8_t> &buffer, size_t limit, uint8_t data);
|
||||
void BufferSend_uint16(std::vector<uint8_t> &buffer, size_t limit, uint16_t data);
|
||||
void BufferSend_uint32(std::vector<uint8_t> &buffer, size_t limit, uint32_t data);
|
||||
void BufferSend_uint64(std::vector<uint8_t> &buffer, size_t limit, uint64_t data);
|
||||
void BufferSend_string(std::vector<uint8_t> &buffer, size_t limit, const std::string_view data);
|
||||
size_t BufferSend_binary_until_full(std::vector<uint8_t> &buffer, size_t limit, const uint8_t *begin, const uint8_t *end);
|
||||
void BufferSend_binary(std::vector<uint8_t> &buffer, size_t limit, const uint8_t *data, const size_t size);
|
||||
void BufferSend_buffer(std::vector<uint8_t> &buffer, size_t limit, const uint8_t *data, const size_t size);
|
||||
|
||||
template <typename T>
|
||||
struct BufferSerialisationHelper {
|
||||
@@ -66,30 +66,30 @@ struct BufferSerialisationHelper {
|
||||
BufferSend_string(self->GetSerialisationBuffer(), self->GetSerialisationLimit(), data);
|
||||
}
|
||||
|
||||
size_t Send_binary_until_full(const byte *begin, const byte *end)
|
||||
size_t Send_binary_until_full(const uint8_t *begin, const uint8_t *end)
|
||||
{
|
||||
T *self = static_cast<T *>(this);
|
||||
return BufferSend_binary_until_full(self->GetSerialisationBuffer(), self->GetSerialisationLimit(), begin, end);
|
||||
}
|
||||
|
||||
void Send_binary(const byte *data, const size_t size)
|
||||
void Send_binary(const uint8_t *data, const size_t size)
|
||||
{
|
||||
T *self = static_cast<T *>(this);
|
||||
BufferSend_binary(self->GetSerialisationBuffer(), self->GetSerialisationLimit(), data, size);
|
||||
}
|
||||
|
||||
void Send_binary(std::span<const byte> data)
|
||||
void Send_binary(std::span<const uint8_t> data)
|
||||
{
|
||||
this->Send_binary(data.data(), data.size());
|
||||
}
|
||||
|
||||
void Send_buffer(const byte *data, const size_t size)
|
||||
void Send_buffer(const uint8_t *data, const size_t size)
|
||||
{
|
||||
T *self = static_cast<T *>(this);
|
||||
BufferSend_buffer(self->GetSerialisationBuffer(), self->GetSerialisationLimit(), data, size);
|
||||
}
|
||||
|
||||
void Send_buffer(const std::vector<byte> &data)
|
||||
void Send_buffer(const std::vector<uint8_t> &data)
|
||||
{
|
||||
this->Send_buffer(data.data(), data.size());
|
||||
}
|
||||
@@ -100,7 +100,7 @@ void BufferRecvStringValidate(std::string &buffer, StringValidationSettings sett
|
||||
template <typename T>
|
||||
struct BufferDeserialisationHelper {
|
||||
private:
|
||||
const byte *GetBuffer()
|
||||
const uint8_t *GetBuffer()
|
||||
{
|
||||
return static_cast<T *>(this)->GetDeserialisationBuffer();
|
||||
}
|
||||
@@ -253,7 +253,7 @@ public:
|
||||
* @param buffer The buffer to put the data into.
|
||||
* @param size The size of the data.
|
||||
*/
|
||||
void Recv_binary(byte *buffer, size_t size)
|
||||
void Recv_binary(uint8_t *buffer, size_t size)
|
||||
{
|
||||
if (!this->CanRecvBytes(size, true)) return;
|
||||
|
||||
@@ -267,7 +267,7 @@ public:
|
||||
* Reads binary data.
|
||||
* @param buffer The buffer to put the data into.
|
||||
*/
|
||||
void Recv_binary(std::span<byte> buffer)
|
||||
void Recv_binary(std::span<uint8_t> buffer)
|
||||
{
|
||||
this->Recv_binary(buffer.data(), buffer.size());
|
||||
}
|
||||
@@ -331,11 +331,11 @@ public:
|
||||
};
|
||||
|
||||
struct BufferSerialiser : public BufferSerialisationHelper<BufferSerialiser> {
|
||||
std::vector<byte> &buffer;
|
||||
std::vector<uint8_t> &buffer;
|
||||
|
||||
BufferSerialiser(std::vector<byte> &buffer) : buffer(buffer) {}
|
||||
BufferSerialiser(std::vector<uint8_t> &buffer) : buffer(buffer) {}
|
||||
|
||||
std::vector<byte> &GetSerialisationBuffer() { return this->buffer; }
|
||||
std::vector<uint8_t> &GetSerialisationBuffer() { return this->buffer; }
|
||||
size_t GetSerialisationLimit() const { return std::numeric_limits<size_t>::max(); }
|
||||
};
|
||||
|
||||
|
@@ -81,7 +81,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,
|
||||
@@ -112,7 +112,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];
|
||||
}
|
||||
|
@@ -87,12 +87,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, CalTime::Year to_euro, const char *prefix, const char *suffix, const char *code, byte symbol_pos, StringID name) :
|
||||
CurrencySpec(uint16_t rate, const char *separator, CalTime::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 CheckSwitchToEuro();
|
||||
void ResetCurrencies(bool preserve_custom = true);
|
||||
byte GetNewgrfCurrencyIdConverted(byte grfcurr_id);
|
||||
uint8_t GetNewgrfCurrencyIdConverted(uint8_t grfcurr_id);
|
||||
|
||||
#endif /* CURRENCY_H */
|
||||
|
@@ -1146,7 +1146,7 @@ static void DepotSellAllConfirmationCallback(Window *win, bool confirmed)
|
||||
if (confirmed) {
|
||||
DepotWindow *w = (DepotWindow*)win;
|
||||
TileIndex tile = w->window_number;
|
||||
byte vehtype = w->type;
|
||||
uint8_t vehtype = w->type;
|
||||
DoCommandP(tile, vehtype, 0, CMD_DEPOT_SELL_ALL_VEHICLES);
|
||||
}
|
||||
}
|
||||
|
@@ -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
|
||||
@@ -39,7 +39,7 @@ enum Direction : byte {
|
||||
DECLARE_POSTFIX_INCREMENT(Direction)
|
||||
|
||||
/** Define basic enum properties */
|
||||
template <> struct EnumPropsT<Direction> : MakeEnumPropsT<Direction, byte, DIR_BEGIN, DIR_END, INVALID_DIR, 3> {};
|
||||
template <> struct EnumPropsT<Direction> : MakeEnumPropsT<Direction, uint8_t, DIR_BEGIN, DIR_END, INVALID_DIR, 3> {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -59,7 +59,7 @@ template <> struct EnumPropsT<Direction> : MakeEnumPropsT<Direction, byte, DIR_B
|
||||
* modulo DIR_END or use the #ChangeDirDiff(DirDiff, DirDiff) function.
|
||||
* @see ChangeDirDiff(DirDiff, DirDiff)
|
||||
*/
|
||||
enum DirDiff : byte {
|
||||
enum DirDiff : uint8_t {
|
||||
DIRDIFF_SAME = 0, ///< Both directions faces to the same direction
|
||||
DIRDIFF_45RIGHT = 1, ///< Angle of 45 degrees right
|
||||
DIRDIFF_90RIGHT = 2, ///< Angle of 90 degrees right
|
||||
@@ -74,7 +74,7 @@ enum DirDiff : byte {
|
||||
*
|
||||
* 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
|
||||
@@ -87,7 +87,7 @@ DECLARE_POSTFIX_INCREMENT(DiagDirection)
|
||||
DECLARE_ENUM_AS_ADDABLE(DiagDirection)
|
||||
|
||||
/** Define basic enum properties */
|
||||
template <> struct EnumPropsT<DiagDirection> : MakeEnumPropsT<DiagDirection, byte, DIAGDIR_BEGIN, DIAGDIR_END, INVALID_DIAGDIR, 2> {};
|
||||
template <> struct EnumPropsT<DiagDirection> : MakeEnumPropsT<DiagDirection, uint8_t, DIAGDIR_BEGIN, DIAGDIR_END, INVALID_DIAGDIR, 2> {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -119,14 +119,14 @@ 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
|
||||
INVALID_AXIS = 0xFF, ///< Flag for an invalid Axis
|
||||
};
|
||||
/** Helper information for extract tool. */
|
||||
template <> struct EnumPropsT<Axis> : MakeEnumPropsT<Axis, byte, AXIS_X, AXIS_END, INVALID_AXIS, 1> {};
|
||||
template <> struct EnumPropsT<Axis> : MakeEnumPropsT<Axis, uint8_t, AXIS_X, AXIS_END, INVALID_AXIS, 1> {};
|
||||
DECLARE_ENUM_AS_ADDABLE(Axis)
|
||||
|
||||
#endif /* DIRECTION_TYPE_H */
|
||||
|
@@ -963,11 +963,11 @@ static const Disaster _disasters[] = {
|
||||
|
||||
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 (CalTime::CurYear() >= _disasters[i].min_year && CalTime::CurYear() < _disasters[i].max_year) buf[j++] = (byte)i;
|
||||
if (CalTime::CurYear() >= _disasters[i].min_year && CalTime::CurYear() < _disasters[i].max_year) buf[j++] = (uint8_t)i;
|
||||
}
|
||||
|
||||
if (j == 0) return;
|
||||
|
@@ -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. */
|
||||
|
@@ -142,7 +142,7 @@ Money CalculateCompanyValueExcludingShares(const Company *c, bool including_loan
|
||||
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;
|
||||
@@ -264,7 +264,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;
|
||||
}
|
||||
|
@@ -28,9 +28,9 @@ enum EconomyType : uint8_t {
|
||||
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
|
||||
@@ -154,7 +154,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.
|
||||
@@ -175,7 +175,7 @@ enum ExpensesType : byte {
|
||||
};
|
||||
|
||||
/** Define basic enum properties for ExpensesType */
|
||||
template <> struct EnumPropsT<ExpensesType> : MakeEnumPropsT<ExpensesType, byte, EXPENSES_CONSTRUCTION, EXPENSES_END, INVALID_EXPENSES, 8> {};
|
||||
template <> struct EnumPropsT<ExpensesType> : MakeEnumPropsT<ExpensesType, uint8_t, EXPENSES_CONSTRUCTION, EXPENSES_END, INVALID_EXPENSES, 8> {};
|
||||
|
||||
/**
|
||||
* Data type for storage of Money for each #ExpensesType category.
|
||||
@@ -241,21 +241,21 @@ static const uint LOCK_DEPOT_TILE_FACTOR = 2;
|
||||
struct CargoPayment;
|
||||
typedef uint32_t CargoPaymentID;
|
||||
|
||||
enum CargoPaymentAlgorithm : byte {
|
||||
enum CargoPaymentAlgorithm : uint8_t {
|
||||
CPA_BEGIN = 0, ///< Used for iterations and limit testing
|
||||
CPA_TRADITIONAL = 0, ///< Traditional algorithm
|
||||
CPA_MODERN, ///< Modern algorithm
|
||||
CPA_END, ///< Used for iterations and limit testing
|
||||
};
|
||||
|
||||
enum TickRateMode : byte {
|
||||
enum TickRateMode : uint8_t {
|
||||
TRM_BEGIN = 0, ///< Used for iterations and limit testing
|
||||
TRM_TRADITIONAL = 0, ///< Traditional value (30ms)
|
||||
TRM_MODERN, ///< Modern value (27ms)
|
||||
TRM_END, ///< Used for iterations and limit testing
|
||||
};
|
||||
|
||||
enum CargoScalingMode : byte {
|
||||
enum CargoScalingMode : uint8_t {
|
||||
CSM_BEGIN = 0, ///< Used for iterations and limit testing
|
||||
CSM_MONTHLY = 0, ///< Traditional cargo scaling
|
||||
CSM_DAYLENGTH, ///< Also scale by day length
|
||||
|
@@ -267,9 +267,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[] = {
|
||||
@@ -344,7 +344,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 }
|
||||
|
@@ -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() {}
|
||||
|
@@ -88,7 +88,7 @@ struct DualTrackBits {
|
||||
* @param override pointer to PCP override, can be nullptr
|
||||
* @return trackbits of tile if it is electrified
|
||||
*/
|
||||
static DualTrackBits GetRailTrackBitsUniversal(TileIndex t, byte *override)
|
||||
static DualTrackBits GetRailTrackBitsUniversal(TileIndex t, uint8_t *override)
|
||||
{
|
||||
DualTrackBits out;
|
||||
out.primary = TRACK_BIT_NONE;
|
||||
@@ -326,10 +326,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:
|
||||
@@ -499,7 +499,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];
|
||||
@@ -579,7 +579,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 = get_wire_sprite(t, (t == halftile_track));
|
||||
byte PCPconfig = HasBit(PCPstatus, PCPpositions[t][0]) +
|
||||
uint8_t PCPconfig = HasBit(PCPstatus, PCPpositions[t][0]) +
|
||||
(HasBit(PCPstatus, PCPpositions[t][1]) << 1);
|
||||
|
||||
const SortableSpriteStruct *sss;
|
||||
|
@@ -26,7 +26,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).
|
||||
@@ -54,10 +54,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
|
||||
|
@@ -45,7 +45,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[][14];
|
||||
|
@@ -41,42 +41,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
|
||||
@@ -99,33 +99,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
|
||||
};
|
||||
|
||||
@@ -146,14 +146,14 @@ struct EngineInfo {
|
||||
CalTime::Date base_intro; ///< Basic date of engine introduction (without random parts).
|
||||
YearDelta lifelength; ///< Lifetime of a single vehicle
|
||||
YearDelta 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
|
||||
|
@@ -523,7 +523,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);
|
||||
|
@@ -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
|
||||
|
@@ -16,8 +16,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 {
|
||||
@@ -34,7 +34,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?
|
||||
};
|
||||
|
||||
|
@@ -158,7 +158,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);
|
||||
}
|
||||
|
@@ -28,7 +28,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!
|
||||
|
||||
|
||||
static GamelogActionType _gamelog_action_type = GLAT_NONE; ///< action to record if anything changes
|
||||
@@ -510,7 +510,7 @@ void GamelogTestMode()
|
||||
* @param bug type of bug, @see enum GRFBugs
|
||||
* @param data additional data
|
||||
*/
|
||||
static void GamelogGRFBug(uint32_t grfid, byte bug, uint64_t data)
|
||||
static void GamelogGRFBug(uint32_t grfid, uint8_t bug, uint64_t data)
|
||||
{
|
||||
assert(_gamelog_action_type == GLAT_GRFBUG);
|
||||
|
||||
@@ -667,7 +667,7 @@ static GRFList *GenerateGRFList(const GRFConfig *grfc)
|
||||
if (IsLoggableGrfConfig(g)) n++;
|
||||
}
|
||||
|
||||
GRFList *list = (GRFList*)MallocT<byte>(sizeof(GRFList) + n * sizeof(GRFConfig*));
|
||||
GRFList *list = (GRFList*)MallocT<uint8_t>(sizeof(GRFList) + n * sizeof(GRFConfig*));
|
||||
|
||||
list->n = 0;
|
||||
for (const GRFConfig *g = grfc; g != nullptr; g = g->next) {
|
||||
@@ -766,7 +766,7 @@ void GamelogGRFUpdate(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 GamelogInfo(const std::vector<LoggedAction> &gamelog_actions, uint32_t *last_ottd_rev, byte *ever_modified, bool *removed_newgrfs)
|
||||
void GamelogInfo(const std::vector<LoggedAction> &gamelog_actions, uint32_t *last_ottd_rev, uint8_t *ever_modified, bool *removed_newgrfs)
|
||||
{
|
||||
for (const LoggedAction &la : gamelog_actions) {
|
||||
for (const LoggedChange &lc : la.changes) {
|
||||
|
@@ -64,7 +64,7 @@ void GamelogTestMode();
|
||||
|
||||
bool GamelogGRFBugReverse(uint32_t grfid, uint16_t internal_id);
|
||||
|
||||
void GamelogInfo(const std::vector<LoggedAction> &gamelog_actions, uint32_t *last_ottd_rev, byte *ever_modified, bool *removed_newgrfs);
|
||||
void GamelogInfo(const std::vector<LoggedAction> &gamelog_actions, uint32_t *last_ottd_rev, uint8_t *ever_modified, bool *removed_newgrfs);
|
||||
const char *GamelogGetLastRevision(const std::vector<LoggedAction> &gamelog_actions);
|
||||
|
||||
#endif /* GAMELOG_H */
|
||||
|
@@ -39,14 +39,14 @@ struct LoggedChange {
|
||||
GamelogChangeType ct; ///< Type of change logged in this struct
|
||||
union {
|
||||
struct {
|
||||
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, ...)
|
||||
} mode;
|
||||
struct {
|
||||
char *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
|
||||
} revision;
|
||||
struct {
|
||||
uint32_t type; ///< type of savegame, @see SavegameType
|
||||
@@ -72,7 +72,7 @@ struct LoggedChange {
|
||||
struct {
|
||||
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
|
||||
} grfbug;
|
||||
};
|
||||
};
|
||||
|
@@ -92,7 +92,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();
|
||||
|
@@ -62,7 +62,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);
|
||||
|
28
src/gfx.cpp
28
src/gfx.cpp
@@ -37,9 +37,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?
|
||||
@@ -64,13 +64,13 @@ uint32_t _pause_countdown;
|
||||
std::string _switch_baseset;
|
||||
static bool _adjust_gui_zoom_startup_done = false;
|
||||
|
||||
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;
|
||||
|
||||
struct GfxBlitterCtx {
|
||||
const DrawPixelInfo *dpi;
|
||||
const byte *colour_remap_ptr = nullptr;
|
||||
byte string_colourremap[3]; ///< Recoloursprite for stringdrawing. The grf loader ensures that #SpriteType::Font sprites only use colours 0 to 2.
|
||||
const uint8_t *colour_remap_ptr = nullptr;
|
||||
uint8_t string_colourremap[3]; ///< Recoloursprite for stringdrawing. The grf loader ensures that #SpriteType::Font sprites only use colours 0 to 2.
|
||||
int sprite_brightness_adjust = 0;
|
||||
|
||||
GfxBlitterCtx(const DrawPixelInfo *dpi) : dpi(dpi) {}
|
||||
@@ -163,7 +163,7 @@ void GfxFillRect(Blitter *blitter, const DrawPixelInfo *dpi, int left, int top,
|
||||
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);
|
||||
@@ -462,7 +462,7 @@ void DrawBox(const DrawPixelInfo *dpi, int x, int y, int dx1, int dy1, int dx2,
|
||||
* ....V.
|
||||
*/
|
||||
|
||||
static const byte colour = PC_WHITE;
|
||||
static const uint8_t colour = PC_WHITE;
|
||||
|
||||
GfxDrawLineUnscaled(dpi, x, y, x + dx1, y + dy1, colour);
|
||||
GfxDrawLineUnscaled(dpi, x, y, x + dx2, y + dy2, colour);
|
||||
@@ -506,7 +506,7 @@ void GfxBlitterCtx::SetColourRemap(TextColour colour)
|
||||
colour &= ~(TC_NO_SHADE | TC_IS_PALETTE_COLOUR | TC_FORCED);
|
||||
|
||||
this->string_colourremap[0] = 0;
|
||||
this->string_colourremap[1] = raw_colour ? (byte)colour : _string_colourmap[colour];
|
||||
this->string_colourremap[1] = raw_colour ? (uint8_t)colour : _string_colourmap[colour];
|
||||
this->string_colourremap[2] = no_shade ? 0 : 1;
|
||||
this->colour_remap_ptr = this->string_colourremap;
|
||||
}
|
||||
@@ -1263,9 +1263,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();
|
||||
}
|
||||
|
||||
@@ -1278,7 +1278,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;
|
||||
}
|
||||
@@ -1318,7 +1318,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];
|
||||
@@ -1331,9 +1331,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);
|
||||
}
|
||||
|
@@ -49,9 +49,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?
|
||||
@@ -210,8 +210,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);
|
||||
uint64_t GetBroadestDigitsValue(uint count, FontSize size = FS_NORMAL);
|
||||
|
||||
|
@@ -110,7 +110,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 */
|
||||
@@ -249,7 +249,7 @@ enum Colours : uint8_t {
|
||||
COLOUR_END,
|
||||
INVALID_COLOUR = 0xFF,
|
||||
};
|
||||
template <> struct EnumPropsT<Colours> : MakeEnumPropsT<Colours, byte, COLOUR_BEGIN, COLOUR_END, INVALID_COLOUR, 8> {};
|
||||
template <> struct EnumPropsT<Colours> : MakeEnumPropsT<Colours, uint8_t, COLOUR_BEGIN, COLOUR_END, INVALID_COLOUR, 8> {};
|
||||
DECLARE_POSTFIX_INCREMENT(Colours)
|
||||
DECLARE_ENUM_AS_ADDABLE(Colours)
|
||||
|
||||
@@ -311,7 +311,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
|
||||
|
@@ -56,12 +56,12 @@ static SpriteFile &LoadGrfFile(const std::string &filename, uint load_index, boo
|
||||
|
||||
DEBUG(sprite, 2, "Reading grf-file '%s'", filename.c_str());
|
||||
|
||||
byte container_ver = file.GetContainerVersion();
|
||||
uint8_t container_ver = file.GetContainerVersion();
|
||||
if (container_ver == 0) usererror("Base grf '%s' is corrupt", filename.c_str());
|
||||
ReadGRFSpriteOffsets(file);
|
||||
if (container_ver >= 2) {
|
||||
/* Read compression. */
|
||||
byte compression = file.ReadByte();
|
||||
uint8_t compression = file.ReadByte();
|
||||
if (compression != 0) usererror("Unsupported compression format");
|
||||
}
|
||||
|
||||
@@ -93,12 +93,12 @@ static void LoadGrfFileIndexed(const std::string &filename, const SpriteID *inde
|
||||
|
||||
DEBUG(sprite, 2, "Reading indexed grf-file '%s'", filename.c_str());
|
||||
|
||||
byte container_ver = file.GetContainerVersion();
|
||||
uint8_t container_ver = file.GetContainerVersion();
|
||||
if (container_ver == 0) usererror("Base grf '%s' is corrupt", filename.c_str());
|
||||
ReadGRFSpriteOffsets(file);
|
||||
if (container_ver >= 2) {
|
||||
/* Read compression. */
|
||||
byte compression = file.ReadByte();
|
||||
uint8_t compression = file.ReadByte();
|
||||
if (compression != 0) usererror("Unsupported compression format");
|
||||
}
|
||||
|
||||
@@ -434,7 +434,7 @@ static SpriteID GetSpriteIDForClearGround(const ClearGround cg, const Slope slop
|
||||
{
|
||||
switch (cg) {
|
||||
case CLEAR_GRASS:
|
||||
return GetSpriteIDForClearLand(slope, (byte) multi);
|
||||
return GetSpriteIDForClearLand(slope, (uint8_t)multi);
|
||||
case CLEAR_ROUGH:
|
||||
return GetSpriteIDForHillyLand(slope, multi);
|
||||
case CLEAR_ROCKS:
|
||||
@@ -467,8 +467,8 @@ void GfxDetermineMainColours()
|
||||
extern uint32_t _vp_map_vegetation_clear_colours[16][6][8];
|
||||
memset(_vp_map_vegetation_clear_colours, 0, sizeof(_vp_map_vegetation_clear_colours));
|
||||
const struct {
|
||||
byte min;
|
||||
byte max;
|
||||
uint8_t min;
|
||||
uint8_t max;
|
||||
} multi[6] = {
|
||||
{ 0, 3 }, // CLEAR_GRASS, density
|
||||
{ 0, 7 }, // CLEAR_ROUGH, "random" based on position
|
||||
|
@@ -295,7 +295,7 @@ CommandCost CmdGoalQuestion(TileIndex tile, DoCommandFlag flags, uint32_t p1, ui
|
||||
|
||||
static_assert(GOAL_QUESTION_BUTTON_COUNT < 29);
|
||||
uint32_t button_mask = GB(p2, 0, GOAL_QUESTION_BUTTON_COUNT);
|
||||
byte type = GB(p2, 29, 2);
|
||||
uint8_t type = GB(p2, 29, 2);
|
||||
bool is_client = HasBit(p2, 31);
|
||||
|
||||
if (_current_company != OWNER_DEITY) return CMD_ERROR;
|
||||
@@ -352,7 +352,7 @@ CommandCost CmdGoalQuestionAnswer(TileIndex tile, DoCommandFlag flags, uint32_t
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
Game::NewEvent(new ScriptEventGoalQuestionAnswer(p1, (ScriptCompany::CompanyID)(byte)_current_company, (ScriptGoal::QuestionButton)(1 << p2)));
|
||||
Game::NewEvent(new ScriptEventGoalQuestionAnswer(p1, (ScriptCompany::CompanyID)(uint8_t)_current_company, (ScriptGoal::QuestionButton)(1 << p2)));
|
||||
}
|
||||
|
||||
return CommandCost();
|
||||
|
@@ -483,7 +483,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);
|
||||
|
@@ -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
|
||||
|
@@ -185,9 +185,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. */
|
||||
EconTime::Month month;
|
||||
@@ -201,7 +201,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
|
||||
|
||||
/**
|
||||
@@ -457,7 +457,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;
|
||||
|
||||
@@ -622,7 +622,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));
|
||||
}
|
||||
@@ -1010,7 +1010,7 @@ struct DeliveredCargoGraphWindow : ExcludingCargoBaseGraphWindow {
|
||||
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));
|
||||
}
|
||||
@@ -1489,7 +1489,7 @@ struct PaymentRatesGraphWindow : BaseGraphWindow {
|
||||
for (const CargoSpec *cs : _sorted_standard_cargo_specs) {
|
||||
this->colours[i] = cs->legend_colour;
|
||||
for (int j = 0; j != this->num_on_x_axis; j++) {
|
||||
const byte ctt = _cargo_payment_x_mode ? static_cast<byte>(factor / static_cast<float>((j + 1) * this->x_values_increment)) : (j + 1) * 4;
|
||||
const uint8_t ctt = _cargo_payment_x_mode ? static_cast<uint8_t>(factor / static_cast<float>((j + 1) * this->x_values_increment)) : (j + 1) * 4;
|
||||
this->cost[i][j] = GetTransportedGoodsIncome(_cargo_payment_x_mode ? 1 : 10, _cargo_payment_x_mode ? 200 : 20, ctt, cs->Index());
|
||||
}
|
||||
i++;
|
||||
@@ -1993,7 +1993,7 @@ struct StationCargoGraphWindow final : BaseGraphWindow {
|
||||
/* Redraw box if lowered */
|
||||
if (lowered) DrawFrameRect(r.left, y, r.right, y + this->line_height - 1, COLOUR_BROWN, lowered ? FR_LOWERED : FR_NONE);
|
||||
|
||||
const byte clk_dif = lowered ? 1 : 0;
|
||||
const uint8_t clk_dif = lowered ? 1 : 0;
|
||||
const int rect_x = clk_dif + (rtl ? ir.right - this->legend_width : ir.left);
|
||||
|
||||
GfxFillRect(rect_x, y + padding + clk_dif, rect_x + this->legend_width, y + row_height - 1 + clk_dif, PC_BLACK);
|
||||
|
@@ -42,8 +42,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) {
|
||||
|
@@ -72,9 +72,9 @@ struct GroundVehicleAcceleration {
|
||||
* virtual uint16_t GetWeightWithoutCargo() const = 0;
|
||||
* virtual uint16_t GetCargoWeight() 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;
|
||||
@@ -439,9 +439,9 @@ protected:
|
||||
*/
|
||||
inline uint DoUpdateSpeed(GroundVehicleAcceleration accel, int min_speed, int max_speed, int advisory_max_speed, bool use_realistic_braking)
|
||||
{
|
||||
const byte initial_subspeed = this->subspeed;
|
||||
const uint8_t initial_subspeed = this->subspeed;
|
||||
uint spd = this->subspeed + accel.acceleration;
|
||||
this->subspeed = (byte)spd;
|
||||
this->subspeed = (uint8_t)spd;
|
||||
|
||||
if (!use_realistic_braking) {
|
||||
max_speed = std::min(max_speed, advisory_max_speed);
|
||||
@@ -490,7 +490,7 @@ protected:
|
||||
this->subspeed = 0;
|
||||
} else {
|
||||
tempspeed = braking_speed;
|
||||
this->subspeed = (byte)spd;
|
||||
this->subspeed = (uint8_t)spd;
|
||||
}
|
||||
} else {
|
||||
tempspeed = advisory_max_speed;
|
||||
|
@@ -64,7 +64,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);
|
||||
@@ -76,7 +76,7 @@ void ShowExtraViewportWindowForTileUnderCursor();
|
||||
void ShowModifierKeyToggleWindow();
|
||||
|
||||
/* 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();
|
||||
|
@@ -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 = MapSizeX();
|
||||
@@ -489,7 +489,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:
|
||||
@@ -528,7 +528,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);
|
||||
@@ -548,7 +548,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 < MapSizeY() - edge_distance; row++) {
|
||||
|
@@ -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 */
|
||||
|
@@ -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 ||
|
||||
|
16
src/house.h
16
src/house.h
@@ -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.
|
||||
|
||||
@@ -106,12 +106,12 @@ struct HouseSpec {
|
||||
/* Standard properties */
|
||||
CalTime::Year min_year; ///< introduction year of the house
|
||||
CalTime::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...)
|
||||
@@ -122,13 +122,13 @@ 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
|
||||
HouseCtrlFlags ctrl_flags; ///< control 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;
|
||||
|
@@ -39,7 +39,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. */
|
||||
@@ -71,10 +71,10 @@ struct Industry : IndustryPool::PoolItem<&_industry_pool> {
|
||||
std::array<CargoID, INDUSTRY_NUM_OUTPUTS> produced_cargo{}; ///< 16 production cargo slots
|
||||
std::array<uint16_t, INDUSTRY_NUM_OUTPUTS> produced_cargo_waiting{}; ///< amount of cargo produced per cargo
|
||||
std::array<uint16_t, INDUSTRY_NUM_OUTPUTS> incoming_cargo_waiting{}; ///< incoming cargo waiting to be processed
|
||||
std::array<byte, INDUSTRY_NUM_OUTPUTS> production_rate{}; ///< production rate for each cargo
|
||||
std::array<uint8_t, INDUSTRY_NUM_OUTPUTS> production_rate{}; ///< production rate for each cargo
|
||||
std::array<uint32_t, INDUSTRY_NUM_OUTPUTS> this_month_production{}; ///< stats of this month's production per cargo
|
||||
std::array<uint32_t, INDUSTRY_NUM_OUTPUTS> this_month_transported{}; ///< stats of this month's transport per cargo
|
||||
std::array<byte, INDUSTRY_NUM_OUTPUTS> last_month_pct_transported{}; ///< percentage transported per cargo in the last full month
|
||||
std::array<uint8_t, INDUSTRY_NUM_OUTPUTS> last_month_pct_transported{}; ///< percentage transported per cargo in the last full month
|
||||
std::array<uint32_t, INDUSTRY_NUM_OUTPUTS> last_month_production{}; ///< total units produced per cargo in the last full month
|
||||
std::array<uint32_t, INDUSTRY_NUM_OUTPUTS> last_month_transported{}; ///< total units transported per cargo in the last full month
|
||||
|
||||
@@ -82,17 +82,17 @@ struct Industry : IndustryPool::PoolItem<&_industry_pool> {
|
||||
mutable std::string cached_name; ///< NOSAVE: Cache of the resolved name of the industry
|
||||
|
||||
uint16_t counter; ///< used for animation and/or production (if available cargo)
|
||||
byte prod_level; ///< general production level
|
||||
uint8_t prod_level; ///< general production level
|
||||
Colours random_colour; ///< randomized colour of the industry, for display purpose
|
||||
EconTime::Year last_prod_year; ///< last 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?
|
||||
|
||||
Owner founder; ///< Founder 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)
|
||||
EconTime::Date last_cargo_accepted_at[INDUSTRY_NUM_INPUTS]; ///< Last day each cargo type was accepted by this industry
|
||||
@@ -236,7 +236,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.
|
||||
|
@@ -57,7 +57,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];
|
||||
@@ -450,7 +450,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 (a == INVALID_CARGO || 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, VMDF_NOT_MAP_MODE);
|
||||
@@ -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, VMDF_NOT_MAP_MODE);
|
||||
@@ -788,13 +788,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);
|
||||
@@ -1031,7 +1031,7 @@ bool IsTileForestIndustry(TileIndex tile)
|
||||
return false;
|
||||
}
|
||||
|
||||
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.
|
||||
@@ -1056,7 +1056,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);
|
||||
@@ -1068,7 +1068,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;
|
||||
|
||||
@@ -1478,7 +1478,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);
|
||||
}
|
||||
@@ -1846,7 +1846,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 (size_t ci = 0; ci < std::size(i->production_rate); ci++) {
|
||||
i->production_rate[ci] = ClampTo<byte>((RandomRange(256) + 128) * i->production_rate[ci] >> 8);
|
||||
i->production_rate[ci] = ClampTo<uint8_t>((RandomRange(256) + 128) * i->production_rate[ci] >> 8);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1869,7 +1869,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;
|
||||
@@ -2213,7 +2213,7 @@ CommandCost CmdIndustrySetFlags(TileIndex tile, DoCommandFlag flags, uint32_t p1
|
||||
* @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;
|
||||
@@ -2389,7 +2389,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;
|
||||
@@ -2402,7 +2402,7 @@ static uint16_t GetIndustryGamePlayProbability(IndustryType it, byte *min_number
|
||||
return 0;
|
||||
}
|
||||
|
||||
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) && CalTime::CurYear() > 1950) ||
|
||||
((ind_spc->behaviour & INDUSTRYBEH_AFTER_1960) && CalTime::CurYear() < 1960) ||
|
||||
@@ -2575,10 +2575,10 @@ static void UpdateIndustryStatistics(Industry *i)
|
||||
{
|
||||
for (size_t j = 0; j < std::size(i->produced_cargo); j++) {
|
||||
if (i->produced_cargo[j] != INVALID_CARGO) {
|
||||
byte pct = 0;
|
||||
uint8_t pct = 0;
|
||||
if (i->this_month_production[j] != 0) {
|
||||
i->last_prod_year = EconTime::CurYear();
|
||||
pct = ClampTo<byte>(((uint64_t)i->this_month_transported[j]) * 256 / i->this_month_production[j]);
|
||||
pct = ClampTo<uint8_t>(((uint64_t)i->this_month_transported[j]) * 256 / i->this_month_production[j]);
|
||||
}
|
||||
i->last_month_pct_transported[j] = pct;
|
||||
|
||||
@@ -2602,7 +2602,7 @@ void Industry::RecomputeProductionMultipliers()
|
||||
|
||||
/* Rates are rounded up, so e.g. oilrig always produces some passengers */
|
||||
for (size_t i = 0; i < std::size(this->production_rate); i++) {
|
||||
this->production_rate[i] = ClampTo<byte>(CeilDiv(indspec->production_rate[i] * this->prod_level, PRODLEVEL_DEFAULT));
|
||||
this->production_rate[i] = ClampTo<uint8_t>(CeilDiv(indspec->production_rate[i] * this->prod_level, PRODLEVEL_DEFAULT));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2626,7 +2626,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;
|
||||
@@ -2886,8 +2886,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);
|
||||
|
@@ -178,7 +178,7 @@ static inline void GetAllCargoSuffixes(CargoSuffixInOut use_input, CargoSuffixTy
|
||||
/* Reworked behaviour with new many-in-many-out scheme */
|
||||
for (size_t j = 0; j < std::size(suffixes); j++) {
|
||||
if (cargoes[j] != INVALID_CARGO) {
|
||||
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 {
|
||||
@@ -836,7 +836,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
|
||||
@@ -1081,10 +1081,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;
|
||||
|
||||
@@ -1096,7 +1096,7 @@ public:
|
||||
if (i->production_rate[line - IL_RATE1] >= 255) return;
|
||||
/* a zero production industry is unlikely to give anything but zero, so push it a little bit */
|
||||
int new_prod = i->production_rate[line - IL_RATE1] == 0 ? 1 : i->production_rate[line - IL_RATE1] * 2;
|
||||
i->production_rate[line - IL_RATE1] = ClampTo<byte>(new_prod);
|
||||
i->production_rate[line - IL_RATE1] = ClampTo<uint8_t>(new_prod);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1584,7 +1584,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);
|
||||
|
@@ -97,10 +97,10 @@ inline void SetIndustryCompleted(TileIndex tile)
|
||||
* @pre IsTileType(tile, MP_INDUSTRY)
|
||||
* @return the construction stage
|
||||
*/
|
||||
inline byte GetIndustryConstructionStage(TileIndex tile)
|
||||
inline uint8_t GetIndustryConstructionStage(TileIndex tile)
|
||||
{
|
||||
dbg_assert_tile(IsTileType(tile, MP_INDUSTRY), tile);
|
||||
return IsIndustryCompleted(tile) ? (byte)INDUSTRY_COMPLETED : GB(_m[tile].m1, 0, 2);
|
||||
return IsIndustryCompleted(tile) ? (uint8_t)INDUSTRY_COMPLETED : GB(_m[tile].m1, 0, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,7 +109,7 @@ inline byte GetIndustryConstructionStage(TileIndex tile)
|
||||
* @param value the new construction stage
|
||||
* @pre IsTileType(tile, MP_INDUSTRY)
|
||||
*/
|
||||
inline void SetIndustryConstructionStage(TileIndex tile, byte value)
|
||||
inline void SetIndustryConstructionStage(TileIndex tile, uint8_t value)
|
||||
{
|
||||
dbg_assert_tile(IsTileType(tile, MP_INDUSTRY), tile);
|
||||
SB(_m[tile].m1, 0, 2, value);
|
||||
@@ -159,7 +159,7 @@ inline void SetIndustryGfx(TileIndex t, IndustryGfx gfx)
|
||||
* @pre IsTileType(tile, MP_INDUSTRY)
|
||||
* @return the construction counter
|
||||
*/
|
||||
inline byte GetIndustryConstructionCounter(TileIndex tile)
|
||||
inline uint8_t GetIndustryConstructionCounter(TileIndex tile)
|
||||
{
|
||||
dbg_assert_tile(IsTileType(tile, MP_INDUSTRY), tile);
|
||||
return GB(_m[tile].m1, 2, 2);
|
||||
@@ -171,7 +171,7 @@ inline byte GetIndustryConstructionCounter(TileIndex tile)
|
||||
* @param value the new value for the construction counter
|
||||
* @pre IsTileType(tile, MP_INDUSTRY)
|
||||
*/
|
||||
inline void SetIndustryConstructionCounter(TileIndex tile, byte value)
|
||||
inline void SetIndustryConstructionCounter(TileIndex tile, uint8_t value)
|
||||
{
|
||||
dbg_assert_tile(IsTileType(tile, MP_INDUSTRY), tile);
|
||||
SB(_m[tile].m1, 2, 2, value);
|
||||
@@ -196,7 +196,7 @@ inline void ResetIndustryConstructionStage(TileIndex tile)
|
||||
* @param tile the tile to get the animation loop number of
|
||||
* @pre IsTileType(tile, MP_INDUSTRY)
|
||||
*/
|
||||
inline byte GetIndustryAnimationLoop(TileIndex tile)
|
||||
inline uint8_t GetIndustryAnimationLoop(TileIndex tile)
|
||||
{
|
||||
dbg_assert_tile(IsTileType(tile, MP_INDUSTRY), tile);
|
||||
return _m[tile].m4;
|
||||
@@ -208,7 +208,7 @@ inline byte GetIndustryAnimationLoop(TileIndex tile)
|
||||
* @param count the new animation frame number
|
||||
* @pre IsTileType(tile, MP_INDUSTRY)
|
||||
*/
|
||||
inline void SetIndustryAnimationLoop(TileIndex tile, byte count)
|
||||
inline void SetIndustryAnimationLoop(TileIndex tile, uint8_t count)
|
||||
{
|
||||
dbg_assert_tile(IsTileType(tile, MP_INDUSTRY), tile);
|
||||
_m[tile].m4 = count;
|
||||
@@ -221,7 +221,7 @@ inline void SetIndustryAnimationLoop(TileIndex tile, byte count)
|
||||
* @pre IsTileType(tile, MP_INDUSTRY)
|
||||
* @return requested bits
|
||||
*/
|
||||
inline byte GetIndustryRandomBits(TileIndex tile)
|
||||
inline uint8_t GetIndustryRandomBits(TileIndex tile)
|
||||
{
|
||||
dbg_assert_tile(IsTileType(tile, MP_INDUSTRY), tile);
|
||||
return _m[tile].m3;
|
||||
@@ -234,7 +234,7 @@ inline byte GetIndustryRandomBits(TileIndex tile)
|
||||
* @param bits the random bits
|
||||
* @pre IsTileType(tile, MP_INDUSTRY)
|
||||
*/
|
||||
inline void SetIndustryRandomBits(TileIndex tile, byte bits)
|
||||
inline void SetIndustryRandomBits(TileIndex tile, uint8_t bits)
|
||||
{
|
||||
dbg_assert_tile(IsTileType(tile, MP_INDUSTRY), tile);
|
||||
_m[tile].m3 = bits;
|
||||
@@ -247,7 +247,7 @@ inline void SetIndustryRandomBits(TileIndex tile, byte bits)
|
||||
* @pre IsTileType(tile, MP_INDUSTRY)
|
||||
* @return requested triggers
|
||||
*/
|
||||
inline byte GetIndustryTriggers(TileIndex tile)
|
||||
inline uint8_t GetIndustryTriggers(TileIndex tile)
|
||||
{
|
||||
dbg_assert_tile(IsTileType(tile, MP_INDUSTRY), tile);
|
||||
return GB(_me[tile].m6, 3, 3);
|
||||
@@ -261,7 +261,7 @@ inline byte GetIndustryTriggers(TileIndex tile)
|
||||
* @param triggers the triggers to set
|
||||
* @pre IsTileType(tile, MP_INDUSTRY)
|
||||
*/
|
||||
inline void SetIndustryTriggers(TileIndex tile, byte triggers)
|
||||
inline void SetIndustryTriggers(TileIndex tile, uint8_t triggers)
|
||||
{
|
||||
dbg_assert_tile(IsTileType(tile, MP_INDUSTRY), tile);
|
||||
SB(_me[tile].m6, 3, 3, triggers);
|
||||
|
@@ -112,30 +112,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
|
||||
std::array<CargoID, INDUSTRY_NUM_OUTPUTS> produced_cargo{};
|
||||
std::array<std::variant<CargoLabel, MixedCargoType>, INDUSTRY_NUM_OUTPUTS> produced_cargo_label{};
|
||||
std::array<byte, INDUSTRY_NUM_OUTPUTS> production_rate{};
|
||||
std::array<uint8_t, INDUSTRY_NUM_OUTPUTS> production_rate{};
|
||||
/**
|
||||
* 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;
|
||||
std::array<CargoID, INDUSTRY_NUM_INPUTS> accepts_cargo{}; ///< 16 accepted cargoes.
|
||||
std::array<std::variant<CargoLabel, MixedCargoType>, INDUSTRY_NUM_INPUTS> accepts_cargo_label{};
|
||||
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 */
|
||||
@@ -162,8 +162,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
|
||||
|
@@ -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,
|
||||
|
@@ -81,7 +81,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,
|
||||
};
|
||||
@@ -105,10 +105,10 @@ static TileIndex _current_estuary = INVALID_TILE;
|
||||
/** Whether the current river is a big river that others flow into */
|
||||
static bool _is_main_river = false;
|
||||
|
||||
byte _cached_snowline = 0;
|
||||
byte _cached_highest_snowline = 0;
|
||||
byte _cached_lowest_snowline = 0;
|
||||
byte _cached_tree_placement_highest_snowline = 0;
|
||||
uint8_t _cached_snowline = 0;
|
||||
uint8_t _cached_highest_snowline = 0;
|
||||
uint8_t _cached_lowest_snowline = 0;
|
||||
uint8_t _cached_tree_placement_highest_snowline = 0;
|
||||
|
||||
/**
|
||||
* Map 2D viewport or smallmap coordinate to 3D world or tile coordinate.
|
||||
@@ -407,7 +407,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,
|
||||
@@ -462,7 +462,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,
|
||||
@@ -530,7 +530,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;
|
||||
@@ -552,7 +552,7 @@ void SetSnowLine(byte table[SNOW_LINE_MONTHS][SNOW_LINE_DAYS])
|
||||
* @return the snow line height.
|
||||
* @ingroup SnowLineGroup
|
||||
*/
|
||||
byte GetSnowLineUncached()
|
||||
uint8_t GetSnowLineUncached()
|
||||
{
|
||||
if (_snow_line == nullptr) return _settings_game.game_creation.snow_line_height;
|
||||
|
||||
@@ -833,8 +833,8 @@ void InitializeLandscape()
|
||||
for (uint y = 0; y < MapSizeY(); y++) MakeVoid(TileXY(MapMaxX(), 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)
|
||||
{
|
||||
@@ -858,7 +858,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.
|
||||
@@ -1510,7 +1510,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 {
|
||||
|
@@ -22,43 +22,43 @@ 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 GetSnowLineUncached();
|
||||
void SetSnowLine(uint8_t table[SNOW_LINE_MONTHS][SNOW_LINE_DAYS]);
|
||||
uint8_t GetSnowLineUncached();
|
||||
void UpdateCachedSnowLine();
|
||||
void UpdateCachedSnowLineBounds();
|
||||
void ClearSnowLine();
|
||||
|
||||
inline byte GetSnowLine()
|
||||
inline uint8_t GetSnowLine()
|
||||
{
|
||||
extern byte _cached_snowline;
|
||||
extern uint8_t _cached_snowline;
|
||||
return _cached_snowline;
|
||||
}
|
||||
|
||||
inline byte HighestSnowLine()
|
||||
inline uint8_t HighestSnowLine()
|
||||
{
|
||||
extern byte _cached_highest_snowline;
|
||||
extern uint8_t _cached_highest_snowline;
|
||||
return _cached_highest_snowline;
|
||||
}
|
||||
|
||||
inline byte LowestSnowLine()
|
||||
inline uint8_t LowestSnowLine()
|
||||
{
|
||||
extern byte _cached_lowest_snowline;
|
||||
extern uint8_t _cached_lowest_snowline;
|
||||
return _cached_lowest_snowline;
|
||||
}
|
||||
|
||||
inline byte HighestTreePlacementSnowLine()
|
||||
inline uint8_t HighestTreePlacementSnowLine()
|
||||
{
|
||||
extern byte _cached_tree_placement_highest_snowline;
|
||||
extern uint8_t _cached_tree_placement_highest_snowline;
|
||||
return _cached_tree_placement_highest_snowline;
|
||||
}
|
||||
|
||||
inline byte LowestTreePlacementSnowLine()
|
||||
inline uint8_t LowestTreePlacementSnowLine()
|
||||
{
|
||||
return LowestSnowLine();
|
||||
}
|
||||
@@ -169,6 +169,6 @@ void RunTileLoop(bool apply_day_length = false);
|
||||
void RunAuxiliaryTileLoop();
|
||||
|
||||
void InitializeLandscape();
|
||||
bool GenerateLandscape(byte mode);
|
||||
bool GenerateLandscape(uint8_t mode);
|
||||
|
||||
#endif /* LANDSCAPE_H */
|
||||
|
@@ -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 {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user