Codechange: rename byte to uint8_t (#12308)

This commit is contained in:
Patric Stout
2024-03-16 23:59:32 +01:00
committed by GitHub
parent bd7120bae4
commit a3cfd23cf9
355 changed files with 1654 additions and 1656 deletions

View File

@@ -16,14 +16,14 @@
ScriptBridgeList::ScriptBridgeList()
{
for (byte j = 0; j < MAX_BRIDGES; j++) {
for (uint8_t j = 0; j < MAX_BRIDGES; j++) {
if (ScriptBridge::IsValidBridge(j)) this->AddItem(j);
}
}
ScriptBridgeList_Length::ScriptBridgeList_Length(SQInteger length)
{
for (byte j = 0; j < MAX_BRIDGES; j++) {
for (uint8_t j = 0; j < MAX_BRIDGES; j++) {
if (ScriptBridge::IsValidBridge(j)) {
if (length >= ScriptBridge::GetMinLength(j) && length <= ScriptBridge::GetMaxLength(j)) this->AddItem(j);
}

View File

@@ -32,7 +32,7 @@
{
if (company == COMPANY_SELF) {
if (!::Company::IsValidID(_current_company)) return COMPANY_INVALID;
return (CompanyID)((byte)_current_company);
return (CompanyID)((uint8_t)_current_company);
}
return ::Company::IsValidID(company) ? company : COMPANY_INVALID;

View File

@@ -99,7 +99,7 @@ public:
* Types of expenses.
* @api -ai
*/
enum ExpensesType : byte {
enum ExpensesType : uint8_t {
EXPENSES_CONSTRUCTION = ::EXPENSES_CONSTRUCTION, ///< Construction costs.
EXPENSES_NEW_VEHICLES = ::EXPENSES_NEW_VEHICLES, ///< New vehicles.
EXPENSES_TRAIN_RUN = ::EXPENSES_TRAIN_RUN, ///< Running costs trains.

View File

@@ -36,7 +36,7 @@ public:
/**
* Goal types that can be given to a goal.
*/
enum GoalType : byte {
enum GoalType : uint8_t {
/* Note: these values represent part of the in-game GoalType enum */
GT_NONE = ::GT_NONE, ///< Destination is not linked.
GT_TILE = ::GT_TILE, ///< Destination is a tile.

View File

@@ -262,7 +262,7 @@
auto company_id = ::Industry::Get(industry_id)->exclusive_supplier;
if (!::Company::IsValidID(company_id)) return ScriptCompany::COMPANY_INVALID;
return (ScriptCompany::CompanyID)((byte)company_id);
return (ScriptCompany::CompanyID)((uint8_t)company_id);
}
/* static */ bool ScriptIndustry::SetExclusiveSupplier(IndustryID industry_id, ScriptCompany::CompanyID company_id)
@@ -282,7 +282,7 @@
auto company_id = ::Industry::Get(industry_id)->exclusive_consumer;
if (!::Company::IsValidID(company_id)) return ScriptCompany::COMPANY_INVALID;
return (ScriptCompany::CompanyID)((byte)company_id);
return (ScriptCompany::CompanyID)((uint8_t)company_id);
}
/* static */ bool ScriptIndustry::SetExclusiveConsumer(IndustryID industry_id, ScriptCompany::CompanyID company_id)

View File

@@ -42,7 +42,7 @@ public:
/**
* The type of a link.
*/
enum LinkType : byte {
enum LinkType : uint8_t {
LINK_NONE = ::LT_NONE, ///< No link
LINK_TILE = ::LT_TILE, ///< Link a tile
LINK_INDUSTRY = ::LT_INDUSTRY, ///< Link an industry

View File

@@ -40,7 +40,7 @@ public:
/**
* Types of rail known to the game.
*/
enum RailType : byte {
enum RailType : uint8_t {
/* Note: these values represent part of the in-game static values */
RAILTYPE_INVALID = ::INVALID_RAILTYPE, ///< Invalid RailType.
};

View File

@@ -245,13 +245,13 @@ static int32_t LookupWithBuildOnSlopes(::Slope slope, const Array<> &existing, i
SLOPE_W, SLOPE_EW, SLOPE_SW, SLOPE_WSE,
SLOPE_W, SLOPE_SW, SLOPE_EW, SLOPE_WSE,
SLOPE_SW, SLOPE_WSE, SLOPE_WSE};
static const byte base_rotates[] = {0, 0, 1, 0, 2, 0, 1, 0, 3, 3, 2, 3, 2, 2, 1};
static const uint8_t base_rotates[] = {0, 0, 1, 0, 2, 0, 1, 0, 3, 3, 2, 3, 2, 2, 1};
if (slope >= (::Slope)lengthof(base_slopes)) {
/* This slope is an invalid slope, so ignore it. */
return -1;
}
byte base_rotate = base_rotates[slope];
uint8_t base_rotate = base_rotates[slope];
slope = base_slopes[slope];
/* Some slopes don't need rotating, so return early when we know we do

View File

@@ -57,7 +57,7 @@ public:
/**
* Story page element types.
*/
enum StoryPageElementType : byte {
enum StoryPageElementType : uint8_t {
SPET_TEXT = ::SPET_TEXT, ///< An element that displays a block of text.
SPET_LOCATION = ::SPET_LOCATION, ///< An element that displays a single line of text along with a button to view the referenced location.
SPET_GOAL = ::SPET_GOAL, ///< An element that displays a goal.
@@ -75,7 +75,7 @@ public:
* Formatting and layout flags for story page buttons.
* The SPBF_FLOAT_LEFT and SPBF_FLOAT_RIGHT flags can not be combined.
*/
enum StoryPageButtonFlags : byte {
enum StoryPageButtonFlags : uint8_t {
SPBF_NONE = ::SPBF_NONE, ///< No special formatting for button.
SPBF_FLOAT_LEFT = ::SPBF_FLOAT_LEFT, ///< Button is placed to the left of the following paragraph.
SPBF_FLOAT_RIGHT = ::SPBF_FLOAT_RIGHT, ///< Button is placed to the right of the following paragraph.
@@ -84,7 +84,7 @@ public:
/**
* Mouse cursors usable by story page buttons.
*/
enum StoryPageButtonCursor : byte {
enum StoryPageButtonCursor : uint8_t {
SPBC_MOUSE = ::SPBC_MOUSE,
SPBC_ZZZ = ::SPBC_ZZZ,
SPBC_BUOY = ::SPBC_BUOY,
@@ -146,7 +146,7 @@ public:
* Colour codes usable for story page button elements.
* Place a colour value in the lowest 8 bits of the \c reference parameter to the button.
*/
enum StoryPageButtonColour : byte {
enum StoryPageButtonColour : uint8_t {
SPBC_DARK_BLUE = ::COLOUR_DARK_BLUE,
SPBC_PALE_GREEN = ::COLOUR_PALE_GREEN,
SPBC_PINK = ::COLOUR_PINK,

View File

@@ -47,7 +47,7 @@
{
if (!IsAwarded(subsidy_id)) return ScriptCompany::COMPANY_INVALID;
return (ScriptCompany::CompanyID)((byte)::Subsidy::Get(subsidy_id)->awarded);
return (ScriptCompany::CompanyID)((uint8_t)::Subsidy::Get(subsidy_id)->awarded);
}
/* static */ ScriptDate::Date ScriptSubsidy::GetExpireDate(SubsidyID subsidy_id)

View File

@@ -209,7 +209,7 @@
if (::IsTileType(tile, MP_HOUSE)) return ScriptCompany::COMPANY_INVALID;
if (::IsTileType(tile, MP_INDUSTRY)) return ScriptCompany::COMPANY_INVALID;
return ScriptCompany::ResolveCompanyID((ScriptCompany::CompanyID)(byte)::GetTileOwner(tile));
return ScriptCompany::ResolveCompanyID((ScriptCompany::CompanyID)(uint8_t)::GetTileOwner(tile));
}
/* static */ bool ScriptTile::HasTransportType(TileIndex tile, TransportType transport_type)

View File

@@ -294,7 +294,7 @@
EnforcePrecondition(false, layout >= ROAD_LAYOUT_ORIGINAL && layout <= ROAD_LAYOUT_RANDOM);
} else {
/* The layout parameter is ignored for AIs when custom layouts is disabled. */
layout = (RoadLayout) (byte)_settings_game.economy.town_layout;
layout = (RoadLayout) (uint8_t)_settings_game.economy.town_layout;
}
std::string text;

View File

@@ -87,7 +87,7 @@
/* Define all types here, so we don't have to include the whole _type.h maze */
typedef uint BridgeType; ///< Internal name, not of any use for you.
typedef byte CargoID; ///< The ID of a cargo.
typedef uint8_t CargoID; ///< The ID of a cargo.
class CommandCost; ///< The cost of a command.
typedef uint16_t EngineID; ///< The ID of an engine.
typedef uint16_t GoalID; ///< The ID of a goal.

View File

@@ -353,7 +353,7 @@
if (!IsValidVehicle(vehicle_id)) return ScriptVehicle::VS_INVALID;
const Vehicle *v = ::Vehicle::Get(vehicle_id);
byte vehstatus = v->vehstatus;
uint8_t vehstatus = v->vehstatus;
if (vehstatus & ::VS_CRASHED) return ScriptVehicle::VS_CRASHED;
if (v->breakdown_ctr != 0) return ScriptVehicle::VS_BROKEN;

View File

@@ -344,7 +344,7 @@ ScriptLogTypes::LogData &ScriptInstance::GetLogData()
* - null: No data.
*/
static byte _script_sl_byte; ///< Used as source/target by the script saveload code to store/load a single byte.
static uint8_t _script_sl_byte; ///< Used as source/target by the script saveload code to store/load a single byte.
/** SaveLoad array that saves/loads exactly one byte. */
static const SaveLoad _script_byte[] = {
@@ -386,7 +386,7 @@ static const SaveLoad _script_byte[] = {
return false;
}
if (!test) {
_script_sl_byte = (byte)len;
_script_sl_byte = (uint8_t)len;
SlObject(nullptr, _script_byte);
SlCopy(const_cast<char *>(buf), len, SLE_CHAR);
}