EarendelDevelopers / factorio-mods

This is a public repository for tracking issues with Earendel's factorio mods.
19 stars 3 forks source link

AAI industries erases changes to fuel_categories if fuel_category is still set in data-final-fixes #306

Open harag-on-steam opened 1 year ago

harag-on-steam commented 1 year ago

https://wiki.factorio.com/Types/EnergySource#fuel_categories states that fuel_categories takes precedence. So the reversal of precedence in data-final-fixes.lua, line 51 looks like a clear bug to me.

I propose the following instead

if not burner.fuel_categories then
  burner.fuel_categories = (burner.fuel_category and { burner.fuel_category }) or { "chemical" } -- the implicit default
elseif burner.fuel_category and not data_util.table_contains(burner.fuel_categories, burner.fuel_category) then
  table.insert(burner.fuel_categories, burner.fuel_category)
end
burner.fuel_category = nil -- always obsolete after the above

-- avoid adding processed-chemical twice
if data_util.table_contains( burner.fuel_categories, "chemical") and not data_util.table_contains(burner.fuel_categories, "processed-chemical") then
  table.insert(burner.fuel_categories, "processed-chemical")
end

(yes, I transfer ownership of that code)