Sync with L2jServer HighFive Apr 10th 2015.

This commit is contained in:
MobiusDev
2015-04-11 07:15:16 +00:00
parent 46669bba9d
commit ebfe860e5a
16 changed files with 221 additions and 204 deletions

View File

@ -19,18 +19,17 @@
package com.l2jserver.gameserver.pathfinding.geonodes;
import com.l2jserver.gameserver.pathfinding.AbstractNode;
import com.l2jserver.gameserver.pathfinding.AbstractNodeLoc;
/**
* @author -Nemesiss-
*/
public class GeoNode extends AbstractNode
public class GeoNode extends AbstractNode<GeoNodeLoc>
{
private final int _neighborsIdx;
private short _cost;
private GeoNode[] _neighbors;
public GeoNode(AbstractNodeLoc Loc, int Neighbors_idx)
public GeoNode(GeoNodeLoc Loc, int Neighbors_idx)
{
super(Loc);
_neighborsIdx = Neighbors_idx;
@ -51,15 +50,13 @@ public class GeoNode extends AbstractNode
return _neighbors;
}
public void attachNeighbors()
public void attachNeighbors(GeoNode[] neighbors)
{
if (getLoc() == null)
{
_neighbors = null;
}
else
{
_neighbors = GeoPathFinding.getInstance().readNeighbors(this, _neighborsIdx);
}
_neighbors = neighbors;
}
public int getNeighborsIdx()
{
return _neighborsIdx;
}
}

View File

@ -155,7 +155,7 @@ public class GeoPathFinding extends PathFinding
i++;
visited.add(node);
node.attachNeighbors();
node.attachNeighbors(readNeighbors(node));
GeoNode[] neighbors = node.getNeighbors();
if (neighbors == null)
{
@ -191,7 +191,7 @@ public class GeoPathFinding extends PathFinding
return null;
}
public List<AbstractNodeLoc> constructPath2(AbstractNode node)
public List<AbstractNodeLoc> constructPath2(AbstractNode<GeoNodeLoc> node)
{
LinkedList<AbstractNodeLoc> path = new LinkedList<>();
int previousDirectionX = -1000;
@ -216,8 +216,15 @@ public class GeoPathFinding extends PathFinding
return path;
}
public GeoNode[] readNeighbors(GeoNode n, int idx)
private GeoNode[] readNeighbors(GeoNode n)
{
if (n.getLoc() == null)
{
return null;
}
int idx = n.getNeighborsIdx();
int node_x = n.getLoc().getNodeX();
int node_y = n.getLoc().getNodeY();
// short node_z = n.getLoc().getZ();
@ -225,7 +232,7 @@ public class GeoPathFinding extends PathFinding
short regoffset = getRegionOffset(getRegionX(node_x), getRegionY(node_y));
ByteBuffer pn = _pathNodes.get(regoffset);
List<AbstractNode> neighbors = new ArrayList<>(8);
List<AbstractNode<GeoNodeLoc>> neighbors = new ArrayList<>(8);
GeoNode newNode;
short new_node_x, new_node_y;