From b87cbd398bcd780a1e02509720b6fd29adca083a Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Thu, 6 Feb 2020 01:06:49 +0200 Subject: [PATCH] Do not cancel navigation if overriding path is non-existent --- .../java/com/eu/habbo/habbohotel/rooms/RoomLayout.java | 2 +- .../java/com/eu/habbo/habbohotel/rooms/RoomUnit.java | 10 ++++++---- 2 files changed, 7 insertions(+), 5 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 6d620b2d..3f99af34 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java @@ -317,7 +317,7 @@ public class RoomLayout { return this.findPath(oldTile, newTile, goalLocation, roomUnit, true); } - return new LinkedList<>(); + return null; } private RoomTile findTile(List tiles, short x, short y) { diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java index 47489f78..a876a4d4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java @@ -177,6 +177,9 @@ public class RoomUnit { } Deque peekPath = room.getLayout().findPath(this.currentLocation, this.path.peek(), this.goalLocation, this); + + if (peekPath == null) peekPath = new LinkedList<>(); + if (peekPath.size() >= 3) { if (path.isEmpty()) return true; @@ -543,10 +546,9 @@ public class RoomUnit { public void findPath() { - if (this.room != null && this.room.getLayout() != null && this.goalLocation != null && (this.goalLocation.isWalkable() || this.room.canSitOrLayAt(this.goalLocation.x, this.goalLocation.y) || this.canOverrideTile(this.goalLocation))) - { - - this.path = this.room.getLayout().findPath(this.currentLocation, this.goalLocation, this.goalLocation, this); + if (this.room != null && this.room.getLayout() != null && this.goalLocation != null && (this.goalLocation.isWalkable() || this.room.canSitOrLayAt(this.goalLocation.x, this.goalLocation.y) || this.canOverrideTile(this.goalLocation))) { + Deque path = this.room.getLayout().findPath(this.currentLocation, this.goalLocation, this.goalLocation, this); + if (path != null) this.path = path; } }