Quality Processing - 2.1 Fork


This mods adds new processing chains for upgrading an item's quality. Now updated for Factorio 2.1!

Content
4 days ago
2.1
374
Factorio: Space Age Icon Space Age Mod
Manufacturing

b [fixed] Possible bug

5 days ago

Hi, thanks for keeping this mod alive on 2.1!

Full disclosure: this bug was found by Claude (Anthropic's AI assistant), which I've been using to locally patch mods that aren't maintained for 2.1 anymore. While reviewing your fork against the original, it spotted the issue below. I checked the explanation and the patch, but the analysis is the AI's, not mine.

Cause
In Factorio 2.1, RecipePrototype::category and additional_categories were merged into categories (array). You already updated the mod's own recipes to categories, but the complexity calculation still reads recipe.category, which is now always nil for vanilla and modded 2.1 recipes:

  • line 90: shared.array_contains(excluded_recipe_categories, recipe.category)
  • lines 690–691: recipe_category_multiplier[recipe.category]

Effect
No crash, but upgrade costs are calculated differently than intended:
- recycling recipes (recycling category) are no longer excluded from the recipe graph,
- the smelting x2 multiplier is never applied, so smelted items are cheaper to upgrade.

Suggested fix
A small helper that reads both the 2.1 and the old format:

local function get_recipe_categories(recipe)
    if recipe.categories then return recipe.categories end
    if recipe.category then return {recipe.category} end
    return {"crafting"}
end

local function has_excluded_category(recipe)
    for _, category in pairs(get_recipe_categories(recipe)) do
        if shared.array_contains(excluded_recipe_categories, category) then return true end
    end
    return false
end

local function get_category_multiplier(recipe)
    local multiplier = 1
    for _, category in pairs(get_recipe_categories(recipe)) do
        local m = recipe_category_multiplier[category]
        if m ~= nil and m > multiplier then multiplier = m end
    end
    return multiplier
end

Then line 90 becomes if has_excluded_category(recipe) then and lines 689–692 become local multiplier = get_category_multiplier(recipe).

I'm running this patch locally and it loads fine.

Minor side note: loot recipe collection is commented out in processing_recipes.lua (lines 58–63), so loot-only items fall back to the fallback complexity. Not sure if that's intentional.

4 days ago

Thanks for the bug report. I've looked into this and implemented my own solution to properly check for the recipe.categories array without bloating the code.
The patch is in version 2.0.3. Effectively, this means items crafted mainly from products smelted in several steps (e.g. steel) are more expensive to upgrade.

Regarding the commented out code in processing_recipes.lua, this was already in the base 2.0 version of the mod and I have no clue was it does.
(Honestly this mod's code is a bit of a mess.)

New response