1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-20 19:02:41 +01:00

Codechange: rename CargoID to CargoType and amend related variables/comments

This commit is contained in:
Rubidium
2025-01-22 18:08:59 +01:00
committed by rubidium42
parent d05cc2ef92
commit e894a5880c
129 changed files with 1009 additions and 1009 deletions

View File

@@ -18,7 +18,7 @@
#include "../../safeguards.h"
/* static */ bool ScriptCargo::IsValidCargo(CargoID cargo_type)
/* static */ bool ScriptCargo::IsValidCargo(CargoType cargo_type)
{
return (cargo_type < NUM_CARGO && ::CargoSpec::Get(cargo_type)->IsValid());
}
@@ -28,7 +28,7 @@
return (towneffect_type >= (TownEffect)TAE_BEGIN && towneffect_type < (TownEffect)TAE_END);
}
/* static */ std::optional<std::string> ScriptCargo::GetName(CargoID cargo_type)
/* static */ std::optional<std::string> ScriptCargo::GetName(CargoType cargo_type)
{
if (!IsValidCargo(cargo_type)) return std::nullopt;
@@ -36,7 +36,7 @@
return GetString(STR_JUST_CARGO_LIST);
}
/* static */ std::optional<std::string> ScriptCargo::GetCargoLabel(CargoID cargo_type)
/* static */ std::optional<std::string> ScriptCargo::GetCargoLabel(CargoType cargo_type)
{
if (!IsValidCargo(cargo_type)) return std::nullopt;
const CargoSpec *cargo = ::CargoSpec::Get(cargo_type);
@@ -50,27 +50,27 @@
return cargo_label;
}
/* static */ bool ScriptCargo::IsFreight(CargoID cargo_type)
/* static */ bool ScriptCargo::IsFreight(CargoType cargo_type)
{
if (!IsValidCargo(cargo_type)) return false;
const CargoSpec *cargo = ::CargoSpec::Get(cargo_type);
return cargo->is_freight;
}
/* static */ bool ScriptCargo::HasCargoClass(CargoID cargo_type, CargoClass cargo_class)
/* static */ bool ScriptCargo::HasCargoClass(CargoType cargo_type, CargoClass cargo_class)
{
if (!IsValidCargo(cargo_type)) return false;
return ::IsCargoInClass(cargo_type, (::CargoClass)cargo_class);
}
/* static */ ScriptCargo::TownEffect ScriptCargo::GetTownEffect(CargoID cargo_type)
/* static */ ScriptCargo::TownEffect ScriptCargo::GetTownEffect(CargoType cargo_type)
{
if (!IsValidCargo(cargo_type)) return TE_NONE;
return (ScriptCargo::TownEffect)::CargoSpec::Get(cargo_type)->town_acceptance_effect;
}
/* static */ Money ScriptCargo::GetCargoIncome(CargoID cargo_type, SQInteger distance, SQInteger days_in_transit)
/* static */ Money ScriptCargo::GetCargoIncome(CargoType cargo_type, SQInteger distance, SQInteger days_in_transit)
{
if (!IsValidCargo(cargo_type)) return -1;
@@ -79,13 +79,13 @@
return ::GetTransportedGoodsIncome(1, distance, Clamp(days_in_transit * 2 / 5, 0, UINT16_MAX), cargo_type);
}
/* static */ ScriptCargo::DistributionType ScriptCargo::GetDistributionType(CargoID cargo_type)
/* static */ ScriptCargo::DistributionType ScriptCargo::GetDistributionType(CargoType cargo_type)
{
if (!ScriptCargo::IsValidCargo(cargo_type)) return INVALID_DISTRIBUTION_TYPE;
return (ScriptCargo::DistributionType)_settings_game.linkgraph.GetDistributionType(cargo_type);
}
/* static */ SQInteger ScriptCargo::GetWeight(CargoID cargo_type, SQInteger amount)
/* static */ SQInteger ScriptCargo::GetWeight(CargoType cargo_type, SQInteger amount)
{
if (!IsValidCargo(cargo_type)) return -1;

View File

@@ -53,7 +53,7 @@ public:
/**
* Special cargo types.
*/
enum SpecialCargoID {
enum SpecialCargoType {
/* Note: these values represent part of the in-game CargoTypes enum */
CT_AUTO_REFIT = ::CARGO_AUTO_REFIT, ///< Automatically choose cargo type when doing auto-refitting.
CT_NO_REFIT = ::CARGO_NO_REFIT, ///< Do not refit cargo of a vehicle.
@@ -75,7 +75,7 @@ public:
* @param cargo_type The cargo to check.
* @return True if and only if the cargo type is valid.
*/
static bool IsValidCargo(CargoID cargo_type);
static bool IsValidCargo(CargoType cargo_type);
/**
* Checks whether the given town effect type is valid.
@@ -90,7 +90,7 @@ public:
* @pre IsValidCargo(cargo_type).
* @return The name of the cargo type.
*/
static std::optional<std::string> GetName(CargoID cargo_type);
static std::optional<std::string> GetName(CargoType cargo_type);
/**
* Gets the string representation of the cargo label.
@@ -107,7 +107,7 @@ public:
* - In other words: Only use the cargo label, if you know more about the behaviour
* of a specific cargo from a specific industry set, than the API methods can tell you.
*/
static std::optional<std::string> GetCargoLabel(CargoID cargo_type);
static std::optional<std::string> GetCargoLabel(CargoType cargo_type);
/**
* Checks whether the give cargo is a freight or not.
@@ -117,7 +117,7 @@ public:
* @pre ScriptCargo::IsValidCargo(cargo_type).
* @return True if and only if the cargo is freight.
*/
static bool IsFreight(CargoID cargo_type);
static bool IsFreight(CargoType cargo_type);
/**
* Check if this cargo is in the requested cargo class.
@@ -126,7 +126,7 @@ public:
* @param cargo_class The class to check for.
* @return True if and only if the cargo is in the cargo class.
*/
static bool HasCargoClass(CargoID cargo_type, CargoClass cargo_class);
static bool HasCargoClass(CargoType cargo_type, CargoClass cargo_class);
/**
* Get the effect this cargo has on a town.
@@ -134,7 +134,7 @@ public:
* @pre ScriptCargo::IsValidCargo(cargo_type).
* @return The effect this cargo has on a town, or TE_NONE if it has no effect.
*/
static TownEffect GetTownEffect(CargoID cargo_type);
static TownEffect GetTownEffect(CargoType cargo_type);
/**
* Get the income for transporting a piece of cargo over the
@@ -147,14 +147,14 @@ public:
* 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.
*/
static Money GetCargoIncome(CargoID cargo_type, SQInteger distance, SQInteger days_in_transit);
static Money GetCargoIncome(CargoType cargo_type, SQInteger distance, SQInteger days_in_transit);
/**
* Get the cargo distribution type for a cargo.
* @param cargo_type The cargo to check on.
* @return The cargo distribution type for the given cargo.
*/
static DistributionType GetDistributionType(CargoID cargo_type);
static DistributionType GetDistributionType(CargoType cargo_type);
/**
* Get the weight in tonnes for the given amount of
@@ -165,7 +165,7 @@ public:
* @pre ScriptCargo::IsValidCargo(cargo_type).
* @return The weight in tonnes for that quantity of cargo.
*/
static SQInteger GetWeight(CargoID cargo_type, SQInteger amount);
static SQInteger GetWeight(CargoType cargo_type, SQInteger amount);
};
#endif /* SCRIPT_CARGO_HPP */

View File

@@ -30,7 +30,7 @@ ScriptCargoList_IndustryAccepting::ScriptCargoList_IndustryAccepting(IndustryID
const Industry *ind = ::Industry::Get(industry_id);
for (const auto &a : ind->accepted) {
if (::IsValidCargoID(a.cargo)) {
if (::IsValidCargoType(a.cargo)) {
this->AddItem(a.cargo);
}
}
@@ -42,7 +42,7 @@ ScriptCargoList_IndustryProducing::ScriptCargoList_IndustryProducing(IndustryID
const Industry *ind = ::Industry::Get(industry_id);
for (const auto &p : ind->produced) {
if (::IsValidCargoID(p.cargo)) {
if (::IsValidCargoType(p.cargo)) {
this->AddItem(p.cargo);
}
}
@@ -53,7 +53,7 @@ ScriptCargoList_StationAccepting::ScriptCargoList_StationAccepting(StationID sta
if (!ScriptStation::IsValidStation(station_id)) return;
const Station *st = ::Station::Get(station_id);
for (CargoID i = 0; i < NUM_CARGO; i++) {
for (CargoType i = 0; i < NUM_CARGO; i++) {
if (HasBit(st->goods[i].status, GoodsEntry::GES_ACCEPTANCE)) this->AddItem(i);
}
}

View File

@@ -15,7 +15,7 @@
#include "../../safeguards.h"
/* static */ SQInteger ScriptCargoMonitor::GetTownDeliveryAmount(ScriptCompany::CompanyID company, CargoID cargo, TownID town_id, bool keep_monitoring)
/* static */ SQInteger ScriptCargoMonitor::GetTownDeliveryAmount(ScriptCompany::CompanyID company, CargoType cargo, TownID town_id, bool keep_monitoring)
{
CompanyID cid = static_cast<CompanyID>(company);
if (cid >= MAX_COMPANIES) return -1;
@@ -26,7 +26,7 @@
return GetDeliveryAmount(monitor, keep_monitoring);
}
/* static */ SQInteger ScriptCargoMonitor::GetIndustryDeliveryAmount(ScriptCompany::CompanyID company, CargoID cargo, IndustryID industry_id, bool keep_monitoring)
/* static */ SQInteger ScriptCargoMonitor::GetIndustryDeliveryAmount(ScriptCompany::CompanyID company, CargoType cargo, IndustryID industry_id, bool keep_monitoring)
{
CompanyID cid = static_cast<CompanyID>(company);
if (cid >= MAX_COMPANIES) return -1;
@@ -37,7 +37,7 @@
return GetDeliveryAmount(monitor, keep_monitoring);
}
/* static */ SQInteger ScriptCargoMonitor::GetTownPickupAmount(ScriptCompany::CompanyID company, CargoID cargo, TownID town_id, bool keep_monitoring)
/* static */ SQInteger ScriptCargoMonitor::GetTownPickupAmount(ScriptCompany::CompanyID company, CargoType cargo, TownID town_id, bool keep_monitoring)
{
CompanyID cid = static_cast<CompanyID>(company);
if (cid >= MAX_COMPANIES) return -1;
@@ -48,7 +48,7 @@
return GetPickupAmount(monitor, keep_monitoring);
}
/* static */ SQInteger ScriptCargoMonitor::GetIndustryPickupAmount(ScriptCompany::CompanyID company, CargoID cargo, IndustryID industry_id, bool keep_monitoring)
/* static */ SQInteger ScriptCargoMonitor::GetIndustryPickupAmount(ScriptCompany::CompanyID company, CargoType cargo, IndustryID industry_id, bool keep_monitoring)
{
CompanyID cid = static_cast<CompanyID>(company);
if (cid >= MAX_COMPANIES) return -1;

View File

@@ -51,7 +51,7 @@ public:
* @return Amount of delivered cargo of the given cargo type to the given town by the given company since the last call, or
* \c -1 if a parameter is out-of-bound.
*/
static SQInteger GetTownDeliveryAmount(ScriptCompany::CompanyID company, CargoID cargo, TownID town_id, bool keep_monitoring);
static SQInteger GetTownDeliveryAmount(ScriptCompany::CompanyID company, CargoType cargo, TownID town_id, bool keep_monitoring);
/**
* Get the amount of cargo delivered to an industry by a company since the last query, and update the monitoring state.
@@ -62,7 +62,7 @@ public:
* @return Amount of delivered cargo of the given cargo type to the given industry by the given company since the last call, or
* \c -1 if a parameter is out-of-bound.
*/
static SQInteger GetIndustryDeliveryAmount(ScriptCompany::CompanyID company, CargoID cargo, IndustryID industry_id, bool keep_monitoring);
static SQInteger GetIndustryDeliveryAmount(ScriptCompany::CompanyID company, CargoType cargo, IndustryID industry_id, bool keep_monitoring);
/**
* Get the amount of cargo picked up (and delivered) from a town by a company since the last query, and update the monitoring state.
@@ -74,7 +74,7 @@ public:
* \c -1 if a parameter is out-of-bound.
* @note Amounts of picked-up cargo are added during final delivery of it, to prevent users from getting credit for picking up without delivering it.
*/
static SQInteger GetTownPickupAmount(ScriptCompany::CompanyID company, CargoID cargo, TownID town_id, bool keep_monitoring);
static SQInteger GetTownPickupAmount(ScriptCompany::CompanyID company, CargoType cargo, TownID town_id, bool keep_monitoring);
/**
* Get the amount of cargo picked up (and delivered) from an industry by a company since the last query, and update the monitoring state.
@@ -86,7 +86,7 @@ public:
* \c -1 if a parameter is out-of-bound.
* @note Amounts of picked-up cargo are added during final delivery of it, to prevent users from getting credit for picking up without delivering it.
*/
static SQInteger GetIndustryPickupAmount(ScriptCompany::CompanyID company, CargoID cargo, IndustryID industry_id, bool keep_monitoring);
static SQInteger GetIndustryPickupAmount(ScriptCompany::CompanyID company, CargoType cargo, IndustryID industry_id, bool keep_monitoring);
/** Stop monitoring everything. */
static void StopAllMonitoring();

View File

@@ -50,7 +50,7 @@
return GetString(STR_ENGINE_NAME);
}
/* static */ CargoID ScriptEngine::GetCargoType(EngineID engine_id)
/* static */ CargoType ScriptEngine::GetCargoType(EngineID engine_id)
{
if (!IsValidEngine(engine_id)) return INVALID_CARGO;
@@ -59,24 +59,24 @@
auto it = std::max_element(std::cbegin(cap), std::cend(cap));
if (*it == 0) return INVALID_CARGO;
return CargoID(std::distance(std::cbegin(cap), it));
return CargoType(std::distance(std::cbegin(cap), it));
}
/* static */ bool ScriptEngine::CanRefitCargo(EngineID engine_id, CargoID cargo_id)
/* static */ bool ScriptEngine::CanRefitCargo(EngineID engine_id, CargoType cargo_type)
{
if (!IsValidEngine(engine_id)) return false;
if (!ScriptCargo::IsValidCargo(cargo_id)) return false;
if (!ScriptCargo::IsValidCargo(cargo_type)) return false;
return HasBit(::GetUnionOfArticulatedRefitMasks(engine_id, true), cargo_id);
return HasBit(::GetUnionOfArticulatedRefitMasks(engine_id, true), cargo_type);
}
/* static */ bool ScriptEngine::CanPullCargo(EngineID engine_id, CargoID cargo_id)
/* static */ bool ScriptEngine::CanPullCargo(EngineID engine_id, CargoType cargo_type)
{
if (!IsValidEngine(engine_id)) return false;
if (GetVehicleType(engine_id) != ScriptVehicle::VT_RAIL) return false;
if (!ScriptCargo::IsValidCargo(cargo_id)) return false;
if (!ScriptCargo::IsValidCargo(cargo_type)) return false;
return (::RailVehInfo(engine_id)->ai_passenger_only != 1) || ScriptCargo::HasCargoClass(cargo_id, ScriptCargo::CC_PASSENGERS);
return (::RailVehInfo(engine_id)->ai_passenger_only != 1) || ScriptCargo::HasCargoClass(cargo_type, ScriptCargo::CC_PASSENGERS);
}

View File

@@ -53,7 +53,7 @@ public:
* @pre IsValidEngine(engine_id).
* @return The cargo-type of the engine.
*/
static CargoID GetCargoType(EngineID engine_id);
static CargoType GetCargoType(EngineID engine_id);
/**
* Check if the cargo of an engine can be refitted to your requested. If
@@ -61,26 +61,26 @@ public:
* In case of articulated vehicles the function decides whether at least one
* part can carry the cargo.
* @param engine_id The engine to check for refitting.
* @param cargo_id The cargo to check for refitting.
* @param cargo_type The cargo to check for refitting.
* @pre IsValidEngine(engine_id).
* @pre ScriptCargo::IsValidCargo(cargo_id).
* @pre ScriptCargo::IsValidCargo(cargo_type).
* @return True if the engine can carry this cargo, either via refit, or
* by default.
*/
static bool CanRefitCargo(EngineID engine_id, CargoID cargo_id);
static bool CanRefitCargo(EngineID engine_id, CargoType cargo_type);
/**
* Check if the engine can pull a wagon with the given cargo.
* @param engine_id The engine to check.
* @param cargo_id The cargo to check.
* @param cargo_type The cargo to check.
* @pre IsValidEngine(engine_id).
* @pre GetVehicleType(engine_id) == ScriptVehicle::VT_RAIL.
* @pre ScriptCargo::IsValidCargo(cargo_id).
* @pre ScriptCargo::IsValidCargo(cargo_type).
* @return True if the engine can pull wagons carrying this cargo.
* @note This function is not exhaustive; a true here does not mean
* that the vehicle can pull the wagons, a false does mean it can't.
*/
static bool CanPullCargo(EngineID engine_id, CargoID cargo_id);
static bool CanPullCargo(EngineID engine_id, CargoType cargo_type);
/**
* Get the capacity of an engine. In case it can transport multiple cargoes, it

View File

@@ -37,7 +37,7 @@ std::optional<std::string> ScriptEventEnginePreview::GetName()
return GetString(STR_ENGINE_NAME);
}
CargoID ScriptEventEnginePreview::GetCargoType()
CargoType ScriptEventEnginePreview::GetCargoType()
{
if (!this->IsEngineValid()) return INVALID_CARGO;
CargoArray cap = ::GetCapacityOfArticulatedParts(this->engine);
@@ -45,7 +45,7 @@ CargoID ScriptEventEnginePreview::GetCargoType()
auto it = std::max_element(std::cbegin(cap), std::cend(cap));
if (*it == 0) return INVALID_CARGO;
return CargoID(std::distance(std::cbegin(cap), it));
return CargoType(std::distance(std::cbegin(cap), it));
}
int32_t ScriptEventEnginePreview::GetCapacity()

View File

@@ -255,7 +255,7 @@ public:
* returns the first/main.
* @return The cargo-type of the engine.
*/
CargoID GetCargoType();
CargoType GetCargoType();
/**
* Get the capacity of the offered engine. In case it can transport multiple cargoes, it

View File

@@ -66,67 +66,67 @@
return ScriptObject::Command<CMD_INDUSTRY_SET_TEXT>::Do(industry_id, text != nullptr ? text->GetEncodedText() : std::string{});
}
/* static */ ScriptIndustry::CargoAcceptState ScriptIndustry::IsCargoAccepted(IndustryID industry_id, CargoID cargo_id)
/* static */ ScriptIndustry::CargoAcceptState ScriptIndustry::IsCargoAccepted(IndustryID industry_id, CargoType cargo_type)
{
if (!IsValidIndustry(industry_id)) return CAS_NOT_ACCEPTED;
if (!ScriptCargo::IsValidCargo(cargo_id)) return CAS_NOT_ACCEPTED;
if (!ScriptCargo::IsValidCargo(cargo_type)) return CAS_NOT_ACCEPTED;
/* Not const because IndustryTemporarilyRefusesCargo tests a callback which needs a non-const object. */
Industry *i = ::Industry::Get(industry_id);
if (!i->IsCargoAccepted(cargo_id)) return CAS_NOT_ACCEPTED;
if (IndustryTemporarilyRefusesCargo(i, cargo_id)) return CAS_TEMP_REFUSED;
if (!i->IsCargoAccepted(cargo_type)) return CAS_NOT_ACCEPTED;
if (IndustryTemporarilyRefusesCargo(i, cargo_type)) return CAS_TEMP_REFUSED;
return CAS_ACCEPTED;
}
/* static */ SQInteger ScriptIndustry::GetStockpiledCargo(IndustryID industry_id, CargoID cargo_id)
/* static */ SQInteger ScriptIndustry::GetStockpiledCargo(IndustryID industry_id, CargoType cargo_type)
{
if (!IsValidIndustry(industry_id)) return -1;
if (!ScriptCargo::IsValidCargo(cargo_id)) return -1;
if (!ScriptCargo::IsValidCargo(cargo_type)) return -1;
const Industry *i = ::Industry::Get(industry_id);
auto it = i->GetCargoAccepted(cargo_id);
auto it = i->GetCargoAccepted(cargo_type);
if (it == std::end(i->accepted)) return -1;
return it->waiting;
}
/* static */ SQInteger ScriptIndustry::GetLastMonthProduction(IndustryID industry_id, CargoID cargo_id)
/* static */ SQInteger ScriptIndustry::GetLastMonthProduction(IndustryID industry_id, CargoType cargo_type)
{
if (!IsValidIndustry(industry_id)) return -1;
if (!ScriptCargo::IsValidCargo(cargo_id)) return -1;
if (!ScriptCargo::IsValidCargo(cargo_type)) return -1;
const Industry *i = ::Industry::Get(industry_id);
auto it = i->GetCargoProduced(cargo_id);
auto it = i->GetCargoProduced(cargo_type);
if (it == std::end(i->produced)) return -1;
return it->history[LAST_MONTH].production;
}
/* static */ SQInteger ScriptIndustry::GetLastMonthTransported(IndustryID industry_id, CargoID cargo_id)
/* static */ SQInteger ScriptIndustry::GetLastMonthTransported(IndustryID industry_id, CargoType cargo_type)
{
if (!IsValidIndustry(industry_id)) return -1;
if (!ScriptCargo::IsValidCargo(cargo_id)) return -1;
if (!ScriptCargo::IsValidCargo(cargo_type)) return -1;
const Industry *i = ::Industry::Get(industry_id);
auto it = i->GetCargoProduced(cargo_id);
auto it = i->GetCargoProduced(cargo_type);
if (it == std::end(i->produced)) return -1;
return it->history[LAST_MONTH].transported;
}
/* static */ SQInteger ScriptIndustry::GetLastMonthTransportedPercentage(IndustryID industry_id, CargoID cargo_id)
/* static */ SQInteger ScriptIndustry::GetLastMonthTransportedPercentage(IndustryID industry_id, CargoType cargo_type)
{
if (!IsValidIndustry(industry_id)) return -1;
if (!ScriptCargo::IsValidCargo(cargo_id)) return -1;
if (!ScriptCargo::IsValidCargo(cargo_type)) return -1;
const Industry *i = ::Industry::Get(industry_id);
auto it = i->GetCargoProduced(cargo_id);
auto it = i->GetCargoProduced(cargo_type);
if (it == std::end(i->produced)) return -1;
return ::ToPercent8(it->history[LAST_MONTH].PctTransported());
@@ -226,12 +226,12 @@
return i->last_prod_year.base();
}
/* static */ ScriptDate::Date ScriptIndustry::GetCargoLastAcceptedDate(IndustryID industry_id, CargoID cargo_type)
/* static */ ScriptDate::Date ScriptIndustry::GetCargoLastAcceptedDate(IndustryID industry_id, CargoType cargo_type)
{
const Industry *i = Industry::GetIfValid(industry_id);
if (i == nullptr) return ScriptDate::DATE_INVALID;
if (!::IsValidCargoID(cargo_type)) {
if (!::IsValidCargoType(cargo_type)) {
auto it = std::max_element(std::begin(i->accepted), std::end(i->accepted), [](const auto &a, const auto &b) { return a.last_accepted < b.last_accepted; });
return (ScriptDate::Date)it->last_accepted.base();
} else {

View File

@@ -23,9 +23,9 @@ class ScriptIndustry : public ScriptObject {
public:
/** Ways for an industry to accept a cargo. */
enum CargoAcceptState {
CAS_NOT_ACCEPTED, ///< The CargoID is not accepted by this industry.
CAS_ACCEPTED, ///< The industry currently accepts this CargoID.
CAS_TEMP_REFUSED, ///< The industry temporarily refuses to accept this CargoID but may do so again in the future.
CAS_NOT_ACCEPTED, ///< The CargoType is not accepted by this industry.
CAS_ACCEPTED, ///< The industry currently accepts this CargoType.
CAS_TEMP_REFUSED, ///< The industry temporarily refuses to accept this CargoType but may do so again in the future.
};
/**
@@ -109,55 +109,55 @@ public:
/**
* See whether an industry currently accepts a certain cargo.
* @param industry_id The index of the industry.
* @param cargo_id The index of the cargo.
* @param cargo_type The index of the cargo.
* @pre IsValidIndustry(industry_id).
* @pre ScriptCargo::IsValidCargo(cargo_id).
* @pre ScriptCargo::IsValidCargo(cargo_type).
* @return Whether the industry accepts, temporarily refuses or never accepts this cargo.
*/
static CargoAcceptState IsCargoAccepted(IndustryID industry_id, CargoID cargo_id);
static CargoAcceptState IsCargoAccepted(IndustryID industry_id, CargoType cargo_type);
/**
* Get the amount of cargo stockpiled for processing.
* @param industry_id The index of the industry.
* @param cargo_id The index of the cargo.
* @param cargo_type The index of the cargo.
* @pre IsValidIndustry(industry_id).
* @pre ScriptCargo::IsValidCargo(cargo_id).
* @pre ScriptCargo::IsValidCargo(cargo_type).
* @return The amount of cargo that is waiting for processing.
*/
static SQInteger GetStockpiledCargo(IndustryID industry_id, CargoID cargo_id);
static SQInteger GetStockpiledCargo(IndustryID industry_id, CargoType cargo_type);
/**
* Get the total last economy-month's production of the given cargo at an industry.
* @param industry_id The index of the industry.
* @param cargo_id The index of the cargo.
* @param cargo_type The index of the cargo.
* @pre IsValidIndustry(industry_id).
* @pre ScriptCargo::IsValidCargo(cargo_id).
* @pre ScriptCargo::IsValidCargo(cargo_type).
* @return The last economy-month's production of the given cargo for this industry.
* @see \ref ScriptEconomyTime
*/
static SQInteger GetLastMonthProduction(IndustryID industry_id, CargoID cargo_id);
static SQInteger GetLastMonthProduction(IndustryID industry_id, CargoType cargo_type);
/**
* Get the total amount of cargo transported from an industry last economy-month.
* @param industry_id The index of the industry.
* @param cargo_id The index of the cargo.
* @param cargo_type The index of the cargo.
* @pre IsValidIndustry(industry_id).
* @pre ScriptCargo::IsValidCargo(cargo_id).
* @pre ScriptCargo::IsValidCargo(cargo_type).
* @return The amount of given cargo transported from this industry last economy-month.
* @see \ref ScriptEconomyTime
*/
static SQInteger GetLastMonthTransported(IndustryID industry_id, CargoID cargo_id);
static SQInteger GetLastMonthTransported(IndustryID industry_id, CargoType cargo_type);
/**
* Get the percentage of cargo transported from an industry last economy-month.
* @param industry_id The index of the industry.
* @param cargo_id The index of the cargo.
* @param cargo_type The index of the cargo.
* @pre IsValidIndustry(industry_id).
* @pre ScriptCargo::IsValidCargo(cargo_id).
* @pre ScriptCargo::IsValidCargo(cargo_type).
* @return The percentage of given cargo transported from this industry last economy-month.
* @see \ref ScriptEconomyTime
*/
static SQInteger GetLastMonthTransportedPercentage(IndustryID industry_id, CargoID cargo_id);
static SQInteger GetLastMonthTransportedPercentage(IndustryID industry_id, CargoType cargo_type);
/**
* Gets the location of the industry.
@@ -269,7 +269,7 @@ public:
* @see \ref ScriptEconomyTime
* @api -ai
*/
static ScriptDate::Date GetCargoLastAcceptedDate(IndustryID industry_id, CargoID cargo_type);
static ScriptDate::Date GetCargoLastAcceptedDate(IndustryID industry_id, CargoType cargo_type);
/**
* Get the current control flags for an industry.

View File

@@ -18,16 +18,16 @@ ScriptIndustryList::ScriptIndustryList(HSQUIRRELVM vm)
ScriptList::FillList<Industry>(vm, this);
}
ScriptIndustryList_CargoAccepting::ScriptIndustryList_CargoAccepting(CargoID cargo_id)
ScriptIndustryList_CargoAccepting::ScriptIndustryList_CargoAccepting(CargoType cargo_type)
{
ScriptList::FillList<Industry>(this,
[cargo_id](const Industry *i) { return i->IsCargoAccepted(cargo_id); }
[cargo_type](const Industry *i) { return i->IsCargoAccepted(cargo_type); }
);
}
ScriptIndustryList_CargoProducing::ScriptIndustryList_CargoProducing(CargoID cargo_id)
ScriptIndustryList_CargoProducing::ScriptIndustryList_CargoProducing(CargoType cargo_type)
{
ScriptList::FillList<Industry>(this,
[cargo_id](const Industry *i) { return i->IsCargoProduced(cargo_id); }
[cargo_type](const Industry *i) { return i->IsCargoProduced(cargo_type); }
);
}

View File

@@ -58,9 +58,9 @@ public:
class ScriptIndustryList_CargoAccepting : public ScriptList {
public:
/**
* @param cargo_id The cargo this industry should accept.
* @param cargo_type The cargo this industry should accept.
*/
ScriptIndustryList_CargoAccepting(CargoID cargo_id);
ScriptIndustryList_CargoAccepting(CargoType cargo_type);
};
/**
@@ -72,9 +72,9 @@ public:
class ScriptIndustryList_CargoProducing : public ScriptList {
public:
/**
* @param cargo_id The cargo this industry should produce.
* @param cargo_type The cargo this industry should produce.
*/
ScriptIndustryList_CargoProducing(CargoID cargo_id);
ScriptIndustryList_CargoProducing(CargoType cargo_type);
};
#endif /* SCRIPT_INDUSTRYLIST_HPP */

View File

@@ -71,8 +71,8 @@
const IndustrySpec *ins = ::GetIndustrySpec(industry_type);
ScriptList *list = new ScriptList();
for (const CargoID &c : ins->produced_cargo) {
if (::IsValidCargoID(c)) list->AddItem(c);
for (const CargoType &c : ins->produced_cargo) {
if (::IsValidCargoType(c)) list->AddItem(c);
}
return list;
@@ -85,8 +85,8 @@
const IndustrySpec *ins = ::GetIndustrySpec(industry_type);
ScriptList *list = new ScriptList();
for (const CargoID &c : ins->accepts_cargo) {
if (::IsValidCargoID(c)) list->AddItem(c);
for (const CargoType &c : ins->accepts_cargo) {
if (::IsValidCargoType(c)) list->AddItem(c);
}
return list;

View File

@@ -42,22 +42,22 @@ public:
static std::optional<std::string> GetName(IndustryType industry_type);
/**
* Get a list of CargoID possible produced by this industry-type.
* Get a list of CargoType possible produced by this industry-type.
* @warning This function only returns the default cargoes of the industry type.
* Industries can specify new cargotypes on construction.
* @param industry_type The type to get the CargoIDs for.
* @param industry_type The type to get the CargoTypes for.
* @pre IsValidIndustryType(industry_type).
* @return The CargoIDs of all cargotypes this industry could produce.
* @return The CargoTypes of all cargotypes this industry could produce.
*/
static ScriptList *GetProducedCargo(IndustryType industry_type);
/**
* Get a list of CargoID accepted by this industry-type.
* Get a list of CargoType accepted by this industry-type.
* @warning This function only returns the default cargoes of the industry type.
* Industries can specify new cargotypes on construction.
* @param industry_type The type to get the CargoIDs for.
* @param industry_type The type to get the CargoTypes for.
* @pre IsValidIndustryType(industry_type).
* @return The CargoIDs of all cargotypes this industry accepts.
* @return The CargoTypes of all cargotypes this industry accepts.
*/
static ScriptList *GetAcceptedCargo(IndustryType industry_type);

View File

@@ -370,7 +370,7 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr
return (ScriptOrder::StopLocation)order->GetStopLocation();
}
/* static */ CargoID ScriptOrder::GetOrderRefit(VehicleID vehicle_id, OrderPosition order_position)
/* static */ CargoType ScriptOrder::GetOrderRefit(VehicleID vehicle_id, OrderPosition order_position)
{
if (!IsValidVehicleOrder(vehicle_id, order_position)) return CARGO_NO_REFIT;
if (order_position != ORDER_CURRENT && !IsGotoStationOrder(vehicle_id, order_position) && !IsGotoDepotOrder(vehicle_id, order_position)) return CARGO_NO_REFIT;
@@ -437,7 +437,7 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr
return ScriptObject::Command<CMD_MODIFY_ORDER>::Do(0, vehicle_id, order_pos, MOF_STOP_LOCATION, stop_location);
}
/* static */ bool ScriptOrder::SetOrderRefit(VehicleID vehicle_id, OrderPosition order_position, CargoID refit_cargo)
/* static */ bool ScriptOrder::SetOrderRefit(VehicleID vehicle_id, OrderPosition order_position, CargoType refit_cargo)
{
EnforceCompanyModeValid(false);
EnforcePrecondition(false, IsValidVehicleOrder(vehicle_id, order_position));

View File

@@ -348,7 +348,7 @@ public:
* in the orderlist, but they can be the current order of a vehicle.
* @return The refit cargo of the order or CT_NO_REFIT if no refit is set.
*/
static CargoID GetOrderRefit(VehicleID vehicle_id, OrderPosition order_position);
static CargoType GetOrderRefit(VehicleID vehicle_id, OrderPosition order_position);
/**
* Sets the OrderPosition to jump to if the check succeeds of the given order for the given vehicle.
@@ -427,7 +427,7 @@ public:
* @game @pre ScriptCompanyMode::IsValid().
* @return Whether the order has been/can be changed.
*/
static bool SetOrderRefit(VehicleID vehicle_id, OrderPosition order_position, CargoID refit_cargo);
static bool SetOrderRefit(VehicleID vehicle_id, OrderPosition order_position, CargoType refit_cargo);
/**
* Appends an order to the end of the vehicle's order list.

View File

@@ -162,7 +162,7 @@
return ScriptObject::Command<CMD_BUILD_RAIL_STATION>::Do(tile, (::RailType)GetCurrentRailType(), direction == RAILTRACK_NW_SE ? AXIS_Y : AXIS_X, num_platforms, platform_length, STAT_CLASS_DFLT, 0, ScriptStation::IsValidStation(station_id) ? station_id : INVALID_STATION, adjacent);
}
/* static */ bool ScriptRail::BuildNewGRFRailStation(TileIndex tile, RailTrack direction, SQInteger num_platforms, SQInteger platform_length, StationID station_id, CargoID cargo_id, IndustryType source_industry, IndustryType goal_industry, SQInteger distance, bool source_station)
/* static */ bool ScriptRail::BuildNewGRFRailStation(TileIndex tile, RailTrack direction, SQInteger num_platforms, SQInteger platform_length, StationID station_id, CargoType cargo_type, IndustryType source_industry, IndustryType goal_industry, SQInteger distance, bool source_station)
{
EnforceCompanyModeValid(false);
EnforcePrecondition(false, ::IsValidTile(tile));
@@ -171,14 +171,14 @@
EnforcePrecondition(false, platform_length > 0 && platform_length <= 0xFF);
EnforcePrecondition(false, IsRailTypeAvailable(GetCurrentRailType()));
EnforcePrecondition(false, station_id == ScriptStation::STATION_NEW || station_id == ScriptStation::STATION_JOIN_ADJACENT || ScriptStation::IsValidStation(station_id));
EnforcePrecondition(false, ScriptCargo::IsValidCargo(cargo_id));
EnforcePrecondition(false, ScriptCargo::IsValidCargo(cargo_type));
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));
const GRFFile *file;
uint16_t res = GetAiPurchaseCallbackResult(
GSF_STATIONS,
cargo_id,
cargo_type,
0,
source_industry,
goal_industry,

View File

@@ -276,7 +276,7 @@ public:
* @param num_platforms The number of platforms to build.
* @param platform_length The length of each platform.
* @param station_id The station to join, ScriptStation::STATION_NEW or ScriptStation::STATION_JOIN_ADJACENT.
* @param cargo_id The CargoID of the cargo that will be transported from / to this station.
* @param cargo_type The CargoType of the cargo that will be transported from / to this station.
* @param source_industry The IndustryType of the industry you'll transport goods from, ScriptIndustryType::INDUSTRYTYPE_UNKNOWN or ScriptIndustryType::INDUSTRYTYPE_TOWN.
* @param goal_industry The IndustryType of the industry you'll transport goods to, ScriptIndustryType::INDUSTRYTYPE_UNKNOWN or ScriptIndustryType::INDUSTRYTYPE_TOWN.
* @param distance The manhattan distance you'll transport the cargo over.
@@ -299,7 +299,7 @@ public:
* @exception ScriptStation::ERR_STATION_TOO_MANY_STATIONS_IN_TOWN
* @return Whether the station has been/can be build or not.
*/
static bool BuildNewGRFRailStation(TileIndex tile, RailTrack direction, SQInteger num_platforms, SQInteger platform_length, StationID station_id, CargoID cargo_id, IndustryType source_industry, IndustryType goal_industry, SQInteger distance, bool source_station);
static bool BuildNewGRFRailStation(TileIndex tile, RailTrack direction, SQInteger num_platforms, SQInteger platform_length, StationID station_id, CargoType cargo_type, IndustryType source_industry, IndustryType goal_industry, SQInteger distance, bool source_station);
/**
* Build a rail waypoint.

View File

@@ -20,7 +20,7 @@
#include "../../safeguards.h"
/* static */ ScriptRoad::RoadVehicleType ScriptRoad::GetRoadVehicleTypeForCargo(CargoID cargo_type)
/* static */ ScriptRoad::RoadVehicleType ScriptRoad::GetRoadVehicleTypeForCargo(CargoType cargo_type)
{
return ScriptCargo::HasCargoClass(cargo_type, ScriptCargo::CC_PASSENGERS) ? ROADVEHTYPE_BUS : ROADVEHTYPE_TRUCK;
}

View File

@@ -100,7 +100,7 @@ public:
* @pre ScriptCargo::IsValidCargo(cargo_type).
* @return The road vehicle type needed to transport the cargo.
*/
static RoadVehicleType GetRoadVehicleTypeForCargo(CargoID cargo_type);
static RoadVehicleType GetRoadVehicleTypeForCargo(CargoType cargo_type);
/**
* Checks whether the given tile is actually a tile with road that can be

View File

@@ -41,25 +41,25 @@
template <bool Tfrom, bool Tvia>
/* static */ bool ScriptStation::IsCargoRequestValid(StationID station_id,
StationID from_station_id, StationID via_station_id, CargoID cargo_id)
StationID from_station_id, StationID via_station_id, CargoType cargo_type)
{
if (!IsValidStation(station_id)) return false;
if (Tfrom && !IsValidStation(from_station_id) && from_station_id != STATION_INVALID) return false;
if (Tvia && !IsValidStation(via_station_id) && via_station_id != STATION_INVALID) return false;
if (!ScriptCargo::IsValidCargo(cargo_id)) return false;
if (!ScriptCargo::IsValidCargo(cargo_type)) return false;
return true;
}
template <bool Tfrom, bool Tvia>
/* static */ SQInteger ScriptStation::CountCargoWaiting(StationID station_id,
StationID from_station_id, StationID via_station_id, CargoID cargo_id)
StationID from_station_id, StationID via_station_id, CargoType cargo_type)
{
if (!ScriptStation::IsCargoRequestValid<Tfrom, Tvia>(station_id, from_station_id,
via_station_id, cargo_id)) {
via_station_id, cargo_type)) {
return -1;
}
const ::GoodsEntry &goods = ::Station::Get(station_id)->goods[cargo_id];
const ::GoodsEntry &goods = ::Station::Get(station_id)->goods[cargo_type];
if (!goods.HasData()) return 0;
const StationCargoList &cargo_list = goods.GetData().cargo;
@@ -78,39 +78,39 @@ template <bool Tfrom, bool Tvia>
return cargo_count;
}
/* static */ SQInteger ScriptStation::GetCargoWaiting(StationID station_id, CargoID cargo_id)
/* static */ SQInteger ScriptStation::GetCargoWaiting(StationID station_id, CargoType cargo_type)
{
return CountCargoWaiting<false, false>(station_id, STATION_INVALID, STATION_INVALID, cargo_id);
return CountCargoWaiting<false, false>(station_id, STATION_INVALID, STATION_INVALID, cargo_type);
}
/* static */ SQInteger ScriptStation::GetCargoWaitingFrom(StationID station_id,
StationID from_station_id, CargoID cargo_id)
StationID from_station_id, CargoType cargo_type)
{
return CountCargoWaiting<true, false>(station_id, from_station_id, STATION_INVALID, cargo_id);
return CountCargoWaiting<true, false>(station_id, from_station_id, STATION_INVALID, cargo_type);
}
/* static */ SQInteger ScriptStation::GetCargoWaitingVia(StationID station_id,
StationID via_station_id, CargoID cargo_id)
StationID via_station_id, CargoType cargo_type)
{
return CountCargoWaiting<false, true>(station_id, STATION_INVALID, via_station_id, cargo_id);
return CountCargoWaiting<false, true>(station_id, STATION_INVALID, via_station_id, cargo_type);
}
/* static */ SQInteger ScriptStation::GetCargoWaitingFromVia(StationID station_id,
StationID from_station_id, StationID via_station_id, CargoID cargo_id)
StationID from_station_id, StationID via_station_id, CargoType cargo_type)
{
return CountCargoWaiting<true, true>(station_id, from_station_id, via_station_id, cargo_id);
return CountCargoWaiting<true, true>(station_id, from_station_id, via_station_id, cargo_type);
}
template <bool Tfrom, bool Tvia>
/* static */ SQInteger ScriptStation::CountCargoPlanned(StationID station_id,
StationID from_station_id, StationID via_station_id, CargoID cargo_id)
StationID from_station_id, StationID via_station_id, CargoType cargo_type)
{
if (!ScriptStation::IsCargoRequestValid<Tfrom, Tvia>(station_id, from_station_id,
via_station_id, cargo_id)) {
via_station_id, cargo_type)) {
return -1;
}
const ::GoodsEntry &goods = ::Station::Get(station_id)->goods[cargo_id];
const ::GoodsEntry &goods = ::Station::Get(station_id)->goods[cargo_type];
if (!goods.HasData()) return 0;
const FlowStatMap &flows = goods.GetData().flows;
@@ -122,42 +122,42 @@ template <bool Tfrom, bool Tvia>
}
}
/* static */ SQInteger ScriptStation::GetCargoPlanned(StationID station_id, CargoID cargo_id)
/* static */ SQInteger ScriptStation::GetCargoPlanned(StationID station_id, CargoType cargo_type)
{
return CountCargoPlanned<false, false>(station_id, STATION_INVALID, STATION_INVALID, cargo_id);
return CountCargoPlanned<false, false>(station_id, STATION_INVALID, STATION_INVALID, cargo_type);
}
/* static */ SQInteger ScriptStation::GetCargoPlannedFrom(StationID station_id,
StationID from_station_id, CargoID cargo_id)
StationID from_station_id, CargoType cargo_type)
{
return CountCargoPlanned<true, false>(station_id, from_station_id, STATION_INVALID, cargo_id);
return CountCargoPlanned<true, false>(station_id, from_station_id, STATION_INVALID, cargo_type);
}
/* static */ SQInteger ScriptStation::GetCargoPlannedVia(StationID station_id,
StationID via_station_id, CargoID cargo_id)
StationID via_station_id, CargoType cargo_type)
{
return CountCargoPlanned<false, true>(station_id, STATION_INVALID, via_station_id, cargo_id);
return CountCargoPlanned<false, true>(station_id, STATION_INVALID, via_station_id, cargo_type);
}
/* static */ SQInteger ScriptStation::GetCargoPlannedFromVia(StationID station_id,
StationID from_station_id, StationID via_station_id, CargoID cargo_id)
StationID from_station_id, StationID via_station_id, CargoType cargo_type)
{
return CountCargoPlanned<true, true>(station_id, from_station_id, via_station_id, cargo_id);
return CountCargoPlanned<true, true>(station_id, from_station_id, via_station_id, cargo_type);
}
/* static */ bool ScriptStation::HasCargoRating(StationID station_id, CargoID cargo_id)
/* static */ bool ScriptStation::HasCargoRating(StationID station_id, CargoType cargo_type)
{
if (!IsValidStation(station_id)) return false;
if (!ScriptCargo::IsValidCargo(cargo_id)) return false;
if (!ScriptCargo::IsValidCargo(cargo_type)) return false;
return ::Station::Get(station_id)->goods[cargo_id].HasRating();
return ::Station::Get(station_id)->goods[cargo_type].HasRating();
}
/* static */ SQInteger ScriptStation::GetCargoRating(StationID station_id, CargoID cargo_id)
/* static */ SQInteger ScriptStation::GetCargoRating(StationID station_id, CargoType cargo_type)
{
if (!ScriptStation::HasCargoRating(station_id, cargo_id)) return -1;
if (!ScriptStation::HasCargoRating(station_id, cargo_type)) return -1;
return ::ToPercent8(::Station::Get(station_id)->goods[cargo_id].rating);
return ::ToPercent8(::Station::Get(station_id)->goods[cargo_type].rating);
}
/* static */ SQInteger ScriptStation::GetCoverageRadius(ScriptStation::StationType station_type)

