Skip to content

Commit

Permalink
Fix: Is raw cargo changed based on industries on map (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
F1rrel authored Apr 2, 2023
1 parent 8a9a100 commit 0a734ac
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions cargo.nut
Original file line number Diff line number Diff line change
Expand Up @@ -1231,15 +1231,16 @@ function GetCargoTable(hash)
/* Checks if one of the industry types that produce this cargo is a raw industry */
function IsRawCargo(cargo)
{
local industry_list = GSIndustryList_CargoProducing(cargo);
industry_list.Valuate(GSIndustry.GetIndustryType);
industry_list.Sort(GSList.SORT_BY_VALUE, true);

while (industry_list.Count() > 0) {
local industry_type = industry_list.GetValue(industry_list.Begin());
if (GSIndustryType.IsRawIndustry(industry_type))
return 1;
industry_list.RemoveValue(industry_type);
local industry_type_list= GSIndustryTypeList();
industry_type_list.Valuate(GSIndustryType.IsRawIndustry);
industry_type_list.KeepValue(1);

foreach (industry_type, _ in industry_type_list) {
local cargo_list = GSIndustryType.GetProducedCargo(industry_type);
foreach (accepted, _ in cargo_list) {
if (accepted == cargo)
return 1;
}
}

return 0;
Expand All @@ -1264,6 +1265,7 @@ function CreateDefaultCargoCat()
raw_list.AddList(cargo_list);
raw_list.KeepValue(1);

Log.Info("Raw industries: " + raw_list.Count(), Log.LVL_INFO);
if (raw_list.Count() > 10) {
::CargoCat.append([]);
::CargoCat.append([]);
Expand Down

0 comments on commit 0a734ac

Please sign in to comment.