diff options
author | syeyoung <cyoung06@naver.com> | 2023-02-11 19:45:58 +0900 |
---|---|---|
committer | syeyoung <cyoung06@naver.com> | 2023-02-11 19:45:58 +0900 |
commit | c25ae28babd2f68c588715cc1157a4e1ee2eb862 (patch) | |
tree | 60bc92968e319cafc99334e4b9d0a259c03bf14f /mod | |
parent | 85fa716c4f000f2e0b50c6c5f4449d4033b87f97 (diff) | |
download | Skyblock-Dungeons-Guide-c25ae28babd2f68c588715cc1157a4e1ee2eb862.tar.gz Skyblock-Dungeons-Guide-c25ae28babd2f68c588715cc1157a4e1ee2eb862.tar.bz2 Skyblock-Dungeons-Guide-c25ae28babd2f68c588715cc1157a4e1ee2eb862.zip |
- Do not deadlock pathfinder
Signed-off-by: syeyoung <cyoung06@naver.com>
Diffstat (limited to 'mod')
3 files changed, 27 insertions, 12 deletions
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/algorithms/AStarCornerCut.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/algorithms/AStarCornerCut.java index d0fc9a16..2d060fbc 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/algorithms/AStarCornerCut.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/algorithms/AStarCornerCut.java @@ -114,16 +114,21 @@ public class AStarCornerCut implements IPathfinder { @Override public void setTarget(Vec3 from) { - if (lastSx != (int)Math.round(from.xCoord * 2) || lastSy != (int)Math.round(from.yCoord*2) || lastSz != (int)Math.round(from.zCoord * 2)) { + int tobeX = (int) Math.round(from.xCoord * 2); + int tobeY = (int) Math.round(from.zCoord * 2); + int tobeZ = (int) Math.round(from.yCoord * 2); + if (lastSx != tobeX || lastSy != tobeY || lastSz != tobeZ) { } else { return; } + if (dungeonRoom.isBlocked(tobeX, tobeY, tobeZ)) return; + + this.lastSx = tobeX; + this.lastSz = tobeY; + this.lastSy = tobeZ; open.clear(); pfindIdx++; found = false; - this.lastSx = (int) Math.round(from.xCoord * 2); - this.lastSy = (int) Math.round(from.yCoord * 2); - this.lastSz = (int) Math.round(from.zCoord * 2); goalNode = openNode(lastSx, lastSy, lastSz); diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/algorithms/AStarFineGrid.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/algorithms/AStarFineGrid.java index e3b73d52..9980a7c7 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/algorithms/AStarFineGrid.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/algorithms/AStarFineGrid.java @@ -111,16 +111,21 @@ public class AStarFineGrid implements IPathfinder { @Override public void setTarget(Vec3 from) { - if (lastSx != (int)Math.round(from.xCoord * 2) || lastSy != (int)Math.round(from.yCoord*2) || lastSz != (int)Math.round(from.zCoord * 2)) { + int tobeX = (int) Math.round(from.xCoord * 2); + int tobeY = (int) Math.round(from.zCoord * 2); + int tobeZ = (int) Math.round(from.yCoord * 2); + if (lastSx != tobeX || lastSy != tobeY || lastSz != tobeZ) { } else { return; } + if (dungeonRoom.isBlocked(tobeX, tobeY, tobeZ)) return; + + this.lastSx = tobeX; + this.lastSz = tobeY; + this.lastSy = tobeZ; open.clear(); pfindIdx++; found = false; - this.lastSx = (int) Math.round(from.xCoord * 2); - this.lastSy = (int) Math.round(from.yCoord * 2); - this.lastSz = (int) Math.round(from.zCoord * 2); goalNode = openNode(lastSx, lastSy, lastSz); diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/algorithms/ThetaStar.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/algorithms/ThetaStar.java index ce7ffcc8..9365485a 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/algorithms/ThetaStar.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/algorithms/ThetaStar.java @@ -124,16 +124,21 @@ public class ThetaStar implements IPathfinder { @Override public void setTarget(Vec3 from) { - if (lastSx != (int)Math.round(from.xCoord * 2) || lastSy != (int)Math.round(from.yCoord*2) || lastSz != (int)Math.round(from.zCoord * 2)) { + int tobeX = (int) Math.round(from.xCoord * 2); + int tobeY = (int) Math.round(from.zCoord * 2); + int tobeZ = (int) Math.round(from.yCoord * 2); + if (lastSx != tobeX || lastSy != tobeY || lastSz != tobeZ) { } else { return; } + if (dungeonRoom.isBlocked(tobeX, tobeY, tobeZ)) return; + + this.lastSx = tobeX; + this.lastSz = tobeY; + this.lastSy = tobeZ; open.clear(); pfindIdx++; found = false; - this.lastSx = (int) Math.round(from.xCoord * 2); - this.lastSy = (int) Math.round(from.yCoord * 2); - this.lastSz = (int) Math.round(from.zCoord * 2); goalNode = openNode(lastSx, lastSy, lastSz); |