View File

@@ -79,88 +79,88 @@ public:
/**
* See how much cargo there is waiting on a station.
* @param station_id The station to get the cargo-waiting of.
* @param cargo_id The cargo to get the cargo-waiting of.
* @param cargo_type The cargo to get the cargo-waiting of.
* @pre IsValidStation(station_id).
* @pre IsValidCargo(cargo_id).
* @pre IsValidCargo(cargo_type).
* @return The amount of units waiting at the station.
*/
static SQInteger GetCargoWaiting(StationID station_id, CargoID cargo_id);
static SQInteger GetCargoWaiting(StationID station_id, CargoType cargo_type);
/**
* See how much cargo with a specific source station there is waiting on a station.
* @param station_id The station to get the cargo-waiting of.
* @param from_station_id The source station of the cargo. Pass STATION_INVALID to get cargo of which the source has been deleted.
* @param cargo_id The cargo to get the cargo-waiting of.
* @param cargo_type The cargo to get the cargo-waiting of.
* @pre IsValidStation(station_id).
* @pre IsValidStation(from_station_id) || from_station_id == STATION_INVALID.
* @pre IsValidCargo(cargo_id).
* @pre IsValidCargo(cargo_type).
* @return The amount of units waiting at the station originating from from_station_id.
* @note source station means, the station where cargo was first loaded.
*/
static SQInteger GetCargoWaitingFrom(StationID station_id, StationID from_station_id, CargoID cargo_id);
static SQInteger GetCargoWaitingFrom(StationID station_id, StationID from_station_id, CargoType cargo_type);
/**
* See how much cargo with a specific via-station there is waiting on a station.
* @param station_id The station to get the cargo-waiting of.
* @param via_station_id The next station the cargo is going to. Pass STATION_INVALID to get waiting cargo for "via any station".
* @param cargo_id The cargo to get the cargo-waiting of.
* @param cargo_type The cargo to get the cargo-waiting of.
* @pre IsValidStation(station_id).
* @pre IsValidStation(via_station_id) || via_station_id == STATION_INVALID.
* @pre IsValidCargo(cargo_id).
* @pre IsValidCargo(cargo_type).
* @return The amount of units waiting at the station with via_station_id as next hop.
* @note if ScriptCargo.GetCargoDistributionType(cargo_id) == ScriptCargo.DT_MANUAL, then all waiting cargo will have STATION_INVALID as next hop.
* @note if ScriptCargo.GetCargoDistributionType(cargo_type) == ScriptCargo.DT_MANUAL, then all waiting cargo will have STATION_INVALID as next hop.
*/
static SQInteger GetCargoWaitingVia(StationID station_id, StationID via_station_id, CargoID cargo_id);
static SQInteger GetCargoWaitingVia(StationID station_id, StationID via_station_id, CargoType cargo_type);
/**
* See how much cargo with a specific via-station and source station there is waiting on a station.
* @param station_id The station to get the cargo-waiting of.
* @param from_station_id The source station of the cargo. Pass STATION_INVALID to get cargo of which the source has been deleted.
* @param via_station_id The next station the cargo is going to. Pass STATION_INVALID to get waiting cargo for "via any station".
* @param cargo_id The cargo to get the cargo-waiting of.
* @param cargo_type The cargo to get the cargo-waiting of.
* @pre IsValidStation(station_id).
* @pre IsValidStation(from_station_id) || from_station_id == STATION_INVALID.
* @pre IsValidStation(via_station_id) || via_station_id == STATION_INVALID.
* @pre IsValidCargo(cargo_id).
* @pre IsValidCargo(cargo_type).
* @return The amount of units waiting at the station with from_station_id as source and via_station_id as next hop.
* @note if ScriptCargo.GetCargoDistributionType(cargo_id) == ScriptCargo.DT_MANUAL, then all waiting cargo will have STATION_INVALID as next hop.
* @note if ScriptCargo.GetCargoDistributionType(cargo_type) == ScriptCargo.DT_MANUAL, then all waiting cargo will have STATION_INVALID as next hop.
*/
static SQInteger GetCargoWaitingFromVia(StationID station_id, StationID from_station_id, StationID via_station_id, CargoID cargo_id);
static SQInteger GetCargoWaitingFromVia(StationID station_id, StationID from_station_id, StationID via_station_id, CargoType cargo_type);
/**
* See how much cargo was planned to pass (including production and consumption) this station per month.
* @param station_id The station to get the planned flow for.
* @param cargo_id The cargo type to get the planned flow for.
* @param cargo_type The cargo type to get the planned flow for.
* @pre IsValidStation(station_id).
* @pre IsValidCargo(cargo_id).
* @pre IsValidCargo(cargo_type).
* @return The amount of cargo units planned to pass the station per month.
*/
static SQInteger GetCargoPlanned(StationID station_id, CargoID cargo_id);
static SQInteger GetCargoPlanned(StationID station_id, CargoType cargo_type);
/**
* See how much cargo from the specified origin was planned to pass (including production and consumption) this station per month.
* @param station_id The station to get the planned flow for.
* @param from_station_id The station the cargo originates at.
* @param cargo_id The cargo type to get the planned flow for.
* @param cargo_type The cargo type to get the planned flow for.
* @pre IsValidStation(station_id).
* @pre IsValidStation(from_station_id) || from_station_id == STATION_INVALID.
* @pre IsValidCargo(cargo_id).
* @pre IsValidCargo(cargo_type).
* @return The amount of cargo units from the specified origin planned to pass the station per month.
*/
static SQInteger GetCargoPlannedFrom(StationID station_id, StationID from_station_id, CargoID cargo_id);
static SQInteger GetCargoPlannedFrom(StationID station_id, StationID from_station_id, CargoType cargo_type);
/**
* See how much cargo was planned to pass (including production and consumption) this station per month, heading for the specified next hop.
* @param station_id The station to get the planned flow for.
* @param via_station_id The next station the cargo will go on to.
* @param cargo_id The cargo type to get the planned flow for.
* @param cargo_type The cargo type to get the planned flow for.
* @pre IsValidStation(station_id).
* @pre IsValidStation(via_station_id) || via_station_id == STATION_INVALID.
* @pre IsValidCargo(cargo_id).
* @pre IsValidCargo(cargo_type).
* @return The amount of cargo units planned to pass the station per month, going via the specified next hop.
* @note Cargo planned to go "via" the same station that's being queried is actually planned to be consumed there.
*/
static SQInteger GetCargoPlannedVia(StationID station_id, StationID via_station_id, CargoID cargo_id);
static SQInteger GetCargoPlannedVia(StationID station_id, StationID via_station_id, CargoType cargo_type);
/**
* See how much cargo from the specified origin was planned to pass this station per month,
@@ -168,37 +168,37 @@ public:
* @param station_id The station to get the planned flow for.
* @param from_station_id The station the cargo originates at.
* @param via_station_id The next station the cargo will go on to.
* @param cargo_id The cargo type to get the planned flow for.
* @param cargo_type The cargo type to get the planned flow for.
* @pre IsValidStation(station_id).
* @pre IsValidStation(from_station_id) || from_station_id == STATION_INVALID.
* @pre IsValidStation(via_station_id) || via_station_id == STATION_INVALID.
* @pre IsValidCargo(cargo_id).
* @pre IsValidCargo(cargo_type).
* @return The amount of cargo units from the specified origin planned to pass the station per month, going via the specified next hop.
* @note Cargo planned to go "via" the same station that's being queried is actually planned to be consumed there.
* @note Cargo planned to pass "from" the same station that's being queried is actually produced there.
*/
static SQInteger GetCargoPlannedFromVia(StationID station_id, StationID from_station_id, StationID via_station_id, CargoID cargo_id);
static SQInteger GetCargoPlannedFromVia(StationID station_id, StationID from_station_id, StationID via_station_id, CargoType cargo_type);
/**
* Check whether the given cargo at the given station a rating.
* @param station_id The station to get the cargo-rating state of.
* @param cargo_id The cargo to get the cargo-rating state of.
* @param cargo_type The cargo to get the cargo-rating state of.
* @pre IsValidStation(station_id).
* @pre IsValidCargo(cargo_id).
* @pre IsValidCargo(cargo_type).
* @return True if the cargo has a rating, otherwise false.
*/
static bool HasCargoRating(StationID station_id, CargoID cargo_id);
static bool HasCargoRating(StationID station_id, CargoType cargo_type);
/**
* See how high the rating is of a cargo on a station.
* @param station_id The station to get the cargo-rating of.
* @param cargo_id The cargo to get the cargo-rating of.
* @param cargo_type The cargo to get the cargo-rating of.
* @pre IsValidStation(station_id).
* @pre IsValidCargo(cargo_id).
* @pre HasCargoRating(station_id, cargo_id).
* @pre IsValidCargo(cargo_type).
* @pre HasCargoRating(station_id, cargo_type).
* @return The rating in percent of the cargo on the station.
*/
static SQInteger GetCargoRating(StationID station_id, CargoID cargo_id);
static SQInteger GetCargoRating(StationID station_id, CargoType cargo_type);
/**
* Get the coverage radius of this type of station.
@@ -299,15 +299,15 @@ public:
private:
template <bool Tfrom, bool Tvia>
static bool IsCargoRequestValid(StationID station_id, StationID from_station_id,
StationID via_station_id, CargoID cargo_id);
StationID via_station_id, CargoType cargo_type);
template <bool Tfrom, bool Tvia>
static SQInteger CountCargoWaiting(StationID station_id, StationID from_station_id,
StationID via_station_id, CargoID cargo_id);
StationID via_station_id, CargoType cargo_type);
template <bool Tfrom, bool Tvia>
static SQInteger CountCargoPlanned(StationID station_id, StationID from_station_id,
StationID via_station_id, CargoID cargo_id);
StationID via_station_id, CargoType cargo_type);
};

View File

@@ -40,7 +40,7 @@ ScriptStationList_Vehicle::ScriptStationList_Vehicle(VehicleID vehicle_id)
}
ScriptStationList_Cargo::ScriptStationList_Cargo(ScriptStationList_Cargo::CargoMode mode,
ScriptStationList_Cargo::CargoSelector selector, StationID station_id, CargoID cargo,
ScriptStationList_Cargo::CargoSelector selector, StationID station_id, CargoType cargo,
StationID other_station)
{
switch (mode) {
@@ -56,7 +56,7 @@ ScriptStationList_Cargo::ScriptStationList_Cargo(ScriptStationList_Cargo::CargoM
}
ScriptStationList_CargoWaiting::ScriptStationList_CargoWaiting(
ScriptStationList_Cargo::CargoSelector selector, StationID station_id, CargoID cargo,
ScriptStationList_Cargo::CargoSelector selector, StationID station_id, CargoType cargo,
StationID other_station)
{
switch (selector) {
@@ -78,7 +78,7 @@ ScriptStationList_CargoWaiting::ScriptStationList_CargoWaiting(
}
ScriptStationList_CargoPlanned::ScriptStationList_CargoPlanned(
ScriptStationList_Cargo::CargoSelector selector, StationID station_id, CargoID cargo,
ScriptStationList_Cargo::CargoSelector selector, StationID station_id, CargoType cargo,
StationID other_station)
{
switch (selector) {
@@ -101,7 +101,7 @@ ScriptStationList_CargoPlanned::ScriptStationList_CargoPlanned(
class CargoCollector {
public:
CargoCollector(ScriptStationList_Cargo *parent, StationID station_id, CargoID cargo,
CargoCollector(ScriptStationList_Cargo *parent, StationID station_id, CargoType cargo,
StationID other);
~CargoCollector() ;
@@ -121,7 +121,7 @@ private:
};
CargoCollector::CargoCollector(ScriptStationList_Cargo *parent,
StationID station_id, CargoID cargo, StationID other) :
StationID station_id, CargoType cargo, StationID other) :
list(parent), ge(nullptr), other_station(other), last_key(INVALID_STATION), amount(0)
{
if (!ScriptStation::IsValidStation(station_id)) return;
@@ -175,7 +175,7 @@ void CargoCollector::Update(StationID from, StationID via, uint amount)
template <ScriptStationList_Cargo::CargoSelector Tselector>
void ScriptStationList_CargoWaiting::Add(StationID station_id, CargoID cargo, StationID other_station)
void ScriptStationList_CargoWaiting::Add(StationID station_id, CargoType cargo, StationID other_station)
{
CargoCollector collector(this, station_id, cargo, other_station);
if (collector.GE() == nullptr) return;
@@ -190,7 +190,7 @@ void ScriptStationList_CargoWaiting::Add(StationID station_id, CargoID cargo, St
template <ScriptStationList_Cargo::CargoSelector Tselector>
void ScriptStationList_CargoPlanned::Add(StationID station_id, CargoID cargo, StationID other_station)
void ScriptStationList_CargoPlanned::Add(StationID station_id, CargoType cargo, StationID other_station)
{
CargoCollector collector(this, station_id, cargo, other_station);
if (collector.GE() == nullptr) return;
@@ -210,13 +210,13 @@ void ScriptStationList_CargoPlanned::Add(StationID station_id, CargoID cargo, St
}
ScriptStationList_CargoWaitingByFrom::ScriptStationList_CargoWaitingByFrom(StationID station_id,
CargoID cargo)
CargoType cargo)
{
this->Add<CS_BY_FROM>(station_id, cargo);
}
ScriptStationList_CargoWaitingViaByFrom::ScriptStationList_CargoWaitingViaByFrom(
StationID station_id, CargoID cargo, StationID via)
StationID station_id, CargoType cargo, StationID via)
{
CargoCollector collector(this, station_id, cargo, via);
if (collector.GE() == nullptr) return;
@@ -231,39 +231,39 @@ ScriptStationList_CargoWaitingViaByFrom::ScriptStationList_CargoWaitingViaByFrom
ScriptStationList_CargoWaitingByVia::ScriptStationList_CargoWaitingByVia(StationID station_id,
CargoID cargo)
CargoType cargo)
{
this->Add<CS_BY_VIA>(station_id, cargo);
}
ScriptStationList_CargoWaitingFromByVia::ScriptStationList_CargoWaitingFromByVia(
StationID station_id, CargoID cargo, StationID from)
StationID station_id, CargoType cargo, StationID from)
{
this->Add<CS_FROM_BY_VIA>(station_id, cargo, from);
}
ScriptStationList_CargoPlannedByFrom::ScriptStationList_CargoPlannedByFrom(StationID station_id,
CargoID cargo)
CargoType cargo)
{
this->Add<CS_BY_FROM>(station_id, cargo);
}
ScriptStationList_CargoPlannedViaByFrom::ScriptStationList_CargoPlannedViaByFrom(
StationID station_id, CargoID cargo, StationID via)
StationID station_id, CargoType cargo, StationID via)
{
this->Add<CS_VIA_BY_FROM>(station_id, cargo, via);
}
ScriptStationList_CargoPlannedByVia::ScriptStationList_CargoPlannedByVia(StationID station_id,
CargoID cargo)
CargoType cargo)
{
this->Add<CS_BY_VIA>(station_id, cargo);
}
ScriptStationList_CargoPlannedFromByVia::ScriptStationList_CargoPlannedFromByVia(
StationID station_id, CargoID cargo, StationID from)
StationID station_id, CargoType cargo, StationID from)
{
CargoCollector collector(this, station_id, cargo, from);
if (collector.GE() == nullptr) return;

View File

@@ -61,7 +61,7 @@ public:
* @param cargo Cargo type to query for.
* @param other_station Other station to restrict the query with.
*/
ScriptStationList_Cargo(ScriptStationList_Cargo::CargoMode mode, ScriptStationList_Cargo::CargoSelector selector, StationID station_id, CargoID cargo, StationID other_station);
ScriptStationList_Cargo(ScriptStationList_Cargo::CargoMode mode, ScriptStationList_Cargo::CargoSelector selector, StationID station_id, CargoType cargo, StationID other_station);
protected:
@@ -93,7 +93,7 @@ protected:
* @param other_station Other station to restrict the query with.
*/
template <CargoSelector Tselector>
void Add(StationID station_id, CargoID cargo, StationID other_station = INVALID_STATION);
void Add(StationID station_id, CargoType cargo, StationID other_station = INVALID_STATION);
public:
@@ -105,7 +105,7 @@ public:
* @param cargo Cargo type to query for.
* @param other_station Other station to restrict the query with.
*/
ScriptStationList_CargoWaiting(ScriptStationList_Cargo::CargoSelector selector, StationID station_id, CargoID cargo, StationID other_station);
ScriptStationList_CargoWaiting(ScriptStationList_Cargo::CargoSelector selector, StationID station_id, CargoType cargo, StationID other_station);
};
/**
@@ -130,7 +130,7 @@ protected:
* @param other_station Other station to restrict the query with.
*/
template <CargoSelector Tselector>
void Add(StationID station_id, CargoID cargo, StationID other_station = INVALID_STATION);
void Add(StationID station_id, CargoType cargo, StationID other_station = INVALID_STATION);
public:
@@ -142,7 +142,7 @@ public:
* @param cargo Cargo type to query for.
* @param other_station Other station to restrict the query with.
*/
ScriptStationList_CargoPlanned(ScriptStationList_Cargo::CargoSelector selector, StationID station_id, CargoID cargo, StationID other_station);
ScriptStationList_CargoPlanned(ScriptStationList_Cargo::CargoSelector selector, StationID station_id, CargoType cargo, StationID other_station);
};
/**
@@ -157,7 +157,7 @@ public:
* @param station_id Station to query for waiting cargo.
* @param cargo Cargo type to query for.
*/
ScriptStationList_CargoWaitingByFrom(StationID station_id, CargoID cargo);
ScriptStationList_CargoWaitingByFrom(StationID station_id, CargoType cargo);
};
/**
@@ -173,7 +173,7 @@ public:
* @param cargo Cargo type to query for.
* @param via Next hop to restrict the query with.
*/
ScriptStationList_CargoWaitingViaByFrom(StationID station_id, CargoID cargo, StationID via);
ScriptStationList_CargoWaitingViaByFrom(StationID station_id, CargoType cargo, StationID via);
};
/**
@@ -188,7 +188,7 @@ public:
* @param station_id Station to query for waiting cargo.
* @param cargo Cargo type to query for.
*/
ScriptStationList_CargoWaitingByVia(StationID station_id, CargoID cargo);
ScriptStationList_CargoWaitingByVia(StationID station_id, CargoType cargo);
};
/**
@@ -204,7 +204,7 @@ public:
* @param cargo Cargo type to query for.
* @param from Origin station to restrict the query with.
*/
ScriptStationList_CargoWaitingFromByVia(StationID station_id, CargoID cargo, StationID from);
ScriptStationList_CargoWaitingFromByVia(StationID station_id, CargoType cargo, StationID from);
};
/**
@@ -219,7 +219,7 @@ public:
* @param station_id Station to query for planned flows.
* @param cargo Cargo type to query for.
*/
ScriptStationList_CargoPlannedByFrom(StationID station_id, CargoID cargo);
ScriptStationList_CargoPlannedByFrom(StationID station_id, CargoType cargo);
};
/**
@@ -235,7 +235,7 @@ public:
* @param cargo Cargo type to query for.
* @param via Next hop to restrict the query with.
*/
ScriptStationList_CargoPlannedViaByFrom(StationID station_id, CargoID cargo, StationID via);
ScriptStationList_CargoPlannedViaByFrom(StationID station_id, CargoType cargo, StationID via);
};
/**
@@ -251,7 +251,7 @@ public:
* @param station_id Station to query for planned flows.
* @param cargo Cargo type to query for.
*/
ScriptStationList_CargoPlannedByVia(StationID station_id, CargoID cargo);
ScriptStationList_CargoPlannedByVia(StationID station_id, CargoType cargo);
};
/**
@@ -268,7 +268,7 @@ public:
* @param cargo Cargo type to query for.
* @param from Origin station to restrict the query with.
*/
ScriptStationList_CargoPlannedFromByVia(StationID station_id, CargoID cargo, StationID from);
ScriptStationList_CargoPlannedFromByVia(StationID station_id, CargoType cargo, StationID from);
};
/**

View File

@@ -31,7 +31,7 @@
return ::Subsidy::Get(subsidy_id)->IsAwarded();
}
/* static */ bool ScriptSubsidy::Create(CargoID cargo_type, SubsidyParticipantType from_type, SQInteger from_id, SubsidyParticipantType to_type, SQInteger to_id)
/* static */ bool ScriptSubsidy::Create(CargoType cargo_type, SubsidyParticipantType from_type, SQInteger from_id, SubsidyParticipantType to_type, SQInteger to_id)
{
EnforceDeityMode(false);
EnforcePrecondition(false, ScriptCargo::IsValidCargo(cargo_type));
@@ -63,7 +63,7 @@
return (ScriptDate::Date)TimerGameEconomy::ConvertYMDToDate(ymd.year, ymd.month, ymd.day).base();
}
/* static */ CargoID ScriptSubsidy::GetCargoType(SubsidyID subsidy_id)
/* static */ CargoType ScriptSubsidy::GetCargoType(SubsidyID subsidy_id)
{
if (!IsValidSubsidy(subsidy_id)) return INVALID_CARGO;

View File

@@ -63,7 +63,7 @@ public:
* @pre (to_type == SPT_INDUSTRY && ScriptIndustry::IsValidIndustry(to_id)) || (to_type == SPT_TOWN && ScriptTown::IsValidTown(to_id))
* @api -ai
*/
static bool Create(CargoID cargo_type, SubsidyParticipantType from_type, SQInteger from_id, SubsidyParticipantType to_type, SQInteger to_id);
static bool Create(CargoType cargo_type, SubsidyParticipantType from_type, SQInteger from_id, SubsidyParticipantType to_type, SQInteger to_id);
/**
* Get the company index of the company this subsidy is awarded to.
@@ -93,7 +93,7 @@ public:
* @pre IsValidSubsidy(subsidy_id).
* @return The cargo type to transport.
*/
static CargoID GetCargoType(SubsidyID subsidy_id);
static CargoType GetCargoType(SubsidyID subsidy_id);
/**
* Returns the type of source of subsidy.

View File

@@ -224,7 +224,7 @@
}
}
/* static */ SQInteger ScriptTile::GetCargoAcceptance(TileIndex tile, CargoID cargo_type, SQInteger width, SQInteger height, SQInteger radius)
/* static */ SQInteger ScriptTile::GetCargoAcceptance(TileIndex tile, CargoType cargo_type, SQInteger width, SQInteger height, SQInteger radius)
{
if (!::IsValidTile(tile) || width <= 0 || height <= 0 || radius < 0 || !ScriptCargo::IsValidCargo(cargo_type)) return -1;
@@ -232,7 +232,7 @@
return acceptance[cargo_type];
}
/* static */ SQInteger ScriptTile::GetCargoProduction(TileIndex tile, CargoID cargo_type, SQInteger width, SQInteger height, SQInteger radius)
/* static */ SQInteger ScriptTile::GetCargoProduction(TileIndex tile, CargoType cargo_type, SQInteger width, SQInteger height, SQInteger radius)
{
if (!::IsValidTile(tile) || width <= 0 || height <= 0 || radius < 0 || !ScriptCargo::IsValidCargo(cargo_type)) return -1;

View File

@@ -376,7 +376,7 @@ public:
* @pre radius >= 0.
* @return Values below 8 mean no acceptance; the more the better.
*/
static SQInteger GetCargoAcceptance(TileIndex tile, CargoID cargo_type, SQInteger width, SQInteger height, SQInteger radius);
static SQInteger GetCargoAcceptance(TileIndex tile, CargoType cargo_type, SQInteger width, SQInteger height, SQInteger radius);
/**
* Checks how many producers in the radius produces this cargo.
@@ -393,7 +393,7 @@ public:
* @pre radius >= 0.
* @return The number of producers that produce this cargo within radius of the tile.
*/
static SQInteger GetCargoProduction(TileIndex tile, CargoID cargo_type, SQInteger width, SQInteger height, SQInteger radius);
static SQInteger GetCargoProduction(TileIndex tile, CargoType cargo_type, SQInteger width, SQInteger height, SQInteger radius);
/**
* Get the manhattan distance from the tile to the tile.

View File

@@ -95,7 +95,7 @@ ScriptTileList_IndustryAccepting::ScriptTileList_IndustryAccepting(IndustryID in
/* Only add the tile if it accepts the cargo (sometimes just 1 tile of an
* industry triggers the acceptance). */
CargoArray acceptance = ::GetAcceptanceAroundTiles(cur_tile, 1, 1, radius);
if (std::none_of(std::begin(i->accepted), std::end(i->accepted), [&acceptance](const auto &a) { return ::IsValidCargoID(a.cargo) && acceptance[a.cargo] != 0; })) continue;
if (std::none_of(std::begin(i->accepted), std::end(i->accepted), [&acceptance](const auto &a) { return ::IsValidCargoType(a.cargo) && acceptance[a.cargo] != 0; })) continue;
this->AddTile(cur_tile);
}

View File

@@ -86,33 +86,33 @@
return t->xy;
}
/* static */ SQInteger ScriptTown::GetLastMonthProduction(TownID town_id, CargoID cargo_id)
/* static */ SQInteger ScriptTown::GetLastMonthProduction(TownID town_id, CargoType cargo_type)
{
if (!IsValidTown(town_id)) return -1;
if (!ScriptCargo::IsValidCargo(cargo_id)) return -1;
if (!ScriptCargo::IsValidCargo(cargo_type)) return -1;
const Town *t = ::Town::Get(town_id);
return t->supplied[cargo_id].old_max;
return t->supplied[cargo_type].old_max;
}
/* static */ SQInteger ScriptTown::GetLastMonthSupplied(TownID town_id, CargoID cargo_id)
/* static */ SQInteger ScriptTown::GetLastMonthSupplied(TownID town_id, CargoType cargo_type)
{
if (!IsValidTown(town_id)) return -1;
if (!ScriptCargo::IsValidCargo(cargo_id)) return -1;
if (!ScriptCargo::IsValidCargo(cargo_type)) return -1;
const Town *t = ::Town::Get(town_id);
return t->supplied[cargo_id].old_act;
return t->supplied[cargo_type].old_act;
}
/* static */ SQInteger ScriptTown::GetLastMonthTransportedPercentage(TownID town_id, CargoID cargo_id)
/* static */ SQInteger ScriptTown::GetLastMonthTransportedPercentage(TownID town_id, CargoType cargo_type)
{
if (!IsValidTown(town_id)) return -1;
if (!ScriptCargo::IsValidCargo(cargo_id)) return -1;
if (!ScriptCargo::IsValidCargo(cargo_type)) return -1;
const Town *t = ::Town::Get(town_id);
return ::ToPercent8(t->GetPercentTransported(cargo_id));
return ::ToPercent8(t->GetPercentTransported(cargo_type));
}
/* static */ SQInteger ScriptTown::GetLastMonthReceived(TownID town_id, ScriptCargo::TownEffect towneffect_id)

