diff --git a/core/src/mindustry/ai/ControlPathfinder.java b/core/src/mindustry/ai/ControlPathfinder.java index c6e1c5aa86..1853fe865b 100644 --- a/core/src/mindustry/ai/ControlPathfinder.java +++ b/core/src/mindustry/ai/ControlPathfinder.java @@ -64,8 +64,17 @@ public class ControlPathfinder{ start(); }); + //only update the world when a solid block is removed or placed, everything else doesn't matter + Events.on(TilePreChangeEvent.class, e -> { + if(e.tile.solid()){ + worldUpdateId ++; + } + }); + Events.on(TileChangeEvent.class, e -> { - worldUpdateId ++; + if(e.tile.solid()){ + worldUpdateId ++; + } }); Events.on(ResetEvent.class, event -> stop()); @@ -447,7 +456,7 @@ public class ControlPathfinder{ lastId = curId; //re-do everything when world updates - if(Time.timeSinceMillis(lastTime) > 1000 * 2 && (worldUpdateId != lastWorldUpdate || !destination.epsilonEquals(lastDestination, 2f))){ + if(Time.timeSinceMillis(lastTime) > 1000 * 3 && (worldUpdateId != lastWorldUpdate || !destination.epsilonEquals(lastDestination, 2f))){ lastTime = Time.millis(); lastWorldUpdate = worldUpdateId; pathIndex = 0; diff --git a/core/src/mindustry/input/DesktopInput.java b/core/src/mindustry/input/DesktopInput.java index 07ab619cbc..9369c74deb 100644 --- a/core/src/mindustry/input/DesktopInput.java +++ b/core/src/mindustry/input/DesktopInput.java @@ -280,7 +280,7 @@ public class DesktopInput extends InputHandler{ } //validate commanding units - selectedUnits.removeAll(u -> !u.isCommandable()); + selectedUnits.removeAll(u -> !u.isCommandable() || !u.isValid()); if(!scene.hasMouse() && !locked){ if(Core.input.keyDown(Binding.control) && Core.input.keyTap(Binding.select)){