Pneumatic Transport

by Saienai

Removes all belts and adds pneumatic in/out stations (with built in inserters) that convert any/all items into fluid-like states for transport through pipes. Alternative lore: LIQUIFY EVERYTHING!!!!

Content
1 year, 1 month ago
1.1
2.28K
Logistics Fluids

b Previous thread erroneously locked: dfsCanRemoveItem can still cause infinite recursion

1 year, 4 months ago
(updated 1 year, 4 months ago)

Specifically, in pneumatic transport (v1.1.6, the most recent one) in /prototypes/entity_update.lua, line 81. The bug is in your mod.

The itemLinks table which is populated with all recipes using suspicious items which are marked for removal by this mod (ex. belts, inserters, and other things that can be disabled in mod settings) does not check for cyclic links, and the function mentioned in my last thread will simply cause an infinite loop. ANY item which outputs itself and is considered suspicious will cause an infinite loop and will not allow Pneumatic Transport to load. This does not happen in vanilla Factorio, but as I noted in my previous thread, in one of K2, 248k, or BZ, such recipes exist, and do cause crashes.

Again, I already fixed this issue in my local copy of PT, I'm very sure of the exact line of code that's causing it. Modifying entity_update.lua lines 80:111 to instead contain

 --depth first search to see if the crafting chain ends with non-selected items
 local function dfsCanRemoveItem(itemName, depth)
   if (not suspiciousItems[itemName]) and (not string.find(itemName, "pneumatic-")) then
     return false
   elseif itemLinks[itemName] == nil then
     return true
   elseif depth > 10 then
     return false
   else
     for _, name in ipairs(itemLinks[itemName]) do
       if not dfsCanRemoveItem(name, depth + 1) then
         return false
       end
     end
     return true
   end
 end

 --If we can remove the item based on the dfs, then we also hide the liquify/solidify recipes for said items
 local removedItems = {}
 for name, _ in pairs(suspiciousItems) do
   if dfsCanRemoveItem(name, 0) then
     removedItems[name] = 1

     if data.raw.recipe["pneumatic-liquify-"..name] then
       data.raw.recipe["pneumatic-liquify-"..name].enabled = false
       data.raw.recipe["pneumatic-liquify-"..name].hidden = true
     end
     if data.raw.recipe["pneumatic-solidify-"..name] then
       data.raw.recipe["pneumatic-solidify-"..name].enabled = false
       data.raw.recipe["pneumatic-solidify-"..name].hidden = true
     end
   end
 end

is sufficient to fix the issue. The depth limit is arbitrary but is sufficiently high that no non-cyclic recipes should be able to reach it.

1 year, 4 months ago

You are absolutely right and it will be fixed in the next update.
Not sure how I wasnt able to find the function on my first look through (and I guess I forgot about it since it didnt ping anything in my memory when I was reading your original post).
Sorry about that and thanks for double checking!

1 year, 4 months ago

No problem! It shouldn't be an issue for like 99% of modlists, but thanks for fixing it regardless.

New response