@@ -16,7 +16,7 @@
|
||||
#include "../../safeguards.h"
|
||||
|
||||
extern Town *AirportGetNearestTown(const struct AirportSpec *as, Direction rotation, TileIndex tile, TileIterator &&it, uint &mindist);
|
||||
extern uint8 GetAirportNoiseLevelForDistance(const struct AirportSpec *as, uint distance);
|
||||
extern uint8_t GetAirportNoiseLevelForDistance(const struct AirportSpec *as, uint distance);
|
||||
|
||||
/* static */ bool ScriptAirport::IsValidAirportType(AirportType type)
|
||||
{
|
||||
@@ -171,5 +171,5 @@ extern uint8 GetAirportNoiseLevelForDistance(const struct AirportSpec *as, uint
|
||||
{
|
||||
if (!IsAirportInformationAvailable(type)) return -1;
|
||||
|
||||
return (int64)GetMaintenanceCostFactor(type) * _price[PR_INFRASTRUCTURE_AIRPORT] >> 3;
|
||||
return (int64_t)GetMaintenanceCostFactor(type) * _price[PR_INFRASTRUCTURE_AIRPORT] >> 3;
|
||||
}
|
||||
|
@@ -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.
|
||||
*/
|
||||
|
@@ -87,7 +87,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.
|
||||
*/
|
||||
|
@@ -40,11 +40,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;
|
||||
}
|
||||
|
@@ -143,7 +143,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.
|
||||
@@ -162,7 +162,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.
|
||||
*/
|
||||
|
@@ -25,7 +25,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
|
||||
|
@@ -169,7 +169,7 @@
|
||||
return ::Company::Get(company)->old_economy[quarter - 1].company_value;
|
||||
}
|
||||
|
||||
/* static */ Money ScriptCompany::GetAnnualExpenseValue(CompanyID company, uint32 year_offset, ExpensesType expenses_type)
|
||||
/* static */ Money ScriptCompany::GetAnnualExpenseValue(CompanyID company, uint32_t year_offset, ExpensesType expenses_type)
|
||||
{
|
||||
EnforcePrecondition(false, expenses_type < (ExpensesType)::EXPENSES_END);
|
||||
EnforcePrecondition(false, year_offset <= 2);
|
||||
@@ -211,7 +211,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);
|
||||
|
||||
@@ -229,7 +229,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());
|
||||
@@ -249,7 +249,7 @@
|
||||
EnforcePrecondition(false, company != COMPANY_INVALID);
|
||||
|
||||
/* Network commands only allow 0 to indicate invalid tiles, not INVALID_TILE */
|
||||
return ScriptObject::DoCommandEx(tile == INVALID_TILE ? 0 : tile, company | expenses_type << 8, 0, (uint64)(delta), CMD_CHANGE_BANK_BALANCE);
|
||||
return ScriptObject::DoCommandEx(tile == INVALID_TILE ? 0 : tile, company | expenses_type << 8, 0, (uint64_t)(delta), CMD_CHANGE_BANK_BALANCE);
|
||||
}
|
||||
|
||||
/* static */ bool ScriptCompany::BuildCompanyHQ(TileIndex tile)
|
||||
@@ -303,7 +303,7 @@
|
||||
{
|
||||
EnforceCompanyModeValid(false);
|
||||
EnforcePrecondition(false, money >= 0);
|
||||
EnforcePrecondition(false, (int64)money <= UINT32_MAX);
|
||||
EnforcePrecondition(false, (int64_t)money <= UINT32_MAX);
|
||||
return ScriptObject::DoCommand(0, 0, money, CMD_CHANGE_COMPANY_SETTING, "company.engine_renew_money");
|
||||
}
|
||||
|
||||
|
@@ -321,7 +321,7 @@ public:
|
||||
* @pre year_offset <= 2.
|
||||
* @return The value of the company in the given quarter.
|
||||
*/
|
||||
static Money GetAnnualExpenseValue(CompanyID company, uint32 year_offset, ExpensesType expenses_type);
|
||||
static Money GetAnnualExpenseValue(CompanyID company, uint32_t year_offset, ExpensesType expenses_type);
|
||||
|
||||
/**
|
||||
* Build your company's HQ on the given tile.
|
||||
@@ -364,7 +364,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.
|
||||
*/
|
||||
|
@@ -275,7 +275,7 @@
|
||||
EnforcePrecondition(false, IsValidEngine(engine_id));
|
||||
EnforcePrecondition(false, company != ScriptCompany::COMPANY_INVALID);
|
||||
|
||||
return ScriptObject::DoCommand(0, engine_id, (uint32)company | (1 << 31), CMD_ENGINE_CTRL);
|
||||
return ScriptObject::DoCommand(0, engine_id, (uint32_t)company | (1 << 31), CMD_ENGINE_CTRL);
|
||||
}
|
||||
|
||||
/* static */ bool ScriptEngine::DisableForCompany(EngineID engine_id, ScriptCompany::CompanyID company)
|
||||
|
@@ -46,7 +46,7 @@ CargoID ScriptEventEnginePreview::GetCargoType()
|
||||
return CargoID(std::distance(std::cbegin(cap), it));
|
||||
}
|
||||
|
||||
int32 ScriptEventEnginePreview::GetCapacity()
|
||||
int32_t ScriptEventEnginePreview::GetCapacity()
|
||||
{
|
||||
if (!this->IsEngineValid()) return -1;
|
||||
const Engine *e = ::Engine::Get(this->engine);
|
||||
@@ -68,11 +68,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;
|
||||
}
|
||||
@@ -89,7 +89,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) {
|
||||
|
@@ -254,7 +254,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.
|
||||
@@ -263,7 +263,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.
|
||||
@@ -285,7 +285,7 @@ public:
|
||||
#ifdef DOXYGEN_API
|
||||
ScriptVehicle::VehicleType GetVehicleType();
|
||||
#else
|
||||
int32 GetVehicleType();
|
||||
int32_t GetVehicleType();
|
||||
#endif /* DOXYGEN_API */
|
||||
|
||||
/**
|
||||
@@ -950,7 +950,7 @@ 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.
|
||||
@@ -978,7 +978,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),
|
||||
@@ -997,7 +997,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.
|
||||
@@ -1012,7 +1012,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.
|
||||
};
|
||||
|
@@ -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.
|
||||
|
@@ -116,7 +116,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);
|
||||
|
||||
@@ -136,7 +136,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);
|
||||
|
@@ -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 */
|
||||
|
@@ -198,8 +198,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;
|
||||
|
@@ -270,7 +270,7 @@
|
||||
|
||||
auto company = ScriptCompany::ResolveCompanyID(company_id);
|
||||
::Owner owner = (company == ScriptCompany::COMPANY_INVALID ? ::INVALID_OWNER : (::Owner)company);
|
||||
return ScriptObject::DoCommand(0, industry_id, (1 << 8) | ((uint8)owner), CMD_INDUSTRY_SET_EXCLUSIVITY);
|
||||
return ScriptObject::DoCommand(0, industry_id, (1 << 8) | ((uint8_t)owner), CMD_INDUSTRY_SET_EXCLUSIVITY);
|
||||
}
|
||||
|
||||
/* static */ ScriptCompany::CompanyID ScriptIndustry::GetExclusiveConsumer(IndustryID industry_id)
|
||||
@@ -290,7 +290,7 @@
|
||||
|
||||
auto company = ScriptCompany::ResolveCompanyID(company_id);
|
||||
::Owner owner = (company == ScriptCompany::COMPANY_INVALID ? ::INVALID_OWNER : (::Owner)company);
|
||||
return ScriptObject::DoCommand(0, industry_id, ((uint8)owner), CMD_INDUSTRY_SET_EXCLUSIVITY);
|
||||
return ScriptObject::DoCommand(0, industry_id, ((uint8_t)owner), CMD_INDUSTRY_SET_EXCLUSIVITY);
|
||||
}
|
||||
|
||||
/* static */ SQInteger ScriptIndustry::GetProductionLevel(IndustryID industry_id)
|
||||
@@ -308,5 +308,5 @@
|
||||
EnforcePrecondition(false, IsValidIndustry(industry_id));
|
||||
EnforcePrecondition(false, prod_level >= PRODLEVEL_MINIMUM && prod_level <= PRODLEVEL_MAXIMUM);
|
||||
|
||||
return ScriptObject::DoCommand(0, industry_id, ((uint8)prod_level) | (show_news ? (1 << 8) : 0), CMD_INDUSTRY_SET_PRODUCTION, custom_news != nullptr ? custom_news->GetEncodedText() : std::string{});
|
||||
return ScriptObject::DoCommand(0, industry_id, ((uint8_t)prod_level) | (show_news ? (1 << 8) : 0), CMD_INDUSTRY_SET_PRODUCTION, custom_news != nullptr ? custom_news->GetEncodedText() : std::string{});
|
||||
}
|
||||
|
@@ -122,8 +122,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::DoCommand(tile, (1 << 16) | (layout_index << 8) | industry_type, seed, CMD_BUILD_INDUSTRY);
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@
|
||||
EnforceDeityOrCompanyModeValid(false);
|
||||
EnforcePrecondition(false, CanProspectIndustry(industry_type));
|
||||
|
||||
uint32 seed = ScriptBase::Rand();
|
||||
uint32_t seed = ScriptBase::Rand();
|
||||
return ScriptObject::DoCommand(0, industry_type, seed, CMD_BUILD_INDUSTRY);
|
||||
}
|
||||
|
||||
|
@@ -16,26 +16,26 @@
|
||||
|
||||
#include "../../safeguards.h"
|
||||
|
||||
/* static */ int64 ScriptInflation::GetPriceFactor()
|
||||
/* static */ int64_t ScriptInflation::GetPriceFactor()
|
||||
{
|
||||
return _economy.inflation_prices;
|
||||
}
|
||||
|
||||
/* static */ int64 ScriptInflation::GetPaymentFactor()
|
||||
/* static */ int64_t ScriptInflation::GetPaymentFactor()
|
||||
{
|
||||
return _economy.inflation_payment;
|
||||
}
|
||||
|
||||
/* static */ bool ScriptInflation::SetPriceFactor(int64 factor)
|
||||
/* static */ bool ScriptInflation::SetPriceFactor(int64_t factor)
|
||||
{
|
||||
EnforcePrecondition(false, factor >= 1 << 16 && factor <= (int64)MAX_INFLATION);
|
||||
if ((uint64)factor == _economy.inflation_prices) return true;
|
||||
return ScriptObject::DoCommand(0, CHT_INFLATION_COST, (uint32)factor, CMD_CHEAT_SETTING);
|
||||
EnforcePrecondition(false, factor >= 1 << 16 && factor <= (int64_t)MAX_INFLATION);
|
||||
if ((uint64_t)factor == _economy.inflation_prices) return true;
|
||||
return ScriptObject::DoCommand(0, CHT_INFLATION_COST, (uint32_t)factor, CMD_CHEAT_SETTING);
|
||||
}
|
||||
|
||||
/* static */ bool ScriptInflation::SetPaymentFactor(int64 factor)
|
||||
/* static */ bool ScriptInflation::SetPaymentFactor(int64_t factor)
|
||||
{
|
||||
EnforcePrecondition(false, factor >= 1 << 16 && factor <= (int64)MAX_INFLATION);
|
||||
if ((uint64)factor == _economy.inflation_payment) return true;
|
||||
return ScriptObject::DoCommand(0, CHT_INFLATION_INCOME, (uint32)factor, CMD_CHEAT_SETTING);
|
||||
EnforcePrecondition(false, factor >= 1 << 16 && factor <= (int64_t)MAX_INFLATION);
|
||||
if ((uint64_t)factor == _economy.inflation_payment) return true;
|
||||
return ScriptObject::DoCommand(0, CHT_INFLATION_INCOME, (uint32_t)factor, CMD_CHEAT_SETTING);
|
||||
}
|
||||
|
@@ -23,13 +23,13 @@ public:
|
||||
* Get the inflation factor for prices.
|
||||
* @return Inflation factor, 16 bit fixed point.
|
||||
*/
|
||||
static int64 GetPriceFactor();
|
||||
static int64_t GetPriceFactor();
|
||||
|
||||
/**
|
||||
* Get the inflation factor for payments.
|
||||
* @return Inflation factor, 16 bit fixed point.
|
||||
*/
|
||||
static int64 GetPaymentFactor();
|
||||
static int64_t GetPaymentFactor();
|
||||
|
||||
/**
|
||||
* Set the inflation factor for prices.
|
||||
@@ -37,7 +37,7 @@ public:
|
||||
* @return True, if the inflation factor was changed.
|
||||
* @api -ai
|
||||
*/
|
||||
static bool SetPriceFactor(int64 factor);
|
||||
static bool SetPriceFactor(int64_t factor);
|
||||
|
||||
/**
|
||||
* Set the inflation factor for payments.
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
* @return True, if the inflation factor was changed.
|
||||
* @api -ai
|
||||
*/
|
||||
static bool SetPaymentFactor(int64 factor);
|
||||
static bool SetPaymentFactor(int64_t factor);
|
||||
};
|
||||
|
||||
#endif /* SCRIPT_INFLATION_HPP */
|
||||
|
@@ -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.
|
||||
|
@@ -91,7 +91,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);
|
||||
}
|
||||
@@ -103,7 +103,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);
|
||||
}
|
||||
|
@@ -35,7 +35,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;
|
||||
|
@@ -102,7 +102,7 @@ ScriptObject::ActiveInstance::~ActiveInstance()
|
||||
return GetStorage()->async_mode_instance;
|
||||
}
|
||||
|
||||
/* static */ void ScriptObject::SetLastCommand(TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd)
|
||||
/* static */ void ScriptObject::SetLastCommand(TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd)
|
||||
{
|
||||
ScriptStorage *s = GetStorage();
|
||||
DEBUG(script, 6, "SetLastCommand company=%02d tile=%06x p1=%08x p2=%08x p3=" OTTD_PRINTFHEX64PAD " cmd=%d", s->root_company, tile, p1, p2, p3, cmd);
|
||||
@@ -113,7 +113,7 @@ ScriptObject::ActiveInstance::~ActiveInstance()
|
||||
s->last_cmd = cmd & CMD_ID_MASK;
|
||||
}
|
||||
|
||||
/* static */ bool ScriptObject::CheckLastCommand(TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd)
|
||||
/* static */ bool ScriptObject::CheckLastCommand(TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd)
|
||||
{
|
||||
ScriptStorage *s = GetStorage();
|
||||
DEBUG(script, 6, "CheckLastCommand company=%02d tile=%06x p1=%08x p2=%08x p3=" OTTD_PRINTFHEX64PAD " cmd=%d", s->root_company, tile, p1, p2, p3, cmd);
|
||||
@@ -160,12 +160,12 @@ ScriptObject::ActiveInstance::~ActiveInstance()
|
||||
return GetStorage()->last_cost;
|
||||
}
|
||||
|
||||
/* static */ void ScriptObject::SetLastCommandResultData(uint32 last_result)
|
||||
/* static */ void ScriptObject::SetLastCommandResultData(uint32_t last_result)
|
||||
{
|
||||
GetStorage()->last_result = last_result;
|
||||
}
|
||||
|
||||
/* static */ uint32 ScriptObject::GetLastCommandResultData()
|
||||
/* static */ uint32_t ScriptObject::GetLastCommandResultData()
|
||||
{
|
||||
return GetStorage()->last_result;
|
||||
}
|
||||
@@ -327,7 +327,7 @@ ScriptObject::ActiveInstance::~ActiveInstance()
|
||||
return GetStorage()->callback_value[index];
|
||||
}
|
||||
|
||||
/* static */ bool ScriptObject::DoCommandEx(TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint cmd, const char *text, const CommandAuxiliaryBase *aux_data, Script_SuspendCallbackProc *callback)
|
||||
/* static */ bool ScriptObject::DoCommandEx(TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint cmd, const char *text, const CommandAuxiliaryBase *aux_data, Script_SuspendCallbackProc *callback)
|
||||
{
|
||||
if (!ScriptObject::CanSuspend()) {
|
||||
throw Script_FatalError("You are not allowed to execute any DoCommand (even indirect) in your constructor, Save(), Load(), and any valuator.");
|
||||
|
@@ -93,19 +93,19 @@ protected:
|
||||
/**
|
||||
* Executes a raw DoCommand for the script.
|
||||
*/
|
||||
static bool DoCommandEx(TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint cmd, const char *text = nullptr, const CommandAuxiliaryBase *aux_data = nullptr, Script_SuspendCallbackProc *callback = nullptr);
|
||||
static bool DoCommandEx(TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint cmd, const char *text = nullptr, const CommandAuxiliaryBase *aux_data = nullptr, Script_SuspendCallbackProc *callback = nullptr);
|
||||
|
||||
static bool DoCommandEx(TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint cmd, const std::string &text, const CommandAuxiliaryBase *aux_data = nullptr, Script_SuspendCallbackProc *callback = nullptr)
|
||||
static bool DoCommandEx(TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint cmd, const std::string &text, const CommandAuxiliaryBase *aux_data = nullptr, Script_SuspendCallbackProc *callback = nullptr)
|
||||
{
|
||||
return ScriptObject::DoCommandEx(tile, p1, p2, p3, cmd, text.c_str(), aux_data, callback);
|
||||
}
|
||||
|
||||
static bool DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint cmd, const char *text = nullptr, Script_SuspendCallbackProc *callback = nullptr)
|
||||
static bool DoCommand(TileIndex tile, uint32_t p1, uint32_t p2, uint cmd, const char *text = nullptr, Script_SuspendCallbackProc *callback = nullptr)
|
||||
{
|
||||
return ScriptObject::DoCommandEx(tile, p1, p2, 0, cmd, text, nullptr, callback);
|
||||
}
|
||||
|
||||
static bool DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint cmd, const std::string &text, Script_SuspendCallbackProc *callback = nullptr)
|
||||
static bool DoCommand(TileIndex tile, uint32_t p1, uint32_t p2, uint cmd, const std::string &text, Script_SuspendCallbackProc *callback = nullptr)
|
||||
{
|
||||
return ScriptObject::DoCommandEx(tile, p1, p2, 0, cmd, text.c_str(), nullptr, callback);
|
||||
}
|
||||
@@ -113,12 +113,12 @@ protected:
|
||||
/**
|
||||
* Store the latest command executed by the script.
|
||||
*/
|
||||
static void SetLastCommand(TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint cmd);
|
||||
static void SetLastCommand(TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint cmd);
|
||||
|
||||
/**
|
||||
* Check if it's the latest command executed by the script.
|
||||
*/
|
||||
static bool CheckLastCommand(TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint cmd);
|
||||
static bool CheckLastCommand(TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint cmd);
|
||||
|
||||
/**
|
||||
* Sets the DoCommand costs counter to a value.
|
||||
@@ -289,12 +289,12 @@ protected:
|
||||
/**
|
||||
* Set the result data of the last command.
|
||||
*/
|
||||
static void SetLastCommandResultData(uint32 last_result);
|
||||
static void SetLastCommandResultData(uint32_t last_result);
|
||||
|
||||
/**
|
||||
* Get the result data of the last command.
|
||||
*/
|
||||
static uint32 GetLastCommandResultData();
|
||||
static uint32_t GetLastCommandResultData();
|
||||
|
||||
/**
|
||||
* Set a variable that can be used by callback functions to pass information.
|
||||
|
@@ -103,7 +103,7 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr
|
||||
return res;
|
||||
}
|
||||
|
||||
/* static */ bool ScriptOrder::ScriptOrderModifyOrder(VehicleID vehicle_id, VehicleOrderID order_position, uint32 p2, Script_SuspendCallbackProc *callback)
|
||||
/* static */ bool ScriptOrder::ScriptOrderModifyOrder(VehicleID vehicle_id, VehicleOrderID order_position, uint32_t p2, Script_SuspendCallbackProc *callback)
|
||||
{
|
||||
return ScriptObject::DoCommandEx(0, vehicle_id, p2, order_position, CMD_MODIFY_ORDER, nullptr, 0, callback);
|
||||
}
|
||||
@@ -449,8 +449,8 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr
|
||||
EnforcePrecondition(false, IsGotoStationOrder(vehicle_id, order_position) || (IsGotoDepotOrder(vehicle_id, order_position) && refit_cargo != CT_AUTO_REFIT));
|
||||
EnforcePrecondition(false, ScriptCargo::IsValidCargo(refit_cargo) || refit_cargo == CT_AUTO_REFIT || refit_cargo == CT_NO_REFIT);
|
||||
|
||||
uint32 p1 = vehicle_id;
|
||||
uint32 p2 = refit_cargo | ScriptOrderPositionToRealOrderPosition(vehicle_id, ScriptOrder::ResolveOrderPosition(vehicle_id, order_position)) << 16;
|
||||
uint32_t p1 = vehicle_id;
|
||||
uint32_t p2 = refit_cargo | ScriptOrderPositionToRealOrderPosition(vehicle_id, ScriptOrder::ResolveOrderPosition(vehicle_id, order_position)) << 16;
|
||||
return ScriptObject::DoCommand(0, p1, p2, CMD_ORDER_REFIT);
|
||||
}
|
||||
|
||||
|
@@ -604,7 +604,7 @@ public:
|
||||
static SQInteger GetOrderDistance(ScriptVehicle::VehicleType vehicle_type, TileIndex origin_tile, TileIndex dest_tile);
|
||||
|
||||
protected:
|
||||
static bool ScriptOrderModifyOrder(VehicleID vehicle_id, VehicleOrderID order_position, uint32 p2, Script_SuspendCallbackProc *callback = nullptr);
|
||||
static bool ScriptOrderModifyOrder(VehicleID vehicle_id, VehicleOrderID order_position, uint32_t p2, Script_SuspendCallbackProc *callback = nullptr);
|
||||
};
|
||||
DECLARE_ENUM_AS_BIT_SET(ScriptOrder::ScriptOrderFlags)
|
||||
|
||||
|
@@ -155,7 +155,7 @@
|
||||
EnforcePrecondition(false, IsRailTypeAvailable(GetCurrentRailType()));
|
||||
EnforcePrecondition(false, station_id == ScriptStation::STATION_NEW || station_id == ScriptStation::STATION_JOIN_ADJACENT || ScriptStation::IsValidStation(station_id));
|
||||
|
||||
uint32 p1 = GetCurrentRailType() | (platform_length << 16) | (num_platforms << 8);
|
||||
uint32_t p1 = GetCurrentRailType() | (platform_length << 16) | (num_platforms << 8);
|
||||
if (direction == RAILTRACK_NW_SE) p1 |= (1 << 6);
|
||||
if (station_id != ScriptStation::STATION_JOIN_ADJACENT) p1 |= (1 << 24);
|
||||
return ScriptObject::DoCommand(tile, p1, (ScriptStation::IsValidStation(station_id) ? station_id : INVALID_STATION) << 16, CMD_BUILD_RAIL_STATION);
|
||||
@@ -174,12 +174,12 @@
|
||||
EnforcePrecondition(false, source_industry == ScriptIndustryType::INDUSTRYTYPE_UNKNOWN || source_industry == ScriptIndustryType::INDUSTRYTYPE_TOWN || ScriptIndustryType::IsValidIndustryType(source_industry));
|
||||
EnforcePrecondition(false, goal_industry == ScriptIndustryType::INDUSTRYTYPE_UNKNOWN || goal_industry == ScriptIndustryType::INDUSTRYTYPE_TOWN || ScriptIndustryType::IsValidIndustryType(goal_industry));
|
||||
|
||||
uint32 p1 = GetCurrentRailType() | (platform_length << 16) | (num_platforms << 8);
|
||||
uint32_t p1 = GetCurrentRailType() | (platform_length << 16) | (num_platforms << 8);
|
||||
if (direction == RAILTRACK_NW_SE) p1 |= 1 << 6;
|
||||
if (station_id != ScriptStation::STATION_JOIN_ADJACENT) p1 |= (1 << 24);
|
||||
|
||||
const GRFFile *file;
|
||||
uint16 res = GetAiPurchaseCallbackResult(
|
||||
uint16_t res = GetAiPurchaseCallbackResult(
|
||||
GSF_STATIONS,
|
||||
cargo_id,
|
||||
0,
|
||||
@@ -191,7 +191,7 @@
|
||||
std::min<SQInteger>(15u, num_platforms) << 4 | std::min<SQInteger>(15u, platform_length),
|
||||
&file
|
||||
);
|
||||
uint32 p2 = (ScriptStation::IsValidStation(station_id) ? station_id : INVALID_STATION) << 16;
|
||||
uint32_t p2 = (ScriptStation::IsValidStation(station_id) ? station_id : INVALID_STATION) << 16;
|
||||
if (res != CALLBACK_FAILED) {
|
||||
int index = 0;
|
||||
const StationSpec *spec = StationClass::GetByGrf(file->grfid, res, &index);
|
||||
@@ -293,10 +293,10 @@
|
||||
* Prepare the second parameter for CmdBuildRailroadTrack and CmdRemoveRailroadTrack. The direction
|
||||
* depends on all three tiles. Sometimes the third tile needs to be adjusted.
|
||||
*/
|
||||
static uint32 SimulateDrag(TileIndex from, TileIndex tile, TileIndex *to)
|
||||
static uint32_t SimulateDrag(TileIndex from, TileIndex tile, TileIndex *to)
|
||||
{
|
||||
int diag_offset = abs(abs((int)::TileX(*to) - (int)::TileX(tile)) - abs((int)::TileY(*to) - (int)::TileY(tile)));
|
||||
uint32 p2 = 0;
|
||||
uint32_t p2 = 0;
|
||||
if (::TileY(from) == ::TileY(*to)) {
|
||||
p2 |= (TRACK_X << 6);
|
||||
*to -= Clamp((int)::TileX(*to) - (int)::TileX(tile), -1, 1);
|
||||
@@ -365,7 +365,7 @@ static uint32 SimulateDrag(TileIndex from, TileIndex tile, TileIndex *to)
|
||||
(::TileX(from) == ::TileX(tile) && ::TileX(tile) == ::TileX(to)) ||
|
||||
(::TileY(from) == ::TileY(tile) && ::TileY(tile) == ::TileY(to)));
|
||||
|
||||
uint32 p2 = SimulateDrag(from, tile, &to) | 1 << 10 | 1 << 11 | ScriptRail::GetCurrentRailType();;
|
||||
uint32_t p2 = SimulateDrag(from, tile, &to) | 1 << 10 | 1 << 11 | ScriptRail::GetCurrentRailType();;
|
||||
return ScriptObject::DoCommand(tile, to, p2, CMD_BUILD_RAILROAD_TRACK);
|
||||
}
|
||||
|
||||
@@ -382,7 +382,7 @@ static uint32 SimulateDrag(TileIndex from, TileIndex tile, TileIndex *to)
|
||||
(::TileX(from) == ::TileX(tile) && ::TileX(tile) == ::TileX(to)) ||
|
||||
(::TileY(from) == ::TileY(tile) && ::TileY(tile) == ::TileY(to)));
|
||||
|
||||
uint32 p2 = SimulateDrag(from, tile, &to);
|
||||
uint32_t p2 = SimulateDrag(from, tile, &to);
|
||||
return ScriptObject::DoCommand(tile, to, p2, CMD_REMOVE_RAILROAD_TRACK);
|
||||
}
|
||||
|
||||
|
@@ -189,7 +189,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);
|
||||
}
|
||||
@@ -204,7 +204,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. */
|
||||
@@ -231,7 +231,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;
|
||||
@@ -247,7 +247,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;
|
||||
@@ -268,7 +268,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)) {
|
||||
@@ -326,7 +326,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);
|
||||
}
|
||||
@@ -404,7 +404,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)) {
|
||||
@@ -421,8 +421,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;
|
||||
@@ -496,7 +496,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++;
|
||||
|
@@ -62,7 +62,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.
|
||||
};
|
||||
|
@@ -64,7 +64,7 @@ template<bool Tfrom, bool Tvia>
|
||||
const StationCargoList &cargo_list = ge.data->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()),
|
||||
@@ -164,7 +164,7 @@ template<bool Tfrom, bool Tvia>
|
||||
if (station_type == STATION_AIRPORT) return -1;
|
||||
if (!HasExactlyOneBit(station_type)) return -1;
|
||||
|
||||
const int32 inc = _settings_game.station.catchment_increase;
|
||||
const int32_t inc = _settings_game.station.catchment_increase;
|
||||
|
||||
if (!_settings_game.station.modified_catchment) return CA_UNMODIFIED + inc;
|
||||
|
||||
|
@@ -44,7 +44,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::DoCommand(0,
|
||||
@@ -76,7 +76,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:
|
||||
@@ -126,7 +126,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:
|
||||
|
@@ -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.
|
||||
|
@@ -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()) {
|
||||
|
@@ -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;
|
||||
@@ -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)
|
||||
@@ -304,7 +304,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)) {
|
||||
ScriptController::DecreaseOps(50000);
|
||||
ScriptObject::SetLastError(ScriptError::ERR_NAME_IS_NOT_UNIQUE);
|
||||
@@ -360,7 +360,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::DoCommand(0, town_id | (company_id << 16), new_rating, CMD_TOWN_RATING);
|
||||
|
@@ -236,7 +236,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().
|
||||
@@ -393,7 +393,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().
|
||||
|
@@ -85,24 +85,24 @@
|
||||
#include <squirrel.h>
|
||||
|
||||
/* 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.
|
||||
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 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 uint32 TileIndex; ///< The ID of a tile (just named differently).
|
||||
typedef uint16 TownID; ///< The ID of a town.
|
||||
typedef uint32 VehicleID; ///< The ID of a vehicle.
|
||||
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_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_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 uint32_t TileIndex; ///< The ID of a tile (just named differently).
|
||||
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.
|
||||
|
@@ -416,7 +416,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;
|
||||
}
|
||||
@@ -429,7 +429,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();
|
||||
}
|
||||
|
@@ -83,7 +83,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);
|
||||
@@ -92,7 +92,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.
|
||||
*/
|
||||
@@ -102,9 +102,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.
|
||||
|
Reference in New Issue
Block a user