Codechange: automatic adding of _t to (u)int types, and WChar to char32_t

for i in `find src -type f|grep -v 3rdparty/fmt|grep -v 3rdparty/catch2|grep -v 3rdparty/opengl|grep -v stdafx.h`; do sed 's/uint16& /uint16 \&/g;s/int8\([ >*),;[]\)/int8_t\1/g;s/int16\([ >*),;[]\)/int16_t\1/g;s/int32\([ >*),;[]\)/int32_t\1/g;s/int64\([ >*),;[]\)/int64_t\1/g;s/ uint32(/ uint32_t(/g;s/_uint8_t/_uint8/;s/Uint8_t/Uint8/;s/ft_int64_t/ft_int64/g;s/uint64$/uint64_t/;s/WChar/char32_t/g;s/char32_t char32_t/char32_t WChar/' -i $i; done
This commit is contained in:
Rubidium
2023-05-08 19:01:06 +02:00
committed by rubidium42
parent 4f4810dc28
commit eaae0bb5e7
564 changed files with 4561 additions and 4561 deletions

View File

@@ -169,5 +169,5 @@
{
if (!IsAirportInformationAvailable(type)) return -1;
return (int64)GetMaintenanceCostFactor(type) * _price[PR_INFRASTRUCTURE_AIRPORT] >> 3;
return (int64_t)GetMaintenanceCostFactor(type) * _price[PR_INFRASTRUCTURE_AIRPORT] >> 3;
}

View File

@@ -23,21 +23,21 @@ class ScriptBase : public ScriptObject {
public:
/**
* Get a random value.
* @return A random value between 0 and MAX(uint32).
* @return A random value between 0 and MAX(uint32_t).
*/
static SQInteger Rand();
/**
* Get a random value.
* @param unused_param This parameter is not used, but is needed to work with lists.
* @return A random value between 0 and MAX(uint32).
* @return A random value between 0 and MAX(uint32_t).
*/
static SQInteger RandItem(SQInteger unused_param);
/**
* Get a random value in a range.
* @param max The first number this function will never return (the maximum it returns is max - 1).
* The value will be clamped to 0 .. MAX(uint32).
* The value will be clamped to 0 .. MAX(uint32_t).
* @return A random value between 0 .. max - 1.
*/
static SQInteger RandRange(SQInteger max);
@@ -46,7 +46,7 @@ public:
* Get a random value in a range.
* @param unused_param This parameter is not used, but is needed to work with lists.
* @param max The first number this function will never return (the maximum it returns is max - 1).
* The value will be clamped to 0 .. MAX(uint32).
* The value will be clamped to 0 .. MAX(uint32_t).
* @return A random value between 0 .. max - 1.
*/
static SQInteger RandRangeItem(SQInteger unused_param, SQInteger max);
@@ -55,9 +55,9 @@ public:
* Returns approximately 'out' times true when called 'max' times.
* After all, it is a random function.
* @param out How many times it should return true.
* The value will be clamped to 0 .. MAX(uint32).
* The value will be clamped to 0 .. MAX(uint32_t).
* @param max Out of this many times.
* The value will be clamped to 0 .. MAX(uint32).
* The value will be clamped to 0 .. MAX(uint32_t).
* @pre \a out is at most equal to \a max.
* @return True if the chance worked out.
*/
@@ -68,9 +68,9 @@ public:
* After all, it is a random function.
* @param unused_param This parameter is not used, but is needed to work with lists.
* @param out How many times it should return true.
* The value will be clamped to 0 .. MAX(uint32).
* The value will be clamped to 0 .. MAX(uint32_t).
* @param max Out of this many times.
* The value will be clamped to 0 .. MAX(uint32).
* The value will be clamped to 0 .. MAX(uint32_t).
* @pre \a out is at most equal to \a max.
* @return True if the chance worked out.
*/

View File

@@ -86,7 +86,7 @@ public:
* Get the new cost of a bridge, excluding the road and/or rail.
* @param bridge_id The bridge to get the new cost of.
* @param length The length of the bridge.
* The value will be clamped to 0 .. MAX(int32).
* The value will be clamped to 0 .. MAX(int32_t).
* @pre IsValidBridge(bridge_id).
* @return The new cost the bridge has.
*/

View File

@@ -41,11 +41,11 @@
if (!IsValidCargo(cargo_type)) return std::nullopt;
const CargoSpec *cargo = ::CargoSpec::Get(cargo_type);
/* cargo->label is a uint32 packing a 4 character non-terminated string,
/* cargo->label is a uint32_t packing a 4 character non-terminated string,
* like "PASS", "COAL", "OIL_". New ones can be defined by NewGRFs */
std::string cargo_label;
for (uint i = 0; i < sizeof(cargo->label); i++) {
cargo_label.push_back(GB(cargo->label, (uint8)(sizeof(cargo->label) - i - 1) * 8, 8));
cargo_label.push_back(GB(cargo->label, (uint8_t)(sizeof(cargo->label) - i - 1) * 8, 8));
}
return cargo_label;
}

