From 3b9cb63ca2e97d4149b3352b73e9f9f3f4298f1a Mon Sep 17 00:00:00 2001 From: MobiusDevelopment <8391001+MobiusDevelopment@users.noreply.github.com> Date: Thu, 21 Mar 2019 23:38:52 +0000 Subject: [PATCH] GeoEngine infinite loop precautions and cleanup. --- .../l2jmobius/gameserver/geoengine/GeoEngine.java | 6 ++++-- .../geoengine/GeoEnginePathfinding.java | 6 ++++-- .../geoengine/pathfinding/NodeBuffer.java | 15 +-------------- .../l2jmobius/gameserver/geoengine/GeoEngine.java | 6 ++++-- .../geoengine/GeoEnginePathfinding.java | 6 ++++-- .../geoengine/pathfinding/NodeBuffer.java | 15 +-------------- .../l2jmobius/gameserver/geoengine/GeoEngine.java | 6 ++++-- .../geoengine/GeoEnginePathfinding.java | 6 ++++-- .../geoengine/pathfinding/NodeBuffer.java | 15 +-------------- .../l2jmobius/gameserver/geoengine/GeoEngine.java | 6 ++++-- .../geoengine/GeoEnginePathfinding.java | 6 ++++-- .../geoengine/pathfinding/NodeBuffer.java | 15 +-------------- .../l2jmobius/gameserver/geoengine/GeoEngine.java | 6 ++++-- .../geoengine/GeoEnginePathfinding.java | 6 ++++-- .../geoengine/pathfinding/NodeBuffer.java | 15 +-------------- .../l2jmobius/gameserver/geoengine/GeoEngine.java | 6 ++++-- .../geoengine/GeoEnginePathfinding.java | 6 ++++-- .../geoengine/pathfinding/NodeBuffer.java | 15 +-------------- .../l2jmobius/gameserver/geoengine/GeoEngine.java | 6 ++++-- .../geoengine/GeoEnginePathfinding.java | 6 ++++-- .../geoengine/pathfinding/NodeBuffer.java | 15 +-------------- .../l2jmobius/gameserver/geoengine/GeoEngine.java | 6 ++++-- .../geoengine/GeoEnginePathfinding.java | 6 ++++-- .../geoengine/pathfinding/NodeBuffer.java | 15 +-------------- .../l2jmobius/gameserver/geoengine/GeoEngine.java | 6 ++++-- .../geoengine/GeoEnginePathfinding.java | 6 ++++-- .../geoengine/pathfinding/NodeBuffer.java | 15 +-------------- .../l2jmobius/gameserver/geoengine/GeoEngine.java | 6 ++++-- .../geoengine/GeoEnginePathfinding.java | 6 ++++-- .../geoengine/pathfinding/NodeBuffer.java | 15 +-------------- .../l2jmobius/gameserver/geoengine/GeoEngine.java | 6 ++++-- .../geoengine/GeoEnginePathfinding.java | 6 ++++-- .../geoengine/pathfinding/NodeBuffer.java | 15 +-------------- .../l2jmobius/gameserver/geoengine/GeoEngine.java | 6 ++++-- .../geoengine/GeoEnginePathfinding.java | 6 ++++-- .../geoengine/pathfinding/NodeBuffer.java | 15 +-------------- .../l2jmobius/gameserver/geoengine/GeoEngine.java | 6 ++++-- .../geoengine/GeoEnginePathfinding.java | 6 ++++-- .../geoengine/pathfinding/NodeBuffer.java | 15 +-------------- 39 files changed, 117 insertions(+), 234 deletions(-) diff --git a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java index 1c2a71766c..608ee75183 100644 --- a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java +++ b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java @@ -841,7 +841,8 @@ public class GeoEngine int ny = gpy; // loop - do + int count = 0; + while (count++ < Config.MAX_ITERATIONS) { direction = 0; @@ -892,7 +893,8 @@ public class GeoEngine return new GeoLocation(gox, goy, goz); } } - while (true); + + return new GeoLocation(gox, goy, goz); } /** diff --git a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java index b33b0292ac..58c22ee5f5 100644 --- a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java +++ b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java @@ -135,7 +135,8 @@ final class GeoEnginePathfinding extends GeoEngine GeoLocation nodeB = (GeoLocation) point.next(); // iterate thought the path to optimize it - while (point.hasNext()) + int count = 0; + while (point.hasNext() && (count++ < Config.MAX_ITERATIONS)) { // get node C GeoLocation nodeC = (GeoLocation) path.get(point.nextIndex()); @@ -184,7 +185,8 @@ final class GeoEnginePathfinding extends GeoEngine Node parent = target.getParent(); // while parent exists - while (parent != null) + int count = 0; + while ((parent != null) && (count++ < Config.MAX_ITERATIONS)) { // get parent <> target direction X/Y final int nx = parent.getLoc().getGeoX() - target.getLoc().getGeoX(); diff --git a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java index fa0ba3dc99..628d76be55 100644 --- a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java +++ b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java @@ -39,10 +39,6 @@ public class NodeBuffer private int _gty = 0; private short _gtz = 0; - // pathfinding statistics - private long _timeStamp = 0; - private long _lastElapsedTime = 0; - private Node _current = null; /** @@ -77,9 +73,6 @@ public class NodeBuffer */ public final Node findPath(int gox, int goy, short goz, int gtx, int gty, short gtz) { - // load timestamp - _timeStamp = System.currentTimeMillis(); - // set coordinates (middle of the line (gox,goy) - (gtx,gty), will be in the center of the buffer) _cx = gox + ((gtx - gox - _size) / 2); _cy = goy + ((gty - goy - _size) / 2); @@ -106,7 +99,7 @@ public class NodeBuffer // move pointer _current = _current.getChild(); } - while ((_current != null) && (++count < Config.MAX_ITERATIONS)); + while ((_current != null) && (count++ < Config.MAX_ITERATIONS)); return null; } @@ -132,12 +125,6 @@ public class NodeBuffer } _lock.unlock(); - _lastElapsedTime = System.currentTimeMillis() - _timeStamp; - } - - public final long getElapsedTime() - { - return _lastElapsedTime; } /** diff --git a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java index 1c2a71766c..608ee75183 100644 --- a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java +++ b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java @@ -841,7 +841,8 @@ public class GeoEngine int ny = gpy; // loop - do + int count = 0; + while (count++ < Config.MAX_ITERATIONS) { direction = 0; @@ -892,7 +893,8 @@ public class GeoEngine return new GeoLocation(gox, goy, goz); } } - while (true); + + return new GeoLocation(gox, goy, goz); } /** diff --git a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java index b33b0292ac..58c22ee5f5 100644 --- a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java +++ b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java @@ -135,7 +135,8 @@ final class GeoEnginePathfinding extends GeoEngine GeoLocation nodeB = (GeoLocation) point.next(); // iterate thought the path to optimize it - while (point.hasNext()) + int count = 0; + while (point.hasNext() && (count++ < Config.MAX_ITERATIONS)) { // get node C GeoLocation nodeC = (GeoLocation) path.get(point.nextIndex()); @@ -184,7 +185,8 @@ final class GeoEnginePathfinding extends GeoEngine Node parent = target.getParent(); // while parent exists - while (parent != null) + int count = 0; + while ((parent != null) && (count++ < Config.MAX_ITERATIONS)) { // get parent <> target direction X/Y final int nx = parent.getLoc().getGeoX() - target.getLoc().getGeoX(); diff --git a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java index fa0ba3dc99..628d76be55 100644 --- a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java +++ b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java @@ -39,10 +39,6 @@ public class NodeBuffer private int _gty = 0; private short _gtz = 0; - // pathfinding statistics - private long _timeStamp = 0; - private long _lastElapsedTime = 0; - private Node _current = null; /** @@ -77,9 +73,6 @@ public class NodeBuffer */ public final Node findPath(int gox, int goy, short goz, int gtx, int gty, short gtz) { - // load timestamp - _timeStamp = System.currentTimeMillis(); - // set coordinates (middle of the line (gox,goy) - (gtx,gty), will be in the center of the buffer) _cx = gox + ((gtx - gox - _size) / 2); _cy = goy + ((gty - goy - _size) / 2); @@ -106,7 +99,7 @@ public class NodeBuffer // move pointer _current = _current.getChild(); } - while ((_current != null) && (++count < Config.MAX_ITERATIONS)); + while ((_current != null) && (count++ < Config.MAX_ITERATIONS)); return null; } @@ -132,12 +125,6 @@ public class NodeBuffer } _lock.unlock(); - _lastElapsedTime = System.currentTimeMillis() - _timeStamp; - } - - public final long getElapsedTime() - { - return _lastElapsedTime; } /** diff --git a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java index 1c2a71766c..608ee75183 100644 --- a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java +++ b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java @@ -841,7 +841,8 @@ public class GeoEngine int ny = gpy; // loop - do + int count = 0; + while (count++ < Config.MAX_ITERATIONS) { direction = 0; @@ -892,7 +893,8 @@ public class GeoEngine return new GeoLocation(gox, goy, goz); } } - while (true); + + return new GeoLocation(gox, goy, goz); } /** diff --git a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java index b33b0292ac..58c22ee5f5 100644 --- a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java +++ b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java @@ -135,7 +135,8 @@ final class GeoEnginePathfinding extends GeoEngine GeoLocation nodeB = (GeoLocation) point.next(); // iterate thought the path to optimize it - while (point.hasNext()) + int count = 0; + while (point.hasNext() && (count++ < Config.MAX_ITERATIONS)) { // get node C GeoLocation nodeC = (GeoLocation) path.get(point.nextIndex()); @@ -184,7 +185,8 @@ final class GeoEnginePathfinding extends GeoEngine Node parent = target.getParent(); // while parent exists - while (parent != null) + int count = 0; + while ((parent != null) && (count++ < Config.MAX_ITERATIONS)) { // get parent <> target direction X/Y final int nx = parent.getLoc().getGeoX() - target.getLoc().getGeoX(); diff --git a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java index fa0ba3dc99..628d76be55 100644 --- a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java +++ b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java @@ -39,10 +39,6 @@ public class NodeBuffer private int _gty = 0; private short _gtz = 0; - // pathfinding statistics - private long _timeStamp = 0; - private long _lastElapsedTime = 0; - private Node _current = null; /** @@ -77,9 +73,6 @@ public class NodeBuffer */ public final Node findPath(int gox, int goy, short goz, int gtx, int gty, short gtz) { - // load timestamp - _timeStamp = System.currentTimeMillis(); - // set coordinates (middle of the line (gox,goy) - (gtx,gty), will be in the center of the buffer) _cx = gox + ((gtx - gox - _size) / 2); _cy = goy + ((gty - goy - _size) / 2); @@ -106,7 +99,7 @@ public class NodeBuffer // move pointer _current = _current.getChild(); } - while ((_current != null) && (++count < Config.MAX_ITERATIONS)); + while ((_current != null) && (count++ < Config.MAX_ITERATIONS)); return null; } @@ -132,12 +125,6 @@ public class NodeBuffer } _lock.unlock(); - _lastElapsedTime = System.currentTimeMillis() - _timeStamp; - } - - public final long getElapsedTime() - { - return _lastElapsedTime; } /** diff --git a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java index 1c2a71766c..608ee75183 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java @@ -841,7 +841,8 @@ public class GeoEngine int ny = gpy; // loop - do + int count = 0; + while (count++ < Config.MAX_ITERATIONS) { direction = 0; @@ -892,7 +893,8 @@ public class GeoEngine return new GeoLocation(gox, goy, goz); } } - while (true); + + return new GeoLocation(gox, goy, goz); } /** diff --git a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java index b33b0292ac..58c22ee5f5 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java @@ -135,7 +135,8 @@ final class GeoEnginePathfinding extends GeoEngine GeoLocation nodeB = (GeoLocation) point.next(); // iterate thought the path to optimize it - while (point.hasNext()) + int count = 0; + while (point.hasNext() && (count++ < Config.MAX_ITERATIONS)) { // get node C GeoLocation nodeC = (GeoLocation) path.get(point.nextIndex()); @@ -184,7 +185,8 @@ final class GeoEnginePathfinding extends GeoEngine Node parent = target.getParent(); // while parent exists - while (parent != null) + int count = 0; + while ((parent != null) && (count++ < Config.MAX_ITERATIONS)) { // get parent <> target direction X/Y final int nx = parent.getLoc().getGeoX() - target.getLoc().getGeoX(); diff --git a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java index fa0ba3dc99..628d76be55 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java @@ -39,10 +39,6 @@ public class NodeBuffer private int _gty = 0; private short _gtz = 0; - // pathfinding statistics - private long _timeStamp = 0; - private long _lastElapsedTime = 0; - private Node _current = null; /** @@ -77,9 +73,6 @@ public class NodeBuffer */ public final Node findPath(int gox, int goy, short goz, int gtx, int gty, short gtz) { - // load timestamp - _timeStamp = System.currentTimeMillis(); - // set coordinates (middle of the line (gox,goy) - (gtx,gty), will be in the center of the buffer) _cx = gox + ((gtx - gox - _size) / 2); _cy = goy + ((gty - goy - _size) / 2); @@ -106,7 +99,7 @@ public class NodeBuffer // move pointer _current = _current.getChild(); } - while ((_current != null) && (++count < Config.MAX_ITERATIONS)); + while ((_current != null) && (count++ < Config.MAX_ITERATIONS)); return null; } @@ -132,12 +125,6 @@ public class NodeBuffer } _lock.unlock(); - _lastElapsedTime = System.currentTimeMillis() - _timeStamp; - } - - public final long getElapsedTime() - { - return _lastElapsedTime; } /** diff --git a/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java b/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java index 1c2a71766c..608ee75183 100644 --- a/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java +++ b/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java @@ -841,7 +841,8 @@ public class GeoEngine int ny = gpy; // loop - do + int count = 0; + while (count++ < Config.MAX_ITERATIONS) { direction = 0; @@ -892,7 +893,8 @@ public class GeoEngine return new GeoLocation(gox, goy, goz); } } - while (true); + + return new GeoLocation(gox, goy, goz); } /** diff --git a/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java b/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java index b33b0292ac..58c22ee5f5 100644 --- a/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java +++ b/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java @@ -135,7 +135,8 @@ final class GeoEnginePathfinding extends GeoEngine GeoLocation nodeB = (GeoLocation) point.next(); // iterate thought the path to optimize it - while (point.hasNext()) + int count = 0; + while (point.hasNext() && (count++ < Config.MAX_ITERATIONS)) { // get node C GeoLocation nodeC = (GeoLocation) path.get(point.nextIndex()); @@ -184,7 +185,8 @@ final class GeoEnginePathfinding extends GeoEngine Node parent = target.getParent(); // while parent exists - while (parent != null) + int count = 0; + while ((parent != null) && (count++ < Config.MAX_ITERATIONS)) { // get parent <> target direction X/Y final int nx = parent.getLoc().getGeoX() - target.getLoc().getGeoX(); diff --git a/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java b/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java index fa0ba3dc99..628d76be55 100644 --- a/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java +++ b/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java @@ -39,10 +39,6 @@ public class NodeBuffer private int _gty = 0; private short _gtz = 0; - // pathfinding statistics - private long _timeStamp = 0; - private long _lastElapsedTime = 0; - private Node _current = null; /** @@ -77,9 +73,6 @@ public class NodeBuffer */ public final Node findPath(int gox, int goy, short goz, int gtx, int gty, short gtz) { - // load timestamp - _timeStamp = System.currentTimeMillis(); - // set coordinates (middle of the line (gox,goy) - (gtx,gty), will be in the center of the buffer) _cx = gox + ((gtx - gox - _size) / 2); _cy = goy + ((gty - goy - _size) / 2); @@ -106,7 +99,7 @@ public class NodeBuffer // move pointer _current = _current.getChild(); } - while ((_current != null) && (++count < Config.MAX_ITERATIONS)); + while ((_current != null) && (count++ < Config.MAX_ITERATIONS)); return null; } @@ -132,12 +125,6 @@ public class NodeBuffer } _lock.unlock(); - _lastElapsedTime = System.currentTimeMillis() - _timeStamp; - } - - public final long getElapsedTime() - { - return _lastElapsedTime; } /** diff --git a/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java b/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java index 1c2a71766c..608ee75183 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java +++ b/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java @@ -841,7 +841,8 @@ public class GeoEngine int ny = gpy; // loop - do + int count = 0; + while (count++ < Config.MAX_ITERATIONS) { direction = 0; @@ -892,7 +893,8 @@ public class GeoEngine return new GeoLocation(gox, goy, goz); } } - while (true); + + return new GeoLocation(gox, goy, goz); } /** diff --git a/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java b/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java index b33b0292ac..58c22ee5f5 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java +++ b/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java @@ -135,7 +135,8 @@ final class GeoEnginePathfinding extends GeoEngine GeoLocation nodeB = (GeoLocation) point.next(); // iterate thought the path to optimize it - while (point.hasNext()) + int count = 0; + while (point.hasNext() && (count++ < Config.MAX_ITERATIONS)) { // get node C GeoLocation nodeC = (GeoLocation) path.get(point.nextIndex()); @@ -184,7 +185,8 @@ final class GeoEnginePathfinding extends GeoEngine Node parent = target.getParent(); // while parent exists - while (parent != null) + int count = 0; + while ((parent != null) && (count++ < Config.MAX_ITERATIONS)) { // get parent <> target direction X/Y final int nx = parent.getLoc().getGeoX() - target.getLoc().getGeoX(); diff --git a/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java b/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java index fa0ba3dc99..628d76be55 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java +++ b/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java @@ -39,10 +39,6 @@ public class NodeBuffer private int _gty = 0; private short _gtz = 0; - // pathfinding statistics - private long _timeStamp = 0; - private long _lastElapsedTime = 0; - private Node _current = null; /** @@ -77,9 +73,6 @@ public class NodeBuffer */ public final Node findPath(int gox, int goy, short goz, int gtx, int gty, short gtz) { - // load timestamp - _timeStamp = System.currentTimeMillis(); - // set coordinates (middle of the line (gox,goy) - (gtx,gty), will be in the center of the buffer) _cx = gox + ((gtx - gox - _size) / 2); _cy = goy + ((gty - goy - _size) / 2); @@ -106,7 +99,7 @@ public class NodeBuffer // move pointer _current = _current.getChild(); } - while ((_current != null) && (++count < Config.MAX_ITERATIONS)); + while ((_current != null) && (count++ < Config.MAX_ITERATIONS)); return null; } @@ -132,12 +125,6 @@ public class NodeBuffer } _lock.unlock(); - _lastElapsedTime = System.currentTimeMillis() - _timeStamp; - } - - public final long getElapsedTime() - { - return _lastElapsedTime; } /** diff --git a/L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java b/L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java index 1c2a71766c..608ee75183 100644 --- a/L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java +++ b/L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java @@ -841,7 +841,8 @@ public class GeoEngine int ny = gpy; // loop - do + int count = 0; + while (count++ < Config.MAX_ITERATIONS) { direction = 0; @@ -892,7 +893,8 @@ public class GeoEngine return new GeoLocation(gox, goy, goz); } } - while (true); + + return new GeoLocation(gox, goy, goz); } /** diff --git a/L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java b/L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java index b33b0292ac..58c22ee5f5 100644 --- a/L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java +++ b/L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java @@ -135,7 +135,8 @@ final class GeoEnginePathfinding extends GeoEngine GeoLocation nodeB = (GeoLocation) point.next(); // iterate thought the path to optimize it - while (point.hasNext()) + int count = 0; + while (point.hasNext() && (count++ < Config.MAX_ITERATIONS)) { // get node C GeoLocation nodeC = (GeoLocation) path.get(point.nextIndex()); @@ -184,7 +185,8 @@ final class GeoEnginePathfinding extends GeoEngine Node parent = target.getParent(); // while parent exists - while (parent != null) + int count = 0; + while ((parent != null) && (count++ < Config.MAX_ITERATIONS)) { // get parent <> target direction X/Y final int nx = parent.getLoc().getGeoX() - target.getLoc().getGeoX(); diff --git a/L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java b/L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java index fa0ba3dc99..628d76be55 100644 --- a/L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java +++ b/L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java @@ -39,10 +39,6 @@ public class NodeBuffer private int _gty = 0; private short _gtz = 0; - // pathfinding statistics - private long _timeStamp = 0; - private long _lastElapsedTime = 0; - private Node _current = null; /** @@ -77,9 +73,6 @@ public class NodeBuffer */ public final Node findPath(int gox, int goy, short goz, int gtx, int gty, short gtz) { - // load timestamp - _timeStamp = System.currentTimeMillis(); - // set coordinates (middle of the line (gox,goy) - (gtx,gty), will be in the center of the buffer) _cx = gox + ((gtx - gox - _size) / 2); _cy = goy + ((gty - goy - _size) / 2); @@ -106,7 +99,7 @@ public class NodeBuffer // move pointer _current = _current.getChild(); } - while ((_current != null) && (++count < Config.MAX_ITERATIONS)); + while ((_current != null) && (count++ < Config.MAX_ITERATIONS)); return null; } @@ -132,12 +125,6 @@ public class NodeBuffer } _lock.unlock(); - _lastElapsedTime = System.currentTimeMillis() - _timeStamp; - } - - public final long getElapsedTime() - { - return _lastElapsedTime; } /** diff --git a/L2J_Mobius_C6_Interlude/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java b/L2J_Mobius_C6_Interlude/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java index 2097b35010..fe85b74dfc 100644 --- a/L2J_Mobius_C6_Interlude/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java +++ b/L2J_Mobius_C6_Interlude/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java @@ -827,7 +827,8 @@ public class GeoEngine int ny = gpy; // loop - do + int count = 0; + while (count++ < Config.MAX_ITERATIONS) { direction = 0; @@ -878,7 +879,8 @@ public class GeoEngine return new GeoLocation(gox, goy, goz); } } - while (true); + + return new GeoLocation(gox, goy, goz); } /** diff --git a/L2J_Mobius_C6_Interlude/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java b/L2J_Mobius_C6_Interlude/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java index e76b84df3c..ed8dde9ddb 100644 --- a/L2J_Mobius_C6_Interlude/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java +++ b/L2J_Mobius_C6_Interlude/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java @@ -134,7 +134,8 @@ final class GeoEnginePathfinding extends GeoEngine GeoLocation nodeB = (GeoLocation) point.next(); // iterate thought the path to optimize it - while (point.hasNext()) + int count = 0; + while (point.hasNext() && (count++ < Config.MAX_ITERATIONS)) { // get node C GeoLocation nodeC = (GeoLocation) path.get(point.nextIndex()); @@ -183,7 +184,8 @@ final class GeoEnginePathfinding extends GeoEngine Node parent = target.getParent(); // while parent exists - while (parent != null) + int count = 0; + while ((parent != null) && (count++ < Config.MAX_ITERATIONS)) { // get parent <> target direction X/Y final int nx = parent.getLoc().getGeoX() - target.getLoc().getGeoX(); diff --git a/L2J_Mobius_C6_Interlude/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java b/L2J_Mobius_C6_Interlude/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java index fa0ba3dc99..628d76be55 100644 --- a/L2J_Mobius_C6_Interlude/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java +++ b/L2J_Mobius_C6_Interlude/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java @@ -39,10 +39,6 @@ public class NodeBuffer private int _gty = 0; private short _gtz = 0; - // pathfinding statistics - private long _timeStamp = 0; - private long _lastElapsedTime = 0; - private Node _current = null; /** @@ -77,9 +73,6 @@ public class NodeBuffer */ public final Node findPath(int gox, int goy, short goz, int gtx, int gty, short gtz) { - // load timestamp - _timeStamp = System.currentTimeMillis(); - // set coordinates (middle of the line (gox,goy) - (gtx,gty), will be in the center of the buffer) _cx = gox + ((gtx - gox - _size) / 2); _cy = goy + ((gty - goy - _size) / 2); @@ -106,7 +99,7 @@ public class NodeBuffer // move pointer _current = _current.getChild(); } - while ((_current != null) && (++count < Config.MAX_ITERATIONS)); + while ((_current != null) && (count++ < Config.MAX_ITERATIONS)); return null; } @@ -132,12 +125,6 @@ public class NodeBuffer } _lock.unlock(); - _lastElapsedTime = System.currentTimeMillis() - _timeStamp; - } - - public final long getElapsedTime() - { - return _lastElapsedTime; } /** diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java index 06f36ee1b1..3457a91eab 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java @@ -827,7 +827,8 @@ public class GeoEngine int ny = gpy; // loop - do + int count = 0; + while (count++ < Config.MAX_ITERATIONS) { direction = 0; @@ -878,7 +879,8 @@ public class GeoEngine return new GeoLocation(gox, goy, goz); } } - while (true); + + return new GeoLocation(gox, goy, goz); } /** diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java index 26337f2a4e..237fcd2801 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java @@ -134,7 +134,8 @@ final class GeoEnginePathfinding extends GeoEngine GeoLocation nodeB = (GeoLocation) point.next(); // iterate thought the path to optimize it - while (point.hasNext()) + int count = 0; + while (point.hasNext() && (count++ < Config.MAX_ITERATIONS)) { // get node C GeoLocation nodeC = (GeoLocation) path.get(point.nextIndex()); @@ -183,7 +184,8 @@ final class GeoEnginePathfinding extends GeoEngine Node parent = target.getParent(); // while parent exists - while (parent != null) + int count = 0; + while ((parent != null) && (count++ < Config.MAX_ITERATIONS)) { // get parent <> target direction X/Y final int nx = parent.getLoc().getGeoX() - target.getLoc().getGeoX(); diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java index fa0ba3dc99..628d76be55 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java @@ -39,10 +39,6 @@ public class NodeBuffer private int _gty = 0; private short _gtz = 0; - // pathfinding statistics - private long _timeStamp = 0; - private long _lastElapsedTime = 0; - private Node _current = null; /** @@ -77,9 +73,6 @@ public class NodeBuffer */ public final Node findPath(int gox, int goy, short goz, int gtx, int gty, short gtz) { - // load timestamp - _timeStamp = System.currentTimeMillis(); - // set coordinates (middle of the line (gox,goy) - (gtx,gty), will be in the center of the buffer) _cx = gox + ((gtx - gox - _size) / 2); _cy = goy + ((gty - goy - _size) / 2); @@ -106,7 +99,7 @@ public class NodeBuffer // move pointer _current = _current.getChild(); } - while ((_current != null) && (++count < Config.MAX_ITERATIONS)); + while ((_current != null) && (count++ < Config.MAX_ITERATIONS)); return null; } @@ -132,12 +125,6 @@ public class NodeBuffer } _lock.unlock(); - _lastElapsedTime = System.currentTimeMillis() - _timeStamp; - } - - public final long getElapsedTime() - { - return _lastElapsedTime; } /** diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java index 1c2a71766c..608ee75183 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java @@ -841,7 +841,8 @@ public class GeoEngine int ny = gpy; // loop - do + int count = 0; + while (count++ < Config.MAX_ITERATIONS) { direction = 0; @@ -892,7 +893,8 @@ public class GeoEngine return new GeoLocation(gox, goy, goz); } } - while (true); + + return new GeoLocation(gox, goy, goz); } /** diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java index b33b0292ac..58c22ee5f5 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java @@ -135,7 +135,8 @@ final class GeoEnginePathfinding extends GeoEngine GeoLocation nodeB = (GeoLocation) point.next(); // iterate thought the path to optimize it - while (point.hasNext()) + int count = 0; + while (point.hasNext() && (count++ < Config.MAX_ITERATIONS)) { // get node C GeoLocation nodeC = (GeoLocation) path.get(point.nextIndex()); @@ -184,7 +185,8 @@ final class GeoEnginePathfinding extends GeoEngine Node parent = target.getParent(); // while parent exists - while (parent != null) + int count = 0; + while ((parent != null) && (count++ < Config.MAX_ITERATIONS)) { // get parent <> target direction X/Y final int nx = parent.getLoc().getGeoX() - target.getLoc().getGeoX(); diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java index fa0ba3dc99..628d76be55 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java @@ -39,10 +39,6 @@ public class NodeBuffer private int _gty = 0; private short _gtz = 0; - // pathfinding statistics - private long _timeStamp = 0; - private long _lastElapsedTime = 0; - private Node _current = null; /** @@ -77,9 +73,6 @@ public class NodeBuffer */ public final Node findPath(int gox, int goy, short goz, int gtx, int gty, short gtz) { - // load timestamp - _timeStamp = System.currentTimeMillis(); - // set coordinates (middle of the line (gox,goy) - (gtx,gty), will be in the center of the buffer) _cx = gox + ((gtx - gox - _size) / 2); _cy = goy + ((gty - goy - _size) / 2); @@ -106,7 +99,7 @@ public class NodeBuffer // move pointer _current = _current.getChild(); } - while ((_current != null) && (++count < Config.MAX_ITERATIONS)); + while ((_current != null) && (count++ < Config.MAX_ITERATIONS)); return null; } @@ -132,12 +125,6 @@ public class NodeBuffer } _lock.unlock(); - _lastElapsedTime = System.currentTimeMillis() - _timeStamp; - } - - public final long getElapsedTime() - { - return _lastElapsedTime; } /** diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java b/L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java index 1c2a71766c..608ee75183 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java @@ -841,7 +841,8 @@ public class GeoEngine int ny = gpy; // loop - do + int count = 0; + while (count++ < Config.MAX_ITERATIONS) { direction = 0; @@ -892,7 +893,8 @@ public class GeoEngine return new GeoLocation(gox, goy, goz); } } - while (true); + + return new GeoLocation(gox, goy, goz); } /** diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java b/L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java index b33b0292ac..58c22ee5f5 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java @@ -135,7 +135,8 @@ final class GeoEnginePathfinding extends GeoEngine GeoLocation nodeB = (GeoLocation) point.next(); // iterate thought the path to optimize it - while (point.hasNext()) + int count = 0; + while (point.hasNext() && (count++ < Config.MAX_ITERATIONS)) { // get node C GeoLocation nodeC = (GeoLocation) path.get(point.nextIndex()); @@ -184,7 +185,8 @@ final class GeoEnginePathfinding extends GeoEngine Node parent = target.getParent(); // while parent exists - while (parent != null) + int count = 0; + while ((parent != null) && (count++ < Config.MAX_ITERATIONS)) { // get parent <> target direction X/Y final int nx = parent.getLoc().getGeoX() - target.getLoc().getGeoX(); diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java b/L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java index fa0ba3dc99..628d76be55 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java @@ -39,10 +39,6 @@ public class NodeBuffer private int _gty = 0; private short _gtz = 0; - // pathfinding statistics - private long _timeStamp = 0; - private long _lastElapsedTime = 0; - private Node _current = null; /** @@ -77,9 +73,6 @@ public class NodeBuffer */ public final Node findPath(int gox, int goy, short goz, int gtx, int gty, short gtz) { - // load timestamp - _timeStamp = System.currentTimeMillis(); - // set coordinates (middle of the line (gox,goy) - (gtx,gty), will be in the center of the buffer) _cx = gox + ((gtx - gox - _size) / 2); _cy = goy + ((gty - goy - _size) / 2); @@ -106,7 +99,7 @@ public class NodeBuffer // move pointer _current = _current.getChild(); } - while ((_current != null) && (++count < Config.MAX_ITERATIONS)); + while ((_current != null) && (count++ < Config.MAX_ITERATIONS)); return null; } @@ -132,12 +125,6 @@ public class NodeBuffer } _lock.unlock(); - _lastElapsedTime = System.currentTimeMillis() - _timeStamp; - } - - public final long getElapsedTime() - { - return _lastElapsedTime; } /** diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java b/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java index 1c2a71766c..608ee75183 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java @@ -841,7 +841,8 @@ public class GeoEngine int ny = gpy; // loop - do + int count = 0; + while (count++ < Config.MAX_ITERATIONS) { direction = 0; @@ -892,7 +893,8 @@ public class GeoEngine return new GeoLocation(gox, goy, goz); } } - while (true); + + return new GeoLocation(gox, goy, goz); } /** diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java b/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java index b33b0292ac..58c22ee5f5 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java @@ -135,7 +135,8 @@ final class GeoEnginePathfinding extends GeoEngine GeoLocation nodeB = (GeoLocation) point.next(); // iterate thought the path to optimize it - while (point.hasNext()) + int count = 0; + while (point.hasNext() && (count++ < Config.MAX_ITERATIONS)) { // get node C GeoLocation nodeC = (GeoLocation) path.get(point.nextIndex()); @@ -184,7 +185,8 @@ final class GeoEnginePathfinding extends GeoEngine Node parent = target.getParent(); // while parent exists - while (parent != null) + int count = 0; + while ((parent != null) && (count++ < Config.MAX_ITERATIONS)) { // get parent <> target direction X/Y final int nx = parent.getLoc().getGeoX() - target.getLoc().getGeoX(); diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java b/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java index fa0ba3dc99..628d76be55 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java @@ -39,10 +39,6 @@ public class NodeBuffer private int _gty = 0; private short _gtz = 0; - // pathfinding statistics - private long _timeStamp = 0; - private long _lastElapsedTime = 0; - private Node _current = null; /** @@ -77,9 +73,6 @@ public class NodeBuffer */ public final Node findPath(int gox, int goy, short goz, int gtx, int gty, short gtz) { - // load timestamp - _timeStamp = System.currentTimeMillis(); - // set coordinates (middle of the line (gox,goy) - (gtx,gty), will be in the center of the buffer) _cx = gox + ((gtx - gox - _size) / 2); _cy = goy + ((gty - goy - _size) / 2); @@ -106,7 +99,7 @@ public class NodeBuffer // move pointer _current = _current.getChild(); } - while ((_current != null) && (++count < Config.MAX_ITERATIONS)); + while ((_current != null) && (count++ < Config.MAX_ITERATIONS)); return null; } @@ -132,12 +125,6 @@ public class NodeBuffer } _lock.unlock(); - _lastElapsedTime = System.currentTimeMillis() - _timeStamp; - } - - public final long getElapsedTime() - { - return _lastElapsedTime; } /** diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java index 1c2a71766c..608ee75183 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/com/l2jmobius/gameserver/geoengine/GeoEngine.java @@ -841,7 +841,8 @@ public class GeoEngine int ny = gpy; // loop - do + int count = 0; + while (count++ < Config.MAX_ITERATIONS) { direction = 0; @@ -892,7 +893,8 @@ public class GeoEngine return new GeoLocation(gox, goy, goz); } } - while (true); + + return new GeoLocation(gox, goy, goz); } /** diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java index b33b0292ac..58c22ee5f5 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/com/l2jmobius/gameserver/geoengine/GeoEnginePathfinding.java @@ -135,7 +135,8 @@ final class GeoEnginePathfinding extends GeoEngine GeoLocation nodeB = (GeoLocation) point.next(); // iterate thought the path to optimize it - while (point.hasNext()) + int count = 0; + while (point.hasNext() && (count++ < Config.MAX_ITERATIONS)) { // get node C GeoLocation nodeC = (GeoLocation) path.get(point.nextIndex()); @@ -184,7 +185,8 @@ final class GeoEnginePathfinding extends GeoEngine Node parent = target.getParent(); // while parent exists - while (parent != null) + int count = 0; + while ((parent != null) && (count++ < Config.MAX_ITERATIONS)) { // get parent <> target direction X/Y final int nx = parent.getLoc().getGeoX() - target.getLoc().getGeoX(); diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java index fa0ba3dc99..628d76be55 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/com/l2jmobius/gameserver/geoengine/pathfinding/NodeBuffer.java @@ -39,10 +39,6 @@ public class NodeBuffer private int _gty = 0; private short _gtz = 0; - // pathfinding statistics - private long _timeStamp = 0; - private long _lastElapsedTime = 0; - private Node _current = null; /** @@ -77,9 +73,6 @@ public class NodeBuffer */ public final Node findPath(int gox, int goy, short goz, int gtx, int gty, short gtz) { - // load timestamp - _timeStamp = System.currentTimeMillis(); - // set coordinates (middle of the line (gox,goy) - (gtx,gty), will be in the center of the buffer) _cx = gox + ((gtx - gox - _size) / 2); _cy = goy + ((gty - goy - _size) / 2); @@ -106,7 +99,7 @@ public class NodeBuffer // move pointer _current = _current.getChild(); } - while ((_current != null) && (++count < Config.MAX_ITERATIONS)); + while ((_current != null) && (count++ < Config.MAX_ITERATIONS)); return null; } @@ -132,12 +125,6 @@ public class NodeBuffer } _lock.unlock(); - _lastElapsedTime = System.currentTimeMillis() - _timeStamp; - } - - public final long getElapsedTime() - { - return _lastElapsedTime; } /**