diff --git a/core/src/io/anuke/mindustry/entities/TileEntity.java b/core/src/io/anuke/mindustry/entities/TileEntity.java index 98c7a767bb..426da9fb6c 100644 --- a/core/src/io/anuke/mindustry/entities/TileEntity.java +++ b/core/src/io/anuke/mindustry/entities/TileEntity.java @@ -157,9 +157,7 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{ } public void removeFromProximity(){ - if(power != null){ - tile.block().powerGraphRemoved(tile); - } + tile.block().onProximityRemoved(tile); GridPoint2[] nearby = Edges.getEdges(tile.block().size); for(GridPoint2 point : nearby){ @@ -202,7 +200,7 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{ proximity.add(tile); } - if(tile.block().hasPower) tile.block().updatePowerGraph(tile); + tile.block().onProximityAdded(tile); tile.block().onProximityUpdate(tile); } diff --git a/core/src/io/anuke/mindustry/world/Block.java b/core/src/io/anuke/mindustry/world/Block.java index 85d38301d9..90e513763b 100644 --- a/core/src/io/anuke/mindustry/world/Block.java +++ b/core/src/io/anuke/mindustry/world/Block.java @@ -139,7 +139,17 @@ public class Block extends BaseBlock { return drops != null && drops.item == item; } - public void updatePowerGraph(Tile tile){ + public void onProximityRemoved(Tile tile){ + if(tile.entity.power != null){ + tile.block().powerGraphRemoved(tile); + } + } + + public void onProximityAdded(Tile tile){ + if(tile.block().hasPower) tile.block().updatePowerGraph(tile); + } + + protected void updatePowerGraph(Tile tile){ TileEntity entity = tile.entity(); for(Tile other : getPowerConnections(tile, tempTiles)){ @@ -149,7 +159,7 @@ public class Block extends BaseBlock { } } - public void powerGraphRemoved(Tile tile){ + protected void powerGraphRemoved(Tile tile){ tile.entity.power.graph.remove(tile); for(int i = 0; i < tile.entity.power.links.size; i++){ Tile other = world.tile(tile.entity.power.links.get(i)); diff --git a/core/src/io/anuke/mindustry/world/blocks/storage/StorageBlock.java b/core/src/io/anuke/mindustry/world/blocks/storage/StorageBlock.java index acb586fabb..32c085756e 100644 --- a/core/src/io/anuke/mindustry/world/blocks/storage/StorageBlock.java +++ b/core/src/io/anuke/mindustry/world/blocks/storage/StorageBlock.java @@ -19,8 +19,7 @@ public abstract class StorageBlock extends Block{ } @Override - public void onProximityUpdate(Tile tile){ - super.onProximityUpdate(tile); + public void onProximityAdded(Tile tile){ StorageEntity entity = tile.entity(); entity.graph.add(tile); @@ -33,8 +32,7 @@ public abstract class StorageBlock extends Block{ } @Override - public void removed(Tile tile){ - super.removed(tile); + public void onProximityRemoved(Tile tile){ StorageEntity entity = tile.entity(); entity.graph.remove(tile); } diff --git a/core/src/io/anuke/mindustry/world/blocks/storage/StorageGraph.java b/core/src/io/anuke/mindustry/world/blocks/storage/StorageGraph.java index 6fbb31ec39..a7f8c1feb9 100644 --- a/core/src/io/anuke/mindustry/world/blocks/storage/StorageGraph.java +++ b/core/src/io/anuke/mindustry/world/blocks/storage/StorageGraph.java @@ -26,15 +26,13 @@ public class StorageGraph{ other.entity().graph = null; } - if(tiles.remove(tile) && tile.block() instanceof CoreBlock){ - cores --; - } - cores = 0; for(Tile other : tile.entity.proximity()){ - if(other.block() instanceof StorageBlock){ - reflow(tile, other); + if(other.block() instanceof StorageBlock && other.entity().graph == null){ + StorageGraph graph = new StorageGraph(); + other.entity().graph = graph; + graph.reflow(tile, other); } } } @@ -58,7 +56,7 @@ public class StorageGraph{ } public void merge(StorageGraph other){ - if(this == other) return; + if(this == other || other == null) return; for(Tile tile : other.tiles){ StorageEntity e = tile.entity(); diff --git a/server/src/io/anuke/mindustry/server/ServerControl.java b/server/src/io/anuke/mindustry/server/ServerControl.java index b8a88fb15c..e9601b65dc 100644 --- a/server/src/io/anuke/mindustry/server/ServerControl.java +++ b/server/src/io/anuke/mindustry/server/ServerControl.java @@ -97,7 +97,7 @@ public class ServerControl extends Module{ world.sectors.save(); gameOvers = 0; inExtraRound = true; - Settings.putInt("sector_x", world.getSector().x + world.getSector().width); + Settings.putInt("sector_x", world.getSector().x + 1); Settings.save(); Call.onInfoMessage("[accent]Sector conquered![]\n" + roundExtraTime + " seconds until deployment in next sector.");