From ebbf01c6e5207d03dbaca1198d0bda4faa72dca5 Mon Sep 17 00:00:00 2001 From: Anuken Date: Thu, 20 Sep 2018 09:29:16 -0400 Subject: [PATCH] Synchronization --- .../mindustry/world/blocks/power/PowerGraph.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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 c4f9115555..c17ad9986a 100644 --- a/core/src/io/anuke/mindustry/world/blocks/power/PowerGraph.java +++ b/core/src/io/anuke/mindustry/world/blocks/power/PowerGraph.java @@ -28,7 +28,7 @@ public class PowerGraph{ return graphID; } - public void update(){ + public synchronized void update(){ if(threads.getFrameID() == lastFrameUpdated || consumers.size == 0 || producers.size == 0){ return; } @@ -70,13 +70,13 @@ public class PowerGraph{ } } - public void add(PowerGraph graph){ + public synchronized void add(PowerGraph graph){ for(Tile tile : graph.all){ add(tile); } } - public void add(Tile tile){ + public synchronized void add(Tile tile){ tile.entity.power.graph = this; all.add(tile); @@ -89,7 +89,7 @@ public class PowerGraph{ } } - public void clear(){ + public synchronized void clear(){ for(Tile other : all){ other.entity.power.graph = null; } @@ -98,7 +98,7 @@ public class PowerGraph{ consumers.clear(); } - public void reflow(Tile tile){ + public synchronized void reflow(Tile tile){ queue.clear(); queue.addLast(tile); while(queue.size > 0){ @@ -113,7 +113,7 @@ public class PowerGraph{ } } - public void remove(Tile tile){ + public synchronized void remove(Tile tile){ clear(); for(Tile other : tile.block().getPowerConnections(tile, outArray1)){