From a2473ea19e820492ae2e60bdf0d1fc5d1475677a Mon Sep 17 00:00:00 2001 From: MobiusDev <8391001+MobiusDevelopment@users.noreply.github.com> Date: Sun, 6 Aug 2017 18:21:28 +0000 Subject: [PATCH] Apply latest Classic commit to GoD branches. --- .../java/com/l2jmobius/gameserver/ai/L2CharacterAI.java | 6 +++--- .../com/l2jmobius/gameserver/model/actor/L2Character.java | 5 +++-- .../l2jmobius/gameserver/network/clientpackets/UseItem.java | 3 ++- .../java/com/l2jmobius/gameserver/ai/L2CharacterAI.java | 6 +++--- .../com/l2jmobius/gameserver/model/actor/L2Character.java | 5 +++-- .../l2jmobius/gameserver/network/clientpackets/UseItem.java | 3 ++- 6 files changed, 16 insertions(+), 12 deletions(-) diff --git a/L2J_Mobius_Helios/java/com/l2jmobius/gameserver/ai/L2CharacterAI.java b/L2J_Mobius_Helios/java/com/l2jmobius/gameserver/ai/L2CharacterAI.java index 6438f27825..934341249a 100644 --- a/L2J_Mobius_Helios/java/com/l2jmobius/gameserver/ai/L2CharacterAI.java +++ b/L2J_Mobius_Helios/java/com/l2jmobius/gameserver/ai/L2CharacterAI.java @@ -28,9 +28,9 @@ import static com.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_REST; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.TimeUnit; import java.util.logging.Logger; -import com.l2jmobius.gameserver.GameTimeController; import com.l2jmobius.gameserver.ThreadPoolManager; import com.l2jmobius.gameserver.enums.ItemLocation; import com.l2jmobius.gameserver.geodata.GeoData; @@ -306,9 +306,9 @@ public class L2CharacterAI extends AbstractAI return; } - if (_actor.getAttackEndTime() > GameTimeController.getInstance().getGameTicks()) + if (_actor.isAttackingNow()) { - ThreadPoolManager.getInstance().scheduleGeneral(new CastTask(_actor, skill, target, item, forceUse, dontMove), _actor.getAttackEndTime() - System.currentTimeMillis()); + ThreadPoolManager.getInstance().scheduleGeneral(new CastTask(_actor, skill, target, item, forceUse, dontMove), _actor.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis())); } else { diff --git a/L2J_Mobius_Helios/java/com/l2jmobius/gameserver/model/actor/L2Character.java b/L2J_Mobius_Helios/java/com/l2jmobius/gameserver/model/actor/L2Character.java index 795bf13a3e..d1c3434468 100644 --- a/L2J_Mobius_Helios/java/com/l2jmobius/gameserver/model/actor/L2Character.java +++ b/L2J_Mobius_Helios/java/com/l2jmobius/gameserver/model/actor/L2Character.java @@ -33,6 +33,7 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentSkipListMap; import java.util.concurrent.LinkedBlockingDeque; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.locks.ReentrantLock; import java.util.function.Predicate; @@ -1139,7 +1140,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe final int timeToHit = timeAtk / 2; // the hit is calculated to happen halfway to the animation - might need further tuning e.g. in bow case final int ssGrade = (weaponItem != null) ? weaponItem.getItemGrade().ordinal() : 0; final Attack attack = new Attack(this, target, wasSSCharged, ssGrade); - _attackEndTime = System.currentTimeMillis() + timeAtk; + _attackEndTime = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(timeAtk); // Make sure that char is facing selected target // also works: setHeading(Util.convertDegreeToClientHeading(Util.calculateAngleFrom(this, target))); @@ -3156,7 +3157,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe */ public final boolean isAttackingNow() { - return _attackEndTime > System.currentTimeMillis(); + return _attackEndTime > System.nanoTime(); } /** diff --git a/L2J_Mobius_Helios/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java b/L2J_Mobius_Helios/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java index 99914f44fc..7d80202cca 100644 --- a/L2J_Mobius_Helios/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java +++ b/L2J_Mobius_Helios/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java @@ -17,6 +17,7 @@ package com.l2jmobius.gameserver.network.clientpackets; import java.util.List; +import java.util.concurrent.TimeUnit; import com.l2jmobius.Config; import com.l2jmobius.commons.network.PacketReader; @@ -255,7 +256,7 @@ public final class UseItem implements IClientIncomingPacket // Equip or unEquip activeChar.useEquippableItem(item, false); - }, activeChar.getAttackEndTime() - System.currentTimeMillis()); + }, activeChar.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis())); } else { diff --git a/L2J_Mobius_Underground/java/com/l2jmobius/gameserver/ai/L2CharacterAI.java b/L2J_Mobius_Underground/java/com/l2jmobius/gameserver/ai/L2CharacterAI.java index 6438f27825..934341249a 100644 --- a/L2J_Mobius_Underground/java/com/l2jmobius/gameserver/ai/L2CharacterAI.java +++ b/L2J_Mobius_Underground/java/com/l2jmobius/gameserver/ai/L2CharacterAI.java @@ -28,9 +28,9 @@ import static com.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_REST; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.TimeUnit; import java.util.logging.Logger; -import com.l2jmobius.gameserver.GameTimeController; import com.l2jmobius.gameserver.ThreadPoolManager; import com.l2jmobius.gameserver.enums.ItemLocation; import com.l2jmobius.gameserver.geodata.GeoData; @@ -306,9 +306,9 @@ public class L2CharacterAI extends AbstractAI return; } - if (_actor.getAttackEndTime() > GameTimeController.getInstance().getGameTicks()) + if (_actor.isAttackingNow()) { - ThreadPoolManager.getInstance().scheduleGeneral(new CastTask(_actor, skill, target, item, forceUse, dontMove), _actor.getAttackEndTime() - System.currentTimeMillis()); + ThreadPoolManager.getInstance().scheduleGeneral(new CastTask(_actor, skill, target, item, forceUse, dontMove), _actor.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis())); } else { diff --git a/L2J_Mobius_Underground/java/com/l2jmobius/gameserver/model/actor/L2Character.java b/L2J_Mobius_Underground/java/com/l2jmobius/gameserver/model/actor/L2Character.java index 795bf13a3e..d1c3434468 100644 --- a/L2J_Mobius_Underground/java/com/l2jmobius/gameserver/model/actor/L2Character.java +++ b/L2J_Mobius_Underground/java/com/l2jmobius/gameserver/model/actor/L2Character.java @@ -33,6 +33,7 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentSkipListMap; import java.util.concurrent.LinkedBlockingDeque; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.locks.ReentrantLock; import java.util.function.Predicate; @@ -1139,7 +1140,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe final int timeToHit = timeAtk / 2; // the hit is calculated to happen halfway to the animation - might need further tuning e.g. in bow case final int ssGrade = (weaponItem != null) ? weaponItem.getItemGrade().ordinal() : 0; final Attack attack = new Attack(this, target, wasSSCharged, ssGrade); - _attackEndTime = System.currentTimeMillis() + timeAtk; + _attackEndTime = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(timeAtk); // Make sure that char is facing selected target // also works: setHeading(Util.convertDegreeToClientHeading(Util.calculateAngleFrom(this, target))); @@ -3156,7 +3157,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe */ public final boolean isAttackingNow() { - return _attackEndTime > System.currentTimeMillis(); + return _attackEndTime > System.nanoTime(); } /** diff --git a/L2J_Mobius_Underground/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java b/L2J_Mobius_Underground/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java index 99914f44fc..7d80202cca 100644 --- a/L2J_Mobius_Underground/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java +++ b/L2J_Mobius_Underground/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java @@ -17,6 +17,7 @@ package com.l2jmobius.gameserver.network.clientpackets; import java.util.List; +import java.util.concurrent.TimeUnit; import com.l2jmobius.Config; import com.l2jmobius.commons.network.PacketReader; @@ -255,7 +256,7 @@ public final class UseItem implements IClientIncomingPacket // Equip or unEquip activeChar.useEquippableItem(item, false); - }, activeChar.getAttackEndTime() - System.currentTimeMillis()); + }, activeChar.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis())); } else {