View File

@@ -142,7 +142,7 @@ public:
* @param cargo_type The cargo to transport.
* @pre ScriptCargo::IsValidCargo(cargo_type).
* @param distance The distance the cargo travels from begin to end.
* The value will be clamped to 0 .. MAX(uint32).
* The value will be clamped to 0 .. MAX(uint32_t).
* @param days_in_transit Amount of (game) days the cargo is in transit.
* The max value of this variable is 637. Any value higher returns the same as 637 would.
* @return The amount of money that would be earned by this trip.
@@ -161,7 +161,7 @@ public:
* cargo for the specified type.
* @param cargo_type The cargo to check on.
* @param amount The quantity of cargo.
* The value will be clamped to 0 .. MAX(uint32).
* The value will be clamped to 0 .. MAX(uint32_t).
* @pre ScriptCargo::IsValidCargo(cargo_type).
* @return The weight in tonnes for that quantity of cargo.
*/

View File

@@ -24,7 +24,7 @@ class ScriptClient : public ScriptObject {
public:
/** Different constants related to ClientID. */
enum ClientID : uint32 {
enum ClientID : uint32_t {
CLIENT_INVALID = 0, ///< Client is not part of anything
CLIENT_SERVER = 1, ///< Servers always have this ID
CLIENT_FIRST = 2, ///< The first client ID

View File

@@ -204,7 +204,7 @@
{
EnforceCompanyModeValid(false);
EnforcePrecondition(false, loan >= 0);
EnforcePrecondition(false, ((int64)loan % GetLoanInterval()) == 0);
EnforcePrecondition(false, ((int64_t)loan % GetLoanInterval()) == 0);
EnforcePrecondition(false, loan <= GetMaxLoanAmount());
EnforcePrecondition(false, (loan - GetLoanAmount() + GetBankBalance(COMPANY_SELF)) >= 0);
@@ -224,7 +224,7 @@
EnforceCompanyModeValid(false);
EnforcePrecondition(false, loan >= 0);
Money over_interval = (int64)loan % GetLoanInterval();
Money over_interval = (int64_t)loan % GetLoanInterval();
if (over_interval != 0) loan += GetLoanInterval() - over_interval;
EnforcePrecondition(false, loan <= GetMaxLoanAmount());
@@ -298,7 +298,7 @@
{
EnforceCompanyModeValid(false);
EnforcePrecondition(false, money >= 0);
EnforcePrecondition(false, (int64)money <= UINT32_MAX);
EnforcePrecondition(false, (int64_t)money <= UINT32_MAX);
return ScriptObject::Command<CMD_CHANGE_COMPANY_SETTING>::Do("company.engine_renew_money", money);
}

View File

@@ -351,7 +351,7 @@ public:
/**
* Set the number of months before/after max age to autorenew an engine for your company.
* @param months The new months between autorenew.
* The value will be clamped to MIN(int16) .. MAX(int16).
* The value will be clamped to MIN(int16_t) .. MAX(int16_t).
* @game @pre ScriptCompanyMode::IsValid().
* @return True if autorenew months has been modified.
*/

View File

@@ -53,7 +53,7 @@ CargoID ScriptEventEnginePreview::GetCargoType()
return most_cargo;
}
int32 ScriptEventEnginePreview::GetCapacity()
int32_t ScriptEventEnginePreview::GetCapacity()
{
if (!this->IsEngineValid()) return -1;
const Engine *e = ::Engine::Get(this->engine);
@@ -76,11 +76,11 @@ int32 ScriptEventEnginePreview::GetCapacity()
}
}
int32 ScriptEventEnginePreview::GetMaxSpeed()
int32_t ScriptEventEnginePreview::GetMaxSpeed()
{
if (!this->IsEngineValid()) return -1;
const Engine *e = ::Engine::Get(this->engine);
int32 max_speed = e->GetDisplayMaxSpeed(); // km-ish/h
int32_t max_speed = e->GetDisplayMaxSpeed(); // km-ish/h
if (e->type == VEH_AIRCRAFT) max_speed /= _settings_game.vehicle.plane_speed;
return max_speed;
}
@@ -97,7 +97,7 @@ Money ScriptEventEnginePreview::GetRunningCost()
return ::Engine::Get(this->engine)->GetRunningCost();
}
int32 ScriptEventEnginePreview::GetVehicleType()
int32_t ScriptEventEnginePreview::GetVehicleType()
{
if (!this->IsEngineValid()) return ScriptVehicle::VT_INVALID;
switch (::Engine::Get(this->engine)->type) {

View File

@@ -253,7 +253,7 @@ public:
* returns the first/main.
* @return The capacity of the engine.
*/
int32 GetCapacity();
int32_t GetCapacity();
/**
* Get the maximum speed of the offered engine.
@@ -262,7 +262,7 @@ public:
* This is mph / 1.6, which is roughly km/h.
* To get km/h multiply this number by 1.00584.
*/
int32 GetMaxSpeed();
int32_t GetMaxSpeed();
/**
* Get the new cost of the offered engine.
@@ -284,7 +284,7 @@ public:
#ifdef DOXYGEN_API
ScriptVehicle::VehicleType GetVehicleType();
#else
int32 GetVehicleType();
int32_t GetVehicleType();
#endif /* DOXYGEN_API */
/**
@@ -945,7 +945,7 @@ public:
* @param number The windownumber that was clicked.
* @param widget The widget in the window that was clicked.
*/
ScriptEventWindowWidgetClick(ScriptWindow::WindowClass window, uint32 number, uint8 widget) :
ScriptEventWindowWidgetClick(ScriptWindow::WindowClass window, uint32_t number, uint8_t widget) :
ScriptEvent(ET_WINDOW_WIDGET_CLICK),
window(window),
number(number),
@@ -970,18 +970,18 @@ public:
* Get the number of the window that was clicked.
* @return The clicked identifying number of the widget within the class.
*/
uint32 GetWindowNumber() { return this->number; }
uint32_t GetWindowNumber() { return this->number; }
/**
* Get the number of the widget that was clicked.
* @return The number of the clicked widget.
*/
uint8 GetWidgetNumber() { return this->widget; }
uint8_t GetWidgetNumber() { return this->widget; }
private:
ScriptWindow::WindowClass window; ///< Window of the click.
uint32 number; ///< Number of the click.
uint8 widget; ///< Widget of the click.
uint32_t number; ///< Number of the click.
uint8_t widget; ///< Widget of the click.
};
/**
@@ -998,7 +998,7 @@ public:
* @param company The company that is replying.
* @param button The button the company pressed.
*/
ScriptEventGoalQuestionAnswer(uint16 uniqueid, ScriptCompany::CompanyID company, ScriptGoal::QuestionButton button) :
ScriptEventGoalQuestionAnswer(uint16_t uniqueid, ScriptCompany::CompanyID company, ScriptGoal::QuestionButton button) :
ScriptEvent(ET_GOAL_QUESTION_ANSWER),
uniqueid(uniqueid),
company(company),
@@ -1017,7 +1017,7 @@ public:
* Get the unique id of the question.
* @return The unique id.
*/
uint16 GetUniqueID() { return this->uniqueid; }
uint16_t GetUniqueID() { return this->uniqueid; }
/**
* Get the company that pressed a button.
@@ -1032,7 +1032,7 @@ public:
ScriptGoal::QuestionButton GetButton() { return this->button; }
private:
uint16 uniqueid; ///< The uniqueid of the question.
uint16_t uniqueid; ///< The uniqueid of the question.
ScriptCompany::CompanyID company; ///< The company given the answer.
ScriptGoal::QuestionButton button; ///< The button that was pressed.
};

View File

@@ -63,7 +63,7 @@ public:
* Sets the value of the game setting.
* @param setting The setting to set the value of.
* @param value The value to set the setting to.
* The value will be clamped to MIN(int32) .. MAX(int32).
* The value will be clamped to MIN(int32_t) .. MAX(int32_t).
* @pre IsValid(setting).
* @return True if the action succeeded.
* @note Results achieved in the past offer no guarantee for the future.

View File

@@ -117,7 +117,7 @@
return g != nullptr && g->completed;
}
/* static */ bool ScriptGoal::DoQuestion(SQInteger uniqueid, uint32 target, bool is_client, Text *question, QuestionType type, SQInteger buttons)
/* static */ bool ScriptGoal::DoQuestion(SQInteger uniqueid, uint32_t target, bool is_client, Text *question, QuestionType type, SQInteger buttons)
{
CCountedPtr<Text> counter(question);
@@ -137,7 +137,7 @@
/* static */ bool ScriptGoal::Question(SQInteger uniqueid, ScriptCompany::CompanyID company, Text *question, QuestionType type, SQInteger buttons)
{
EnforcePrecondition(false, company == ScriptCompany::COMPANY_INVALID || ScriptCompany::ResolveCompanyID(company) != ScriptCompany::COMPANY_INVALID);
uint8 c = company;
uint8_t c = company;
if (company == ScriptCompany::COMPANY_INVALID) c = INVALID_COMPANY;
return DoQuestion(uniqueid, c, false, question, type, buttons);

View File

@@ -28,7 +28,7 @@ public:
/**
* The goal IDs.
*/
enum GoalID : uint16 {
enum GoalID : uint16_t {
/* Note: these values represent part of the in-game GoalID enum */
GOAL_INVALID = ::INVALID_GOAL, ///< An invalid goal id.
};
@@ -191,7 +191,7 @@ public:
* @pre question != null && len(question) != 0.
* @pre company == COMPANY_INVALID || ResolveCompanyID(company) != COMPANY_INVALID.
* @pre CountBits(buttons) >= 1 && CountBits(buttons) <= 3.
* @pre uniqueid >= 0 && uniqueid <= MAX(uint16)
* @pre uniqueid >= 0 && uniqueid <= MAX(uint16_t)
* @note Replies to the question are given by you via the event ScriptEventGoalQuestionAnswer.
* @note There is no guarantee you ever get a reply on your question.
*/
@@ -210,7 +210,7 @@ public:
* @pre question != null && len(question) != 0.
* @pre ResolveClientID(client) != CLIENT_INVALID.
* @pre CountBits(buttons) >= 1 && CountBits(buttons) <= 3.
* @pre uniqueid >= 0 && uniqueid <= MAX(uint16)
* @pre uniqueid >= 0 && uniqueid <= MAX(uint16_t)
* @note Replies to the question are given by you via the event ScriptEventGoalQuestionAnswer.
* @note There is no guarantee you ever get a reply on your question.
*/
@@ -221,7 +221,7 @@ public:
* @param uniqueid The uniqueid of the question you want to close.
* @return True if the action succeeded.
* @pre ScriptCompanyMode::IsDeity().
* @pre uniqueid >= 0 && uniqueid <= MAX(uint16)
* @pre uniqueid >= 0 && uniqueid <= MAX(uint16_t)
* @note If you send a question to a single company, and get a reply for them,
* the question is already closed on all clients. Only use this function if
* you want to timeout a question, or if you send the question to all
@@ -233,7 +233,7 @@ protected:
/**
* Does common checks and asks the question.
*/
static bool DoQuestion(SQInteger uniqueid, uint32 target, bool is_client, Text *question, QuestionType type, SQInteger buttons);
static bool DoQuestion(SQInteger uniqueid, uint32_t target, bool is_client, Text *question, QuestionType type, SQInteger buttons);
};
#endif /* SCRIPT_GOAL_HPP */

View File

@@ -201,8 +201,8 @@
{
if (!IsValidGroup(group_id)) return -1;
uint32 occupancy = 0;
uint32 vehicle_count = 0;
uint32_t occupancy = 0;
uint32_t vehicle_count = 0;
for (const Vehicle *v : Vehicle::Iterate()) {
if (v->group_id != group_id) continue;

View File

@@ -123,8 +123,8 @@
EnforcePrecondition(false, CanBuildIndustry(industry_type));
EnforcePrecondition(false, ScriptMap::IsValidTile(tile));
uint32 seed = ScriptBase::Rand();
uint32 layout_index = ScriptBase::RandRange((uint32)::GetIndustrySpec(industry_type)->layouts.size());
uint32_t seed = ScriptBase::Rand();
uint32_t layout_index = ScriptBase::RandRange((uint32_t)::GetIndustrySpec(industry_type)->layouts.size());
return ScriptObject::Command<CMD_BUILD_INDUSTRY>::Do(tile, industry_type, layout_index, true, seed);
}
@@ -133,7 +133,7 @@
EnforceDeityOrCompanyModeValid(false);
EnforcePrecondition(false, CanProspectIndustry(industry_type));
uint32 seed = ScriptBase::Rand();
uint32_t seed = ScriptBase::Rand();
return ScriptObject::Command<CMD_BUILD_INDUSTRY>::Do(0, industry_type, 0, false, seed);
}

View File

@@ -219,26 +219,26 @@ public:
* - description A single line describing the setting. Required.
* - min_value The minimum value of this setting. Required for integer
* settings and not allowed for boolean settings. The value will be
* clamped in the range [MIN(int32), MAX(int32)] (inclusive).
* clamped in the range [MIN(int32_t), MAX(int32_t)] (inclusive).
* - max_value The maximum value of this setting. Required for integer
* settings and not allowed for boolean settings. The value will be
* clamped in the range [MIN(int32), MAX(int32)] (inclusive).
* clamped in the range [MIN(int32_t), MAX(int32_t)] (inclusive).
* - easy_value The default value if the easy difficulty level
* is selected. Required. The value will be clamped in the range
* [MIN(int32), MAX(int32)] (inclusive).
* [MIN(int32_t), MAX(int32_t)] (inclusive).
* - medium_value The default value if the medium difficulty level
* is selected. Required. The value will be clamped in the range
* [MIN(int32), MAX(int32)] (inclusive).
* [MIN(int32_t), MAX(int32_t)] (inclusive).
* - hard_value The default value if the hard difficulty level
* is selected. Required. The value will be clamped in the range
* [MIN(int32), MAX(int32)] (inclusive).
* [MIN(int32_t), MAX(int32_t)] (inclusive).
* - custom_value The default value if the custom difficulty level
* is selected. Required. The value will be clamped in the range
* [MIN(int32), MAX(int32)] (inclusive).
* [MIN(int32_t), MAX(int32_t)] (inclusive).
* - random_deviation If this property has a nonzero value, then the
* actual value of the setting in game will be randomized in the range
* [user_configured_value - random_deviation, user_configured_value + random_deviation] (inclusive).
* random_deviation sign is ignored and the value is clamped in the range [0, MAX(int32)] (inclusive).
* random_deviation sign is ignored and the value is clamped in the range [0, MAX(int32_t)] (inclusive).
* Not allowed if the CONFIG_RANDOM flag is set, otherwise optional.
* - step_size The increase/decrease of the value every time the user
* clicks one of the up/down arrow buttons. Optional, default is 1.

View File

@@ -42,7 +42,7 @@
::Company *c = ::Company::Get((::CompanyID)company);
switch (infra_type) {
case INFRASTRUCTURE_RAIL: {
uint32 count = 0;
uint32_t count = 0;
for (::RailType rt = ::RAILTYPE_BEGIN; rt != ::RAILTYPE_END; rt++) {
count += c->infrastructure.rail[rt];
}
@@ -53,7 +53,7 @@
return c->infrastructure.signal;
case INFRASTRUCTURE_ROAD: {
uint32 count = 0;
uint32_t count = 0;
for (::RoadType rt = ::ROADTYPE_BEGIN; rt != ::ROADTYPE_END; rt++) {
count += c->infrastructure.road[rt];
}
@@ -101,7 +101,7 @@
switch (infra_type) {
case INFRASTRUCTURE_RAIL: {
Money cost;
uint32 rail_total = c->infrastructure.GetRailTotal();
uint32_t rail_total = c->infrastructure.GetRailTotal();
for (::RailType rt = ::RAILTYPE_BEGIN; rt != ::RAILTYPE_END; rt++) {
cost += RailMaintenanceCost(rt, c->infrastructure.rail[rt], rail_total);
}
@@ -113,7 +113,7 @@
case INFRASTRUCTURE_ROAD: {
Money cost;
uint32 road_total = c->infrastructure.GetRoadTotal();
uint32_t road_total = c->infrastructure.GetRoadTotal();
for (::RoadType rt = ::ROADTYPE_BEGIN; rt != ::ROADTYPE_END; rt++) {
cost += RoadMaintenanceCost(rt, c->infrastructure.road[rt], road_total);
}

View File

@@ -36,7 +36,7 @@
(ref_type == NR_INDUSTRY && ScriptIndustry::IsValidIndustry(reference)) ||
(ref_type == NR_TOWN && ScriptTown::IsValidTown(reference)));
uint8 c = company;
uint8_t c = company;
if (company == ScriptCompany::COMPANY_INVALID) c = INVALID_COMPANY;
if (ref_type == NR_NONE) reference = 0;

View File

@@ -176,7 +176,7 @@
EnforcePrecondition(false, goal_industry == ScriptIndustryType::INDUSTRYTYPE_UNKNOWN || goal_industry == ScriptIndustryType::INDUSTRYTYPE_TOWN || ScriptIndustryType::IsValidIndustryType(goal_industry));
const GRFFile *file;
uint16 res = GetAiPurchaseCallbackResult(
uint16_t res = GetAiPurchaseCallbackResult(
GSF_STATIONS,
cargo_id,
0,

View File

@@ -150,7 +150,7 @@
* @param end The part that will be build second.
* @return True if and only if the road bits can be build.
*/
static bool CheckAutoExpandedRoadBits(const Array<> &existing, int32 start, int32 end)
static bool CheckAutoExpandedRoadBits(const Array<> &existing, int32_t start, int32_t end)
{
return (start + end == 0) && (existing.empty() || existing[0] == start || existing[0] == end);
}
@@ -165,7 +165,7 @@ static bool CheckAutoExpandedRoadBits(const Array<> &existing, int32 start, int3
* they are build or 2 when building the first part automatically
* builds the second part.
*/
static int32 LookupWithoutBuildOnSlopes(::Slope slope, const Array<> &existing, int32 start, int32 end)
static int32_t LookupWithoutBuildOnSlopes(::Slope slope, const Array<> &existing, int32_t start, int32_t end)
{
switch (slope) {
/* Flat slopes can always be build. */
@@ -192,7 +192,7 @@ static int32 LookupWithoutBuildOnSlopes(::Slope slope, const Array<> &existing,
* @param neighbour The neighbour.
* @return The rotate neighbour data.
*/
static int32 RotateNeighbour(int32 neighbour)
static int32_t RotateNeighbour(int32_t neighbour)
{
switch (neighbour) {
case -2: return -1;
@@ -208,7 +208,7 @@ static int32 RotateNeighbour(int32 neighbour)
* @param neighbour The neighbour.
* @return The bits representing the direction.
*/
static RoadBits NeighbourToRoadBits(int32 neighbour)
static RoadBits NeighbourToRoadBits(int32_t neighbour)
{
switch (neighbour) {
case -2: return ROAD_NW;
@@ -229,7 +229,7 @@ static RoadBits NeighbourToRoadBits(int32 neighbour)
* they are build or 2 when building the first part automatically
* builds the second part.
*/
static int32 LookupWithBuildOnSlopes(::Slope slope, const Array<> &existing, int32 start, int32 end)
static int32_t LookupWithBuildOnSlopes(::Slope slope, const Array<> &existing, int32_t start, int32_t end)
{
/* Steep slopes behave the same as slopes with one corner raised. */
if (IsSteepSlope(slope)) {
@@ -287,7 +287,7 @@ static int32 LookupWithBuildOnSlopes(::Slope slope, const Array<> &existing, int
RoadBits start_roadbits = NeighbourToRoadBits(start);
RoadBits new_roadbits = start_roadbits | NeighbourToRoadBits(end);
RoadBits existing_roadbits = ROAD_NONE;
for (int32 neighbour : existing) {
for (int32_t neighbour : existing) {
for (int j = 0; j < base_rotate; j++) {
neighbour = RotateNeighbour(neighbour);
}
@@ -365,7 +365,7 @@ static int32 LookupWithBuildOnSlopes(::Slope slope, const Array<> &existing, int
* @param tile The tile to normalise.
* @return True if and only if the tile offset is valid.
*/
static bool NormaliseTileOffset(int32 *tile)
static bool NormaliseTileOffset(int32_t *tile)
{
if (*tile == 1 || *tile == -1) return true;
if (*tile == ::TileDiffXY(0, -1)) {
@@ -382,8 +382,8 @@ static bool NormaliseTileOffset(int32 *tile)
/* static */ SQInteger ScriptRoad::CanBuildConnectedRoadParts(ScriptTile::Slope slope_, Array<> &&existing, TileIndex start_, TileIndex end_)
{
::Slope slope = (::Slope)slope_;
int32 start = start_;
int32 end = end_;
int32_t start = start_;
int32_t end = end_;
/* The start tile and end tile cannot be the same tile either. */
if (start == end) return -1;
@@ -457,7 +457,7 @@ static bool NeighbourHasReachableRoad(::RoadType rt, TileIndex start_tile, DiagD
if (!IsRoadTypeAvailable(GetCurrentRoadType())) return -1;
::RoadType rt = (::RoadType)GetCurrentRoadType();
int32 neighbour = 0;
int32_t neighbour = 0;
if (TileX(tile) > 0 && NeighbourHasReachableRoad(rt, tile, DIAGDIR_NE)) neighbour++;
if (NeighbourHasReachableRoad(rt, tile, DIAGDIR_SE)) neighbour++;

View File

@@ -61,7 +61,7 @@ public:
/**
* Road/tram types
*/
enum RoadTramTypes : uint8 {
enum RoadTramTypes : uint8_t {
ROADTRAMTYPES_ROAD = ::RTTB_ROAD, ///< Road road types.
ROADTRAMTYPES_TRAM = ::RTTB_TRAM, ///< Tram road types.
};

View File

@@ -62,7 +62,7 @@ template<bool Tfrom, bool Tvia>
const StationCargoList &cargo_list = ::Station::Get(station_id)->goods[cargo_id].cargo;
if (!Tfrom && !Tvia) return cargo_list.TotalCount();
uint16 cargo_count = 0;
uint16_t cargo_count = 0;
std::pair<StationCargoList::ConstIterator, StationCargoList::ConstIterator> range = Tvia ?
cargo_list.Packets()->equal_range(via_station_id) :
std::make_pair(StationCargoList::ConstIterator(cargo_list.Packets()->begin()),

View File

@@ -45,7 +45,7 @@ static inline bool StoryPageElementTypeRequiresText(StoryPageElementType type)
EnforceDeityMode(STORY_PAGE_INVALID);
EnforcePrecondition(STORY_PAGE_INVALID, company == ScriptCompany::COMPANY_INVALID || ScriptCompany::ResolveCompanyID(company) != ScriptCompany::COMPANY_INVALID);
uint8 c = company;
uint8_t c = company;
if (company == ScriptCompany::COMPANY_INVALID) c = INVALID_COMPANY;
if (!ScriptObject::Command<CMD_CREATE_STORY_PAGE>::Do(&ScriptInstance::DoCommandReturnStoryPageID,
@@ -73,7 +73,7 @@ static inline bool StoryPageElementTypeRequiresText(StoryPageElementType type)
EnforcePrecondition(STORY_PAGE_ELEMENT_INVALID, type != SPET_GOAL || ScriptGoal::IsValidGoal((ScriptGoal::GoalID)reference));
EnforcePrecondition(STORY_PAGE_ELEMENT_INVALID, type != SPET_GOAL || !(StoryPage::Get(story_page_id)->company == INVALID_COMPANY && Goal::Get(reference)->company != INVALID_COMPANY));
uint32 refid = 0;
uint32_t refid = 0;
TileIndex reftile = 0;
switch (type) {
case SPET_LOCATION:
@@ -122,7 +122,7 @@ static inline bool StoryPageElementTypeRequiresText(StoryPageElementType type)
EnforcePrecondition(false, type != ::SPET_GOAL || ScriptGoal::IsValidGoal((ScriptGoal::GoalID)reference));
EnforcePrecondition(false, type != ::SPET_GOAL || !(p->company == INVALID_COMPANY && Goal::Get(reference)->company != INVALID_COMPANY));
uint32 refid = 0;
uint32_t refid = 0;
TileIndex reftile = 0;
switch (type) {
case ::SPET_LOCATION:

View File

@@ -69,7 +69,7 @@ public:
/**
* Formatting data for button page elements.
*/
typedef uint32 StoryPageButtonFormatting;
typedef uint32_t StoryPageButtonFormatting;
/**
* Formatting and layout flags for story page buttons.

View File

@@ -16,7 +16,7 @@
ScriptStoryPageList::ScriptStoryPageList(ScriptCompany::CompanyID company)
{
uint8 c = company;
uint8_t c = company;
if (company == ScriptCompany::COMPANY_INVALID) c = INVALID_COMPANY;
for (StoryPage *p : StoryPage::Iterate()) {

View File

@@ -133,7 +133,7 @@ SQInteger ScriptText::AddParam(HSQUIRRELVM vm)
SQInteger ScriptText::_set(HSQUIRRELVM vm)
{
int32 k;
int32_t k;
if (sq_gettype(vm, 2) == OT_STRING) {
const SQChar *key_string;
@@ -146,7 +146,7 @@ SQInteger ScriptText::_set(HSQUIRRELVM vm)
} else if (sq_gettype(vm, 2) == OT_INTEGER) {
SQInteger key;
sq_getinteger(vm, 2, &key);
k = (int32)key;
k = (int32_t)key;
} else {
return SQ_ERROR;
}

View File

@@ -160,7 +160,7 @@
{
EnforceDeityMode(false);
EnforcePrecondition(false, IsValidTown(town_id));
uint16 growth_rate;
uint16_t growth_rate;
switch (days_between_town_growth) {
case TOWN_GROWTH_NORMAL:
growth_rate = 0;
@@ -206,7 +206,7 @@
if (!IsValidTown(town_id)) return false;
const Town *t = ::Town::Get(town_id);
return ((uint32)GetDistanceSquareToTile(town_id, tile) <= t->cache.squared_town_zone_radius[0]);
return ((uint32_t)GetDistanceSquareToTile(town_id, tile) <= t->cache.squared_town_zone_radius[0]);
}
/* static */ bool ScriptTown::HasStatue(TownID town_id)
@@ -243,7 +243,7 @@
EnforceCompanyModeValid(ScriptCompany::COMPANY_INVALID);
if (!IsValidTown(town_id)) return ScriptCompany::COMPANY_INVALID;
return (ScriptCompany::CompanyID)(int8)::Town::Get(town_id)->exclusivity;
return (ScriptCompany::CompanyID)(int8_t)::Town::Get(town_id)->exclusivity;
}
/* static */ SQInteger ScriptTown::GetExclusiveRightsDuration(TownID town_id)
@@ -302,7 +302,7 @@
text = name->GetDecodedText();
EnforcePreconditionCustomError(false, ::Utf8StringLength(text) < MAX_LENGTH_TOWN_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG);
}
uint32 townnameparts;
uint32_t townnameparts;
if (!GenerateTownName(ScriptObject::GetRandomizer(), &townnameparts)) {
ScriptObject::SetLastError(ScriptError::ERR_NAME_IS_NOT_UNIQUE);
return false;
@@ -357,7 +357,7 @@
EnforcePrecondition(false, company != ScriptCompany::COMPANY_INVALID);
const Town *t = ::Town::Get(town_id);
int16 new_rating = Clamp(t->ratings[company] + delta, RATING_MINIMUM, RATING_MAXIMUM);
int16_t new_rating = Clamp(t->ratings[company] + delta, RATING_MINIMUM, RATING_MAXIMUM);
if (new_rating == t->ratings[company]) return false;
return ScriptObject::Command<CMD_TOWN_RATING>::Do(town_id, (::CompanyID)company_id, new_rating);

View File

@@ -235,7 +235,7 @@ public:
* @param town_id The index of the town.
* @param towneffect_id The index of the towneffect.
* @param goal The new goal.
* The value will be clamped to 0 .. MAX(uint32).
* The value will be clamped to 0 .. MAX(uint32_t).
* @pre IsValidTown(town_id).
* @pre ScriptCargo::IsValidTownEffect(towneffect_id).
* @pre ScriptCompanyMode::IsDeity().
@@ -392,7 +392,7 @@ public:
* Expand the town.
* @param town_id The town to expand.
* @param houses The amount of houses to grow the town with.
* The value will be clamped to 0 .. MAX(uint32).
* The value will be clamped to 0 .. MAX(uint32_t).
* @pre IsValidTown(town_id).
* @pre houses > 0.
* @pre ScriptCompanyMode::IsDeity().

View File

@@ -89,20 +89,20 @@
typedef uint BridgeType; ///< Internal name, not of any use for you.
typedef byte CargoID; ///< The ID of a cargo.
class CommandCost; ///< The cost of a command.
typedef uint16 EngineID; ///< The ID of an engine.
typedef uint16 GoalID; ///< The ID of a goal.
typedef uint16 GroupID; ///< The ID of a group.
typedef uint16 IndustryID; ///< The ID of an industry.
typedef uint8 IndustryType; ///< The ID of an industry-type.
typedef uint16_t EngineID; ///< The ID of an engine.
typedef uint16_t GoalID; ///< The ID of a goal.
typedef uint16_t GroupID; ///< The ID of a group.
typedef uint16_t IndustryID; ///< The ID of an industry.
typedef uint8_t IndustryType; ///< The ID of an industry-type.
typedef OverflowSafeInt64 Money; ///< Money, stored in a 32bit/64bit safe way. For scripts money is always in pounds.
typedef uint16 SignID; ///< The ID of a sign.
typedef uint16 StationID; ///< The ID of a station.
typedef uint32 StringID; ///< The ID of a string.
typedef uint16 SubsidyID; ///< The ID of a subsidy.
typedef uint16 StoryPageID; ///< The ID of a story page.
typedef uint16 StoryPageElementID; ///< The ID of a story page element.
typedef uint16 TownID; ///< The ID of a town.
typedef uint32 VehicleID; ///< The ID of a vehicle.
typedef uint16_t SignID; ///< The ID of a sign.
typedef uint16_t StationID; ///< The ID of a station.
typedef uint32_t StringID; ///< The ID of a string.
typedef uint16_t SubsidyID; ///< The ID of a subsidy.
typedef uint16_t StoryPageID; ///< The ID of a story page.
typedef uint16_t StoryPageElementID; ///< The ID of a story page element.
typedef uint16_t TownID; ///< The ID of a town.
typedef uint32_t VehicleID; ///< The ID of a vehicle.
/* Types we defined ourself, as the OpenTTD core doesn't have them (yet) */
typedef uint ScriptErrorType;///< The types of errors inside the script framework.

View File

@@ -417,7 +417,7 @@
if (!IsValidVehicle(vehicle_id)) return -1;
if (!ScriptCargo::IsValidCargo(cargo)) return -1;
uint32 amount = 0;
uint32_t amount = 0;
for (const Vehicle *v = ::Vehicle::Get(vehicle_id); v != nullptr; v = v->Next()) {
if (v->cargo_type == cargo) amount += v->cargo_cap;
}
@@ -430,7 +430,7 @@
if (!IsValidVehicle(vehicle_id)) return -1;
if (!ScriptCargo::IsValidCargo(cargo)) return -1;
uint32 amount = 0;
uint32_t amount = 0;
for (const Vehicle *v = ::Vehicle::Get(vehicle_id); v != nullptr; v = v->Next()) {
if (v->cargo_type == cargo) amount += v->cargo.StoredCount();
}

View File

@@ -81,7 +81,7 @@ public:
* Close a window.
* @param window The class of the window to close.
* @param number The number of the window to close, or NUMBER_ALL to close all of this class.
* The value will be clamped to 0 .. MAX(int32) when value is not NUMBER_ALL.
* The value will be clamped to 0 .. MAX(int32_t) when value is not NUMBER_ALL.
* @pre !ScriptGame::IsMultiplayer().
*/
static void Close(WindowClass window, SQInteger number);
@@ -90,7 +90,7 @@ public:
* Check if a window is open.
* @param window The class of the window to check for.
* @param number The number of the window to check for, or NUMBER_ALL to check for any in the class.
* The value will be clamped to 0 .. MAX(int32) when value is not NUMBER_ALL.
* The value will be clamped to 0 .. MAX(int32_t) when value is not NUMBER_ALL.
* @pre !ScriptGame::IsMultiplayer().
* @return True if the window is open.
*/
@@ -100,9 +100,9 @@ public:
* Highlight a widget in a window.
* @param window The class of the window to highlight a widget in.
* @param number The number of the window to highlight a widget in.
* The value will be clamped to 0 .. MAX(int32) when value is not NUMBER_ALL.
* The value will be clamped to 0 .. MAX(int32_t) when value is not NUMBER_ALL.
* @param widget The widget in the window to highlight, or WIDGET_ALL (in combination with TC_INVALID) to disable all widget highlighting on this window.
* The value will be clamped to 0 .. MAX(uint8) when value is not WIDGET_ALL.
* The value will be clamped to 0 .. MAX(uint8_t) when value is not WIDGET_ALL.
* @param colour The colour of the highlight, or TC_INVALID for disabling.
* @pre !ScriptGame::IsMultiplayer().
* @pre number != NUMBER_ALL.