Codechange: rename CargoID to CargoType and amend related variables/comments
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user