View File

@@ -196,42 +196,42 @@ public:
/**
* Get the total last economy-month's production of the given cargo at a town.
* @param town_id The index of the town.
* @param cargo_id The index of the cargo.
* @param cargo_type The index of the cargo.
* @pre IsValidTown(town_id).
* @pre ScriptCargo::IsValidCargo(cargo_id).
* @pre ScriptCargo::IsValidCargo(cargo_type).
* @return The last economy-month's production of the given cargo for this town.
* @see \ref ScriptEconomyTime
*/
static SQInteger GetLastMonthProduction(TownID town_id, CargoID cargo_id);
static SQInteger GetLastMonthProduction(TownID town_id, CargoType cargo_type);
/**
* Get the total amount of cargo supplied from a town last economy-month.
* @param town_id The index of the town.
* @param cargo_id The index of the cargo.
* @param cargo_type The index of the cargo.
* @pre IsValidTown(town_id).
* @pre ScriptCargo::IsValidCargo(cargo_id).
* @pre ScriptCargo::IsValidCargo(cargo_type).
* @return The amount of cargo supplied for transport from this town last economy-month.
* @see \ref ScriptEconomyTime
*/
static SQInteger GetLastMonthSupplied(TownID town_id, CargoID cargo_id);
static SQInteger GetLastMonthSupplied(TownID town_id, CargoType cargo_type);
/**
* Get the percentage of transported production of the given cargo at a town last economy-month.
* @param town_id The index of the town.
* @param cargo_id The index of the cargo.
* @param cargo_type The index of the cargo.
* @pre IsValidTown(town_id).
* @pre ScriptCargo::IsValidCargo(cargo_id).
* @pre ScriptCargo::IsValidCargo(cargo_type).
* @return The percentage of given cargo transported from this town last economy-month.
* @see \ref ScriptEconomyTime
*/
static SQInteger GetLastMonthTransportedPercentage(TownID town_id, CargoID cargo_id);
static SQInteger GetLastMonthTransportedPercentage(TownID town_id, CargoType cargo_type);
/**
* Get the total amount of cargo effects received by a town last economy-month.
* @param town_id The index of the town.
* @param towneffect_id The index of the cargo.
* @pre IsValidTown(town_id).
* @pre ScriptCargo::IsValidTownEffect(cargo_id).
* @pre ScriptCargo::IsValidTownEffect(cargo_type).
* @return The amount of cargo received by this town last economy-month for this cargo effect.
* @see \ref ScriptEconomyTime
*/

