Change: Reorganise industry accept/produce arrays. (#10853)
Use a array of struct for each cargo instead of an array for each statistic. This makes iterating for acceptance and production much simpler. pct_transported is now calculated when needed.
This commit is contained in:
@@ -29,10 +29,9 @@ ScriptCargoList_IndustryAccepting::ScriptCargoList_IndustryAccepting(IndustryID
|
||||
if (!ScriptIndustry::IsValidIndustry(industry_id)) return;
|
||||
|
||||
Industry *ind = ::Industry::Get(industry_id);
|
||||
for (uint i = 0; i < lengthof(ind->accepts_cargo); i++) {
|
||||
CargoID cargo_id = ind->accepts_cargo[i];
|
||||
if (::IsValidCargoID(cargo_id)) {
|
||||
this->AddItem(cargo_id);
|
||||
for (const auto &a : ind->accepted) {
|
||||
if (::IsValidCargoID(a.cargo)) {
|
||||
this->AddItem(a.cargo);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -42,10 +41,9 @@ ScriptCargoList_IndustryProducing::ScriptCargoList_IndustryProducing(IndustryID
|
||||
if (!ScriptIndustry::IsValidIndustry(industry_id)) return;
|
||||
|
||||
Industry *ind = ::Industry::Get(industry_id);
|
||||
for (uint i = 0; i < lengthof(ind->produced_cargo); i++) {
|
||||
CargoID cargo_id = ind->produced_cargo[i];
|
||||
if (::IsValidCargoID(cargo_id)) {
|
||||
this->AddItem(cargo_id);
|
||||
for (const auto &p : ind->produced) {
|
||||
if (::IsValidCargoID(p.cargo)) {
|
||||
this->AddItem(p.cargo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user