From e95c422e7003591652f172877fdeee95c87e0be7 Mon Sep 17 00:00:00 2001 From: MobiusDev <8391001+MobiusDevelopment@users.noreply.github.com> Date: Sun, 22 Apr 2018 23:02:43 +0000 Subject: [PATCH] Prevent walk node list index out of bounds exception. --- .../java/com/l2jmobius/gameserver/model/WalkInfo.java | 2 +- .../java/com/l2jmobius/gameserver/model/WalkInfo.java | 2 +- .../java/com/l2jmobius/gameserver/model/WalkInfo.java | 2 +- .../java/com/l2jmobius/gameserver/model/WalkInfo.java | 2 +- .../java/com/l2jmobius/gameserver/model/WalkInfo.java | 2 +- .../java/com/l2jmobius/gameserver/model/WalkInfo.java | 2 +- .../java/com/l2jmobius/gameserver/model/WalkInfo.java | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/WalkInfo.java b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/WalkInfo.java index 22cfd07cc9..4e8be61b76 100644 --- a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/WalkInfo.java +++ b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/WalkInfo.java @@ -57,7 +57,7 @@ public class WalkInfo */ public L2NpcWalkerNode getCurrentNode() { - return getRoute().getNodeList().get(_currentNode); + return getRoute().getNodeList().get(Math.min(Math.max(0, _currentNode), getRoute().getNodeList().size() - 1)); } /** diff --git a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/WalkInfo.java b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/WalkInfo.java index 22cfd07cc9..4e8be61b76 100644 --- a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/WalkInfo.java +++ b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/WalkInfo.java @@ -57,7 +57,7 @@ public class WalkInfo */ public L2NpcWalkerNode getCurrentNode() { - return getRoute().getNodeList().get(_currentNode); + return getRoute().getNodeList().get(Math.min(Math.max(0, _currentNode), getRoute().getNodeList().size() - 1)); } /** diff --git a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/WalkInfo.java b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/WalkInfo.java index 22cfd07cc9..4e8be61b76 100644 --- a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/WalkInfo.java +++ b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/WalkInfo.java @@ -57,7 +57,7 @@ public class WalkInfo */ public L2NpcWalkerNode getCurrentNode() { - return getRoute().getNodeList().get(_currentNode); + return getRoute().getNodeList().get(Math.min(Math.max(0, _currentNode), getRoute().getNodeList().size() - 1)); } /** diff --git a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/model/WalkInfo.java b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/model/WalkInfo.java index 22cfd07cc9..4e8be61b76 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/model/WalkInfo.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/model/WalkInfo.java @@ -57,7 +57,7 @@ public class WalkInfo */ public L2NpcWalkerNode getCurrentNode() { - return getRoute().getNodeList().get(_currentNode); + return getRoute().getNodeList().get(Math.min(Math.max(0, _currentNode), getRoute().getNodeList().size() - 1)); } /** diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/model/WalkInfo.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/model/WalkInfo.java index bfa4e9f67e..67569455f9 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/model/WalkInfo.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/model/WalkInfo.java @@ -57,7 +57,7 @@ public class WalkInfo */ public L2NpcWalkerNode getCurrentNode() { - return getRoute().getNodeList().get(_currentNode); + return getRoute().getNodeList().get(Math.min(Math.max(0, _currentNode), getRoute().getNodeList().size() - 1)); } /** diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/model/WalkInfo.java b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/model/WalkInfo.java index 22cfd07cc9..4e8be61b76 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/model/WalkInfo.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/model/WalkInfo.java @@ -57,7 +57,7 @@ public class WalkInfo */ public L2NpcWalkerNode getCurrentNode() { - return getRoute().getNodeList().get(_currentNode); + return getRoute().getNodeList().get(Math.min(Math.max(0, _currentNode), getRoute().getNodeList().size() - 1)); } /** diff --git a/L2J_Mobius_Classic_2.0_Zaken/java/com/l2jmobius/gameserver/model/WalkInfo.java b/L2J_Mobius_Classic_2.0_Zaken/java/com/l2jmobius/gameserver/model/WalkInfo.java index 22cfd07cc9..4e8be61b76 100644 --- a/L2J_Mobius_Classic_2.0_Zaken/java/com/l2jmobius/gameserver/model/WalkInfo.java +++ b/L2J_Mobius_Classic_2.0_Zaken/java/com/l2jmobius/gameserver/model/WalkInfo.java @@ -57,7 +57,7 @@ public class WalkInfo */ public L2NpcWalkerNode getCurrentNode() { - return getRoute().getNodeList().get(_currentNode); + return getRoute().getNodeList().get(Math.min(Math.max(0, _currentNode), getRoute().getNodeList().size() - 1)); } /**