Bug: Adding repeaters to a new channel breaks connections on existing channels
I found bug related to how the mod rebuilds wire mesh connections between repeaters. When you assign repeaters to a new channel, any repeaters already connected on other channels lose their connections and get reassigned to different circuit numbers.
Steps to reproduce:
1. Place two repeaters and assign them both to channel "Foo". Connect circuit wires — both ends share the same circuit network number (e.g. 1829).
2. Place two more repeaters and assign them to a new channel "Bar".
3. The "Foo" repeaters are now on mismatched circuit numbers (e.g. 1829 and 1831) and are no longer connected to each other.
You can temporarily restore a broken channel by opening its renamer and committing the same name without changing it, but this just breaks the other channel in the process.
Root cause:
The problem is in ProcessFullLinkMesh. Every time a channel assignment changes, this function calls RemoveAllMeshConnections() followed by MakeMeshConnections(channel) — where channel is only the one channel that was just modified. This means all other channels get torn down but never rebuilt. The same issue exists in CheckPowerReturnedRestoreConnections, which loops over all towers calling MakeMeshConnections per tower, meaning channels can be rebuilt multiple redundant times while others are skipped entirely.
Fix:
The solution is a new RebuildAllMeshConnections function that tears everything down once and then rebuilds every distinct active channel in a single pass:
local function RebuildAllMeshConnections()
RemoveAllMeshConnections()
local rebuilt = {}
for _, surface in pairs(game.surfaces) do
for _, radar in pairs(surface.find_entities_filtered{ name = "wireless-circuit-tower" }) do
if radar.valid and radar.backer_name ~= default_channel_name then
if not rebuilt[radar.backer_name] then
MakeMeshConnections(radar.backer_name)
rebuilt[radar.backer_name] = true
end
end
end
end
end
Then replace the body of ProcessFullLinkMesh and CheckPowerReturnedRestoreConnections to call RebuildAllMeshConnections(), and do the same for the MakeMeshConnections call in the power-restore branch of UpdateTowerPowerStates.
Happy to share a fully patched control.lua if that would be helpful.