Replaced attack and teleport locks with synchronized methods.
This commit is contained in:
parent
1dd47518ad
commit
7d2f14116f
@ -34,7 +34,6 @@ import java.util.concurrent.LinkedBlockingDeque;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
@ -224,9 +223,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
private final byte[] _zones = new byte[ZoneId.getZoneCount()];
|
||||
protected byte _zoneValidateCounter = 4;
|
||||
|
||||
private final ReentrantLock _teleportLock = new ReentrantLock();
|
||||
private final Object _attackLock = new Object();
|
||||
|
||||
private Team _team = Team.NONE;
|
||||
|
||||
protected long _exceptions = 0;
|
||||
@ -577,13 +573,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
}
|
||||
}
|
||||
|
||||
public void onTeleported()
|
||||
{
|
||||
if (!_teleportLock.tryLock())
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
public synchronized void onTeleported()
|
||||
{
|
||||
if (!_isTeleporting)
|
||||
{
|
||||
@ -593,11 +583,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
setIsTeleporting(false);
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureTeleported(this), this);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_teleportLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add L2Character instance that is attacking to the attacker list.
|
||||
@ -905,16 +890,9 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
* </ul>
|
||||
* @param target The L2Character targeted
|
||||
*/
|
||||
public void doAutoAttack(L2Character target)
|
||||
public synchronized void doAutoAttack(L2Character target)
|
||||
{
|
||||
synchronized (_attackLock)
|
||||
{
|
||||
if ((target == null) || isAttackingDisabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!target.isTargetable())
|
||||
if ((target == null) || isAttackingDisabled() || !target.isTargetable())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -1072,6 +1050,12 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
}
|
||||
}
|
||||
|
||||
// Mobius: Do not move when attack is launched.
|
||||
if (isMoving())
|
||||
{
|
||||
stopMove(getLocation());
|
||||
}
|
||||
|
||||
final WeaponType attackType = getAttackType();
|
||||
final boolean isTwoHanded = (weaponItem != null) && (weaponItem.getBodyPart() == L2Item.SLOT_LR_HAND);
|
||||
final int timeAtk = Formulas.calculateTimeBetweenAttacks(_stat.getPAtkSpd());
|
||||
@ -1103,11 +1087,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
inventory.reduceArrowCount(crossbow ? EtcItemType.BOLT : EtcItemType.ARROW);
|
||||
}
|
||||
|
||||
if (isMoving())
|
||||
{
|
||||
stopMove(null);
|
||||
}
|
||||
|
||||
// Check if the L2Character is a L2PcInstance
|
||||
if (isPlayer())
|
||||
{
|
||||
@ -1174,7 +1153,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Attack generateAttackTargetData(L2Character target, L2Weapon weapon, WeaponType weaponType)
|
||||
{
|
||||
|
@ -34,7 +34,6 @@ import java.util.concurrent.LinkedBlockingDeque;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
@ -224,9 +223,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
private final byte[] _zones = new byte[ZoneId.getZoneCount()];
|
||||
protected byte _zoneValidateCounter = 4;
|
||||
|
||||
private final ReentrantLock _teleportLock = new ReentrantLock();
|
||||
private final Object _attackLock = new Object();
|
||||
|
||||
private Team _team = Team.NONE;
|
||||
|
||||
protected long _exceptions = 0;
|
||||
@ -577,13 +573,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
}
|
||||
}
|
||||
|
||||
public void onTeleported()
|
||||
{
|
||||
if (!_teleportLock.tryLock())
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
public synchronized void onTeleported()
|
||||
{
|
||||
if (!_isTeleporting)
|
||||
{
|
||||
@ -593,11 +583,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
setIsTeleporting(false);
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureTeleported(this), this);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_teleportLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add L2Character instance that is attacking to the attacker list.
|
||||
@ -905,16 +890,9 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
* </ul>
|
||||
* @param target The L2Character targeted
|
||||
*/
|
||||
public void doAutoAttack(L2Character target)
|
||||
public synchronized void doAutoAttack(L2Character target)
|
||||
{
|
||||
synchronized (_attackLock)
|
||||
{
|
||||
if ((target == null) || isAttackingDisabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!target.isTargetable())
|
||||
if ((target == null) || isAttackingDisabled() || !target.isTargetable())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -1072,6 +1050,12 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
}
|
||||
}
|
||||
|
||||
// Mobius: Do not move when attack is launched.
|
||||
if (isMoving())
|
||||
{
|
||||
stopMove(getLocation());
|
||||
}
|
||||
|
||||
final WeaponType attackType = getAttackType();
|
||||
final boolean isTwoHanded = (weaponItem != null) && (weaponItem.getBodyPart() == L2Item.SLOT_LR_HAND);
|
||||
final int timeAtk = Formulas.calculateTimeBetweenAttacks(_stat.getPAtkSpd());
|
||||
@ -1103,11 +1087,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
inventory.reduceArrowCount(crossbow ? EtcItemType.BOLT : EtcItemType.ARROW);
|
||||
}
|
||||
|
||||
if (isMoving())
|
||||
{
|
||||
stopMove(null);
|
||||
}
|
||||
|
||||
// Check if the L2Character is a L2PcInstance
|
||||
if (isPlayer())
|
||||
{
|
||||
@ -1174,7 +1153,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Attack generateAttackTargetData(L2Character target, L2Weapon weapon, WeaponType weaponType)
|
||||
{
|
||||
|
@ -34,7 +34,6 @@ import java.util.concurrent.LinkedBlockingDeque;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
@ -224,9 +223,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
private final byte[] _zones = new byte[ZoneId.getZoneCount()];
|
||||
protected byte _zoneValidateCounter = 4;
|
||||
|
||||
private final ReentrantLock _teleportLock = new ReentrantLock();
|
||||
private final Object _attackLock = new Object();
|
||||
|
||||
private Team _team = Team.NONE;
|
||||
|
||||
protected long _exceptions = 0;
|
||||
@ -577,13 +573,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
}
|
||||
}
|
||||
|
||||
public void onTeleported()
|
||||
{
|
||||
if (!_teleportLock.tryLock())
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
public synchronized void onTeleported()
|
||||
{
|
||||
if (!_isTeleporting)
|
||||
{
|
||||
@ -593,11 +583,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
setIsTeleporting(false);
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureTeleported(this), this);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_teleportLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add L2Character instance that is attacking to the attacker list.
|
||||
@ -905,16 +890,9 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
* </ul>
|
||||
* @param target The L2Character targeted
|
||||
*/
|
||||
public void doAutoAttack(L2Character target)
|
||||
public synchronized void doAutoAttack(L2Character target)
|
||||
{
|
||||
synchronized (_attackLock)
|
||||
{
|
||||
if ((target == null) || isAttackingDisabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!target.isTargetable())
|
||||
if ((target == null) || isAttackingDisabled() || !target.isTargetable())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -1072,6 +1050,12 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
}
|
||||
}
|
||||
|
||||
// Mobius: Do not move when attack is launched.
|
||||
if (isMoving())
|
||||
{
|
||||
stopMove(getLocation());
|
||||
}
|
||||
|
||||
final WeaponType attackType = getAttackType();
|
||||
final boolean isTwoHanded = (weaponItem != null) && (weaponItem.getBodyPart() == L2Item.SLOT_LR_HAND);
|
||||
final int timeAtk = Formulas.calculateTimeBetweenAttacks(_stat.getPAtkSpd());
|
||||
@ -1103,11 +1087,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
inventory.reduceArrowCount(crossbow ? EtcItemType.BOLT : EtcItemType.ARROW);
|
||||
}
|
||||
|
||||
if (isMoving())
|
||||
{
|
||||
stopMove(null);
|
||||
}
|
||||
|
||||
// Check if the L2Character is a L2PcInstance
|
||||
if (isPlayer())
|
||||
{
|
||||
@ -1174,7 +1153,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Attack generateAttackTargetData(L2Character target, L2Weapon weapon, WeaponType weaponType)
|
||||
{
|
||||
|
@ -34,7 +34,6 @@ import java.util.concurrent.LinkedBlockingDeque;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
@ -224,9 +223,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
private final byte[] _zones = new byte[ZoneId.getZoneCount()];
|
||||
protected byte _zoneValidateCounter = 4;
|
||||
|
||||
private final ReentrantLock _teleportLock = new ReentrantLock();
|
||||
private final Object _attackLock = new Object();
|
||||
|
||||
private Team _team = Team.NONE;
|
||||
|
||||
protected long _exceptions = 0;
|
||||
@ -577,13 +573,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
}
|
||||
}
|
||||
|
||||
public void onTeleported()
|
||||
{
|
||||
if (!_teleportLock.tryLock())
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
public synchronized void onTeleported()
|
||||
{
|
||||
if (!_isTeleporting)
|
||||
{
|
||||
@ -593,11 +583,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
setIsTeleporting(false);
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureTeleported(this), this);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_teleportLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add L2Character instance that is attacking to the attacker list.
|
||||
@ -905,16 +890,9 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
* </ul>
|
||||
* @param target The L2Character targeted
|
||||
*/
|
||||
public void doAutoAttack(L2Character target)
|
||||
public synchronized void doAutoAttack(L2Character target)
|
||||
{
|
||||
synchronized (_attackLock)
|
||||
{
|
||||
if ((target == null) || isAttackingDisabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!target.isTargetable())
|
||||
if ((target == null) || isAttackingDisabled() || !target.isTargetable())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -1072,6 +1050,12 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
}
|
||||
}
|
||||
|
||||
// Mobius: Do not move when attack is launched.
|
||||
if (isMoving())
|
||||
{
|
||||
stopMove(getLocation());
|
||||
}
|
||||
|
||||
final WeaponType attackType = getAttackType();
|
||||
final boolean isTwoHanded = (weaponItem != null) && (weaponItem.getBodyPart() == L2Item.SLOT_LR_HAND);
|
||||
final int timeAtk = Formulas.calculateTimeBetweenAttacks(_stat.getPAtkSpd());
|
||||
@ -1103,11 +1087,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
inventory.reduceArrowCount(crossbow ? EtcItemType.BOLT : EtcItemType.ARROW);
|
||||
}
|
||||
|
||||
if (isMoving())
|
||||
{
|
||||
stopMove(null);
|
||||
}
|
||||
|
||||
// Check if the L2Character is a L2PcInstance
|
||||
if (isPlayer())
|
||||
{
|
||||
@ -1174,7 +1153,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Attack generateAttackTargetData(L2Character target, L2Weapon weapon, WeaponType weaponType)
|
||||
{
|
||||
|
@ -30,8 +30,6 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.LinkedBlockingDeque;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.concurrent.locks.StampedLock;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@ -227,9 +225,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
private final byte[] _zones = new byte[ZoneId.getZoneCount()];
|
||||
protected byte _zoneValidateCounter = 4;
|
||||
|
||||
private final ReentrantLock _teleportLock = new ReentrantLock();
|
||||
private final StampedLock _attackLock = new StampedLock();
|
||||
|
||||
private Team _team = Team.NONE;
|
||||
|
||||
protected long _exceptions = 0;
|
||||
@ -509,13 +504,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
revalidateZone(true);
|
||||
}
|
||||
|
||||
public void onTeleported()
|
||||
{
|
||||
if (!_teleportLock.tryLock())
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
public synchronized void onTeleported()
|
||||
{
|
||||
if (!_isTeleporting)
|
||||
{
|
||||
@ -525,11 +514,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
setIsTeleporting(false);
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureTeleported(this), this);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_teleportLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add L2Character instance that is attacking to the attacker list.
|
||||
@ -859,12 +843,9 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
* </ul>
|
||||
* @param target The L2Character targeted
|
||||
*/
|
||||
public void doAttack(L2Character target)
|
||||
public synchronized void doAttack(L2Character target)
|
||||
{
|
||||
final long stamp = _attackLock.tryWriteLock();
|
||||
try
|
||||
{
|
||||
if ((target == null) || isAttackingDisabled())
|
||||
if ((target == null) || isAttackingDisabled() || !target.isTargetable())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -984,6 +965,12 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
}
|
||||
}
|
||||
|
||||
// Mobius: Do not move when attack is launched.
|
||||
if (isMoving())
|
||||
{
|
||||
stopMove(getLocation());
|
||||
}
|
||||
|
||||
final L2Weapon weaponItem = getActiveWeaponItem();
|
||||
final int timeAtk = calculateTimeBetweenAttacks();
|
||||
final int timeToHit = timeAtk / 2;
|
||||
@ -1108,11 +1095,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
// Notify AI with EVT_READY_TO_ACT
|
||||
ThreadPool.schedule(new NotifyAITask(this, CtrlEvent.EVT_READY_TO_ACT), timeAtk + reuse);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_attackLock.unlockWrite(stamp);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Launch a Bow attack.<br>
|
||||
|
@ -34,7 +34,6 @@ import java.util.concurrent.LinkedBlockingDeque;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
@ -224,9 +223,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
private final byte[] _zones = new byte[ZoneId.getZoneCount()];
|
||||
protected byte _zoneValidateCounter = 4;
|
||||
|
||||
private final ReentrantLock _teleportLock = new ReentrantLock();
|
||||
private final Object _attackLock = new Object();
|
||||
|
||||
private Team _team = Team.NONE;
|
||||
|
||||
protected long _exceptions = 0;
|
||||
@ -577,13 +573,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
}
|
||||
}
|
||||
|
||||
public void onTeleported()
|
||||
{
|
||||
if (!_teleportLock.tryLock())
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
public synchronized void onTeleported()
|
||||
{
|
||||
if (!_isTeleporting)
|
||||
{
|
||||
@ -593,11 +583,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
setIsTeleporting(false);
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureTeleported(this), this);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_teleportLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add L2Character instance that is attacking to the attacker list.
|
||||
@ -905,16 +890,9 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
* </ul>
|
||||
* @param target The L2Character targeted
|
||||
*/
|
||||
public void doAutoAttack(L2Character target)
|
||||
public synchronized void doAutoAttack(L2Character target)
|
||||
{
|
||||
synchronized (_attackLock)
|
||||
{
|
||||
if ((target == null) || isAttackingDisabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!target.isTargetable())
|
||||
if ((target == null) || isAttackingDisabled() || !target.isTargetable())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -1072,6 +1050,12 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
}
|
||||
}
|
||||
|
||||
// Mobius: Do not move when attack is launched.
|
||||
if (isMoving())
|
||||
{
|
||||
stopMove(getLocation());
|
||||
}
|
||||
|
||||
final WeaponType attackType = getAttackType();
|
||||
final boolean isTwoHanded = (weaponItem != null) && (weaponItem.getBodyPart() == L2Item.SLOT_LR_HAND);
|
||||
final int timeAtk = Formulas.calculateTimeBetweenAttacks(_stat.getPAtkSpd());
|
||||
@ -1103,11 +1087,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
inventory.reduceArrowCount(crossbow ? EtcItemType.BOLT : EtcItemType.ARROW);
|
||||
}
|
||||
|
||||
if (isMoving())
|
||||
{
|
||||
stopMove(null);
|
||||
}
|
||||
|
||||
// Check if the L2Character is a L2PcInstance
|
||||
if (isPlayer())
|
||||
{
|
||||
@ -1174,7 +1153,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Attack generateAttackTargetData(L2Character target, L2Weapon weapon, WeaponType weaponType)
|
||||
{
|
||||
|
@ -34,7 +34,6 @@ import java.util.concurrent.LinkedBlockingDeque;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
@ -224,9 +223,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
private final byte[] _zones = new byte[ZoneId.getZoneCount()];
|
||||
protected byte _zoneValidateCounter = 4;
|
||||
|
||||
private final ReentrantLock _teleportLock = new ReentrantLock();
|
||||
private final Object _attackLock = new Object();
|
||||
|
||||
private Team _team = Team.NONE;
|
||||
|
||||
protected long _exceptions = 0;
|
||||
@ -577,13 +573,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
}
|
||||
}
|
||||
|
||||
public void onTeleported()
|
||||
{
|
||||
if (!_teleportLock.tryLock())
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
public synchronized void onTeleported()
|
||||
{
|
||||
if (!_isTeleporting)
|
||||
{
|
||||
@ -593,11 +583,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
setIsTeleporting(false);
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureTeleported(this), this);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_teleportLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add L2Character instance that is attacking to the attacker list.
|
||||
@ -905,16 +890,9 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
* </ul>
|
||||
* @param target The L2Character targeted
|
||||
*/
|
||||
public void doAutoAttack(L2Character target)
|
||||
public synchronized void doAutoAttack(L2Character target)
|
||||
{
|
||||
synchronized (_attackLock)
|
||||
{
|
||||
if ((target == null) || isAttackingDisabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!target.isTargetable())
|
||||
if ((target == null) || isAttackingDisabled() || !target.isTargetable())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -1072,6 +1050,12 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
}
|
||||
}
|
||||
|
||||
// Mobius: Do not move when attack is launched.
|
||||
if (isMoving())
|
||||
{
|
||||
stopMove(getLocation());
|
||||
}
|
||||
|
||||
final WeaponType attackType = getAttackType();
|
||||
final boolean isTwoHanded = (weaponItem != null) && (weaponItem.getBodyPart() == L2Item.SLOT_LR_HAND);
|
||||
final int timeAtk = Formulas.calculateTimeBetweenAttacks(_stat.getPAtkSpd());
|
||||
@ -1103,11 +1087,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
inventory.reduceArrowCount(crossbow ? EtcItemType.BOLT : EtcItemType.ARROW);
|
||||
}
|
||||
|
||||
if (isMoving())
|
||||
{
|
||||
stopMove(null);
|
||||
}
|
||||
|
||||
// Check if the L2Character is a L2PcInstance
|
||||
if (isPlayer())
|
||||
{
|
||||
@ -1174,7 +1153,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Attack generateAttackTargetData(L2Character target, L2Weapon weapon, WeaponType weaponType)
|
||||
{
|
||||
|
@ -34,7 +34,6 @@ import java.util.concurrent.LinkedBlockingDeque;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
@ -224,9 +223,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
private final byte[] _zones = new byte[ZoneId.getZoneCount()];
|
||||
protected byte _zoneValidateCounter = 4;
|
||||
|
||||
private final ReentrantLock _teleportLock = new ReentrantLock();
|
||||
private final Object _attackLock = new Object();
|
||||
|
||||
private Team _team = Team.NONE;
|
||||
|
||||
protected long _exceptions = 0;
|
||||
@ -577,13 +573,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
}
|
||||
}
|
||||
|
||||
public void onTeleported()
|
||||
{
|
||||
if (!_teleportLock.tryLock())
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
public synchronized void onTeleported()
|
||||
{
|
||||
if (!_isTeleporting)
|
||||
{
|
||||
@ -593,11 +583,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
setIsTeleporting(false);
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureTeleported(this), this);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_teleportLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add L2Character instance that is attacking to the attacker list.
|
||||
@ -905,16 +890,9 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
* </ul>
|
||||
* @param target The L2Character targeted
|
||||
*/
|
||||
public void doAutoAttack(L2Character target)
|
||||
public synchronized void doAutoAttack(L2Character target)
|
||||
{
|
||||
synchronized (_attackLock)
|
||||
{
|
||||
if ((target == null) || isAttackingDisabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!target.isTargetable())
|
||||
if ((target == null) || isAttackingDisabled() || !target.isTargetable())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -1072,6 +1050,12 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
}
|
||||
}
|
||||
|
||||
// Mobius: Do not move when attack is launched.
|
||||
if (isMoving())
|
||||
{
|
||||
stopMove(getLocation());
|
||||
}
|
||||
|
||||
final WeaponType attackType = getAttackType();
|
||||
final boolean isTwoHanded = (weaponItem != null) && (weaponItem.getBodyPart() == L2Item.SLOT_LR_HAND);
|
||||
final int timeAtk = Formulas.calculateTimeBetweenAttacks(_stat.getPAtkSpd());
|
||||
@ -1103,11 +1087,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
inventory.reduceArrowCount(crossbow ? EtcItemType.BOLT : EtcItemType.ARROW);
|
||||
}
|
||||
|
||||
if (isMoving())
|
||||
{
|
||||
stopMove(null);
|
||||
}
|
||||
|
||||
// Check if the L2Character is a L2PcInstance
|
||||
if (isPlayer())
|
||||
{
|
||||
@ -1174,7 +1153,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Attack generateAttackTargetData(L2Character target, L2Weapon weapon, WeaponType weaponType)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user