Removal of CopyOnWriteArrayList from CellPathFinding.

This commit is contained in:
MobiusDevelopment
2022-07-18 08:28:59 +00:00
parent 03aef1c2bd
commit 8658f3a75d
28 changed files with 756 additions and 560 deletions

View File

@@ -17,9 +17,9 @@
package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes; package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.ListIterator;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -114,7 +114,7 @@ public class CellPathFinding extends PathFinding
{ {
if (_debugItems == null) if (_debugItems == null)
{ {
_debugItems = new CopyOnWriteArrayList<>(); _debugItems = new LinkedList<>();
} }
else else
{ {
@@ -179,28 +179,35 @@ public class CellPathFinding extends PathFinding
_postFilterPlayableUses++; _postFilterPlayableUses++;
} }
boolean remove; ListIterator<AbstractNodeLoc> middlePoint;
int currentX;
int currentY;
int currentZ;
int pass = 0; int pass = 0;
boolean remove;
do do
{ {
pass++; pass++;
_postFilterPasses++; _postFilterPasses++;
remove = false; remove = false;
final Iterator<AbstractNodeLoc> endPoint = path.iterator(); middlePoint = path.listIterator();
endPoint.next(); currentX = x;
int currentX = x; currentY = y;
int currentY = y; currentZ = z;
int currentZ = z;
int midPoint = 0; while (middlePoint.hasNext())
while (endPoint.hasNext())
{ {
final AbstractNodeLoc locMiddle = path.get(midPoint); final AbstractNodeLoc locMiddle = middlePoint.next();
final AbstractNodeLoc locEnd = endPoint.next(); if (!middlePoint.hasNext())
{
break;
}
final AbstractNodeLoc locEnd = path.get(middlePoint.nextIndex());
if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance)) if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance))
{ {
path.remove(midPoint); middlePoint.remove();
remove = true; remove = true;
if (debug) if (debug)
{ {
@@ -212,7 +219,6 @@ public class CellPathFinding extends PathFinding
currentX = locMiddle.getX(); currentX = locMiddle.getX();
currentY = locMiddle.getY(); currentY = locMiddle.getY();
currentZ = locMiddle.getZ(); currentZ = locMiddle.getZ();
midPoint++;
} }
} }
} }
@@ -231,7 +237,7 @@ public class CellPathFinding extends PathFinding
private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node) private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node)
{ {
final List<AbstractNodeLoc> path = new CopyOnWriteArrayList<>(); final LinkedList<AbstractNodeLoc> path = new LinkedList<>();
int previousDirectionX = Integer.MIN_VALUE; int previousDirectionX = Integer.MIN_VALUE;
int previousDirectionY = Integer.MIN_VALUE; int previousDirectionY = Integer.MIN_VALUE;
int directionX; int directionX;
@@ -267,16 +273,17 @@ public class CellPathFinding extends PathFinding
previousDirectionX = directionX; previousDirectionX = directionX;
previousDirectionY = directionY; previousDirectionY = directionY;
path.add(0, tempNode.getLoc()); path.addFirst(tempNode.getLoc());
tempNode.setLoc(null); tempNode.setLoc(null);
} }
tempNode = tempNode.getParent(); tempNode = tempNode.getParent();
} }
return path; return path;
} }
private final CellNodeBuffer alloc(int size, boolean playable) private CellNodeBuffer alloc(int size, boolean playable)
{ {
CellNodeBuffer current = null; CellNodeBuffer current = null;
for (BufferInfo i : _allBuffers) for (BufferInfo i : _allBuffers)
@@ -328,7 +335,7 @@ public class CellPathFinding extends PathFinding
return current; return current;
} }
private final void dropDebugItem(int itemId, int num, AbstractNodeLoc loc) private void dropDebugItem(int itemId, int num, AbstractNodeLoc loc)
{ {
final Item item = new Item(IdManager.getInstance().getNextId(), itemId); final Item item = new Item(IdManager.getInstance().getNextId(), itemId);
item.setCount(num); item.setCount(num);
@@ -336,7 +343,7 @@ public class CellPathFinding extends PathFinding
_debugItems.add(item); _debugItems.add(item);
} }
private static final class BufferInfo private static class BufferInfo
{ {
final int mapSize; final int mapSize;
final int count; final int count;

View File

@@ -17,9 +17,9 @@
package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes; package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.ListIterator;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -114,7 +114,7 @@ public class CellPathFinding extends PathFinding
{ {
if (_debugItems == null) if (_debugItems == null)
{ {
_debugItems = new CopyOnWriteArrayList<>(); _debugItems = new LinkedList<>();
} }
else else
{ {
@@ -179,28 +179,35 @@ public class CellPathFinding extends PathFinding
_postFilterPlayableUses++; _postFilterPlayableUses++;
} }
boolean remove; ListIterator<AbstractNodeLoc> middlePoint;
int currentX;
int currentY;
int currentZ;
int pass = 0; int pass = 0;
boolean remove;
do do
{ {
pass++; pass++;
_postFilterPasses++; _postFilterPasses++;
remove = false; remove = false;
final Iterator<AbstractNodeLoc> endPoint = path.iterator(); middlePoint = path.listIterator();
endPoint.next(); currentX = x;
int currentX = x; currentY = y;
int currentY = y; currentZ = z;
int currentZ = z;
int midPoint = 0; while (middlePoint.hasNext())
while (endPoint.hasNext())
{ {
final AbstractNodeLoc locMiddle = path.get(midPoint); final AbstractNodeLoc locMiddle = middlePoint.next();
final AbstractNodeLoc locEnd = endPoint.next(); if (!middlePoint.hasNext())
{
break;
}
final AbstractNodeLoc locEnd = path.get(middlePoint.nextIndex());
if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance)) if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance))
{ {
path.remove(midPoint); middlePoint.remove();
remove = true; remove = true;
if (debug) if (debug)
{ {
@@ -212,7 +219,6 @@ public class CellPathFinding extends PathFinding
currentX = locMiddle.getX(); currentX = locMiddle.getX();
currentY = locMiddle.getY(); currentY = locMiddle.getY();
currentZ = locMiddle.getZ(); currentZ = locMiddle.getZ();
midPoint++;
} }
} }
} }
@@ -231,7 +237,7 @@ public class CellPathFinding extends PathFinding
private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node) private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node)
{ {
final List<AbstractNodeLoc> path = new CopyOnWriteArrayList<>(); final LinkedList<AbstractNodeLoc> path = new LinkedList<>();
int previousDirectionX = Integer.MIN_VALUE; int previousDirectionX = Integer.MIN_VALUE;
int previousDirectionY = Integer.MIN_VALUE; int previousDirectionY = Integer.MIN_VALUE;
int directionX; int directionX;
@@ -267,16 +273,17 @@ public class CellPathFinding extends PathFinding
previousDirectionX = directionX; previousDirectionX = directionX;
previousDirectionY = directionY; previousDirectionY = directionY;
path.add(0, tempNode.getLoc()); path.addFirst(tempNode.getLoc());
tempNode.setLoc(null); tempNode.setLoc(null);
} }
tempNode = tempNode.getParent(); tempNode = tempNode.getParent();
} }
return path; return path;
} }
private final CellNodeBuffer alloc(int size, boolean playable) private CellNodeBuffer alloc(int size, boolean playable)
{ {
CellNodeBuffer current = null; CellNodeBuffer current = null;
for (BufferInfo i : _allBuffers) for (BufferInfo i : _allBuffers)
@@ -328,7 +335,7 @@ public class CellPathFinding extends PathFinding
return current; return current;
} }
private final void dropDebugItem(int itemId, int num, AbstractNodeLoc loc) private void dropDebugItem(int itemId, int num, AbstractNodeLoc loc)
{ {
final Item item = new Item(IdManager.getInstance().getNextId(), itemId); final Item item = new Item(IdManager.getInstance().getNextId(), itemId);
item.setCount(num); item.setCount(num);
@@ -336,7 +343,7 @@ public class CellPathFinding extends PathFinding
_debugItems.add(item); _debugItems.add(item);
} }
private static final class BufferInfo private static class BufferInfo
{ {
final int mapSize; final int mapSize;
final int count; final int count;

View File

@@ -17,9 +17,9 @@
package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes; package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.ListIterator;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -114,7 +114,7 @@ public class CellPathFinding extends PathFinding
{ {
if (_debugItems == null) if (_debugItems == null)
{ {
_debugItems = new CopyOnWriteArrayList<>(); _debugItems = new LinkedList<>();
} }
else else
{ {
@@ -179,28 +179,35 @@ public class CellPathFinding extends PathFinding
_postFilterPlayableUses++; _postFilterPlayableUses++;
} }
boolean remove; ListIterator<AbstractNodeLoc> middlePoint;
int currentX;
int currentY;
int currentZ;
int pass = 0; int pass = 0;
boolean remove;
do do
{ {
pass++; pass++;
_postFilterPasses++; _postFilterPasses++;
remove = false; remove = false;
final Iterator<AbstractNodeLoc> endPoint = path.iterator(); middlePoint = path.listIterator();
endPoint.next(); currentX = x;
int currentX = x; currentY = y;
int currentY = y; currentZ = z;
int currentZ = z;
int midPoint = 0; while (middlePoint.hasNext())
while (endPoint.hasNext())
{ {
final AbstractNodeLoc locMiddle = path.get(midPoint); final AbstractNodeLoc locMiddle = middlePoint.next();
final AbstractNodeLoc locEnd = endPoint.next(); if (!middlePoint.hasNext())
{
break;
}
final AbstractNodeLoc locEnd = path.get(middlePoint.nextIndex());
if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance)) if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance))
{ {
path.remove(midPoint); middlePoint.remove();
remove = true; remove = true;
if (debug) if (debug)
{ {
@@ -212,7 +219,6 @@ public class CellPathFinding extends PathFinding
currentX = locMiddle.getX(); currentX = locMiddle.getX();
currentY = locMiddle.getY(); currentY = locMiddle.getY();
currentZ = locMiddle.getZ(); currentZ = locMiddle.getZ();
midPoint++;
} }
} }
} }
@@ -231,7 +237,7 @@ public class CellPathFinding extends PathFinding
private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node) private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node)
{ {
final List<AbstractNodeLoc> path = new CopyOnWriteArrayList<>(); final LinkedList<AbstractNodeLoc> path = new LinkedList<>();
int previousDirectionX = Integer.MIN_VALUE; int previousDirectionX = Integer.MIN_VALUE;
int previousDirectionY = Integer.MIN_VALUE; int previousDirectionY = Integer.MIN_VALUE;
int directionX; int directionX;
@@ -267,16 +273,17 @@ public class CellPathFinding extends PathFinding
previousDirectionX = directionX; previousDirectionX = directionX;
previousDirectionY = directionY; previousDirectionY = directionY;
path.add(0, tempNode.getLoc()); path.addFirst(tempNode.getLoc());
tempNode.setLoc(null); tempNode.setLoc(null);
} }
tempNode = tempNode.getParent(); tempNode = tempNode.getParent();
} }
return path; return path;
} }
private final CellNodeBuffer alloc(int size, boolean playable) private CellNodeBuffer alloc(int size, boolean playable)
{ {
CellNodeBuffer current = null; CellNodeBuffer current = null;
for (BufferInfo i : _allBuffers) for (BufferInfo i : _allBuffers)
@@ -328,7 +335,7 @@ public class CellPathFinding extends PathFinding
return current; return current;
} }
private final void dropDebugItem(int itemId, int num, AbstractNodeLoc loc) private void dropDebugItem(int itemId, int num, AbstractNodeLoc loc)
{ {
final Item item = new Item(IdManager.getInstance().getNextId(), itemId); final Item item = new Item(IdManager.getInstance().getNextId(), itemId);
item.setCount(num); item.setCount(num);
@@ -336,7 +343,7 @@ public class CellPathFinding extends PathFinding
_debugItems.add(item); _debugItems.add(item);
} }
private static final class BufferInfo private static class BufferInfo
{ {
final int mapSize; final int mapSize;
final int count; final int count;

View File

@@ -17,9 +17,9 @@
package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes; package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.ListIterator;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -114,7 +114,7 @@ public class CellPathFinding extends PathFinding
{ {
if (_debugItems == null) if (_debugItems == null)
{ {
_debugItems = new CopyOnWriteArrayList<>(); _debugItems = new LinkedList<>();
} }
else else
{ {
@@ -179,28 +179,35 @@ public class CellPathFinding extends PathFinding
_postFilterPlayableUses++; _postFilterPlayableUses++;
} }
boolean remove; ListIterator<AbstractNodeLoc> middlePoint;
int currentX;
int currentY;
int currentZ;
int pass = 0; int pass = 0;
boolean remove;
do do
{ {
pass++; pass++;
_postFilterPasses++; _postFilterPasses++;
remove = false; remove = false;
final Iterator<AbstractNodeLoc> endPoint = path.iterator(); middlePoint = path.listIterator();
endPoint.next(); currentX = x;
int currentX = x; currentY = y;
int currentY = y; currentZ = z;
int currentZ = z;
int midPoint = 0; while (middlePoint.hasNext())
while (endPoint.hasNext())
{ {
final AbstractNodeLoc locMiddle = path.get(midPoint); final AbstractNodeLoc locMiddle = middlePoint.next();
final AbstractNodeLoc locEnd = endPoint.next(); if (!middlePoint.hasNext())
{
break;
}
final AbstractNodeLoc locEnd = path.get(middlePoint.nextIndex());
if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance)) if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance))
{ {
path.remove(midPoint); middlePoint.remove();
remove = true; remove = true;
if (debug) if (debug)
{ {
@@ -212,7 +219,6 @@ public class CellPathFinding extends PathFinding
currentX = locMiddle.getX(); currentX = locMiddle.getX();
currentY = locMiddle.getY(); currentY = locMiddle.getY();
currentZ = locMiddle.getZ(); currentZ = locMiddle.getZ();
midPoint++;
} }
} }
} }
@@ -231,7 +237,7 @@ public class CellPathFinding extends PathFinding
private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node) private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node)
{ {
final List<AbstractNodeLoc> path = new CopyOnWriteArrayList<>(); final LinkedList<AbstractNodeLoc> path = new LinkedList<>();
int previousDirectionX = Integer.MIN_VALUE; int previousDirectionX = Integer.MIN_VALUE;
int previousDirectionY = Integer.MIN_VALUE; int previousDirectionY = Integer.MIN_VALUE;
int directionX; int directionX;
@@ -267,16 +273,17 @@ public class CellPathFinding extends PathFinding
previousDirectionX = directionX; previousDirectionX = directionX;
previousDirectionY = directionY; previousDirectionY = directionY;
path.add(0, tempNode.getLoc()); path.addFirst(tempNode.getLoc());
tempNode.setLoc(null); tempNode.setLoc(null);
} }
tempNode = tempNode.getParent(); tempNode = tempNode.getParent();
} }
return path; return path;
} }
private final CellNodeBuffer alloc(int size, boolean playable) private CellNodeBuffer alloc(int size, boolean playable)
{ {
CellNodeBuffer current = null; CellNodeBuffer current = null;
for (BufferInfo i : _allBuffers) for (BufferInfo i : _allBuffers)
@@ -328,7 +335,7 @@ public class CellPathFinding extends PathFinding
return current; return current;
} }
private final void dropDebugItem(int itemId, int num, AbstractNodeLoc loc) private void dropDebugItem(int itemId, int num, AbstractNodeLoc loc)
{ {
final Item item = new Item(IdManager.getInstance().getNextId(), itemId); final Item item = new Item(IdManager.getInstance().getNextId(), itemId);
item.setCount(num); item.setCount(num);
@@ -336,7 +343,7 @@ public class CellPathFinding extends PathFinding
_debugItems.add(item); _debugItems.add(item);
} }
private static final class BufferInfo private static class BufferInfo
{ {
final int mapSize; final int mapSize;
final int count; final int count;

View File

@@ -17,9 +17,9 @@
package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes; package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.ListIterator;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -114,7 +114,7 @@ public class CellPathFinding extends PathFinding
{ {
if (_debugItems == null) if (_debugItems == null)
{ {
_debugItems = new CopyOnWriteArrayList<>(); _debugItems = new LinkedList<>();
} }
else else
{ {
@@ -179,28 +179,35 @@ public class CellPathFinding extends PathFinding
_postFilterPlayableUses++; _postFilterPlayableUses++;
} }
boolean remove; ListIterator<AbstractNodeLoc> middlePoint;
int currentX;
int currentY;
int currentZ;
int pass = 0; int pass = 0;
boolean remove;
do do
{ {
pass++; pass++;
_postFilterPasses++; _postFilterPasses++;
remove = false; remove = false;
final Iterator<AbstractNodeLoc> endPoint = path.iterator(); middlePoint = path.listIterator();
endPoint.next(); currentX = x;
int currentX = x; currentY = y;
int currentY = y; currentZ = z;
int currentZ = z;
int midPoint = 0; while (middlePoint.hasNext())
while (endPoint.hasNext())
{ {
final AbstractNodeLoc locMiddle = path.get(midPoint); final AbstractNodeLoc locMiddle = middlePoint.next();
final AbstractNodeLoc locEnd = endPoint.next(); if (!middlePoint.hasNext())
{
break;
}
final AbstractNodeLoc locEnd = path.get(middlePoint.nextIndex());
if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance)) if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance))
{ {
path.remove(midPoint); middlePoint.remove();
remove = true; remove = true;
if (debug) if (debug)
{ {
@@ -212,7 +219,6 @@ public class CellPathFinding extends PathFinding
currentX = locMiddle.getX(); currentX = locMiddle.getX();
currentY = locMiddle.getY(); currentY = locMiddle.getY();
currentZ = locMiddle.getZ(); currentZ = locMiddle.getZ();
midPoint++;
} }
} }
} }
@@ -231,7 +237,7 @@ public class CellPathFinding extends PathFinding
private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node) private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node)
{ {
final List<AbstractNodeLoc> path = new CopyOnWriteArrayList<>(); final LinkedList<AbstractNodeLoc> path = new LinkedList<>();
int previousDirectionX = Integer.MIN_VALUE; int previousDirectionX = Integer.MIN_VALUE;
int previousDirectionY = Integer.MIN_VALUE; int previousDirectionY = Integer.MIN_VALUE;
int directionX; int directionX;
@@ -267,16 +273,17 @@ public class CellPathFinding extends PathFinding
previousDirectionX = directionX; previousDirectionX = directionX;
previousDirectionY = directionY; previousDirectionY = directionY;
path.add(0, tempNode.getLoc()); path.addFirst(tempNode.getLoc());
tempNode.setLoc(null); tempNode.setLoc(null);
} }
tempNode = tempNode.getParent(); tempNode = tempNode.getParent();
} }
return path; return path;
} }
private final CellNodeBuffer alloc(int size, boolean playable) private CellNodeBuffer alloc(int size, boolean playable)
{ {
CellNodeBuffer current = null; CellNodeBuffer current = null;
for (BufferInfo i : _allBuffers) for (BufferInfo i : _allBuffers)
@@ -328,7 +335,7 @@ public class CellPathFinding extends PathFinding
return current; return current;
} }
private final void dropDebugItem(int itemId, int num, AbstractNodeLoc loc) private void dropDebugItem(int itemId, int num, AbstractNodeLoc loc)
{ {
final Item item = new Item(IdManager.getInstance().getNextId(), itemId); final Item item = new Item(IdManager.getInstance().getNextId(), itemId);
item.setCount(num); item.setCount(num);
@@ -336,7 +343,7 @@ public class CellPathFinding extends PathFinding
_debugItems.add(item); _debugItems.add(item);
} }
private static final class BufferInfo private static class BufferInfo
{ {
final int mapSize; final int mapSize;
final int count; final int count;

View File

@@ -17,9 +17,9 @@
package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes; package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.ListIterator;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -114,7 +114,7 @@ public class CellPathFinding extends PathFinding
{ {
if (_debugItems == null) if (_debugItems == null)
{ {
_debugItems = new CopyOnWriteArrayList<>(); _debugItems = new LinkedList<>();
} }
else else
{ {
@@ -179,28 +179,35 @@ public class CellPathFinding extends PathFinding
_postFilterPlayableUses++; _postFilterPlayableUses++;
} }
boolean remove; ListIterator<AbstractNodeLoc> middlePoint;
int currentX;
int currentY;
int currentZ;
int pass = 0; int pass = 0;
boolean remove;
do do
{ {
pass++; pass++;
_postFilterPasses++; _postFilterPasses++;
remove = false; remove = false;
final Iterator<AbstractNodeLoc> endPoint = path.iterator(); middlePoint = path.listIterator();
endPoint.next(); currentX = x;
int currentX = x; currentY = y;
int currentY = y; currentZ = z;
int currentZ = z;
int midPoint = 0; while (middlePoint.hasNext())
while (endPoint.hasNext())
{ {
final AbstractNodeLoc locMiddle = path.get(midPoint); final AbstractNodeLoc locMiddle = middlePoint.next();
final AbstractNodeLoc locEnd = endPoint.next(); if (!middlePoint.hasNext())
{
break;
}
final AbstractNodeLoc locEnd = path.get(middlePoint.nextIndex());
if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance)) if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance))
{ {
path.remove(midPoint); middlePoint.remove();
remove = true; remove = true;
if (debug) if (debug)
{ {
@@ -212,7 +219,6 @@ public class CellPathFinding extends PathFinding
currentX = locMiddle.getX(); currentX = locMiddle.getX();
currentY = locMiddle.getY(); currentY = locMiddle.getY();
currentZ = locMiddle.getZ(); currentZ = locMiddle.getZ();
midPoint++;
} }
} }
} }
@@ -231,7 +237,7 @@ public class CellPathFinding extends PathFinding
private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node) private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node)
{ {
final List<AbstractNodeLoc> path = new CopyOnWriteArrayList<>(); final LinkedList<AbstractNodeLoc> path = new LinkedList<>();
int previousDirectionX = Integer.MIN_VALUE; int previousDirectionX = Integer.MIN_VALUE;
int previousDirectionY = Integer.MIN_VALUE; int previousDirectionY = Integer.MIN_VALUE;
int directionX; int directionX;
@@ -267,16 +273,17 @@ public class CellPathFinding extends PathFinding
previousDirectionX = directionX; previousDirectionX = directionX;
previousDirectionY = directionY; previousDirectionY = directionY;
path.add(0, tempNode.getLoc()); path.addFirst(tempNode.getLoc());
tempNode.setLoc(null); tempNode.setLoc(null);
} }
tempNode = tempNode.getParent(); tempNode = tempNode.getParent();
} }
return path; return path;
} }
private final CellNodeBuffer alloc(int size, boolean playable) private CellNodeBuffer alloc(int size, boolean playable)
{ {
CellNodeBuffer current = null; CellNodeBuffer current = null;
for (BufferInfo i : _allBuffers) for (BufferInfo i : _allBuffers)
@@ -328,7 +335,7 @@ public class CellPathFinding extends PathFinding
return current; return current;
} }
private final void dropDebugItem(int itemId, int num, AbstractNodeLoc loc) private void dropDebugItem(int itemId, int num, AbstractNodeLoc loc)
{ {
final Item item = new Item(IdManager.getInstance().getNextId(), itemId); final Item item = new Item(IdManager.getInstance().getNextId(), itemId);
item.setCount(num); item.setCount(num);
@@ -336,7 +343,7 @@ public class CellPathFinding extends PathFinding
_debugItems.add(item); _debugItems.add(item);
} }
private static final class BufferInfo private static class BufferInfo
{ {
final int mapSize; final int mapSize;
final int count; final int count;

View File

@@ -17,9 +17,9 @@
package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes; package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.ListIterator;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -114,7 +114,7 @@ public class CellPathFinding extends PathFinding
{ {
if (_debugItems == null) if (_debugItems == null)
{ {
_debugItems = new CopyOnWriteArrayList<>(); _debugItems = new LinkedList<>();
} }
else else
{ {
@@ -179,28 +179,35 @@ public class CellPathFinding extends PathFinding
_postFilterPlayableUses++; _postFilterPlayableUses++;
} }
boolean remove; ListIterator<AbstractNodeLoc> middlePoint;
int currentX;
int currentY;
int currentZ;
int pass = 0; int pass = 0;
boolean remove;
do do
{ {
pass++; pass++;
_postFilterPasses++; _postFilterPasses++;
remove = false; remove = false;
final Iterator<AbstractNodeLoc> endPoint = path.iterator(); middlePoint = path.listIterator();
endPoint.next(); currentX = x;
int currentX = x; currentY = y;
int currentY = y; currentZ = z;
int currentZ = z;
int midPoint = 0; while (middlePoint.hasNext())
while (endPoint.hasNext())
{ {
final AbstractNodeLoc locMiddle = path.get(midPoint); final AbstractNodeLoc locMiddle = middlePoint.next();
final AbstractNodeLoc locEnd = endPoint.next(); if (!middlePoint.hasNext())
{
break;
}
final AbstractNodeLoc locEnd = path.get(middlePoint.nextIndex());
if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance)) if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance))
{ {
path.remove(midPoint); middlePoint.remove();
remove = true; remove = true;
if (debug) if (debug)
{ {
@@ -212,7 +219,6 @@ public class CellPathFinding extends PathFinding
currentX = locMiddle.getX(); currentX = locMiddle.getX();
currentY = locMiddle.getY(); currentY = locMiddle.getY();
currentZ = locMiddle.getZ(); currentZ = locMiddle.getZ();
midPoint++;
} }
} }
} }
@@ -231,7 +237,7 @@ public class CellPathFinding extends PathFinding
private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node) private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node)
{ {
final List<AbstractNodeLoc> path = new CopyOnWriteArrayList<>(); final LinkedList<AbstractNodeLoc> path = new LinkedList<>();
int previousDirectionX = Integer.MIN_VALUE; int previousDirectionX = Integer.MIN_VALUE;
int previousDirectionY = Integer.MIN_VALUE; int previousDirectionY = Integer.MIN_VALUE;
int directionX; int directionX;
@@ -267,16 +273,17 @@ public class CellPathFinding extends PathFinding
previousDirectionX = directionX; previousDirectionX = directionX;
previousDirectionY = directionY; previousDirectionY = directionY;
path.add(0, tempNode.getLoc()); path.addFirst(tempNode.getLoc());
tempNode.setLoc(null); tempNode.setLoc(null);
} }
tempNode = tempNode.getParent(); tempNode = tempNode.getParent();
} }
return path; return path;
} }
private final CellNodeBuffer alloc(int size, boolean playable) private CellNodeBuffer alloc(int size, boolean playable)
{ {
CellNodeBuffer current = null; CellNodeBuffer current = null;
for (BufferInfo i : _allBuffers) for (BufferInfo i : _allBuffers)
@@ -328,7 +335,7 @@ public class CellPathFinding extends PathFinding
return current; return current;
} }
private final void dropDebugItem(int itemId, int num, AbstractNodeLoc loc) private void dropDebugItem(int itemId, int num, AbstractNodeLoc loc)
{ {
final Item item = new Item(IdManager.getInstance().getNextId(), itemId); final Item item = new Item(IdManager.getInstance().getNextId(), itemId);
item.setCount(num); item.setCount(num);
@@ -336,7 +343,7 @@ public class CellPathFinding extends PathFinding
_debugItems.add(item); _debugItems.add(item);
} }
private static final class BufferInfo private static class BufferInfo
{ {
final int mapSize; final int mapSize;
final int count; final int count;

View File

@@ -17,9 +17,9 @@
package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes; package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.ListIterator;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -114,7 +114,7 @@ public class CellPathFinding extends PathFinding
{ {
if (_debugItems == null) if (_debugItems == null)
{ {
_debugItems = new CopyOnWriteArrayList<>(); _debugItems = new LinkedList<>();
} }
else else
{ {
@@ -179,28 +179,35 @@ public class CellPathFinding extends PathFinding
_postFilterPlayableUses++; _postFilterPlayableUses++;
} }
boolean remove; ListIterator<AbstractNodeLoc> middlePoint;
int currentX;
int currentY;
int currentZ;
int pass = 0; int pass = 0;
boolean remove;
do do
{ {
pass++; pass++;
_postFilterPasses++; _postFilterPasses++;
remove = false; remove = false;
final Iterator<AbstractNodeLoc> endPoint = path.iterator(); middlePoint = path.listIterator();
endPoint.next(); currentX = x;
int currentX = x; currentY = y;
int currentY = y; currentZ = z;
int currentZ = z;
int midPoint = 0; while (middlePoint.hasNext())
while (endPoint.hasNext())
{ {
final AbstractNodeLoc locMiddle = path.get(midPoint); final AbstractNodeLoc locMiddle = middlePoint.next();
final AbstractNodeLoc locEnd = endPoint.next(); if (!middlePoint.hasNext())
{
break;
}
final AbstractNodeLoc locEnd = path.get(middlePoint.nextIndex());
if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance)) if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance))
{ {
path.remove(midPoint); middlePoint.remove();
remove = true; remove = true;
if (debug) if (debug)
{ {
@@ -212,7 +219,6 @@ public class CellPathFinding extends PathFinding
currentX = locMiddle.getX(); currentX = locMiddle.getX();
currentY = locMiddle.getY(); currentY = locMiddle.getY();
currentZ = locMiddle.getZ(); currentZ = locMiddle.getZ();
midPoint++;
} }
} }
} }
@@ -231,7 +237,7 @@ public class CellPathFinding extends PathFinding
private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node) private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node)
{ {
final List<AbstractNodeLoc> path = new CopyOnWriteArrayList<>(); final LinkedList<AbstractNodeLoc> path = new LinkedList<>();
int previousDirectionX = Integer.MIN_VALUE; int previousDirectionX = Integer.MIN_VALUE;
int previousDirectionY = Integer.MIN_VALUE; int previousDirectionY = Integer.MIN_VALUE;
int directionX; int directionX;
@@ -267,16 +273,17 @@ public class CellPathFinding extends PathFinding
previousDirectionX = directionX; previousDirectionX = directionX;
previousDirectionY = directionY; previousDirectionY = directionY;
path.add(0, tempNode.getLoc()); path.addFirst(tempNode.getLoc());
tempNode.setLoc(null); tempNode.setLoc(null);
} }
tempNode = tempNode.getParent(); tempNode = tempNode.getParent();
} }
return path; return path;
} }
private final CellNodeBuffer alloc(int size, boolean playable) private CellNodeBuffer alloc(int size, boolean playable)
{ {
CellNodeBuffer current = null; CellNodeBuffer current = null;
for (BufferInfo i : _allBuffers) for (BufferInfo i : _allBuffers)
@@ -328,7 +335,7 @@ public class CellPathFinding extends PathFinding
return current; return current;
} }
private final void dropDebugItem(int itemId, int num, AbstractNodeLoc loc) private void dropDebugItem(int itemId, int num, AbstractNodeLoc loc)
{ {
final Item item = new Item(IdManager.getInstance().getNextId(), itemId); final Item item = new Item(IdManager.getInstance().getNextId(), itemId);
item.setCount(num); item.setCount(num);
@@ -336,7 +343,7 @@ public class CellPathFinding extends PathFinding
_debugItems.add(item); _debugItems.add(item);
} }
private static final class BufferInfo private static class BufferInfo
{ {
final int mapSize; final int mapSize;
final int count; final int count;

View File

@@ -17,9 +17,9 @@
package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes; package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.ListIterator;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -114,7 +114,7 @@ public class CellPathFinding extends PathFinding
{ {
if (_debugItems == null) if (_debugItems == null)
{ {
_debugItems = new CopyOnWriteArrayList<>(); _debugItems = new LinkedList<>();
} }
else else
{ {
@@ -179,28 +179,35 @@ public class CellPathFinding extends PathFinding
_postFilterPlayableUses++; _postFilterPlayableUses++;
} }
boolean remove; ListIterator<AbstractNodeLoc> middlePoint;
int currentX;
int currentY;
int currentZ;
int pass = 0; int pass = 0;
boolean remove;
do do
{ {
pass++; pass++;
_postFilterPasses++; _postFilterPasses++;
remove = false; remove = false;
final Iterator<AbstractNodeLoc> endPoint = path.iterator(); middlePoint = path.listIterator();
endPoint.next(); currentX = x;
int currentX = x; currentY = y;
int currentY = y; currentZ = z;
int currentZ = z;
int midPoint = 0; while (middlePoint.hasNext())
while (endPoint.hasNext())
{ {
final AbstractNodeLoc locMiddle = path.get(midPoint); final AbstractNodeLoc locMiddle = middlePoint.next();
final AbstractNodeLoc locEnd = endPoint.next(); if (!middlePoint.hasNext())
{
break;
}
final AbstractNodeLoc locEnd = path.get(middlePoint.nextIndex());
if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance)) if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance))
{ {
path.remove(midPoint); middlePoint.remove();
remove = true; remove = true;
if (debug) if (debug)
{ {
@@ -212,7 +219,6 @@ public class CellPathFinding extends PathFinding
currentX = locMiddle.getX(); currentX = locMiddle.getX();
currentY = locMiddle.getY(); currentY = locMiddle.getY();
currentZ = locMiddle.getZ(); currentZ = locMiddle.getZ();
midPoint++;
} }
} }
} }
@@ -231,7 +237,7 @@ public class CellPathFinding extends PathFinding
private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node) private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node)
{ {
final List<AbstractNodeLoc> path = new CopyOnWriteArrayList<>(); final LinkedList<AbstractNodeLoc> path = new LinkedList<>();
int previousDirectionX = Integer.MIN_VALUE; int previousDirectionX = Integer.MIN_VALUE;
int previousDirectionY = Integer.MIN_VALUE; int previousDirectionY = Integer.MIN_VALUE;
int directionX; int directionX;
@@ -267,16 +273,17 @@ public class CellPathFinding extends PathFinding
previousDirectionX = directionX; previousDirectionX = directionX;
previousDirectionY = directionY; previousDirectionY = directionY;
path.add(0, tempNode.getLoc()); path.addFirst(tempNode.getLoc());
tempNode.setLoc(null); tempNode.setLoc(null);
} }
tempNode = tempNode.getParent(); tempNode = tempNode.getParent();
} }
return path; return path;
} }
private final CellNodeBuffer alloc(int size, boolean playable) private CellNodeBuffer alloc(int size, boolean playable)
{ {
CellNodeBuffer current = null; CellNodeBuffer current = null;
for (BufferInfo i : _allBuffers) for (BufferInfo i : _allBuffers)
@@ -328,7 +335,7 @@ public class CellPathFinding extends PathFinding
return current; return current;
} }
private final void dropDebugItem(int itemId, int num, AbstractNodeLoc loc) private void dropDebugItem(int itemId, int num, AbstractNodeLoc loc)
{ {
final Item item = new Item(IdManager.getInstance().getNextId(), itemId); final Item item = new Item(IdManager.getInstance().getNextId(), itemId);
item.setCount(num); item.setCount(num);
@@ -336,7 +343,7 @@ public class CellPathFinding extends PathFinding
_debugItems.add(item); _debugItems.add(item);
} }
private static final class BufferInfo private static class BufferInfo
{ {
final int mapSize; final int mapSize;
final int count; final int count;

View File

@@ -17,9 +17,9 @@
package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes; package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.ListIterator;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -114,7 +114,7 @@ public class CellPathFinding extends PathFinding
{ {
if (_debugItems == null) if (_debugItems == null)
{ {
_debugItems = new CopyOnWriteArrayList<>(); _debugItems = new LinkedList<>();
} }
else else
{ {
@@ -179,28 +179,35 @@ public class CellPathFinding extends PathFinding
_postFilterPlayableUses++; _postFilterPlayableUses++;
} }
boolean remove; ListIterator<AbstractNodeLoc> middlePoint;
int currentX;
int currentY;
int currentZ;
int pass = 0; int pass = 0;
boolean remove;
do do
{ {
pass++; pass++;
_postFilterPasses++; _postFilterPasses++;
remove = false; remove = false;
final Iterator<AbstractNodeLoc> endPoint = path.iterator(); middlePoint = path.listIterator();
endPoint.next(); currentX = x;
int currentX = x; currentY = y;
int currentY = y; currentZ = z;
int currentZ = z;
int midPoint = 0; while (middlePoint.hasNext())
while (endPoint.hasNext())
{ {
final AbstractNodeLoc locMiddle = path.get(midPoint); final AbstractNodeLoc locMiddle = middlePoint.next();
final AbstractNodeLoc locEnd = endPoint.next(); if (!middlePoint.hasNext())
{
break;
}
final AbstractNodeLoc locEnd = path.get(middlePoint.nextIndex());
if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance)) if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance))
{ {
path.remove(midPoint); middlePoint.remove();
remove = true; remove = true;
if (debug) if (debug)
{ {
@@ -212,7 +219,6 @@ public class CellPathFinding extends PathFinding
currentX = locMiddle.getX(); currentX = locMiddle.getX();
currentY = locMiddle.getY(); currentY = locMiddle.getY();
currentZ = locMiddle.getZ(); currentZ = locMiddle.getZ();
midPoint++;
} }
} }
} }
@@ -231,7 +237,7 @@ public class CellPathFinding extends PathFinding
private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node) private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node)
{ {
final List<AbstractNodeLoc> path = new CopyOnWriteArrayList<>(); final LinkedList<AbstractNodeLoc> path = new LinkedList<>();
int previousDirectionX = Integer.MIN_VALUE; int previousDirectionX = Integer.MIN_VALUE;
int previousDirectionY = Integer.MIN_VALUE; int previousDirectionY = Integer.MIN_VALUE;
int directionX; int directionX;
@@ -267,16 +273,17 @@ public class CellPathFinding extends PathFinding
previousDirectionX = directionX; previousDirectionX = directionX;
previousDirectionY = directionY; previousDirectionY = directionY;
path.add(0, tempNode.getLoc()); path.addFirst(tempNode.getLoc());
tempNode.setLoc(null); tempNode.setLoc(null);
} }
tempNode = tempNode.getParent(); tempNode = tempNode.getParent();
} }
return path; return path;
} }
private final CellNodeBuffer alloc(int size, boolean playable) private CellNodeBuffer alloc(int size, boolean playable)
{ {
CellNodeBuffer current = null; CellNodeBuffer current = null;
for (BufferInfo i : _allBuffers) for (BufferInfo i : _allBuffers)
@@ -328,7 +335,7 @@ public class CellPathFinding extends PathFinding
return current; return current;
} }
private final void dropDebugItem(int itemId, int num, AbstractNodeLoc loc) private void dropDebugItem(int itemId, int num, AbstractNodeLoc loc)
{ {
final Item item = new Item(IdManager.getInstance().getNextId(), itemId); final Item item = new Item(IdManager.getInstance().getNextId(), itemId);
item.setCount(num); item.setCount(num);
@@ -336,7 +343,7 @@ public class CellPathFinding extends PathFinding
_debugItems.add(item); _debugItems.add(item);
} }
private static final class BufferInfo private static class BufferInfo
{ {
final int mapSize; final int mapSize;
final int count; final int count;

View File

@@ -17,9 +17,9 @@
package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes; package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.ListIterator;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -114,7 +114,7 @@ public class CellPathFinding extends PathFinding
{ {
if (_debugItems == null) if (_debugItems == null)
{ {
_debugItems = new CopyOnWriteArrayList<>(); _debugItems = new LinkedList<>();
} }
else else
{ {
@@ -179,28 +179,35 @@ public class CellPathFinding extends PathFinding
_postFilterPlayableUses++; _postFilterPlayableUses++;
} }
boolean remove; ListIterator<AbstractNodeLoc> middlePoint;
int currentX;
int currentY;
int currentZ;
int pass = 0; int pass = 0;
boolean remove;
do do
{ {
pass++; pass++;
_postFilterPasses++; _postFilterPasses++;
remove = false; remove = false;
final Iterator<AbstractNodeLoc> endPoint = path.iterator(); middlePoint = path.listIterator();
endPoint.next(); currentX = x;
int currentX = x; currentY = y;
int currentY = y; currentZ = z;
int currentZ = z;
int midPoint = 0; while (middlePoint.hasNext())
while (endPoint.hasNext())
{ {
final AbstractNodeLoc locMiddle = path.get(midPoint); final AbstractNodeLoc locMiddle = middlePoint.next();
final AbstractNodeLoc locEnd = endPoint.next(); if (!middlePoint.hasNext())
{
break;
}
final AbstractNodeLoc locEnd = path.get(middlePoint.nextIndex());
if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance)) if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance))
{ {
path.remove(midPoint); middlePoint.remove();
remove = true; remove = true;
if (debug) if (debug)
{ {
@@ -212,7 +219,6 @@ public class CellPathFinding extends PathFinding
currentX = locMiddle.getX(); currentX = locMiddle.getX();
currentY = locMiddle.getY(); currentY = locMiddle.getY();
currentZ = locMiddle.getZ(); currentZ = locMiddle.getZ();
midPoint++;
} }
} }
} }
@@ -231,7 +237,7 @@ public class CellPathFinding extends PathFinding
private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node) private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node)
{ {
final List<AbstractNodeLoc> path = new CopyOnWriteArrayList<>(); final LinkedList<AbstractNodeLoc> path = new LinkedList<>();
int previousDirectionX = Integer.MIN_VALUE; int previousDirectionX = Integer.MIN_VALUE;
int previousDirectionY = Integer.MIN_VALUE; int previousDirectionY = Integer.MIN_VALUE;
int directionX; int directionX;
@@ -267,16 +273,17 @@ public class CellPathFinding extends PathFinding
previousDirectionX = directionX; previousDirectionX = directionX;
previousDirectionY = directionY; previousDirectionY = directionY;
path.add(0, tempNode.getLoc()); path.addFirst(tempNode.getLoc());
tempNode.setLoc(null); tempNode.setLoc(null);
} }
tempNode = tempNode.getParent(); tempNode = tempNode.getParent();
} }
return path; return path;
} }
private final CellNodeBuffer alloc(int size, boolean playable) private CellNodeBuffer alloc(int size, boolean playable)
{ {
CellNodeBuffer current = null; CellNodeBuffer current = null;
for (BufferInfo i : _allBuffers) for (BufferInfo i : _allBuffers)
@@ -328,7 +335,7 @@ public class CellPathFinding extends PathFinding
return current; return current;
} }
private final void dropDebugItem(int itemId, int num, AbstractNodeLoc loc) private void dropDebugItem(int itemId, int num, AbstractNodeLoc loc)
{ {
final Item item = new Item(IdManager.getInstance().getNextId(), itemId); final Item item = new Item(IdManager.getInstance().getNextId(), itemId);
item.setCount(num); item.setCount(num);
@@ -336,7 +343,7 @@ public class CellPathFinding extends PathFinding
_debugItems.add(item); _debugItems.add(item);
} }
private static final class BufferInfo private static class BufferInfo
{ {
final int mapSize; final int mapSize;
final int count; final int count;

View File

@@ -17,9 +17,9 @@
package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes; package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.ListIterator;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -114,7 +114,7 @@ public class CellPathFinding extends PathFinding
{ {
if (_debugItems == null) if (_debugItems == null)
{ {
_debugItems = new CopyOnWriteArrayList<>(); _debugItems = new LinkedList<>();
} }
else else
{ {
@@ -179,28 +179,35 @@ public class CellPathFinding extends PathFinding
_postFilterPlayableUses++; _postFilterPlayableUses++;
} }
boolean remove; ListIterator<AbstractNodeLoc> middlePoint;
int currentX;
int currentY;
int currentZ;
int pass = 0; int pass = 0;
boolean remove;
do do
{ {
pass++; pass++;
_postFilterPasses++; _postFilterPasses++;
remove = false; remove = false;
final Iterator<AbstractNodeLoc> endPoint = path.iterator(); middlePoint = path.listIterator();
endPoint.next(); currentX = x;
int currentX = x; currentY = y;
int currentY = y; currentZ = z;
int currentZ = z;
int midPoint = 0; while (middlePoint.hasNext())
while (endPoint.hasNext())
{ {
final AbstractNodeLoc locMiddle = path.get(midPoint); final AbstractNodeLoc locMiddle = middlePoint.next();
final AbstractNodeLoc locEnd = endPoint.next(); if (!middlePoint.hasNext())
{
break;
}
final AbstractNodeLoc locEnd = path.get(middlePoint.nextIndex());
if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance)) if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance))
{ {
path.remove(midPoint); middlePoint.remove();
remove = true; remove = true;
if (debug) if (debug)
{ {
@@ -212,7 +219,6 @@ public class CellPathFinding extends PathFinding
currentX = locMiddle.getX(); currentX = locMiddle.getX();
currentY = locMiddle.getY(); currentY = locMiddle.getY();
currentZ = locMiddle.getZ(); currentZ = locMiddle.getZ();
midPoint++;
} }
} }
} }
@@ -231,7 +237,7 @@ public class CellPathFinding extends PathFinding
private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node) private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node)
{ {
final List<AbstractNodeLoc> path = new CopyOnWriteArrayList<>(); final LinkedList<AbstractNodeLoc> path = new LinkedList<>();
int previousDirectionX = Integer.MIN_VALUE; int previousDirectionX = Integer.MIN_VALUE;
int previousDirectionY = Integer.MIN_VALUE; int previousDirectionY = Integer.MIN_VALUE;
int directionX; int directionX;
@@ -267,16 +273,17 @@ public class CellPathFinding extends PathFinding
previousDirectionX = directionX; previousDirectionX = directionX;
previousDirectionY = directionY; previousDirectionY = directionY;
path.add(0, tempNode.getLoc()); path.addFirst(tempNode.getLoc());
tempNode.setLoc(null); tempNode.setLoc(null);
} }
tempNode = tempNode.getParent(); tempNode = tempNode.getParent();
} }
return path; return path;
} }
private final CellNodeBuffer alloc(int size, boolean playable) private CellNodeBuffer alloc(int size, boolean playable)
{ {
CellNodeBuffer current = null; CellNodeBuffer current = null;
for (BufferInfo i : _allBuffers) for (BufferInfo i : _allBuffers)
@@ -328,7 +335,7 @@ public class CellPathFinding extends PathFinding
return current; return current;
} }
private final void dropDebugItem(int itemId, int num, AbstractNodeLoc loc) private void dropDebugItem(int itemId, int num, AbstractNodeLoc loc)
{ {
final Item item = new Item(IdManager.getInstance().getNextId(), itemId); final Item item = new Item(IdManager.getInstance().getNextId(), itemId);
item.setCount(num); item.setCount(num);
@@ -336,7 +343,7 @@ public class CellPathFinding extends PathFinding
_debugItems.add(item); _debugItems.add(item);
} }
private static final class BufferInfo private static class BufferInfo
{ {
final int mapSize; final int mapSize;
final int count; final int count;

View File

@@ -17,9 +17,9 @@
package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes; package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.ListIterator;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -113,7 +113,7 @@ public class CellPathFinding extends PathFinding
{ {
if (_debugItems == null) if (_debugItems == null)
{ {
_debugItems = new CopyOnWriteArrayList<>(); _debugItems = new LinkedList<>();
} }
else else
{ {
@@ -178,28 +178,35 @@ public class CellPathFinding extends PathFinding
_postFilterPlayableUses++; _postFilterPlayableUses++;
} }
boolean remove; ListIterator<AbstractNodeLoc> middlePoint;
int currentX;
int currentY;
int currentZ;
int pass = 0; int pass = 0;
boolean remove;
do do
{ {
pass++; pass++;
_postFilterPasses++; _postFilterPasses++;
remove = false; remove = false;
final Iterator<AbstractNodeLoc> endPoint = path.iterator(); middlePoint = path.listIterator();
endPoint.next(); currentX = x;
int currentX = x; currentY = y;
int currentY = y; currentZ = z;
int currentZ = z;
int midPoint = 0; while (middlePoint.hasNext())
while (endPoint.hasNext())
{ {
final AbstractNodeLoc locMiddle = path.get(midPoint); final AbstractNodeLoc locMiddle = middlePoint.next();
final AbstractNodeLoc locEnd = endPoint.next(); if (!middlePoint.hasNext())
{
break;
}
final AbstractNodeLoc locEnd = path.get(middlePoint.nextIndex());
if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instanceId)) if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instanceId))
{ {
path.remove(midPoint); middlePoint.remove();
remove = true; remove = true;
if (debug) if (debug)
{ {
@@ -211,7 +218,6 @@ public class CellPathFinding extends PathFinding
currentX = locMiddle.getX(); currentX = locMiddle.getX();
currentY = locMiddle.getY(); currentY = locMiddle.getY();
currentZ = locMiddle.getZ(); currentZ = locMiddle.getZ();
midPoint++;
} }
} }
} }
@@ -230,7 +236,7 @@ public class CellPathFinding extends PathFinding
private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node) private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node)
{ {
final List<AbstractNodeLoc> path = new CopyOnWriteArrayList<>(); final LinkedList<AbstractNodeLoc> path = new LinkedList<>();
int previousDirectionX = Integer.MIN_VALUE; int previousDirectionX = Integer.MIN_VALUE;
int previousDirectionY = Integer.MIN_VALUE; int previousDirectionY = Integer.MIN_VALUE;
int directionX; int directionX;
@@ -266,16 +272,17 @@ public class CellPathFinding extends PathFinding
previousDirectionX = directionX; previousDirectionX = directionX;
previousDirectionY = directionY; previousDirectionY = directionY;
path.add(0, tempNode.getLoc()); path.addFirst(tempNode.getLoc());
tempNode.setLoc(null); tempNode.setLoc(null);
} }
tempNode = tempNode.getParent(); tempNode = tempNode.getParent();
} }
return path; return path;
} }
private final CellNodeBuffer alloc(int size, boolean playable) private CellNodeBuffer alloc(int size, boolean playable)
{ {
CellNodeBuffer current = null; CellNodeBuffer current = null;
for (BufferInfo i : _allBuffers) for (BufferInfo i : _allBuffers)
@@ -327,7 +334,7 @@ public class CellPathFinding extends PathFinding
return current; return current;
} }
private final void dropDebugItem(int itemId, int num, AbstractNodeLoc loc) private void dropDebugItem(int itemId, int num, AbstractNodeLoc loc)
{ {
final Item item = new Item(IdManager.getInstance().getNextId(), itemId); final Item item = new Item(IdManager.getInstance().getNextId(), itemId);
item.setCount(num); item.setCount(num);
@@ -335,7 +342,7 @@ public class CellPathFinding extends PathFinding
_debugItems.add(item); _debugItems.add(item);
} }
private static final class BufferInfo private static class BufferInfo
{ {
final int mapSize; final int mapSize;
final int count; final int count;

View File

@@ -17,9 +17,9 @@
package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes; package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.ListIterator;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -113,7 +113,7 @@ public class CellPathFinding extends PathFinding
{ {
if (_debugItems == null) if (_debugItems == null)
{ {
_debugItems = new CopyOnWriteArrayList<>(); _debugItems = new LinkedList<>();
} }
else else
{ {
@@ -178,28 +178,35 @@ public class CellPathFinding extends PathFinding
_postFilterPlayableUses++; _postFilterPlayableUses++;
} }
boolean remove; ListIterator<AbstractNodeLoc> middlePoint;
int currentX;
int currentY;
int currentZ;
int pass = 0; int pass = 0;
boolean remove;
do do
{ {
pass++; pass++;
_postFilterPasses++; _postFilterPasses++;
remove = false; remove = false;
final Iterator<AbstractNodeLoc> endPoint = path.iterator(); middlePoint = path.listIterator();
endPoint.next(); currentX = x;
int currentX = x; currentY = y;
int currentY = y; currentZ = z;
int currentZ = z;
int midPoint = 0; while (middlePoint.hasNext())
while (endPoint.hasNext())
{ {
final AbstractNodeLoc locMiddle = path.get(midPoint); final AbstractNodeLoc locMiddle = middlePoint.next();
final AbstractNodeLoc locEnd = endPoint.next(); if (!middlePoint.hasNext())
{
break;
}
final AbstractNodeLoc locEnd = path.get(middlePoint.nextIndex());
if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instanceId)) if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instanceId))
{ {
path.remove(midPoint); middlePoint.remove();
remove = true; remove = true;
if (debug) if (debug)
{ {
@@ -211,7 +218,6 @@ public class CellPathFinding extends PathFinding
currentX = locMiddle.getX(); currentX = locMiddle.getX();
currentY = locMiddle.getY(); currentY = locMiddle.getY();
currentZ = locMiddle.getZ(); currentZ = locMiddle.getZ();
midPoint++;
} }
} }
} }
@@ -230,7 +236,7 @@ public class CellPathFinding extends PathFinding
private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node) private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node)
{ {
final List<AbstractNodeLoc> path = new CopyOnWriteArrayList<>(); final LinkedList<AbstractNodeLoc> path = new LinkedList<>();
int previousDirectionX = Integer.MIN_VALUE; int previousDirectionX = Integer.MIN_VALUE;
int previousDirectionY = Integer.MIN_VALUE; int previousDirectionY = Integer.MIN_VALUE;
int directionX; int directionX;
@@ -266,16 +272,17 @@ public class CellPathFinding extends PathFinding
previousDirectionX = directionX; previousDirectionX = directionX;
previousDirectionY = directionY; previousDirectionY = directionY;
path.add(0, tempNode.getLoc()); path.addFirst(tempNode.getLoc());
tempNode.setLoc(null); tempNode.setLoc(null);
} }
tempNode = tempNode.getParent(); tempNode = tempNode.getParent();
} }
return path; return path;
} }
private final CellNodeBuffer alloc(int size, boolean playable) private CellNodeBuffer alloc(int size, boolean playable)
{ {
CellNodeBuffer current = null; CellNodeBuffer current = null;
for (BufferInfo i : _allBuffers) for (BufferInfo i : _allBuffers)
@@ -327,7 +334,7 @@ public class CellPathFinding extends PathFinding
return current; return current;
} }
private final void dropDebugItem(int itemId, int num, AbstractNodeLoc loc) private void dropDebugItem(int itemId, int num, AbstractNodeLoc loc)
{ {
final Item item = new Item(IdManager.getInstance().getNextId(), itemId); final Item item = new Item(IdManager.getInstance().getNextId(), itemId);
item.setCount(num); item.setCount(num);
@@ -335,7 +342,7 @@ public class CellPathFinding extends PathFinding
_debugItems.add(item); _debugItems.add(item);
} }
private static final class BufferInfo private static class BufferInfo
{ {
final int mapSize; final int mapSize;
final int count; final int count;

View File

@@ -17,9 +17,9 @@
package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes; package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.ListIterator;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -113,7 +113,7 @@ public class CellPathFinding extends PathFinding
{ {
if (_debugItems == null) if (_debugItems == null)
{ {
_debugItems = new CopyOnWriteArrayList<>(); _debugItems = new LinkedList<>();
} }
else else
{ {
@@ -178,28 +178,35 @@ public class CellPathFinding extends PathFinding
_postFilterPlayableUses++; _postFilterPlayableUses++;
} }
boolean remove; ListIterator<AbstractNodeLoc> middlePoint;
int currentX;
int currentY;
int currentZ;
int pass = 0; int pass = 0;
boolean remove;
do do
{ {
pass++; pass++;
_postFilterPasses++; _postFilterPasses++;
remove = false; remove = false;
final Iterator<AbstractNodeLoc> endPoint = path.iterator(); middlePoint = path.listIterator();
endPoint.next(); currentX = x;
int currentX = x; currentY = y;
int currentY = y; currentZ = z;
int currentZ = z;
int midPoint = 0; while (middlePoint.hasNext())
while (endPoint.hasNext())
{ {
final AbstractNodeLoc locMiddle = path.get(midPoint); final AbstractNodeLoc locMiddle = middlePoint.next();
final AbstractNodeLoc locEnd = endPoint.next(); if (!middlePoint.hasNext())
{
break;
}
final AbstractNodeLoc locEnd = path.get(middlePoint.nextIndex());
if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instanceId)) if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instanceId))
{ {
path.remove(midPoint); middlePoint.remove();
remove = true; remove = true;
if (debug) if (debug)
{ {
@@ -211,7 +218,6 @@ public class CellPathFinding extends PathFinding
currentX = locMiddle.getX(); currentX = locMiddle.getX();
currentY = locMiddle.getY(); currentY = locMiddle.getY();
currentZ = locMiddle.getZ(); currentZ = locMiddle.getZ();
midPoint++;
} }
} }
} }
@@ -230,7 +236,7 @@ public class CellPathFinding extends PathFinding
private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node) private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node)
{ {
final List<AbstractNodeLoc> path = new CopyOnWriteArrayList<>(); final LinkedList<AbstractNodeLoc> path = new LinkedList<>();
int previousDirectionX = Integer.MIN_VALUE; int previousDirectionX = Integer.MIN_VALUE;
int previousDirectionY = Integer.MIN_VALUE; int previousDirectionY = Integer.MIN_VALUE;
int directionX; int directionX;
@@ -266,16 +272,17 @@ public class CellPathFinding extends PathFinding
previousDirectionX = directionX; previousDirectionX = directionX;
previousDirectionY = directionY; previousDirectionY = directionY;
path.add(0, tempNode.getLoc()); path.addFirst(tempNode.getLoc());
tempNode.setLoc(null); tempNode.setLoc(null);
} }
tempNode = tempNode.getParent(); tempNode = tempNode.getParent();
} }
return path; return path;
} }
private final CellNodeBuffer alloc(int size, boolean playable) private CellNodeBuffer alloc(int size, boolean playable)
{ {
CellNodeBuffer current = null; CellNodeBuffer current = null;
for (BufferInfo i : _allBuffers) for (BufferInfo i : _allBuffers)
@@ -327,7 +334,7 @@ public class CellPathFinding extends PathFinding
return current; return current;
} }
private final void dropDebugItem(int itemId, int num, AbstractNodeLoc loc) private void dropDebugItem(int itemId, int num, AbstractNodeLoc loc)
{ {
final Item item = new Item(IdManager.getInstance().getNextId(), itemId); final Item item = new Item(IdManager.getInstance().getNextId(), itemId);
item.setCount(num); item.setCount(num);
@@ -335,7 +342,7 @@ public class CellPathFinding extends PathFinding
_debugItems.add(item); _debugItems.add(item);
} }
private static final class BufferInfo private static class BufferInfo
{ {
final int mapSize; final int mapSize;
final int count; final int count;

View File

@@ -17,9 +17,9 @@
package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes; package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.ListIterator;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -113,7 +113,7 @@ public class CellPathFinding extends PathFinding
{ {
if (_debugItems == null) if (_debugItems == null)
{ {
_debugItems = new CopyOnWriteArrayList<>(); _debugItems = new LinkedList<>();
} }
else else
{ {
@@ -178,28 +178,35 @@ public class CellPathFinding extends PathFinding
_postFilterPlayableUses++; _postFilterPlayableUses++;
} }
boolean remove; ListIterator<AbstractNodeLoc> middlePoint;
int currentX;
int currentY;
int currentZ;
int pass = 0; int pass = 0;
boolean remove;
do do
{ {
pass++; pass++;
_postFilterPasses++; _postFilterPasses++;
remove = false; remove = false;
final Iterator<AbstractNodeLoc> endPoint = path.iterator(); middlePoint = path.listIterator();
endPoint.next(); currentX = x;
int currentX = x; currentY = y;
int currentY = y; currentZ = z;
int currentZ = z;
int midPoint = 0; while (middlePoint.hasNext())
while (endPoint.hasNext())
{ {
final AbstractNodeLoc locMiddle = path.get(midPoint); final AbstractNodeLoc locMiddle = middlePoint.next();
final AbstractNodeLoc locEnd = endPoint.next(); if (!middlePoint.hasNext())
{
break;
}
final AbstractNodeLoc locEnd = path.get(middlePoint.nextIndex());
if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instanceId)) if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instanceId))
{ {
path.remove(midPoint); middlePoint.remove();
remove = true; remove = true;
if (debug) if (debug)
{ {
@@ -211,7 +218,6 @@ public class CellPathFinding extends PathFinding
currentX = locMiddle.getX(); currentX = locMiddle.getX();
currentY = locMiddle.getY(); currentY = locMiddle.getY();
currentZ = locMiddle.getZ(); currentZ = locMiddle.getZ();
midPoint++;
} }
} }
} }
@@ -230,7 +236,7 @@ public class CellPathFinding extends PathFinding
private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node) private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node)
{ {
final List<AbstractNodeLoc> path = new CopyOnWriteArrayList<>(); final LinkedList<AbstractNodeLoc> path = new LinkedList<>();
int previousDirectionX = Integer.MIN_VALUE; int previousDirectionX = Integer.MIN_VALUE;
int previousDirectionY = Integer.MIN_VALUE; int previousDirectionY = Integer.MIN_VALUE;
int directionX; int directionX;
@@ -266,16 +272,17 @@ public class CellPathFinding extends PathFinding
previousDirectionX = directionX; previousDirectionX = directionX;
previousDirectionY = directionY; previousDirectionY = directionY;
path.add(0, tempNode.getLoc()); path.addFirst(tempNode.getLoc());
tempNode.setLoc(null); tempNode.setLoc(null);
} }
tempNode = tempNode.getParent(); tempNode = tempNode.getParent();
} }
return path; return path;
} }
private final CellNodeBuffer alloc(int size, boolean playable) private CellNodeBuffer alloc(int size, boolean playable)
{ {
CellNodeBuffer current = null; CellNodeBuffer current = null;
for (BufferInfo i : _allBuffers) for (BufferInfo i : _allBuffers)
@@ -327,7 +334,7 @@ public class CellPathFinding extends PathFinding
return current; return current;
} }
private final void dropDebugItem(int itemId, int num, AbstractNodeLoc loc) private void dropDebugItem(int itemId, int num, AbstractNodeLoc loc)
{ {
final Item item = new Item(IdManager.getInstance().getNextId(), itemId); final Item item = new Item(IdManager.getInstance().getNextId(), itemId);
item.setCount(num); item.setCount(num);
@@ -335,7 +342,7 @@ public class CellPathFinding extends PathFinding
_debugItems.add(item); _debugItems.add(item);
} }
private static final class BufferInfo private static class BufferInfo
{ {
final int mapSize; final int mapSize;
final int count; final int count;

View File

@@ -17,9 +17,9 @@
package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes; package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.ListIterator;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -113,7 +113,7 @@ public class CellPathFinding extends PathFinding
{ {
if (_debugItems == null) if (_debugItems == null)
{ {
_debugItems = new CopyOnWriteArrayList<>(); _debugItems = new LinkedList<>();
} }
else else
{ {
@@ -178,28 +178,35 @@ public class CellPathFinding extends PathFinding
_postFilterPlayableUses++; _postFilterPlayableUses++;
} }
boolean remove; ListIterator<AbstractNodeLoc> middlePoint;
int currentX;
int currentY;
int currentZ;
int pass = 0; int pass = 0;
boolean remove;
do do
{ {
pass++; pass++;
_postFilterPasses++; _postFilterPasses++;
remove = false; remove = false;
final Iterator<AbstractNodeLoc> endPoint = path.iterator(); middlePoint = path.listIterator();
endPoint.next(); currentX = x;
int currentX = x; currentY = y;
int currentY = y; currentZ = z;
int currentZ = z;
int midPoint = 0; while (middlePoint.hasNext())
while (endPoint.hasNext())
{ {
final AbstractNodeLoc locMiddle = path.get(midPoint); final AbstractNodeLoc locMiddle = middlePoint.next();
final AbstractNodeLoc locEnd = endPoint.next(); if (!middlePoint.hasNext())
{
break;
}
final AbstractNodeLoc locEnd = path.get(middlePoint.nextIndex());
if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instanceId)) if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instanceId))
{ {
path.remove(midPoint); middlePoint.remove();
remove = true; remove = true;
if (debug) if (debug)
{ {
@@ -211,7 +218,6 @@ public class CellPathFinding extends PathFinding
currentX = locMiddle.getX(); currentX = locMiddle.getX();
currentY = locMiddle.getY(); currentY = locMiddle.getY();
currentZ = locMiddle.getZ(); currentZ = locMiddle.getZ();
midPoint++;
} }
} }
} }
@@ -230,7 +236,7 @@ public class CellPathFinding extends PathFinding
private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node) private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node)
{ {
final List<AbstractNodeLoc> path = new CopyOnWriteArrayList<>(); final LinkedList<AbstractNodeLoc> path = new LinkedList<>();
int previousDirectionX = Integer.MIN_VALUE; int previousDirectionX = Integer.MIN_VALUE;
int previousDirectionY = Integer.MIN_VALUE; int previousDirectionY = Integer.MIN_VALUE;
int directionX; int directionX;
@@ -266,16 +272,17 @@ public class CellPathFinding extends PathFinding
previousDirectionX = directionX; previousDirectionX = directionX;
previousDirectionY = directionY; previousDirectionY = directionY;
path.add(0, tempNode.getLoc()); path.addFirst(tempNode.getLoc());
tempNode.setLoc(null); tempNode.setLoc(null);
} }
tempNode = tempNode.getParent(); tempNode = tempNode.getParent();
} }
return path; return path;
} }
private final CellNodeBuffer alloc(int size, boolean playable) private CellNodeBuffer alloc(int size, boolean playable)
{ {
CellNodeBuffer current = null; CellNodeBuffer current = null;
for (BufferInfo i : _allBuffers) for (BufferInfo i : _allBuffers)
@@ -327,7 +334,7 @@ public class CellPathFinding extends PathFinding
return current; return current;
} }
private final void dropDebugItem(int itemId, int num, AbstractNodeLoc loc) private void dropDebugItem(int itemId, int num, AbstractNodeLoc loc)
{ {
final Item item = new Item(IdManager.getInstance().getNextId(), itemId); final Item item = new Item(IdManager.getInstance().getNextId(), itemId);
item.setCount(num); item.setCount(num);
@@ -335,7 +342,7 @@ public class CellPathFinding extends PathFinding
_debugItems.add(item); _debugItems.add(item);
} }
private static final class BufferInfo private static class BufferInfo
{ {
final int mapSize; final int mapSize;
final int count; final int count;

View File

@@ -17,9 +17,9 @@
package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes; package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.ListIterator;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -114,7 +114,7 @@ public class CellPathFinding extends PathFinding
{ {
if (_debugItems == null) if (_debugItems == null)
{ {
_debugItems = new CopyOnWriteArrayList<>(); _debugItems = new LinkedList<>();
} }
else else
{ {
@@ -179,28 +179,35 @@ public class CellPathFinding extends PathFinding
_postFilterPlayableUses++; _postFilterPlayableUses++;
} }
boolean remove; ListIterator<AbstractNodeLoc> middlePoint;
int currentX;
int currentY;
int currentZ;
int pass = 0; int pass = 0;
boolean remove;
do do
{ {
pass++; pass++;
_postFilterPasses++; _postFilterPasses++;
remove = false; remove = false;
final Iterator<AbstractNodeLoc> endPoint = path.iterator(); middlePoint = path.listIterator();
endPoint.next(); currentX = x;
int currentX = x; currentY = y;
int currentY = y; currentZ = z;
int currentZ = z;
int midPoint = 0; while (middlePoint.hasNext())
while (endPoint.hasNext())
{ {
final AbstractNodeLoc locMiddle = path.get(midPoint); final AbstractNodeLoc locMiddle = middlePoint.next();
final AbstractNodeLoc locEnd = endPoint.next(); if (!middlePoint.hasNext())
{
break;
}
final AbstractNodeLoc locEnd = path.get(middlePoint.nextIndex());
if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance)) if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance))
{ {
path.remove(midPoint); middlePoint.remove();
remove = true; remove = true;
if (debug) if (debug)
{ {
@@ -212,7 +219,6 @@ public class CellPathFinding extends PathFinding
currentX = locMiddle.getX(); currentX = locMiddle.getX();
currentY = locMiddle.getY(); currentY = locMiddle.getY();
currentZ = locMiddle.getZ(); currentZ = locMiddle.getZ();
midPoint++;
} }
} }
} }
@@ -231,7 +237,7 @@ public class CellPathFinding extends PathFinding
private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node) private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node)
{ {
final List<AbstractNodeLoc> path = new CopyOnWriteArrayList<>(); final LinkedList<AbstractNodeLoc> path = new LinkedList<>();
int previousDirectionX = Integer.MIN_VALUE; int previousDirectionX = Integer.MIN_VALUE;
int previousDirectionY = Integer.MIN_VALUE; int previousDirectionY = Integer.MIN_VALUE;
int directionX; int directionX;
@@ -267,16 +273,17 @@ public class CellPathFinding extends PathFinding
previousDirectionX = directionX; previousDirectionX = directionX;
previousDirectionY = directionY; previousDirectionY = directionY;
path.add(0, tempNode.getLoc()); path.addFirst(tempNode.getLoc());
tempNode.setLoc(null); tempNode.setLoc(null);
} }
tempNode = tempNode.getParent(); tempNode = tempNode.getParent();
} }
return path; return path;
} }
private final CellNodeBuffer alloc(int size, boolean playable) private CellNodeBuffer alloc(int size, boolean playable)
{ {
CellNodeBuffer current = null; CellNodeBuffer current = null;
for (BufferInfo i : _allBuffers) for (BufferInfo i : _allBuffers)
@@ -328,7 +335,7 @@ public class CellPathFinding extends PathFinding
return current; return current;
} }
private final void dropDebugItem(int itemId, int num, AbstractNodeLoc loc) private void dropDebugItem(int itemId, int num, AbstractNodeLoc loc)
{ {
final Item item = new Item(IdManager.getInstance().getNextId(), itemId); final Item item = new Item(IdManager.getInstance().getNextId(), itemId);
item.setCount(num); item.setCount(num);
@@ -336,7 +343,7 @@ public class CellPathFinding extends PathFinding
_debugItems.add(item); _debugItems.add(item);
} }
private static final class BufferInfo private static class BufferInfo
{ {
final int mapSize; final int mapSize;
final int count; final int count;

View File

@@ -17,9 +17,9 @@
package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes; package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.ListIterator;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -114,7 +114,7 @@ public class CellPathFinding extends PathFinding
{ {
if (_debugItems == null) if (_debugItems == null)
{ {
_debugItems = new CopyOnWriteArrayList<>(); _debugItems = new LinkedList<>();
} }
else else
{ {
@@ -179,28 +179,35 @@ public class CellPathFinding extends PathFinding
_postFilterPlayableUses++; _postFilterPlayableUses++;
} }
boolean remove; ListIterator<AbstractNodeLoc> middlePoint;
int currentX;
int currentY;
int currentZ;
int pass = 0; int pass = 0;
boolean remove;
do do
{ {
pass++; pass++;
_postFilterPasses++; _postFilterPasses++;
remove = false; remove = false;
final Iterator<AbstractNodeLoc> endPoint = path.iterator(); middlePoint = path.listIterator();
endPoint.next(); currentX = x;
int currentX = x; currentY = y;
int currentY = y; currentZ = z;
int currentZ = z;
int midPoint = 0; while (middlePoint.hasNext())
while (endPoint.hasNext())
{ {
final AbstractNodeLoc locMiddle = path.get(midPoint); final AbstractNodeLoc locMiddle = middlePoint.next();
final AbstractNodeLoc locEnd = endPoint.next(); if (!middlePoint.hasNext())
{
break;
}
final AbstractNodeLoc locEnd = path.get(middlePoint.nextIndex());
if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance)) if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance))
{ {
path.remove(midPoint); middlePoint.remove();
remove = true; remove = true;
if (debug) if (debug)
{ {
@@ -212,7 +219,6 @@ public class CellPathFinding extends PathFinding
currentX = locMiddle.getX(); currentX = locMiddle.getX();
currentY = locMiddle.getY(); currentY = locMiddle.getY();
currentZ = locMiddle.getZ(); currentZ = locMiddle.getZ();
midPoint++;
} }
} }
} }
@@ -231,7 +237,7 @@ public class CellPathFinding extends PathFinding
private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node) private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node)
{ {
final List<AbstractNodeLoc> path = new CopyOnWriteArrayList<>(); final LinkedList<AbstractNodeLoc> path = new LinkedList<>();
int previousDirectionX = Integer.MIN_VALUE; int previousDirectionX = Integer.MIN_VALUE;
int previousDirectionY = Integer.MIN_VALUE; int previousDirectionY = Integer.MIN_VALUE;
int directionX; int directionX;
@@ -267,16 +273,17 @@ public class CellPathFinding extends PathFinding
previousDirectionX = directionX; previousDirectionX = directionX;
previousDirectionY = directionY; previousDirectionY = directionY;
path.add(0, tempNode.getLoc()); path.addFirst(tempNode.getLoc());
tempNode.setLoc(null); tempNode.setLoc(null);
} }
tempNode = tempNode.getParent(); tempNode = tempNode.getParent();
} }
return path; return path;
} }
private final CellNodeBuffer alloc(int size, boolean playable) private CellNodeBuffer alloc(int size, boolean playable)
{ {
CellNodeBuffer current = null; CellNodeBuffer current = null;
for (BufferInfo i : _allBuffers) for (BufferInfo i : _allBuffers)
@@ -328,7 +335,7 @@ public class CellPathFinding extends PathFinding
return current; return current;
} }
private final void dropDebugItem(int itemId, int num, AbstractNodeLoc loc) private void dropDebugItem(int itemId, int num, AbstractNodeLoc loc)
{ {
final Item item = new Item(IdManager.getInstance().getNextId(), itemId); final Item item = new Item(IdManager.getInstance().getNextId(), itemId);
item.setCount(num); item.setCount(num);
@@ -336,7 +343,7 @@ public class CellPathFinding extends PathFinding
_debugItems.add(item); _debugItems.add(item);
} }
private static final class BufferInfo private static class BufferInfo
{ {
final int mapSize; final int mapSize;
final int count; final int count;

View File

@@ -17,9 +17,9 @@
package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes; package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.ListIterator;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -114,7 +114,7 @@ public class CellPathFinding extends PathFinding
{ {
if (_debugItems == null) if (_debugItems == null)
{ {
_debugItems = new CopyOnWriteArrayList<>(); _debugItems = new LinkedList<>();
} }
else else
{ {
@@ -179,28 +179,35 @@ public class CellPathFinding extends PathFinding
_postFilterPlayableUses++; _postFilterPlayableUses++;
} }
boolean remove; ListIterator<AbstractNodeLoc> middlePoint;
int currentX;
int currentY;
int currentZ;
int pass = 0; int pass = 0;
boolean remove;
do do
{ {
pass++; pass++;
_postFilterPasses++; _postFilterPasses++;
remove = false; remove = false;
final Iterator<AbstractNodeLoc> endPoint = path.iterator(); middlePoint = path.listIterator();
endPoint.next(); currentX = x;
int currentX = x; currentY = y;
int currentY = y; currentZ = z;
int currentZ = z;
int midPoint = 0; while (middlePoint.hasNext())
while (endPoint.hasNext())
{ {
final AbstractNodeLoc locMiddle = path.get(midPoint); final AbstractNodeLoc locMiddle = middlePoint.next();
final AbstractNodeLoc locEnd = endPoint.next(); if (!middlePoint.hasNext())
{
break;
}
final AbstractNodeLoc locEnd = path.get(middlePoint.nextIndex());
if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance)) if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance))
{ {
path.remove(midPoint); middlePoint.remove();
remove = true; remove = true;
if (debug) if (debug)
{ {
@@ -212,7 +219,6 @@ public class CellPathFinding extends PathFinding
currentX = locMiddle.getX(); currentX = locMiddle.getX();
currentY = locMiddle.getY(); currentY = locMiddle.getY();
currentZ = locMiddle.getZ(); currentZ = locMiddle.getZ();
midPoint++;
} }
} }
} }
@@ -231,7 +237,7 @@ public class CellPathFinding extends PathFinding
private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node) private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node)
{ {
final List<AbstractNodeLoc> path = new CopyOnWriteArrayList<>(); final LinkedList<AbstractNodeLoc> path = new LinkedList<>();
int previousDirectionX = Integer.MIN_VALUE; int previousDirectionX = Integer.MIN_VALUE;
int previousDirectionY = Integer.MIN_VALUE; int previousDirectionY = Integer.MIN_VALUE;
int directionX; int directionX;
@@ -267,16 +273,17 @@ public class CellPathFinding extends PathFinding
previousDirectionX = directionX; previousDirectionX = directionX;
previousDirectionY = directionY; previousDirectionY = directionY;
path.add(0, tempNode.getLoc()); path.addFirst(tempNode.getLoc());
tempNode.setLoc(null); tempNode.setLoc(null);
} }
tempNode = tempNode.getParent(); tempNode = tempNode.getParent();
} }
return path; return path;
} }
private final CellNodeBuffer alloc(int size, boolean playable) private CellNodeBuffer alloc(int size, boolean playable)
{ {
CellNodeBuffer current = null; CellNodeBuffer current = null;
for (BufferInfo i : _allBuffers) for (BufferInfo i : _allBuffers)
@@ -328,7 +335,7 @@ public class CellPathFinding extends PathFinding
return current; return current;
} }
private final void dropDebugItem(int itemId, int num, AbstractNodeLoc loc) private void dropDebugItem(int itemId, int num, AbstractNodeLoc loc)
{ {
final Item item = new Item(IdManager.getInstance().getNextId(), itemId); final Item item = new Item(IdManager.getInstance().getNextId(), itemId);
item.setCount(num); item.setCount(num);
@@ -336,7 +343,7 @@ public class CellPathFinding extends PathFinding
_debugItems.add(item); _debugItems.add(item);
} }
private static final class BufferInfo private static class BufferInfo
{ {
final int mapSize; final int mapSize;
final int count; final int count;

View File

@@ -17,9 +17,9 @@
package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes; package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.ListIterator;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -114,7 +114,7 @@ public class CellPathFinding extends PathFinding
{ {
if (_debugItems == null) if (_debugItems == null)
{ {
_debugItems = new CopyOnWriteArrayList<>(); _debugItems = new LinkedList<>();
} }
else else
{ {
@@ -179,28 +179,35 @@ public class CellPathFinding extends PathFinding
_postFilterPlayableUses++; _postFilterPlayableUses++;
} }
boolean remove; ListIterator<AbstractNodeLoc> middlePoint;
int currentX;
int currentY;
int currentZ;
int pass = 0; int pass = 0;
boolean remove;
do do
{ {
pass++; pass++;
_postFilterPasses++; _postFilterPasses++;
remove = false; remove = false;
final Iterator<AbstractNodeLoc> endPoint = path.iterator(); middlePoint = path.listIterator();
endPoint.next(); currentX = x;
int currentX = x; currentY = y;
int currentY = y; currentZ = z;
int currentZ = z;
int midPoint = 0; while (middlePoint.hasNext())
while (endPoint.hasNext())
{ {
final AbstractNodeLoc locMiddle = path.get(midPoint); final AbstractNodeLoc locMiddle = middlePoint.next();
final AbstractNodeLoc locEnd = endPoint.next(); if (!middlePoint.hasNext())
{
break;
}
final AbstractNodeLoc locEnd = path.get(middlePoint.nextIndex());
if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance)) if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance))
{ {
path.remove(midPoint); middlePoint.remove();
remove = true; remove = true;
if (debug) if (debug)
{ {
@@ -212,7 +219,6 @@ public class CellPathFinding extends PathFinding
currentX = locMiddle.getX(); currentX = locMiddle.getX();
currentY = locMiddle.getY(); currentY = locMiddle.getY();
currentZ = locMiddle.getZ(); currentZ = locMiddle.getZ();
midPoint++;
} }
} }
} }
@@ -231,7 +237,7 @@ public class CellPathFinding extends PathFinding
private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node) private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node)
{ {
final List<AbstractNodeLoc> path = new CopyOnWriteArrayList<>(); final LinkedList<AbstractNodeLoc> path = new LinkedList<>();
int previousDirectionX = Integer.MIN_VALUE; int previousDirectionX = Integer.MIN_VALUE;
int previousDirectionY = Integer.MIN_VALUE; int previousDirectionY = Integer.MIN_VALUE;
int directionX; int directionX;
@@ -267,16 +273,17 @@ public class CellPathFinding extends PathFinding
previousDirectionX = directionX; previousDirectionX = directionX;
previousDirectionY = directionY; previousDirectionY = directionY;
path.add(0, tempNode.getLoc()); path.addFirst(tempNode.getLoc());
tempNode.setLoc(null); tempNode.setLoc(null);
} }
tempNode = tempNode.getParent(); tempNode = tempNode.getParent();
} }
return path; return path;
} }
private final CellNodeBuffer alloc(int size, boolean playable) private CellNodeBuffer alloc(int size, boolean playable)
{ {
CellNodeBuffer current = null; CellNodeBuffer current = null;
for (BufferInfo i : _allBuffers) for (BufferInfo i : _allBuffers)
@@ -328,7 +335,7 @@ public class CellPathFinding extends PathFinding
return current; return current;
} }
private final void dropDebugItem(int itemId, int num, AbstractNodeLoc loc) private void dropDebugItem(int itemId, int num, AbstractNodeLoc loc)
{ {
final Item item = new Item(IdManager.getInstance().getNextId(), itemId); final Item item = new Item(IdManager.getInstance().getNextId(), itemId);
item.setCount(num); item.setCount(num);
@@ -336,7 +343,7 @@ public class CellPathFinding extends PathFinding
_debugItems.add(item); _debugItems.add(item);
} }
private static final class BufferInfo private static class BufferInfo
{ {
final int mapSize; final int mapSize;
final int count; final int count;

View File

@@ -17,9 +17,9 @@
package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes; package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.ListIterator;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -114,7 +114,7 @@ public class CellPathFinding extends PathFinding
{ {
if (_debugItems == null) if (_debugItems == null)
{ {
_debugItems = new CopyOnWriteArrayList<>(); _debugItems = new LinkedList<>();
} }
else else
{ {
@@ -179,28 +179,35 @@ public class CellPathFinding extends PathFinding
_postFilterPlayableUses++; _postFilterPlayableUses++;
} }
boolean remove; ListIterator<AbstractNodeLoc> middlePoint;
int currentX;
int currentY;
int currentZ;
int pass = 0; int pass = 0;
boolean remove;
do do
{ {
pass++; pass++;
_postFilterPasses++; _postFilterPasses++;
remove = false; remove = false;
final Iterator<AbstractNodeLoc> endPoint = path.iterator(); middlePoint = path.listIterator();
endPoint.next(); currentX = x;
int currentX = x; currentY = y;
int currentY = y; currentZ = z;
int currentZ = z;
int midPoint = 0; while (middlePoint.hasNext())
while (endPoint.hasNext())
{ {
final AbstractNodeLoc locMiddle = path.get(midPoint); final AbstractNodeLoc locMiddle = middlePoint.next();
final AbstractNodeLoc locEnd = endPoint.next(); if (!middlePoint.hasNext())
{
break;
}
final AbstractNodeLoc locEnd = path.get(middlePoint.nextIndex());
if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance)) if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance))
{ {
path.remove(midPoint); middlePoint.remove();
remove = true; remove = true;
if (debug) if (debug)
{ {
@@ -212,7 +219,6 @@ public class CellPathFinding extends PathFinding
currentX = locMiddle.getX(); currentX = locMiddle.getX();
currentY = locMiddle.getY(); currentY = locMiddle.getY();
currentZ = locMiddle.getZ(); currentZ = locMiddle.getZ();
midPoint++;
} }
} }
} }
@@ -231,7 +237,7 @@ public class CellPathFinding extends PathFinding
private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node) private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node)
{ {
final List<AbstractNodeLoc> path = new CopyOnWriteArrayList<>(); final LinkedList<AbstractNodeLoc> path = new LinkedList<>();
int previousDirectionX = Integer.MIN_VALUE; int previousDirectionX = Integer.MIN_VALUE;
int previousDirectionY = Integer.MIN_VALUE; int previousDirectionY = Integer.MIN_VALUE;
int directionX; int directionX;
@@ -267,16 +273,17 @@ public class CellPathFinding extends PathFinding
previousDirectionX = directionX; previousDirectionX = directionX;
previousDirectionY = directionY; previousDirectionY = directionY;
path.add(0, tempNode.getLoc()); path.addFirst(tempNode.getLoc());
tempNode.setLoc(null); tempNode.setLoc(null);
} }
tempNode = tempNode.getParent(); tempNode = tempNode.getParent();
} }
return path; return path;
} }
private final CellNodeBuffer alloc(int size, boolean playable) private CellNodeBuffer alloc(int size, boolean playable)
{ {
CellNodeBuffer current = null; CellNodeBuffer current = null;
for (BufferInfo i : _allBuffers) for (BufferInfo i : _allBuffers)
@@ -328,7 +335,7 @@ public class CellPathFinding extends PathFinding
return current; return current;
} }
private final void dropDebugItem(int itemId, int num, AbstractNodeLoc loc) private void dropDebugItem(int itemId, int num, AbstractNodeLoc loc)
{ {
final Item item = new Item(IdManager.getInstance().getNextId(), itemId); final Item item = new Item(IdManager.getInstance().getNextId(), itemId);
item.setCount(num); item.setCount(num);
@@ -336,7 +343,7 @@ public class CellPathFinding extends PathFinding
_debugItems.add(item); _debugItems.add(item);
} }
private static final class BufferInfo private static class BufferInfo
{ {
final int mapSize; final int mapSize;
final int count; final int count;

View File

@@ -17,9 +17,9 @@
package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes; package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.ListIterator;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -114,7 +114,7 @@ public class CellPathFinding extends PathFinding
{ {
if (_debugItems == null) if (_debugItems == null)
{ {
_debugItems = new CopyOnWriteArrayList<>(); _debugItems = new LinkedList<>();
} }
else else
{ {
@@ -179,28 +179,35 @@ public class CellPathFinding extends PathFinding
_postFilterPlayableUses++; _postFilterPlayableUses++;
} }
boolean remove; ListIterator<AbstractNodeLoc> middlePoint;
int currentX;
int currentY;
int currentZ;
int pass = 0; int pass = 0;
boolean remove;
do do
{ {
pass++; pass++;
_postFilterPasses++; _postFilterPasses++;
remove = false; remove = false;
final Iterator<AbstractNodeLoc> endPoint = path.iterator(); middlePoint = path.listIterator();
endPoint.next(); currentX = x;
int currentX = x; currentY = y;
int currentY = y; currentZ = z;
int currentZ = z;
int midPoint = 0; while (middlePoint.hasNext())
while (endPoint.hasNext())
{ {
final AbstractNodeLoc locMiddle = path.get(midPoint); final AbstractNodeLoc locMiddle = middlePoint.next();
final AbstractNodeLoc locEnd = endPoint.next(); if (!middlePoint.hasNext())
{
break;
}
final AbstractNodeLoc locEnd = path.get(middlePoint.nextIndex());
if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance)) if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance))
{ {
path.remove(midPoint); middlePoint.remove();
remove = true; remove = true;
if (debug) if (debug)
{ {
@@ -212,7 +219,6 @@ public class CellPathFinding extends PathFinding
currentX = locMiddle.getX(); currentX = locMiddle.getX();
currentY = locMiddle.getY(); currentY = locMiddle.getY();
currentZ = locMiddle.getZ(); currentZ = locMiddle.getZ();
midPoint++;
} }
} }
} }
@@ -231,7 +237,7 @@ public class CellPathFinding extends PathFinding
private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node) private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node)
{ {
final List<AbstractNodeLoc> path = new CopyOnWriteArrayList<>(); final LinkedList<AbstractNodeLoc> path = new LinkedList<>();
int previousDirectionX = Integer.MIN_VALUE; int previousDirectionX = Integer.MIN_VALUE;
int previousDirectionY = Integer.MIN_VALUE; int previousDirectionY = Integer.MIN_VALUE;
int directionX; int directionX;
@@ -267,16 +273,17 @@ public class CellPathFinding extends PathFinding
previousDirectionX = directionX; previousDirectionX = directionX;
previousDirectionY = directionY; previousDirectionY = directionY;
path.add(0, tempNode.getLoc()); path.addFirst(tempNode.getLoc());
tempNode.setLoc(null); tempNode.setLoc(null);
} }
tempNode = tempNode.getParent(); tempNode = tempNode.getParent();
} }
return path; return path;
} }
private final CellNodeBuffer alloc(int size, boolean playable) private CellNodeBuffer alloc(int size, boolean playable)
{ {
CellNodeBuffer current = null; CellNodeBuffer current = null;
for (BufferInfo i : _allBuffers) for (BufferInfo i : _allBuffers)
@@ -328,7 +335,7 @@ public class CellPathFinding extends PathFinding
return current; return current;
} }
private final void dropDebugItem(int itemId, int num, AbstractNodeLoc loc) private void dropDebugItem(int itemId, int num, AbstractNodeLoc loc)
{ {
final Item item = new Item(IdManager.getInstance().getNextId(), itemId); final Item item = new Item(IdManager.getInstance().getNextId(), itemId);
item.setCount(num); item.setCount(num);
@@ -336,7 +343,7 @@ public class CellPathFinding extends PathFinding
_debugItems.add(item); _debugItems.add(item);
} }
private static final class BufferInfo private static class BufferInfo
{ {
final int mapSize; final int mapSize;
final int count; final int count;

View File

@@ -17,9 +17,9 @@
package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes; package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.ListIterator;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -114,7 +114,7 @@ public class CellPathFinding extends PathFinding
{ {
if (_debugItems == null) if (_debugItems == null)
{ {
_debugItems = new CopyOnWriteArrayList<>(); _debugItems = new LinkedList<>();
} }
else else
{ {
@@ -179,28 +179,35 @@ public class CellPathFinding extends PathFinding
_postFilterPlayableUses++; _postFilterPlayableUses++;
} }
boolean remove; ListIterator<AbstractNodeLoc> middlePoint;
int currentX;
int currentY;
int currentZ;
int pass = 0; int pass = 0;
boolean remove;
do do
{ {
pass++; pass++;
_postFilterPasses++; _postFilterPasses++;
remove = false; remove = false;
final Iterator<AbstractNodeLoc> endPoint = path.iterator(); middlePoint = path.listIterator();
endPoint.next(); currentX = x;
int currentX = x; currentY = y;
int currentY = y; currentZ = z;
int currentZ = z;
int midPoint = 0; while (middlePoint.hasNext())
while (endPoint.hasNext())
{ {
final AbstractNodeLoc locMiddle = path.get(midPoint); final AbstractNodeLoc locMiddle = middlePoint.next();
final AbstractNodeLoc locEnd = endPoint.next(); if (!middlePoint.hasNext())
{
break;
}
final AbstractNodeLoc locEnd = path.get(middlePoint.nextIndex());
if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance)) if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance))
{ {
path.remove(midPoint); middlePoint.remove();
remove = true; remove = true;
if (debug) if (debug)
{ {
@@ -212,7 +219,6 @@ public class CellPathFinding extends PathFinding
currentX = locMiddle.getX(); currentX = locMiddle.getX();
currentY = locMiddle.getY(); currentY = locMiddle.getY();
currentZ = locMiddle.getZ(); currentZ = locMiddle.getZ();
midPoint++;
} }
} }
} }
@@ -231,7 +237,7 @@ public class CellPathFinding extends PathFinding
private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node) private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node)
{ {
final List<AbstractNodeLoc> path = new CopyOnWriteArrayList<>(); final LinkedList<AbstractNodeLoc> path = new LinkedList<>();
int previousDirectionX = Integer.MIN_VALUE; int previousDirectionX = Integer.MIN_VALUE;
int previousDirectionY = Integer.MIN_VALUE; int previousDirectionY = Integer.MIN_VALUE;
int directionX; int directionX;
@@ -267,16 +273,17 @@ public class CellPathFinding extends PathFinding
previousDirectionX = directionX; previousDirectionX = directionX;
previousDirectionY = directionY; previousDirectionY = directionY;
path.add(0, tempNode.getLoc()); path.addFirst(tempNode.getLoc());
tempNode.setLoc(null); tempNode.setLoc(null);
} }
tempNode = tempNode.getParent(); tempNode = tempNode.getParent();
} }
return path; return path;
} }
private final CellNodeBuffer alloc(int size, boolean playable) private CellNodeBuffer alloc(int size, boolean playable)
{ {
CellNodeBuffer current = null; CellNodeBuffer current = null;
for (BufferInfo i : _allBuffers) for (BufferInfo i : _allBuffers)
@@ -328,7 +335,7 @@ public class CellPathFinding extends PathFinding
return current; return current;
} }
private final void dropDebugItem(int itemId, int num, AbstractNodeLoc loc) private void dropDebugItem(int itemId, int num, AbstractNodeLoc loc)
{ {
final Item item = new Item(IdManager.getInstance().getNextId(), itemId); final Item item = new Item(IdManager.getInstance().getNextId(), itemId);
item.setCount(num); item.setCount(num);
@@ -336,7 +343,7 @@ public class CellPathFinding extends PathFinding
_debugItems.add(item); _debugItems.add(item);
} }
private static final class BufferInfo private static class BufferInfo
{ {
final int mapSize; final int mapSize;
final int count; final int count;

View File

@@ -17,9 +17,9 @@
package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes; package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.ListIterator;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -114,7 +114,7 @@ public class CellPathFinding extends PathFinding
{ {
if (_debugItems == null) if (_debugItems == null)
{ {
_debugItems = new CopyOnWriteArrayList<>(); _debugItems = new LinkedList<>();
} }
else else
{ {
@@ -179,28 +179,35 @@ public class CellPathFinding extends PathFinding
_postFilterPlayableUses++; _postFilterPlayableUses++;
} }
boolean remove; ListIterator<AbstractNodeLoc> middlePoint;
int currentX;
int currentY;
int currentZ;
int pass = 0; int pass = 0;
boolean remove;
do do
{ {
pass++; pass++;
_postFilterPasses++; _postFilterPasses++;
remove = false; remove = false;
final Iterator<AbstractNodeLoc> endPoint = path.iterator(); middlePoint = path.listIterator();
endPoint.next(); currentX = x;
int currentX = x; currentY = y;
int currentY = y; currentZ = z;
int currentZ = z;
int midPoint = 0; while (middlePoint.hasNext())
while (endPoint.hasNext())
{ {
final AbstractNodeLoc locMiddle = path.get(midPoint); final AbstractNodeLoc locMiddle = middlePoint.next();
final AbstractNodeLoc locEnd = endPoint.next(); if (!middlePoint.hasNext())
{
break;
}
final AbstractNodeLoc locEnd = path.get(middlePoint.nextIndex());
if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance)) if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance))
{ {
path.remove(midPoint); middlePoint.remove();
remove = true; remove = true;
if (debug) if (debug)
{ {
@@ -212,7 +219,6 @@ public class CellPathFinding extends PathFinding
currentX = locMiddle.getX(); currentX = locMiddle.getX();
currentY = locMiddle.getY(); currentY = locMiddle.getY();
currentZ = locMiddle.getZ(); currentZ = locMiddle.getZ();
midPoint++;
} }
} }
} }
@@ -231,7 +237,7 @@ public class CellPathFinding extends PathFinding
private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node) private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node)
{ {
final List<AbstractNodeLoc> path = new CopyOnWriteArrayList<>(); final LinkedList<AbstractNodeLoc> path = new LinkedList<>();
int previousDirectionX = Integer.MIN_VALUE; int previousDirectionX = Integer.MIN_VALUE;
int previousDirectionY = Integer.MIN_VALUE; int previousDirectionY = Integer.MIN_VALUE;
int directionX; int directionX;
@@ -267,16 +273,17 @@ public class CellPathFinding extends PathFinding
previousDirectionX = directionX; previousDirectionX = directionX;
previousDirectionY = directionY; previousDirectionY = directionY;
path.add(0, tempNode.getLoc()); path.addFirst(tempNode.getLoc());
tempNode.setLoc(null); tempNode.setLoc(null);
} }
tempNode = tempNode.getParent(); tempNode = tempNode.getParent();
} }
return path; return path;
} }
private final CellNodeBuffer alloc(int size, boolean playable) private CellNodeBuffer alloc(int size, boolean playable)
{ {
CellNodeBuffer current = null; CellNodeBuffer current = null;
for (BufferInfo i : _allBuffers) for (BufferInfo i : _allBuffers)
@@ -328,7 +335,7 @@ public class CellPathFinding extends PathFinding
return current; return current;
} }
private final void dropDebugItem(int itemId, int num, AbstractNodeLoc loc) private void dropDebugItem(int itemId, int num, AbstractNodeLoc loc)
{ {
final Item item = new Item(IdManager.getInstance().getNextId(), itemId); final Item item = new Item(IdManager.getInstance().getNextId(), itemId);
item.setCount(num); item.setCount(num);
@@ -336,7 +343,7 @@ public class CellPathFinding extends PathFinding
_debugItems.add(item); _debugItems.add(item);
} }
private static final class BufferInfo private static class BufferInfo
{ {
final int mapSize; final int mapSize;
final int count; final int count;

View File

@@ -17,9 +17,9 @@
package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes; package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.ListIterator;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -114,7 +114,7 @@ public class CellPathFinding extends PathFinding
{ {
if (_debugItems == null) if (_debugItems == null)
{ {
_debugItems = new CopyOnWriteArrayList<>(); _debugItems = new LinkedList<>();
} }
else else
{ {
@@ -179,28 +179,35 @@ public class CellPathFinding extends PathFinding
_postFilterPlayableUses++; _postFilterPlayableUses++;
} }
boolean remove; ListIterator<AbstractNodeLoc> middlePoint;
int currentX;
int currentY;
int currentZ;
int pass = 0; int pass = 0;
boolean remove;
do do
{ {
pass++; pass++;
_postFilterPasses++; _postFilterPasses++;
remove = false; remove = false;
final Iterator<AbstractNodeLoc> endPoint = path.iterator(); middlePoint = path.listIterator();
endPoint.next(); currentX = x;
int currentX = x; currentY = y;
int currentY = y; currentZ = z;
int currentZ = z;
int midPoint = 0; while (middlePoint.hasNext())
while (endPoint.hasNext())
{ {
final AbstractNodeLoc locMiddle = path.get(midPoint); final AbstractNodeLoc locMiddle = middlePoint.next();
final AbstractNodeLoc locEnd = endPoint.next(); if (!middlePoint.hasNext())
{
break;
}
final AbstractNodeLoc locEnd = path.get(middlePoint.nextIndex());
if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance)) if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance))
{ {
path.remove(midPoint); middlePoint.remove();
remove = true; remove = true;
if (debug) if (debug)
{ {
@@ -212,7 +219,6 @@ public class CellPathFinding extends PathFinding
currentX = locMiddle.getX(); currentX = locMiddle.getX();
currentY = locMiddle.getY(); currentY = locMiddle.getY();
currentZ = locMiddle.getZ(); currentZ = locMiddle.getZ();
midPoint++;
} }
} }
} }
@@ -231,7 +237,7 @@ public class CellPathFinding extends PathFinding
private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node) private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node)
{ {
final List<AbstractNodeLoc> path = new CopyOnWriteArrayList<>(); final LinkedList<AbstractNodeLoc> path = new LinkedList<>();
int previousDirectionX = Integer.MIN_VALUE; int previousDirectionX = Integer.MIN_VALUE;
int previousDirectionY = Integer.MIN_VALUE; int previousDirectionY = Integer.MIN_VALUE;
int directionX; int directionX;
@@ -267,16 +273,17 @@ public class CellPathFinding extends PathFinding
previousDirectionX = directionX; previousDirectionX = directionX;
previousDirectionY = directionY; previousDirectionY = directionY;
path.add(0, tempNode.getLoc()); path.addFirst(tempNode.getLoc());
tempNode.setLoc(null); tempNode.setLoc(null);
} }
tempNode = tempNode.getParent(); tempNode = tempNode.getParent();
} }
return path; return path;
} }
private final CellNodeBuffer alloc(int size, boolean playable) private CellNodeBuffer alloc(int size, boolean playable)
{ {
CellNodeBuffer current = null; CellNodeBuffer current = null;
for (BufferInfo i : _allBuffers) for (BufferInfo i : _allBuffers)
@@ -328,7 +335,7 @@ public class CellPathFinding extends PathFinding
return current; return current;
} }
private final void dropDebugItem(int itemId, int num, AbstractNodeLoc loc) private void dropDebugItem(int itemId, int num, AbstractNodeLoc loc)
{ {
final Item item = new Item(IdManager.getInstance().getNextId(), itemId); final Item item = new Item(IdManager.getInstance().getNextId(), itemId);
item.setCount(num); item.setCount(num);
@@ -336,7 +343,7 @@ public class CellPathFinding extends PathFinding
_debugItems.add(item); _debugItems.add(item);
} }
private static final class BufferInfo private static class BufferInfo
{ {
final int mapSize; final int mapSize;
final int count; final int count;

View File

@@ -17,9 +17,9 @@
package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes; package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.ListIterator;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -114,7 +114,7 @@ public class CellPathFinding extends PathFinding
{ {
if (_debugItems == null) if (_debugItems == null)
{ {
_debugItems = new CopyOnWriteArrayList<>(); _debugItems = new LinkedList<>();
} }
else else
{ {
@@ -179,28 +179,35 @@ public class CellPathFinding extends PathFinding
_postFilterPlayableUses++; _postFilterPlayableUses++;
} }
boolean remove; ListIterator<AbstractNodeLoc> middlePoint;
int currentX;
int currentY;
int currentZ;
int pass = 0; int pass = 0;
boolean remove;
do do
{ {
pass++; pass++;
_postFilterPasses++; _postFilterPasses++;
remove = false; remove = false;
final Iterator<AbstractNodeLoc> endPoint = path.iterator(); middlePoint = path.listIterator();
endPoint.next(); currentX = x;
int currentX = x; currentY = y;
int currentY = y; currentZ = z;
int currentZ = z;
int midPoint = 0; while (middlePoint.hasNext())
while (endPoint.hasNext())
{ {
final AbstractNodeLoc locMiddle = path.get(midPoint); final AbstractNodeLoc locMiddle = middlePoint.next();
final AbstractNodeLoc locEnd = endPoint.next(); if (!middlePoint.hasNext())
{
break;
}
final AbstractNodeLoc locEnd = path.get(middlePoint.nextIndex());
if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance)) if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance))
{ {
path.remove(midPoint); middlePoint.remove();
remove = true; remove = true;
if (debug) if (debug)
{ {
@@ -212,7 +219,6 @@ public class CellPathFinding extends PathFinding
currentX = locMiddle.getX(); currentX = locMiddle.getX();
currentY = locMiddle.getY(); currentY = locMiddle.getY();
currentZ = locMiddle.getZ(); currentZ = locMiddle.getZ();
midPoint++;
} }
} }
} }
@@ -231,7 +237,7 @@ public class CellPathFinding extends PathFinding
private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node) private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node)
{ {
final List<AbstractNodeLoc> path = new CopyOnWriteArrayList<>(); final LinkedList<AbstractNodeLoc> path = new LinkedList<>();
int previousDirectionX = Integer.MIN_VALUE; int previousDirectionX = Integer.MIN_VALUE;
int previousDirectionY = Integer.MIN_VALUE; int previousDirectionY = Integer.MIN_VALUE;
int directionX; int directionX;
@@ -267,16 +273,17 @@ public class CellPathFinding extends PathFinding
previousDirectionX = directionX; previousDirectionX = directionX;
previousDirectionY = directionY; previousDirectionY = directionY;
path.add(0, tempNode.getLoc()); path.addFirst(tempNode.getLoc());
tempNode.setLoc(null); tempNode.setLoc(null);
} }
tempNode = tempNode.getParent(); tempNode = tempNode.getParent();
} }
return path; return path;
} }
private final CellNodeBuffer alloc(int size, boolean playable) private CellNodeBuffer alloc(int size, boolean playable)
{ {
CellNodeBuffer current = null; CellNodeBuffer current = null;
for (BufferInfo i : _allBuffers) for (BufferInfo i : _allBuffers)
@@ -328,7 +335,7 @@ public class CellPathFinding extends PathFinding
return current; return current;
} }
private final void dropDebugItem(int itemId, int num, AbstractNodeLoc loc) private void dropDebugItem(int itemId, int num, AbstractNodeLoc loc)
{ {
final Item item = new Item(IdManager.getInstance().getNextId(), itemId); final Item item = new Item(IdManager.getInstance().getNextId(), itemId);
item.setCount(num); item.setCount(num);
@@ -336,7 +343,7 @@ public class CellPathFinding extends PathFinding
_debugItems.add(item); _debugItems.add(item);
} }
private static final class BufferInfo private static class BufferInfo
{ {
final int mapSize; final int mapSize;
final int count; final int count;

View File

@@ -17,9 +17,9 @@
package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes; package org.l2jmobius.gameserver.geoengine.pathfinding.cellnodes;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.ListIterator;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -114,7 +114,7 @@ public class CellPathFinding extends PathFinding
{ {
if (_debugItems == null) if (_debugItems == null)
{ {
_debugItems = new CopyOnWriteArrayList<>(); _debugItems = new LinkedList<>();
} }
else else
{ {
@@ -179,28 +179,35 @@ public class CellPathFinding extends PathFinding
_postFilterPlayableUses++; _postFilterPlayableUses++;
} }
boolean remove; ListIterator<AbstractNodeLoc> middlePoint;
int currentX;
int currentY;
int currentZ;
int pass = 0; int pass = 0;
boolean remove;
do do
{ {
pass++; pass++;
_postFilterPasses++; _postFilterPasses++;
remove = false; remove = false;
final Iterator<AbstractNodeLoc> endPoint = path.iterator(); middlePoint = path.listIterator();
endPoint.next(); currentX = x;
int currentX = x; currentY = y;
int currentY = y; currentZ = z;
int currentZ = z;
int midPoint = 0; while (middlePoint.hasNext())
while (endPoint.hasNext())
{ {
final AbstractNodeLoc locMiddle = path.get(midPoint); final AbstractNodeLoc locMiddle = middlePoint.next();
final AbstractNodeLoc locEnd = endPoint.next(); if (!middlePoint.hasNext())
{
break;
}
final AbstractNodeLoc locEnd = path.get(middlePoint.nextIndex());
if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance)) if (GeoEngine.getInstance().canMoveToTarget(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instance))
{ {
path.remove(midPoint); middlePoint.remove();
remove = true; remove = true;
if (debug) if (debug)
{ {
@@ -212,7 +219,6 @@ public class CellPathFinding extends PathFinding
currentX = locMiddle.getX(); currentX = locMiddle.getX();
currentY = locMiddle.getY(); currentY = locMiddle.getY();
currentZ = locMiddle.getZ(); currentZ = locMiddle.getZ();
midPoint++;
} }
} }
} }
@@ -231,7 +237,7 @@ public class CellPathFinding extends PathFinding
private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node) private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node)
{ {
final List<AbstractNodeLoc> path = new CopyOnWriteArrayList<>(); final LinkedList<AbstractNodeLoc> path = new LinkedList<>();
int previousDirectionX = Integer.MIN_VALUE; int previousDirectionX = Integer.MIN_VALUE;
int previousDirectionY = Integer.MIN_VALUE; int previousDirectionY = Integer.MIN_VALUE;
int directionX; int directionX;
@@ -267,16 +273,17 @@ public class CellPathFinding extends PathFinding
previousDirectionX = directionX; previousDirectionX = directionX;
previousDirectionY = directionY; previousDirectionY = directionY;
path.add(0, tempNode.getLoc()); path.addFirst(tempNode.getLoc());
tempNode.setLoc(null); tempNode.setLoc(null);
} }
tempNode = tempNode.getParent(); tempNode = tempNode.getParent();
} }
return path; return path;
} }
private final CellNodeBuffer alloc(int size, boolean playable) private CellNodeBuffer alloc(int size, boolean playable)
{ {
CellNodeBuffer current = null; CellNodeBuffer current = null;
for (BufferInfo i : _allBuffers) for (BufferInfo i : _allBuffers)
@@ -328,7 +335,7 @@ public class CellPathFinding extends PathFinding
return current; return current;
} }
private final void dropDebugItem(int itemId, int num, AbstractNodeLoc loc) private void dropDebugItem(int itemId, int num, AbstractNodeLoc loc)
{ {
final Item item = new Item(IdManager.getInstance().getNextId(), itemId); final Item item = new Item(IdManager.getInstance().getNextId(), itemId);
item.setCount(num); item.setCount(num);
@@ -336,7 +343,7 @@ public class CellPathFinding extends PathFinding
_debugItems.add(item); _debugItems.add(item);
} }
private static final class BufferInfo private static class BufferInfo
{ {
final int mapSize; final int mapSize;
final int count; final int count;