diff --git a/core/src/io/anuke/mindustry/content/blocks/Blocks.java b/core/src/io/anuke/mindustry/content/blocks/Blocks.java index 248d0cb95d..d4fbd0d319 100644 --- a/core/src/io/anuke/mindustry/content/blocks/Blocks.java +++ b/core/src/io/anuke/mindustry/content/blocks/Blocks.java @@ -35,8 +35,6 @@ public class Blocks extends BlockList implements ContentList{ blockpart = new BlockPart(); spawn = new Block("spawn"){ - { - } public void drawShadow(Tile tile){} diff --git a/core/src/io/anuke/mindustry/world/Block.java b/core/src/io/anuke/mindustry/world/Block.java index f10990e20b..85d38301d9 100644 --- a/core/src/io/anuke/mindustry/world/Block.java +++ b/core/src/io/anuke/mindustry/world/Block.java @@ -162,7 +162,8 @@ public class Block extends BaseBlock { public Array getPowerConnections(Tile tile, Array out){ out.clear(); for(Tile other : tile.entity.proximity()){ - if(other.entity.power != null && !(consumesPower && other.block().consumesPower && !outputsPower && !other.block().outputsPower)){ + if(other.entity.power != null && !(consumesPower && other.block().consumesPower && !outputsPower && !other.block().outputsPower) + && !tile.entity.power.links.contains(other.packedPosition())){ out.add(other); } } diff --git a/core/src/io/anuke/mindustry/world/blocks/power/PowerGraph.java b/core/src/io/anuke/mindustry/world/blocks/power/PowerGraph.java index f6be43f919..cbb38364a1 100644 --- a/core/src/io/anuke/mindustry/world/blocks/power/PowerGraph.java +++ b/core/src/io/anuke/mindustry/world/blocks/power/PowerGraph.java @@ -1,6 +1,7 @@ package io.anuke.mindustry.world.blocks.power; import com.badlogic.gdx.utils.Array; +import com.badlogic.gdx.utils.IntSet; import com.badlogic.gdx.utils.ObjectSet; import com.badlogic.gdx.utils.Queue; import io.anuke.mindustry.world.Tile; @@ -11,6 +12,7 @@ public class PowerGraph{ private final static Queue queue = new Queue<>(); private final static Array outArray1 = new Array<>(); private final static Array outArray2 = new Array<>(); + private final static IntSet closedSet = new IntSet(); private final ObjectSet producers = new ObjectSet<>(); private final ObjectSet consumers = new ObjectSet<>(); @@ -101,13 +103,15 @@ public class PowerGraph{ public synchronized void reflow(Tile tile){ queue.clear(); queue.addLast(tile); + closedSet.clear(); while(queue.size > 0){ Tile child = queue.removeFirst(); child.entity.power.graph = this; add(child); for(Tile next : child.block().getPowerConnections(child, outArray2)){ - if(next.entity.power != null && next.entity.power.graph == null){ + if(next.entity.power != null && next.entity.power.graph == null && !closedSet.contains(next.packedPosition())){ queue.addLast(next); + closedSet.add(next.packedPosition()); } } } @@ -115,6 +119,7 @@ public class PowerGraph{ public synchronized void remove(Tile tile){ clear(); + closedSet.clear(); for(Tile other : tile.block().getPowerConnections(tile, outArray1)){ if(other.entity.power == null || other.entity.power.graph != null) continue; @@ -126,8 +131,9 @@ public class PowerGraph{ child.entity.power.graph = graph; graph.add(child); for(Tile next : child.block().getPowerConnections(child, outArray2)){ - if(next != tile && next.entity.power != null && next.entity.power.graph == null){ + if(next != tile && next.entity.power != null && next.entity.power.graph == null && !closedSet.contains(next.packedPosition())){ queue.addLast(next); + closedSet.add(next.packedPosition()); } } }