File diff r27420:b37b70eb3169 → r27421:e8c2cdc1e8e6
src/script/api/script_industrytype.cpp
Show inline comments
 
@@ -63,39 +63,39 @@
 

	
 
	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;