|
@@ -51,63 +51,63 @@
|
|
|
|
|
|
/* static */ Money ScriptIndustryType::GetConstructionCost(IndustryType industry_type)
|
|
|
{
|
|
|
if (!IsValidIndustryType(industry_type)) return -1;
|
|
|
if (::GetIndustrySpec(industry_type)->IsRawIndustry() && _settings_game.construction.raw_industry_construction == 0) return -1;
|
|
|
|
|
|
return ::GetIndustrySpec(industry_type)->GetConstructionCost();
|
|
|
}
|
|
|
|
|
|
/* static */ std::optional<std::string> ScriptIndustryType::GetName(IndustryType industry_type)
|
|
|
{
|
|
|
if (!IsValidIndustryType(industry_type)) return std::nullopt;
|
|
|
|
|
|
return GetString(::GetIndustrySpec(industry_type)->name);
|
|
|
}
|
|
|
|
|
|
/* static */ ScriptList *ScriptIndustryType::GetProducedCargo(IndustryType industry_type)
|
|
|
{
|
|
|
if (!IsValidIndustryType(industry_type)) return nullptr;
|
|
|
|
|
|
const IndustrySpec *ins = ::GetIndustrySpec(industry_type);
|
|
|
|
|
|
ScriptList *list = new ScriptList();
|
|
|
for (size_t i = 0; i < lengthof(ins->produced_cargo); i++) {
|
|
|
if (ins->produced_cargo[i] != CT_INVALID) list->AddItem(ins->produced_cargo[i]);
|
|
|
if (::IsValidCargoID(ins->produced_cargo[i])) list->AddItem(ins->produced_cargo[i]);
|
|
|
}
|
|
|
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
/* static */ ScriptList *ScriptIndustryType::GetAcceptedCargo(IndustryType industry_type)
|
|
|
{
|
|
|
if (!IsValidIndustryType(industry_type)) return nullptr;
|
|
|
|
|
|
const IndustrySpec *ins = ::GetIndustrySpec(industry_type);
|
|
|
|
|
|
ScriptList *list = new ScriptList();
|
|
|
for (size_t i = 0; i < lengthof(ins->accepts_cargo); i++) {
|
|
|
if (ins->accepts_cargo[i] != CT_INVALID) list->AddItem(ins->accepts_cargo[i]);
|
|
|
if (::IsValidCargoID(ins->accepts_cargo[i])) list->AddItem(ins->accepts_cargo[i]);
|
|
|
}
|
|
|
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
/* static */ bool ScriptIndustryType::CanBuildIndustry(IndustryType industry_type)
|
|
|
{
|
|
|
if (!IsValidIndustryType(industry_type)) return false;
|
|
|
|
|
|
const bool deity = ScriptCompanyMode::IsDeity();
|
|
|
if (::GetIndustryProbabilityCallback(industry_type, deity ? IACT_RANDOMCREATION : IACT_USERCREATION, 1) == 0) return false;
|
|
|
if (deity) return true;
|
|
|
if (!::GetIndustrySpec(industry_type)->IsRawIndustry()) return true;
|
|
|
|
|
|
/* raw_industry_construction == 1 means "Build as other industries" */
|
|
|
return _settings_game.construction.raw_industry_construction == 1;
|
|
|
}
|
|
|
|
|
|
/* static */ bool ScriptIndustryType::CanProspectIndustry(IndustryType industry_type)
|
|
|
{
|
|
|
if (!IsValidIndustryType(industry_type)) return false;
|
|
|
|
|
|
const bool deity = ScriptCompanyMode::IsDeity();
|
|
|
if (!deity && !::GetIndustrySpec(industry_type)->IsRawIndustry()) return false;
|