diff --git a/core/src/mindustry/ai/ControlPathfinder.java b/core/src/mindustry/ai/ControlPathfinder.java index 5b73bb1ee5..c344d4d746 100644 --- a/core/src/mindustry/ai/ControlPathfinder.java +++ b/core/src/mindustry/ai/ControlPathfinder.java @@ -45,9 +45,7 @@ public class ControlPathfinder implements Runnable{ //static access probably faster than object access static int wwidth, wheight; - - //MAIN THREAD DATA - + //increments each tile change static volatile int worldUpdateId; /** Current pathfinding thread */ @@ -56,9 +54,10 @@ public class ControlPathfinder implements Runnable{ int lastTargetId = 1; /** handles task scheduling on the update thread. */ TaskQueue queue = new TaskQueue(); + /** requests per-unit */ ObjectMap requests = new ObjectMap<>(); - //PATHFINDING THREAD DATA + /** pathfinding thread access only! */ Seq threadRequests = new Seq<>(); public ControlPathfinder(){ @@ -149,7 +148,7 @@ public class ControlPathfinder implements Runnable{ var req = new PathRequest(); req.unit = unit; req.pathType = pathType; - req.destination = destination; + req.destination.set(destination); req.curId = pathId; req.lastUpdateId = state.updateId; req.lastWorldUpdate = worldUpdateId; @@ -168,7 +167,7 @@ public class ControlPathfinder implements Runnable{ req.foundEnd = false; } - req.destination = destination; + req.destination.set(destination); req.curId = pathId; if(req.done){ @@ -366,11 +365,12 @@ public class ControlPathfinder implements Runnable{ volatile boolean done = false; volatile boolean foundEnd = false; + final Vec2 destination = new Vec2(); + final Vec2 lastDestination = new Vec2(); + volatile Unit unit; volatile int pathType; - volatile Vec2 destination; volatile int lastWorldUpdate; - volatile float stuckTime; //TODO only access on main thread?? int pathIndex; @@ -400,7 +400,7 @@ public class ControlPathfinder implements Runnable{ lastId = curId; //re-do everything when world updates - if(Time.timeSinceMillis(lastTime) > 1000 * 1 && worldUpdateId != lastWorldUpdate){ + if(Time.timeSinceMillis(lastTime) > 1000 * 2 && (worldUpdateId != lastWorldUpdate || !destination.epsilonEquals(lastDestination, 2f))){ lastTime = Time.millis(); lastWorldUpdate = worldUpdateId; pathIndex = 0; @@ -496,7 +496,7 @@ public class ControlPathfinder implements Runnable{ void clear(){ done = false; - //TODO horribly expensive + //TODO could be less expensive? frontier = new PathfindQueue(20); cameFrom.clear(); costs.clear(); @@ -511,9 +511,7 @@ public class ControlPathfinder implements Runnable{ foundEnd = false; result.clear(); - - //closed = new GridBits(world.width(), world.height()); - //queue = new PathfindQueue(16); + lastDestination.set(destination); } } } diff --git a/core/src/mindustry/ai/Pathfinder.java b/core/src/mindustry/ai/Pathfinder.java index e5f3f155e5..b76ad3d37a 100644 --- a/core/src/mindustry/ai/Pathfinder.java +++ b/core/src/mindustry/ai/Pathfinder.java @@ -215,9 +215,7 @@ public class Pathfinder implements Runnable{ return; } }catch(Throwable e){ - //TODO remove in production! - Threads.throwAppException(e); - //e.printStackTrace(); + e.printStackTrace(); } } } @@ -403,7 +401,7 @@ public class Pathfinder implements Runnable{ } } - //every 100 iterations, check the time spent - this prevents extra calls to nano time, which itself is slow + //every N iterations, check the time spent - this prevents extra calls to nano time, which itself is slow if(nsToRun >= 0 && (counter++) >= 200){ counter = 0; if(Time.timeSinceNanos(start) >= nsToRun){ diff --git a/core/src/mindustry/content/UnitTypes.java b/core/src/mindustry/content/UnitTypes.java index 3d5cd12396..c115b814b5 100644 --- a/core/src/mindustry/content/UnitTypes.java +++ b/core/src/mindustry/content/UnitTypes.java @@ -2782,7 +2782,7 @@ public class UnitTypes{ speed = 1.1f; hitSize = 44f; health = 18000; - armor = 8f; + armor = 9f; rotateSpeed = 1.6f; lockLegBase = true; legContinuousMove = true; @@ -2849,7 +2849,7 @@ public class UnitTypes{ }}); } - bullet = new BasicBulletType(9f, 75){{ + bullet = new BasicBulletType(9f, 85){{ pierceCap = 2; pierceBuilding = true;