Sync with L2jServer HighFive Apr 10th 2015.
This commit is contained in:
@ -65,9 +65,8 @@ public class L2PlayerAI extends L2PlayableAI
|
||||
@Override
|
||||
protected synchronized void changeIntention(CtrlIntention intention, Object arg0, Object arg1)
|
||||
{
|
||||
// do nothing unless CAST intention
|
||||
// however, forget interrupted actions when starting to use an offensive skill
|
||||
if ((intention != AI_INTENTION_CAST) || ((arg0 != null) && ((Skill) arg0).isBad()))
|
||||
// Forget next if it's not cast or it's cast and skill is toggle.
|
||||
if ((intention != AI_INTENTION_CAST) || ((arg0 != null) && !((Skill) arg0).isToggle()))
|
||||
{
|
||||
_nextIntention = null;
|
||||
super.changeIntention(intention, arg0, arg1);
|
||||
|
@ -35,6 +35,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.LinkedBlockingDeque;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.concurrent.locks.StampedLock;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
@ -232,7 +233,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
private L2Character _debugger = null;
|
||||
|
||||
private final ReentrantLock _teleportLock = new ReentrantLock();
|
||||
private final ReentrantLock _attackLock = new ReentrantLock();
|
||||
private final StampedLock _attackLock = new StampedLock();
|
||||
|
||||
private Team _team = Team.NONE;
|
||||
|
||||
@ -825,10 +826,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
*/
|
||||
public void doAttack(L2Character target)
|
||||
{
|
||||
if (!_attackLock.tryLock())
|
||||
{
|
||||
return;
|
||||
}
|
||||
final long stamp = _attackLock.tryWriteLock();
|
||||
try
|
||||
{
|
||||
if ((target == null) || isAttackingDisabled())
|
||||
@ -932,9 +930,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
|
||||
stopEffectsOnAction();
|
||||
|
||||
// Get the active weapon item corresponding to the active weapon instance (always equipped in the right hand)
|
||||
L2Weapon weaponItem = getActiveWeaponItem();
|
||||
|
||||
// GeoData Los Check here (or dz > 1000)
|
||||
if (!GeoData.getInstance().canSeeTarget(this, target))
|
||||
{
|
||||
@ -945,6 +940,8 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
}
|
||||
|
||||
// BOW and CROSSBOW checks
|
||||
// Get the active weapon item corresponding to the active weapon instance (always equipped in the right hand)
|
||||
L2Weapon weaponItem = getActiveWeaponItem();
|
||||
if ((weaponItem != null) && !isTransformed())
|
||||
{
|
||||
if (weaponItem.getItemType() == WeaponType.BOW)
|
||||
@ -1200,7 +1197,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
}
|
||||
finally
|
||||
{
|
||||
_attackLock.unlock();
|
||||
_attackLock.unlockWrite(stamp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11026,6 +11026,7 @@ public final class L2PcInstance extends L2Playable
|
||||
}
|
||||
}
|
||||
}
|
||||
_revivePet = false;
|
||||
_reviveRequested = 0;
|
||||
_revivePower = 0;
|
||||
}
|
||||
|
@ -18,32 +18,32 @@
|
||||
*/
|
||||
package com.l2jserver.gameserver.pathfinding;
|
||||
|
||||
public abstract class AbstractNode
|
||||
public abstract class AbstractNode<Loc extends AbstractNodeLoc>
|
||||
{
|
||||
private AbstractNodeLoc _loc;
|
||||
private AbstractNode _parent;
|
||||
private Loc _loc;
|
||||
private AbstractNode<Loc> _parent;
|
||||
|
||||
public AbstractNode(AbstractNodeLoc loc)
|
||||
public AbstractNode(Loc loc)
|
||||
{
|
||||
_loc = loc;
|
||||
}
|
||||
|
||||
public void setParent(AbstractNode p)
|
||||
public void setParent(AbstractNode<Loc> p)
|
||||
{
|
||||
_parent = p;
|
||||
}
|
||||
|
||||
public AbstractNode getParent()
|
||||
public AbstractNode<Loc> getParent()
|
||||
{
|
||||
return _parent;
|
||||
}
|
||||
|
||||
public AbstractNodeLoc getLoc()
|
||||
public Loc getLoc()
|
||||
{
|
||||
return _loc;
|
||||
}
|
||||
|
||||
public void setLoc(AbstractNodeLoc l)
|
||||
public void setLoc(Loc l)
|
||||
{
|
||||
_loc = l;
|
||||
}
|
||||
@ -72,7 +72,7 @@ public abstract class AbstractNode
|
||||
{
|
||||
return false;
|
||||
}
|
||||
final AbstractNode other = (AbstractNode) obj;
|
||||
final AbstractNode<?> other = (AbstractNode<?>) obj;
|
||||
if (_loc == null)
|
||||
{
|
||||
if (other._loc != null)
|
||||
|
@ -19,15 +19,14 @@
|
||||
package com.l2jserver.gameserver.pathfinding.cellnodes;
|
||||
|
||||
import com.l2jserver.gameserver.pathfinding.AbstractNode;
|
||||
import com.l2jserver.gameserver.pathfinding.AbstractNodeLoc;
|
||||
|
||||
public class CellNode extends AbstractNode
|
||||
public class CellNode extends AbstractNode<NodeLoc>
|
||||
{
|
||||
private CellNode _next = null;
|
||||
private boolean _isInUse = true;
|
||||
private float _cost = -1000;
|
||||
|
||||
public CellNode(AbstractNodeLoc loc)
|
||||
public CellNode(NodeLoc loc)
|
||||
{
|
||||
super(loc);
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ public class CellNodeBuffer
|
||||
|
||||
private final void getNeighbors()
|
||||
{
|
||||
if (((NodeLoc) _current.getLoc()).canGoNone())
|
||||
if (_current.getLoc().canGoNone())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -155,25 +155,25 @@ public class CellNodeBuffer
|
||||
CellNode nodeN = null;
|
||||
|
||||
// East
|
||||
if (((NodeLoc) _current.getLoc()).canGoEast())
|
||||
if (_current.getLoc().canGoEast())
|
||||
{
|
||||
nodeE = addNode(x + 1, y, z, false);
|
||||
}
|
||||
|
||||
// South
|
||||
if (((NodeLoc) _current.getLoc()).canGoSouth())
|
||||
if (_current.getLoc().canGoSouth())
|
||||
{
|
||||
nodeS = addNode(x, y + 1, z, false);
|
||||
}
|
||||
|
||||
// West
|
||||
if (((NodeLoc) _current.getLoc()).canGoWest())
|
||||
if (_current.getLoc().canGoWest())
|
||||
{
|
||||
nodeW = addNode(x - 1, y, z, false);
|
||||
}
|
||||
|
||||
// North
|
||||
if (((NodeLoc) _current.getLoc()).canGoNorth())
|
||||
if (_current.getLoc().canGoNorth())
|
||||
{
|
||||
nodeN = addNode(x, y - 1, z, false);
|
||||
}
|
||||
@ -183,7 +183,7 @@ public class CellNodeBuffer
|
||||
// SouthEast
|
||||
if ((nodeE != null) && (nodeS != null))
|
||||
{
|
||||
if (((NodeLoc) nodeE.getLoc()).canGoSouth() && ((NodeLoc) nodeS.getLoc()).canGoEast())
|
||||
if (nodeE.getLoc().canGoSouth() && nodeS.getLoc().canGoEast())
|
||||
{
|
||||
addNode(x + 1, y + 1, z, true);
|
||||
}
|
||||
@ -192,7 +192,7 @@ public class CellNodeBuffer
|
||||
// SouthWest
|
||||
if ((nodeS != null) && (nodeW != null))
|
||||
{
|
||||
if (((NodeLoc) nodeW.getLoc()).canGoSouth() && ((NodeLoc) nodeS.getLoc()).canGoWest())
|
||||
if (nodeW.getLoc().canGoSouth() && nodeS.getLoc().canGoWest())
|
||||
{
|
||||
addNode(x - 1, y + 1, z, true);
|
||||
}
|
||||
@ -201,7 +201,7 @@ public class CellNodeBuffer
|
||||
// NorthEast
|
||||
if ((nodeN != null) && (nodeE != null))
|
||||
{
|
||||
if (((NodeLoc) nodeE.getLoc()).canGoNorth() && ((NodeLoc) nodeN.getLoc()).canGoEast())
|
||||
if (nodeE.getLoc().canGoNorth() && nodeN.getLoc().canGoEast())
|
||||
{
|
||||
addNode(x + 1, y - 1, z, true);
|
||||
}
|
||||
@ -210,7 +210,7 @@ public class CellNodeBuffer
|
||||
// NorthWest
|
||||
if ((nodeN != null) && (nodeW != null))
|
||||
{
|
||||
if (((NodeLoc) nodeW.getLoc()).canGoNorth() && ((NodeLoc) nodeN.getLoc()).canGoWest())
|
||||
if (nodeW.getLoc().canGoNorth() && nodeN.getLoc().canGoWest())
|
||||
{
|
||||
addNode(x - 1, y - 1, z, true);
|
||||
}
|
||||
@ -244,7 +244,7 @@ public class CellNodeBuffer
|
||||
// reinit node if needed
|
||||
if (result.getLoc() != null)
|
||||
{
|
||||
((NodeLoc) result.getLoc()).set(x, y, z);
|
||||
result.getLoc().set(x, y, z);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -272,7 +272,7 @@ public class CellNodeBuffer
|
||||
final int stepZ = Math.abs(geoZ - _current.getLoc().getZ());
|
||||
float weight = diagonal ? Config.DIAGONAL_WEIGHT : Config.LOW_WEIGHT;
|
||||
|
||||
if (!((NodeLoc) newNode.getLoc()).canGoAll() || (stepZ > 16))
|
||||
if (!newNode.getLoc().canGoAll() || (stepZ > 16))
|
||||
{
|
||||
weight = Config.HIGH_WEIGHT;
|
||||
}
|
||||
@ -330,7 +330,7 @@ public class CellNodeBuffer
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!((NodeLoc) result.getLoc()).canGoAll())
|
||||
if (!result.getLoc().canGoAll())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -194,11 +194,12 @@ public class CellPathFinding extends PathFinding
|
||||
|
||||
remove = false;
|
||||
final Iterator<AbstractNodeLoc> endPoint = path.iterator();
|
||||
endPoint.next();
|
||||
int currentX = x;
|
||||
int currentY = y;
|
||||
int currentZ = z;
|
||||
|
||||
for (int i = 0; i < path.size(); i++)
|
||||
for (int i = 0; i < path.size() - 1; i++)
|
||||
{
|
||||
AbstractNodeLoc locMiddle = path.get(i);
|
||||
AbstractNodeLoc locEnd = endPoint.next();
|
||||
@ -232,7 +233,7 @@ public class CellPathFinding extends PathFinding
|
||||
return path;
|
||||
}
|
||||
|
||||
private List<AbstractNodeLoc> constructPath(AbstractNode node)
|
||||
private List<AbstractNodeLoc> constructPath(AbstractNode<NodeLoc> node)
|
||||
{
|
||||
final List<AbstractNodeLoc> path = new CopyOnWriteArrayList<>();
|
||||
int previousDirectionX = Integer.MIN_VALUE;
|
||||
|
@ -139,9 +139,9 @@ public class NodeLoc extends AbstractNodeLoc
|
||||
{
|
||||
nswe |= Cell.NSWE_SOUTH;
|
||||
}
|
||||
if (canGoEast())
|
||||
if (canGoWest())
|
||||
{
|
||||
nswe |= Cell.NSWE_EAST;
|
||||
nswe |= Cell.NSWE_WEST;
|
||||
}
|
||||
|
||||
result = (prime * result) + (((_geoHeight & 0xFFFF) << 1) | nswe);
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -18,6 +18,8 @@
|
||||
*/
|
||||
package com.l2jserver.gameserver.pathfinding.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.l2jserver.gameserver.pathfinding.AbstractNode;
|
||||
|
||||
/**
|
||||
@ -25,40 +27,25 @@ import com.l2jserver.gameserver.pathfinding.AbstractNode;
|
||||
*/
|
||||
public class FastNodeList
|
||||
{
|
||||
private final AbstractNode[] _list;
|
||||
private int _size;
|
||||
private final ArrayList<AbstractNode<?>> _list;
|
||||
|
||||
public FastNodeList(int size)
|
||||
{
|
||||
_list = new AbstractNode[size];
|
||||
_list = new ArrayList<>(size);
|
||||
}
|
||||
|
||||
public void add(AbstractNode n)
|
||||
public void add(AbstractNode<?> n)
|
||||
{
|
||||
_list[_size++] = n;
|
||||
_list.add(n);
|
||||
}
|
||||
|
||||
public boolean contains(AbstractNode n)
|
||||
public boolean contains(AbstractNode<?> n)
|
||||
{
|
||||
for (int i = 0; i < _size; i++)
|
||||
{
|
||||
if (_list[i].equals(n))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return _list.contains(n);
|
||||
}
|
||||
|
||||
public boolean containsRev(AbstractNode n)
|
||||
public boolean containsRev(AbstractNode<?> n)
|
||||
{
|
||||
for (int i = _size - 1; i >= 0; i--)
|
||||
{
|
||||
if (_list[i].equals(n))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return _list.lastIndexOf(n) != -1;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user