Used StampedLock to synchronize auto attack method.
This commit is contained in:
@@ -34,6 +34,7 @@ import java.util.concurrent.LinkedBlockingDeque;
|
|||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import java.util.concurrent.locks.StampedLock;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -219,6 +220,8 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
|||||||
private final byte[] _zones = new byte[ZoneId.getZoneCount()];
|
private final byte[] _zones = new byte[ZoneId.getZoneCount()];
|
||||||
protected byte _zoneValidateCounter = 4;
|
protected byte _zoneValidateCounter = 4;
|
||||||
|
|
||||||
|
private final StampedLock _attackLock = new StampedLock();
|
||||||
|
|
||||||
private Team _team = Team.NONE;
|
private Team _team = Team.NONE;
|
||||||
|
|
||||||
protected long _exceptions = 0;
|
protected long _exceptions = 0;
|
||||||
@@ -891,7 +894,14 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
|||||||
* </ul>
|
* </ul>
|
||||||
* @param target The L2Character targeted
|
* @param target The L2Character targeted
|
||||||
*/
|
*/
|
||||||
public synchronized void doAutoAttack(L2Character target)
|
public void doAutoAttack(L2Character target)
|
||||||
|
{
|
||||||
|
final long stamp = _attackLock.tryWriteLock();
|
||||||
|
if (stamp == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if ((target == null) || isAttackingDisabled() || !target.isTargetable())
|
if ((target == null) || isAttackingDisabled() || !target.isTargetable())
|
||||||
{
|
{
|
||||||
@@ -1149,6 +1159,11 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_attackLock.unlockWrite(stamp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Attack generateAttackTargetData(L2Character target, L2Weapon weapon, WeaponType weaponType)
|
private Attack generateAttackTargetData(L2Character target, L2Weapon weapon, WeaponType weaponType)
|
||||||
{
|
{
|
||||||
|
@@ -34,6 +34,7 @@ import java.util.concurrent.LinkedBlockingDeque;
|
|||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import java.util.concurrent.locks.StampedLock;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -219,6 +220,8 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
|||||||
private final byte[] _zones = new byte[ZoneId.getZoneCount()];
|
private final byte[] _zones = new byte[ZoneId.getZoneCount()];
|
||||||
protected byte _zoneValidateCounter = 4;
|
protected byte _zoneValidateCounter = 4;
|
||||||
|
|
||||||
|
private final StampedLock _attackLock = new StampedLock();
|
||||||
|
|
||||||
private Team _team = Team.NONE;
|
private Team _team = Team.NONE;
|
||||||
|
|
||||||
protected long _exceptions = 0;
|
protected long _exceptions = 0;
|
||||||
@@ -891,7 +894,14 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
|||||||
* </ul>
|
* </ul>
|
||||||
* @param target The L2Character targeted
|
* @param target The L2Character targeted
|
||||||
*/
|
*/
|
||||||
public synchronized void doAutoAttack(L2Character target)
|
public void doAutoAttack(L2Character target)
|
||||||
|
{
|
||||||
|
final long stamp = _attackLock.tryWriteLock();
|
||||||
|
if (stamp == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if ((target == null) || isAttackingDisabled() || !target.isTargetable())
|
if ((target == null) || isAttackingDisabled() || !target.isTargetable())
|
||||||
{
|
{
|
||||||
@@ -1149,6 +1159,11 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_attackLock.unlockWrite(stamp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Attack generateAttackTargetData(L2Character target, L2Weapon weapon, WeaponType weaponType)
|
private Attack generateAttackTargetData(L2Character target, L2Weapon weapon, WeaponType weaponType)
|
||||||
{
|
{
|
||||||
|
@@ -34,6 +34,7 @@ import java.util.concurrent.LinkedBlockingDeque;
|
|||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import java.util.concurrent.locks.StampedLock;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -219,6 +220,8 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
|||||||
private final byte[] _zones = new byte[ZoneId.getZoneCount()];
|
private final byte[] _zones = new byte[ZoneId.getZoneCount()];
|
||||||
protected byte _zoneValidateCounter = 4;
|
protected byte _zoneValidateCounter = 4;
|
||||||
|
|
||||||
|
private final StampedLock _attackLock = new StampedLock();
|
||||||
|
|
||||||
private Team _team = Team.NONE;
|
private Team _team = Team.NONE;
|
||||||
|
|
||||||
protected long _exceptions = 0;
|
protected long _exceptions = 0;
|
||||||
@@ -891,7 +894,14 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
|||||||
* </ul>
|
* </ul>
|
||||||
* @param target The L2Character targeted
|
* @param target The L2Character targeted
|
||||||
*/
|
*/
|
||||||
public synchronized void doAutoAttack(L2Character target)
|
public void doAutoAttack(L2Character target)
|
||||||
|
{
|
||||||
|
final long stamp = _attackLock.tryWriteLock();
|
||||||
|
if (stamp == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if ((target == null) || isAttackingDisabled() || !target.isTargetable())
|
if ((target == null) || isAttackingDisabled() || !target.isTargetable())
|
||||||
{
|
{
|
||||||
@@ -1149,6 +1159,11 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_attackLock.unlockWrite(stamp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Attack generateAttackTargetData(L2Character target, L2Weapon weapon, WeaponType weaponType)
|
private Attack generateAttackTargetData(L2Character target, L2Weapon weapon, WeaponType weaponType)
|
||||||
{
|
{
|
||||||
|
@@ -34,6 +34,7 @@ import java.util.concurrent.LinkedBlockingDeque;
|
|||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import java.util.concurrent.locks.StampedLock;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -219,6 +220,8 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
|||||||
private final byte[] _zones = new byte[ZoneId.getZoneCount()];
|
private final byte[] _zones = new byte[ZoneId.getZoneCount()];
|
||||||
protected byte _zoneValidateCounter = 4;
|
protected byte _zoneValidateCounter = 4;
|
||||||
|
|
||||||
|
private final StampedLock _attackLock = new StampedLock();
|
||||||
|
|
||||||
private Team _team = Team.NONE;
|
private Team _team = Team.NONE;
|
||||||
|
|
||||||
protected long _exceptions = 0;
|
protected long _exceptions = 0;
|
||||||
@@ -891,7 +894,14 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
|||||||
* </ul>
|
* </ul>
|
||||||
* @param target The L2Character targeted
|
* @param target The L2Character targeted
|
||||||
*/
|
*/
|
||||||
public synchronized void doAutoAttack(L2Character target)
|
public void doAutoAttack(L2Character target)
|
||||||
|
{
|
||||||
|
final long stamp = _attackLock.tryWriteLock();
|
||||||
|
if (stamp == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if ((target == null) || isAttackingDisabled() || !target.isTargetable())
|
if ((target == null) || isAttackingDisabled() || !target.isTargetable())
|
||||||
{
|
{
|
||||||
@@ -1149,6 +1159,11 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_attackLock.unlockWrite(stamp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Attack generateAttackTargetData(L2Character target, L2Weapon weapon, WeaponType weaponType)
|
private Attack generateAttackTargetData(L2Character target, L2Weapon weapon, WeaponType weaponType)
|
||||||
{
|
{
|
||||||
|
@@ -34,6 +34,7 @@ import java.util.concurrent.LinkedBlockingDeque;
|
|||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import java.util.concurrent.locks.StampedLock;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -219,6 +220,8 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
|||||||
private final byte[] _zones = new byte[ZoneId.getZoneCount()];
|
private final byte[] _zones = new byte[ZoneId.getZoneCount()];
|
||||||
protected byte _zoneValidateCounter = 4;
|
protected byte _zoneValidateCounter = 4;
|
||||||
|
|
||||||
|
private final StampedLock _attackLock = new StampedLock();
|
||||||
|
|
||||||
private Team _team = Team.NONE;
|
private Team _team = Team.NONE;
|
||||||
|
|
||||||
protected long _exceptions = 0;
|
protected long _exceptions = 0;
|
||||||
@@ -891,7 +894,14 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
|||||||
* </ul>
|
* </ul>
|
||||||
* @param target The L2Character targeted
|
* @param target The L2Character targeted
|
||||||
*/
|
*/
|
||||||
public synchronized void doAutoAttack(L2Character target)
|
public void doAutoAttack(L2Character target)
|
||||||
|
{
|
||||||
|
final long stamp = _attackLock.tryWriteLock();
|
||||||
|
if (stamp == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if ((target == null) || isAttackingDisabled() || !target.isTargetable())
|
if ((target == null) || isAttackingDisabled() || !target.isTargetable())
|
||||||
{
|
{
|
||||||
@@ -1149,6 +1159,11 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_attackLock.unlockWrite(stamp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Attack generateAttackTargetData(L2Character target, L2Weapon weapon, WeaponType weaponType)
|
private Attack generateAttackTargetData(L2Character target, L2Weapon weapon, WeaponType weaponType)
|
||||||
{
|
{
|
||||||
|
@@ -34,6 +34,7 @@ import java.util.concurrent.LinkedBlockingDeque;
|
|||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import java.util.concurrent.locks.StampedLock;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -219,6 +220,8 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
|||||||
private final byte[] _zones = new byte[ZoneId.getZoneCount()];
|
private final byte[] _zones = new byte[ZoneId.getZoneCount()];
|
||||||
protected byte _zoneValidateCounter = 4;
|
protected byte _zoneValidateCounter = 4;
|
||||||
|
|
||||||
|
private final StampedLock _attackLock = new StampedLock();
|
||||||
|
|
||||||
private Team _team = Team.NONE;
|
private Team _team = Team.NONE;
|
||||||
|
|
||||||
protected long _exceptions = 0;
|
protected long _exceptions = 0;
|
||||||
@@ -891,7 +894,14 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
|||||||
* </ul>
|
* </ul>
|
||||||
* @param target The L2Character targeted
|
* @param target The L2Character targeted
|
||||||
*/
|
*/
|
||||||
public synchronized void doAutoAttack(L2Character target)
|
public void doAutoAttack(L2Character target)
|
||||||
|
{
|
||||||
|
final long stamp = _attackLock.tryWriteLock();
|
||||||
|
if (stamp == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if ((target == null) || isAttackingDisabled() || !target.isTargetable())
|
if ((target == null) || isAttackingDisabled() || !target.isTargetable())
|
||||||
{
|
{
|
||||||
@@ -1149,6 +1159,11 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_attackLock.unlockWrite(stamp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Attack generateAttackTargetData(L2Character target, L2Weapon weapon, WeaponType weaponType)
|
private Attack generateAttackTargetData(L2Character target, L2Weapon weapon, WeaponType weaponType)
|
||||||
{
|
{
|
||||||
|
@@ -30,6 +30,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
|||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
import java.util.concurrent.LinkedBlockingDeque;
|
import java.util.concurrent.LinkedBlockingDeque;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.locks.StampedLock;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -222,6 +223,8 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
|||||||
private final byte[] _zones = new byte[ZoneId.getZoneCount()];
|
private final byte[] _zones = new byte[ZoneId.getZoneCount()];
|
||||||
protected byte _zoneValidateCounter = 4;
|
protected byte _zoneValidateCounter = 4;
|
||||||
|
|
||||||
|
private final StampedLock _attackLock = new StampedLock();
|
||||||
|
|
||||||
private Team _team = Team.NONE;
|
private Team _team = Team.NONE;
|
||||||
|
|
||||||
protected long _exceptions = 0;
|
protected long _exceptions = 0;
|
||||||
@@ -840,7 +843,14 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
|||||||
* </ul>
|
* </ul>
|
||||||
* @param target The L2Character targeted
|
* @param target The L2Character targeted
|
||||||
*/
|
*/
|
||||||
public synchronized void doAttack(L2Character target)
|
public void doAttack(L2Character target)
|
||||||
|
{
|
||||||
|
final long stamp = _attackLock.tryWriteLock();
|
||||||
|
if (stamp == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if ((target == null) || isAttackingDisabled() || !target.isTargetable())
|
if ((target == null) || isAttackingDisabled() || !target.isTargetable())
|
||||||
{
|
{
|
||||||
@@ -1087,6 +1097,11 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
|||||||
// Notify AI with EVT_READY_TO_ACT
|
// Notify AI with EVT_READY_TO_ACT
|
||||||
ThreadPool.schedule(new NotifyAITask(this, CtrlEvent.EVT_READY_TO_ACT), timeAtk + reuse);
|
ThreadPool.schedule(new NotifyAITask(this, CtrlEvent.EVT_READY_TO_ACT), timeAtk + reuse);
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_attackLock.unlockWrite(stamp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Launch a Bow attack.<br>
|
* Launch a Bow attack.<br>
|
||||||
|
@@ -34,6 +34,7 @@ import java.util.concurrent.LinkedBlockingDeque;
|
|||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import java.util.concurrent.locks.StampedLock;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -219,6 +220,8 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
|||||||
private final byte[] _zones = new byte[ZoneId.getZoneCount()];
|
private final byte[] _zones = new byte[ZoneId.getZoneCount()];
|
||||||
protected byte _zoneValidateCounter = 4;
|
protected byte _zoneValidateCounter = 4;
|
||||||
|
|
||||||
|
private final StampedLock _attackLock = new StampedLock();
|
||||||
|
|
||||||
private Team _team = Team.NONE;
|
private Team _team = Team.NONE;
|
||||||
|
|
||||||
protected long _exceptions = 0;
|
protected long _exceptions = 0;
|
||||||
@@ -891,7 +894,14 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
|||||||
* </ul>
|
* </ul>
|
||||||
* @param target The L2Character targeted
|
* @param target The L2Character targeted
|
||||||
*/
|
*/
|
||||||
public synchronized void doAutoAttack(L2Character target)
|
public void doAutoAttack(L2Character target)
|
||||||
|
{
|
||||||
|
final long stamp = _attackLock.tryWriteLock();
|
||||||
|
if (stamp == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if ((target == null) || isAttackingDisabled() || !target.isTargetable())
|
if ((target == null) || isAttackingDisabled() || !target.isTargetable())
|
||||||
{
|
{
|
||||||
@@ -1149,6 +1159,11 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_attackLock.unlockWrite(stamp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Attack generateAttackTargetData(L2Character target, L2Weapon weapon, WeaponType weaponType)
|
private Attack generateAttackTargetData(L2Character target, L2Weapon weapon, WeaponType weaponType)
|
||||||
{
|
{
|
||||||
|
@@ -34,6 +34,7 @@ import java.util.concurrent.LinkedBlockingDeque;
|
|||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import java.util.concurrent.locks.StampedLock;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -219,6 +220,8 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
|||||||
private final byte[] _zones = new byte[ZoneId.getZoneCount()];
|
private final byte[] _zones = new byte[ZoneId.getZoneCount()];
|
||||||
protected byte _zoneValidateCounter = 4;
|
protected byte _zoneValidateCounter = 4;
|
||||||
|
|
||||||
|
private final StampedLock _attackLock = new StampedLock();
|
||||||
|
|
||||||
private Team _team = Team.NONE;
|
private Team _team = Team.NONE;
|
||||||
|
|
||||||
protected long _exceptions = 0;
|
protected long _exceptions = 0;
|
||||||
@@ -891,7 +894,14 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
|||||||
* </ul>
|
* </ul>
|
||||||
* @param target The L2Character targeted
|
* @param target The L2Character targeted
|
||||||
*/
|
*/
|
||||||
public synchronized void doAutoAttack(L2Character target)
|
public void doAutoAttack(L2Character target)
|
||||||
|
{
|
||||||
|
final long stamp = _attackLock.tryWriteLock();
|
||||||
|
if (stamp == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if ((target == null) || isAttackingDisabled() || !target.isTargetable())
|
if ((target == null) || isAttackingDisabled() || !target.isTargetable())
|
||||||
{
|
{
|
||||||
@@ -1149,6 +1159,11 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_attackLock.unlockWrite(stamp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Attack generateAttackTargetData(L2Character target, L2Weapon weapon, WeaponType weaponType)
|
private Attack generateAttackTargetData(L2Character target, L2Weapon weapon, WeaponType weaponType)
|
||||||
{
|
{
|
||||||
|
@@ -34,6 +34,7 @@ import java.util.concurrent.LinkedBlockingDeque;
|
|||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import java.util.concurrent.locks.StampedLock;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -219,6 +220,8 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
|||||||
private final byte[] _zones = new byte[ZoneId.getZoneCount()];
|
private final byte[] _zones = new byte[ZoneId.getZoneCount()];
|
||||||
protected byte _zoneValidateCounter = 4;
|
protected byte _zoneValidateCounter = 4;
|
||||||
|
|
||||||
|
private final StampedLock _attackLock = new StampedLock();
|
||||||
|
|
||||||
private Team _team = Team.NONE;
|
private Team _team = Team.NONE;
|
||||||
|
|
||||||
protected long _exceptions = 0;
|
protected long _exceptions = 0;
|
||||||
@@ -891,7 +894,14 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
|||||||
* </ul>
|
* </ul>
|
||||||
* @param target The L2Character targeted
|
* @param target The L2Character targeted
|
||||||
*/
|
*/
|
||||||
public synchronized void doAutoAttack(L2Character target)
|
public void doAutoAttack(L2Character target)
|
||||||
|
{
|
||||||
|
final long stamp = _attackLock.tryWriteLock();
|
||||||
|
if (stamp == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if ((target == null) || isAttackingDisabled() || !target.isTargetable())
|
if ((target == null) || isAttackingDisabled() || !target.isTargetable())
|
||||||
{
|
{
|
||||||
@@ -1149,6 +1159,11 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_attackLock.unlockWrite(stamp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Attack generateAttackTargetData(L2Character target, L2Weapon weapon, WeaponType weaponType)
|
private Attack generateAttackTargetData(L2Character target, L2Weapon weapon, WeaponType weaponType)
|
||||||
{
|
{
|
||||||
|
@@ -34,6 +34,7 @@ import java.util.concurrent.LinkedBlockingDeque;
|
|||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import java.util.concurrent.locks.StampedLock;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -219,6 +220,8 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
|||||||
private final byte[] _zones = new byte[ZoneId.getZoneCount()];
|
private final byte[] _zones = new byte[ZoneId.getZoneCount()];
|
||||||
protected byte _zoneValidateCounter = 4;
|
protected byte _zoneValidateCounter = 4;
|
||||||
|
|
||||||
|
private final StampedLock _attackLock = new StampedLock();
|
||||||
|
|
||||||
private Team _team = Team.NONE;
|
private Team _team = Team.NONE;
|
||||||
|
|
||||||
protected long _exceptions = 0;
|
protected long _exceptions = 0;
|
||||||
@@ -891,7 +894,14 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
|||||||
* </ul>
|
* </ul>
|
||||||
* @param target The L2Character targeted
|
* @param target The L2Character targeted
|
||||||
*/
|
*/
|
||||||
public synchronized void doAutoAttack(L2Character target)
|
public void doAutoAttack(L2Character target)
|
||||||
|
{
|
||||||
|
final long stamp = _attackLock.tryWriteLock();
|
||||||
|
if (stamp == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if ((target == null) || isAttackingDisabled() || !target.isTargetable())
|
if ((target == null) || isAttackingDisabled() || !target.isTargetable())
|
||||||
{
|
{
|
||||||
@@ -1149,6 +1159,11 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_attackLock.unlockWrite(stamp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Attack generateAttackTargetData(L2Character target, L2Weapon weapon, WeaponType weaponType)
|
private Attack generateAttackTargetData(L2Character target, L2Weapon weapon, WeaponType weaponType)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user