Fix bug in atmos network merging #38816
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What this does
The merge fix #38663 from 3 weeks ago revealed some ancient bugs but it is actually also partially the culprit here - the merge logic itself contained a bug when handling networks. This presents as devices not flowing correctly to pipes.
(Briefly:
pipelineis only the raw pipes, where the gas lives,networkis comprised of pipeline and devices like vents and scrubbers and stuff).Before that change, networks would just delete and attempt to rebuild entirely (including pipeline) from scratch, but it was too simple and had a problem where networks with devices and adjacent manifolds failed to ever rebuild (main manifestation was distro and waste being merged would brick both pipenets as they got caught in rebuild loops).
The change made one network consume the other rather than simply deleting both, however the bug was that the resulting network didn't rebuild critical devices data (
normal_members). Which specific devices are affected is down to initialisation order (aka nightmares to reproduce).Prior to this PR:
Later this is called:
Because
networkgets set toother.network, insidereturn_networknetworkis not null sonetwork.build_networkdoesn't run. As a result, whenother.networkis consumed in the first block of code, it never runsbuild_networkon the new unified collection.build_networkcrucially callsnetwork_expandwhich essentially syncs up the network with all the connected devices along the full pipeline. tl;dr, the merge incompletely merged, the adopted networks missed machines from newly-merged edges.To ensure the new network actually gets fully properly built, this PR changes the network merge to qdel the old network(s) such that a complete new one gets built.
While #38663 tried to preserve everything (pipeline build and network), this change deletes only the other network but preserves pipeline.
Why it's good
gas flow good for grug pipe experiment
How it was tested
A number of restarts, building various random atmos setups, testing canisters on connectors, testing merging waste and distro, checking digivalves for flow
Changelog
🆑