From d58cc1813614ec4d0adf2fbe493d2b8c124b906c Mon Sep 17 00:00:00 2001 From: Anuken Date: Wed, 15 Aug 2018 18:18:57 -0400 Subject: [PATCH] Fixed block targeting bug --- core/src/io/anuke/mindustry/ai/BlockIndexer.java | 3 +-- core/src/io/anuke/mindustry/core/World.java | 2 +- core/src/io/anuke/mindustry/input/MobileInput.java | 5 +++++ core/src/io/anuke/mindustry/world/Tile.java | 12 ++++++++---- .../io/anuke/mindustry/world/blocks/BuildBlock.java | 3 +-- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/core/src/io/anuke/mindustry/ai/BlockIndexer.java b/core/src/io/anuke/mindustry/ai/BlockIndexer.java index 72c8bafebd..a00170a550 100644 --- a/core/src/io/anuke/mindustry/ai/BlockIndexer.java +++ b/core/src/io/anuke/mindustry/ai/BlockIndexer.java @@ -142,7 +142,7 @@ public class BlockIndexer{ for(int ty = ry * structQuadrantSize; ty < (ry + 1) * structQuadrantSize && ty < world.height(); ty++){ Tile other = world.tile(tx, ty); - if(other == null || other.entity == null || !pred.test(other)) continue; + if(other == null || other.entity == null || other.getTeam() != team || !pred.test(other)) continue; TileEntity e = other.entity; @@ -246,7 +246,6 @@ public class BlockIndexer{ int quadrantX = tile.x / structQuadrantSize; int quadrantY = tile.y / structQuadrantSize; int index = quadrantX + quadrantY * quadWidth(); - //Log.info("Updating quadrant: {0} {1}", quadrantX, quadrantY); for(TeamData data : state.teams.getTeams()){ diff --git a/core/src/io/anuke/mindustry/core/World.java b/core/src/io/anuke/mindustry/core/World.java index ae786b66f6..85ff219551 100644 --- a/core/src/io/anuke/mindustry/core/World.java +++ b/core/src/io/anuke/mindustry/core/World.java @@ -297,7 +297,7 @@ public class World extends Module{ } public void setBlock(Tile tile, Block block, Team team){ - tile.setBlock(block); + tile.setBlock(block, team); if(block.isMultiblock()){ int offsetx = -(block.size - 1) / 2; int offsety = -(block.size - 1) / 2; diff --git a/core/src/io/anuke/mindustry/input/MobileInput.java b/core/src/io/anuke/mindustry/input/MobileInput.java index c28cc5d0c1..e2ad638d90 100644 --- a/core/src/io/anuke/mindustry/input/MobileInput.java +++ b/core/src/io/anuke/mindustry/input/MobileInput.java @@ -584,6 +584,11 @@ public class MobileInput extends InputHandler implements GestureListener{ @Override public void update(){ + if(state.is(State.menu)){ + selection.clear(); + removals.clear(); + mode = none; + } //reset state when not placing if(mode == none){ diff --git a/core/src/io/anuke/mindustry/world/Tile.java b/core/src/io/anuke/mindustry/world/Tile.java index 602932c8f9..40fe497844 100644 --- a/core/src/io/anuke/mindustry/world/Tile.java +++ b/core/src/io/anuke/mindustry/world/Tile.java @@ -167,8 +167,13 @@ public class Tile implements PosTrait, TargetTrait{ } public void setBlock(Block type, Team team){ - setBlock(type); - setTeam(team); + synchronized(tileSetLock){ + preChanged(); + this.wall = type; + this.team = (byte)team.ordinal(); + this.link = 0; + changed(); + } } public void setBlock(Block type){ @@ -393,6 +398,7 @@ public class Tile implements PosTrait, TargetTrait{ if(entity != null){ entity.removeFromProximity(); } + team = 0; } } @@ -404,8 +410,6 @@ public class Tile implements PosTrait, TargetTrait{ entity = null; } - team = 0; - Block block = block(); if(block.hasEntity()){ diff --git a/core/src/io/anuke/mindustry/world/blocks/BuildBlock.java b/core/src/io/anuke/mindustry/world/blocks/BuildBlock.java index 98502f45e3..49e26841b2 100644 --- a/core/src/io/anuke/mindustry/world/blocks/BuildBlock.java +++ b/core/src/io/anuke/mindustry/world/blocks/BuildBlock.java @@ -55,7 +55,6 @@ public class BuildBlock extends Block{ public static void onConstructFinish(Tile tile, Block block, int builderID, byte rotation, Team team){ tile.setRotation(rotation); world.setBlock(tile, block, team); - tile.setTeam(team); Effects.effect(Fx.placeBlock, tile.drawx(), tile.drawy(), block.size); //last builder was this local client player, call placed() @@ -236,7 +235,7 @@ public class BuildBlock extends Block{ progress = Mathf.clamp(progress - amount); - if(progress <= 0 || debug || state.mode.infiniteResources){ + if(progress <= 0 || state.mode.infiniteResources){ Call.onDeconstructFinish(tile, this.recipe == null ? previous : this.recipe.result); } }