From fe6679c10966206796790eaf9674fa6c3b45699c Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Wed, 5 Feb 2020 22:25:54 +0200 Subject: [PATCH] Retry with walkthrough if non-walkthrough path not found --- .../com/eu/habbo/habbohotel/rooms/RoomLayout.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java index 258d023b..6d620b2d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java @@ -257,8 +257,12 @@ public class RoomLayout { return this.heightmap.replace("\r\n", "\r"); }//re - /// Pathfinder Reworked By Quadral, thanks buddy!! You Saved Morningstar <3 public final Deque findPath(RoomTile oldTile, RoomTile newTile, RoomTile goalLocation, RoomUnit roomUnit) { + return this.findPath(oldTile, newTile, goalLocation, roomUnit, false); + } + + /// Pathfinder Reworked By Quadral, thanks buddy!! You Saved Morningstar <3 + public final Deque findPath(RoomTile oldTile, RoomTile newTile, RoomTile goalLocation, RoomUnit roomUnit, boolean isWalktroughRetry) { if (this.room == null || !this.room.isLoaded() || oldTile == null || newTile == null || oldTile.equals(newTile) || newTile.state == RoomTileState.INVALID) return new LinkedList<>(); LinkedList openList = new LinkedList<>(); @@ -291,7 +295,7 @@ public class RoomLayout { double height = currentAdj.getStackHeight() - current.getStackHeight(); if (!ALLOW_FALLING && height < -MAXIMUM_STEP_HEIGHT) continue; if (currentAdj.state == RoomTileState.OPEN && height > MAXIMUM_STEP_HEIGHT) continue; - if (currentAdj.hasUnits() && (!this.room.isAllowWalkthrough() || currentAdj.equals(goalLocation))) { + if (currentAdj.hasUnits() && ((!isWalktroughRetry && !this.room.isAllowWalkthrough()) || currentAdj.equals(goalLocation))) { closedList.add(currentAdj); openList.remove(currentAdj); continue; @@ -308,6 +312,11 @@ public class RoomLayout { } } // System.out.println("Invalid Path."); + + if (!this.room.isAllowWalkthrough()) { + return this.findPath(oldTile, newTile, goalLocation, roomUnit, true); + } + return new LinkedList<>(); }