src/ai/api/ai_industry.cpp
branchnoai
changeset 9795 679ba7cd8426
parent 9737 ee408edf3851
child 9798 28e94a3b2b06
equal deleted inserted replaced
9794:5d866d7cb991 9795:679ba7cd8426
    41 	if (!AICargo::IsValidCargo(cargo_id)) return -1;
    41 	if (!AICargo::IsValidCargo(cargo_id)) return -1;
    42 
    42 
    43 	const Industry *i = ::GetIndustry(industry_id);
    43 	const Industry *i = ::GetIndustry(industry_id);
    44 	const IndustrySpec *indsp = ::GetIndustrySpec(i->type);
    44 	const IndustrySpec *indsp = ::GetIndustrySpec(i->type);
    45 
    45 
    46 	if (indsp->produced_cargo[0] == cargo_id) return i->production_rate[0];
    46 	for (byte j = 0; j < lengthof(indsp->produced_cargo); j++)
    47 	if (indsp->produced_cargo[1] == cargo_id) return i->production_rate[1];
    47 		if (indsp->produced_cargo[j] == cargo_id) return i->production_rate[j];
       
    48 
    48 	return -1;
    49 	return -1;
    49 }
    50 }
    50 
    51 
    51 /* static */ bool AIIndustry::IsCargoAccepted(IndustryID industry_id, CargoID cargo_id)
    52 /* static */ bool AIIndustry::IsCargoAccepted(IndustryID industry_id, CargoID cargo_id)
    52 {
    53 {
    54 	if (!AICargo::IsValidCargo(cargo_id)) return false;
    55 	if (!AICargo::IsValidCargo(cargo_id)) return false;
    55 
    56 
    56 	const Industry *i = ::GetIndustry(industry_id);
    57 	const Industry *i = ::GetIndustry(industry_id);
    57 	const IndustrySpec *indsp = ::GetIndustrySpec(i->type);
    58 	const IndustrySpec *indsp = ::GetIndustrySpec(i->type);
    58 
    59 
    59 	if (indsp->accepts_cargo[0] == cargo_id) return true;
    60 	for (byte j = 0; j < lengthof(indsp->accepts_cargo); j++)
    60 	if (indsp->accepts_cargo[1] == cargo_id) return true;
    61 		if (indsp->accepts_cargo[j] == cargo_id) return true;
    61 	if (indsp->accepts_cargo[2] == cargo_id) return true;
       
    62 
    62 
    63 	return false;
    63 	return false;
    64 }
    64 }
    65 
    65 
    66 /* static */ TileIndex AIIndustry::GetLocation(IndustryID industry_id)
    66 /* static */ TileIndex AIIndustry::GetLocation(IndustryID industry_id)