Merge branch 'master' into jgrpp

Remove 'byte' typedef
This commit is contained in:
Jonathan G Rennison
2024-05-07 17:21:50 +01:00
376 changed files with 2220 additions and 2152 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

@@ -28,7 +28,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.
*/
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

@@ -260,7 +260,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)
@@ -280,7 +280,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

@@ -41,7 +41,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

@@ -284,13 +284,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

@@ -46,7 +46,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

@@ -206,7 +206,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

@@ -296,7 +296,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

@@ -86,7 +86,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

@@ -352,7 +352,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

@@ -408,7 +408,7 @@ ScriptLogTypes::LogData &ScriptInstance::GetLogData()
ScriptLog::Error("Maximum string length is 254 chars. No data saved.");
return false;
}
SlWriteByte((byte)len);
SlWriteByte((uint8_t)len);
SlArray(const_cast<char *>(buf), len, SLE_CHAR);
return true;
}
@@ -561,7 +561,7 @@ bool ScriptInstance::IsPaused()
/* static */ bool ScriptInstance::LoadObjects(ScriptData *data)
{
byte type = SlReadByte();
uint8_t type = SlReadByte();
switch (type) {
case SQSL_INT: {
int64_t value;
@@ -571,7 +571,7 @@ bool ScriptInstance::IsPaused()
}
case SQSL_STRING: {
byte len = SlReadByte();
uint8_t len = SlReadByte();
static char buf[std::numeric_limits<decltype(len)>::max()];
SlArray(buf, len, SLE_CHAR);
if (data != nullptr) data->push_back(StrMakeValid(std::string_view(buf, len)));
@@ -586,7 +586,7 @@ bool ScriptInstance::IsPaused()
}
case SQSL_BOOL: {
byte sl_byte = SlReadByte();
uint8_t sl_byte = SlReadByte();
if (data != nullptr) data->push_back((SQBool)(sl_byte != 0));
return true;
}
@@ -660,7 +660,7 @@ bool ScriptInstance::IsPaused()
/* static */ void ScriptInstance::LoadEmpty()
{
byte sl_byte = SlReadByte();
uint8_t sl_byte = SlReadByte();
/* Check if there was anything saved at all. */
if (sl_byte == 0) return;
@@ -674,7 +674,7 @@ bool ScriptInstance::IsPaused()
return nullptr;
}
byte sl_byte = SlReadByte();
uint8_t sl_byte = SlReadByte();
/* Check if there was anything saved at all. */
if (sl_byte == 0) return nullptr;