View File

@@ -25,7 +25,7 @@
* <td> introduction \ref newgrf_changes "(1)" </td>
* <td> never \ref newgrf_changes "(1)" </td>
* <td> no \ref newgrf_changes "(1)" </td></tr>
* <tr><td>#CargoID </td><td> cargo type </td>
* <tr><td>#CargoType </td><td> cargo type </td>
* <td> game start \ref newgrf_changes "(1)" </td>
* <td> never \ref newgrf_changes "(1)" </td>
* <td> no \ref newgrf_changes "(1)" </td></tr>
@@ -111,7 +111,7 @@
/* Define all types here, so they are added to the API docs. */
typedef uint BridgeType; ///< The ID of a bridge type.
typedef uint8_t CargoID; ///< The ID of a cargo.
typedef uint8_t CargoType; ///< The ID of a cargo 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.

View File

@@ -71,11 +71,11 @@
return v->IsGroundVehicle() ? v->GetGroundVehicleCache()->cached_total_length : -1;
}
/* static */ VehicleID ScriptVehicle::_BuildVehicleInternal(TileIndex depot, EngineID engine_id, CargoID cargo)
/* static */ VehicleID ScriptVehicle::_BuildVehicleInternal(TileIndex depot, EngineID engine_id, CargoType cargo)
{
EnforceCompanyModeValid(VEHICLE_INVALID);
EnforcePrecondition(VEHICLE_INVALID, ScriptEngine::IsBuildable(engine_id));
EnforcePrecondition(VEHICLE_INVALID, !::IsValidCargoID(cargo) || ScriptCargo::IsValidCargo(cargo));
EnforcePrecondition(VEHICLE_INVALID, !::IsValidCargoType(cargo) || ScriptCargo::IsValidCargo(cargo));
::VehicleType type = ::Engine::Get(engine_id)->type;
@@ -92,13 +92,13 @@
return _BuildVehicleInternal(depot, engine_id, INVALID_CARGO);
}
/* static */ VehicleID ScriptVehicle::BuildVehicleWithRefit(TileIndex depot, EngineID engine_id, CargoID cargo)
/* static */ VehicleID ScriptVehicle::BuildVehicleWithRefit(TileIndex depot, EngineID engine_id, CargoType cargo)
{
EnforcePrecondition(VEHICLE_INVALID, ScriptCargo::IsValidCargo(cargo));
return _BuildVehicleInternal(depot, engine_id, cargo);
}
/* static */ SQInteger ScriptVehicle::GetBuildWithRefitCapacity(TileIndex depot, EngineID engine_id, CargoID cargo)
/* static */ SQInteger ScriptVehicle::GetBuildWithRefitCapacity(TileIndex depot, EngineID engine_id, CargoType cargo)
{
if (!ScriptEngine::IsBuildable(engine_id)) return -1;
if (!ScriptCargo::IsValidCargo(cargo)) return -1;
@@ -147,7 +147,7 @@
return _MoveWagonInternal(source_vehicle_id, source_wagon, true, dest_vehicle_id, dest_wagon);
}
/* static */ SQInteger ScriptVehicle::GetRefitCapacity(VehicleID vehicle_id, CargoID cargo)
/* static */ SQInteger ScriptVehicle::GetRefitCapacity(VehicleID vehicle_id, CargoType cargo)
{
if (!IsValidVehicle(vehicle_id)) return -1;
if (!ScriptCargo::IsValidCargo(cargo)) return -1;
@@ -156,7 +156,7 @@
return res.Succeeded() ? refit_capacity : -1;
}
/* static */ bool ScriptVehicle::RefitVehicle(VehicleID vehicle_id, CargoID cargo)
/* static */ bool ScriptVehicle::RefitVehicle(VehicleID vehicle_id, CargoType cargo)
{
EnforceCompanyModeValid(false);
EnforcePrecondition(false, IsValidVehicle(vehicle_id) && ScriptCargo::IsValidCargo(cargo));
@@ -412,7 +412,7 @@
return (ScriptRoad::RoadType)(int)(::RoadVehicle::Get(vehicle_id))->roadtype;
}
/* static */ SQInteger ScriptVehicle::GetCapacity(VehicleID vehicle_id, CargoID cargo)
/* static */ SQInteger ScriptVehicle::GetCapacity(VehicleID vehicle_id, CargoType cargo)
{
if (!IsValidVehicle(vehicle_id)) return -1;
if (!ScriptCargo::IsValidCargo(cargo)) return -1;
@@ -425,7 +425,7 @@
return amount;
}
/* static */ SQInteger ScriptVehicle::GetCargoLoad(VehicleID vehicle_id, CargoID cargo)
/* static */ SQInteger ScriptVehicle::GetCargoLoad(VehicleID vehicle_id, CargoType cargo)
{
if (!IsValidVehicle(vehicle_id)) return -1;
if (!ScriptCargo::IsValidCargo(cargo)) return -1;

View File

@@ -357,7 +357,7 @@ public:
* as the vehicle isn't really built yet. Build it for real first before
* assigning orders.
*/
static VehicleID BuildVehicleWithRefit(TileIndex depot, EngineID engine_id, CargoID cargo);
static VehicleID BuildVehicleWithRefit(TileIndex depot, EngineID engine_id, CargoType cargo);
/**
* Gets the capacity of a vehicle built at the given depot with the given engine and refitted to the given cargo.
@@ -370,7 +370,7 @@ public:
* @pre ScriptCargo::IsValidCargo(cargo).
* @return The capacity the vehicle will have when refited.
*/
static SQInteger GetBuildWithRefitCapacity(TileIndex depot, EngineID engine_id, CargoID cargo);
static SQInteger GetBuildWithRefitCapacity(TileIndex depot, EngineID engine_id, CargoType cargo);
/**
* Clones a vehicle at the given depot, copying or cloning its orders.
@@ -431,7 +431,7 @@ public:
* @pre The vehicle must be stopped in the depot.
* @return The capacity the vehicle will have when refited.
*/
static SQInteger GetRefitCapacity(VehicleID vehicle_id, CargoID cargo);
static SQInteger GetRefitCapacity(VehicleID vehicle_id, CargoType cargo);
/**
* Refits a vehicle to the given cargo type.
@@ -447,7 +447,7 @@ public:
* @exception ScriptVehicle::ERR_VEHICLE_NOT_IN_DEPOT
* @return True if and only if the refit succeeded.
*/
static bool RefitVehicle(VehicleID vehicle_id, CargoID cargo);
static bool RefitVehicle(VehicleID vehicle_id, CargoType cargo);
/**
* Sells the given vehicle.
@@ -546,7 +546,7 @@ public:
* @pre ScriptCargo::IsValidCargo(cargo).
* @return The maximum amount of the given cargo the vehicle can transport.
*/
static SQInteger GetCapacity(VehicleID vehicle_id, CargoID cargo);
static SQInteger GetCapacity(VehicleID vehicle_id, CargoType cargo);
/**
* Get the length of a the total vehicle in 1/16's of a tile.
@@ -565,7 +565,7 @@ public:
* @pre ScriptCargo::IsValidCargo(cargo).
* @return The amount of the given cargo the vehicle is currently transporting.
*/
static SQInteger GetCargoLoad(VehicleID vehicle_id, CargoID cargo);
static SQInteger GetCargoLoad(VehicleID vehicle_id, CargoType cargo);
/**
* Get the group of a given vehicle.
@@ -619,7 +619,7 @@ private:
/**
* Internal function used by BuildVehicle(WithRefit).
*/
static VehicleID _BuildVehicleInternal(TileIndex depot, EngineID engine_id, CargoID cargo);
static VehicleID _BuildVehicleInternal(TileIndex depot, EngineID engine_id, CargoType cargo);
/**
* Internal function used by SellWagon(Chain).