From 510bb0fc2b019c33d9ab998fa5aafc220ea1c7ee Mon Sep 17 00:00:00 2001 From: MobiusDevelopment <8391001+MobiusDevelopment@users.noreply.github.com> Date: Tue, 16 Mar 2021 23:00:53 +0000 Subject: [PATCH] Better pacing method for revalidate zones. --- .../gameserver/model/actor/Creature.java | 21 +++--------- .../model/actor/instance/PlayerInstance.java | 19 +++-------- .../gameserver/model/actor/Creature.java | 21 +++--------- .../model/actor/instance/PlayerInstance.java | 19 +++-------- .../gameserver/model/actor/Creature.java | 21 +++--------- .../model/actor/instance/PlayerInstance.java | 19 +++-------- .../gameserver/model/actor/Creature.java | 21 +++--------- .../model/actor/instance/PlayerInstance.java | 19 +++-------- .../gameserver/model/actor/Creature.java | 21 +++--------- .../model/actor/instance/PlayerInstance.java | 19 +++-------- .../gameserver/model/actor/Creature.java | 21 +++--------- .../model/actor/instance/PlayerInstance.java | 19 +++-------- .../gameserver/model/actor/Creature.java | 21 +++--------- .../model/actor/instance/PlayerInstance.java | 19 +++-------- .../gameserver/model/actor/Creature.java | 21 +++--------- .../model/actor/instance/PlayerInstance.java | 19 +++-------- .../gameserver/model/actor/Creature.java | 21 +++--------- .../model/actor/instance/PlayerInstance.java | 19 +++-------- .../gameserver/model/actor/Creature.java | 21 +++--------- .../model/actor/instance/PlayerInstance.java | 19 +++-------- .../gameserver/model/actor/Creature.java | 23 ++++--------- .../model/actor/instance/PlayerInstance.java | 34 +++++++------------ .../gameserver/model/actor/Creature.java | 23 ++++--------- .../model/actor/instance/PlayerInstance.java | 34 +++++++------------ .../gameserver/model/actor/Creature.java | 21 +++--------- .../model/actor/instance/PlayerInstance.java | 19 +++-------- .../gameserver/model/actor/Creature.java | 21 +++--------- .../model/actor/instance/PlayerInstance.java | 19 +++-------- .../gameserver/model/actor/Creature.java | 21 +++--------- .../model/actor/instance/PlayerInstance.java | 19 +++-------- .../gameserver/model/actor/Creature.java | 21 +++--------- .../model/actor/instance/PlayerInstance.java | 19 +++-------- .../gameserver/model/actor/Creature.java | 21 +++--------- .../model/actor/instance/PlayerInstance.java | 19 +++-------- .../gameserver/model/actor/Creature.java | 21 +++--------- .../model/actor/instance/PlayerInstance.java | 19 +++-------- .../gameserver/model/actor/Creature.java | 21 +++--------- .../model/actor/instance/PlayerInstance.java | 19 +++-------- .../gameserver/model/actor/Creature.java | 21 +++--------- .../model/actor/instance/PlayerInstance.java | 19 +++-------- .../gameserver/model/actor/Creature.java | 21 +++--------- .../model/actor/instance/PlayerInstance.java | 19 +++-------- .../gameserver/model/actor/Creature.java | 21 +++--------- .../model/actor/instance/PlayerInstance.java | 19 +++-------- .../gameserver/model/actor/Creature.java | 21 +++--------- .../model/actor/instance/PlayerInstance.java | 19 +++-------- 46 files changed, 225 insertions(+), 729 deletions(-) diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/Creature.java index 2e5f1ff196..42e0f35c1d 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -223,7 +223,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe private boolean _allSkillsDisabled; private final byte[] _zones = new byte[ZoneId.getZoneCount()]; - protected byte _zoneValidateCounter = 4; + protected final Location _lastZoneValidateLocation = new Location(getX(), getY(), getZ()); private final StampedLock _attackLock = new StampedLock(); @@ -3139,23 +3139,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe public void revalidateZone(boolean force) { - // This function is called too often from movement code - if (force) + // This function is called too often from movement code. + if (!force && (calculateDistance3D(_lastZoneValidateLocation) < (isNpc() && !isInCombat() ? Config.MAX_DRIFT_RANGE : 100))) { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } + return; } + _lastZoneValidateLocation.setXYZ(this); final ZoneRegion region = ZoneManager.getInstance().getRegion(this); if (region != null) diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index b8ac1451e7..4c48d54701 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -1785,23 +1785,12 @@ public class PlayerInstance extends Playable return; } - // This function is called too often from movement code - if (force) + // This function is called too often from movement code. + if (!force && (calculateDistance3D(_lastZoneValidateLocation) < 100)) { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } + return; } + _lastZoneValidateLocation.setXYZ(this); ZoneManager.getInstance().getRegion(this).revalidateZones(this); diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/actor/Creature.java index 2e5f1ff196..42e0f35c1d 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -223,7 +223,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe private boolean _allSkillsDisabled; private final byte[] _zones = new byte[ZoneId.getZoneCount()]; - protected byte _zoneValidateCounter = 4; + protected final Location _lastZoneValidateLocation = new Location(getX(), getY(), getZ()); private final StampedLock _attackLock = new StampedLock(); @@ -3139,23 +3139,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe public void revalidateZone(boolean force) { - // This function is called too often from movement code - if (force) + // This function is called too often from movement code. + if (!force && (calculateDistance3D(_lastZoneValidateLocation) < (isNpc() && !isInCombat() ? Config.MAX_DRIFT_RANGE : 100))) { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } + return; } + _lastZoneValidateLocation.setXYZ(this); final ZoneRegion region = ZoneManager.getInstance().getRegion(this); if (region != null) diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index d15db13500..26b897c7f8 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -1791,23 +1791,12 @@ public class PlayerInstance extends Playable return; } - // This function is called too often from movement code - if (force) + // This function is called too often from movement code. + if (!force && (calculateDistance3D(_lastZoneValidateLocation) < 100)) { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } + return; } + _lastZoneValidateLocation.setXYZ(this); ZoneManager.getInstance().getRegion(this).revalidateZones(this); diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/actor/Creature.java index f671bfe3a9..c6d955d737 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -223,7 +223,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe private boolean _allSkillsDisabled; private final byte[] _zones = new byte[ZoneId.getZoneCount()]; - protected byte _zoneValidateCounter = 4; + protected final Location _lastZoneValidateLocation = new Location(getX(), getY(), getZ()); private final StampedLock _attackLock = new StampedLock(); @@ -3139,23 +3139,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe public void revalidateZone(boolean force) { - // This function is called too often from movement code - if (force) + // This function is called too often from movement code. + if (!force && (calculateDistance3D(_lastZoneValidateLocation) < (isNpc() && !isInCombat() ? Config.MAX_DRIFT_RANGE : 100))) { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } + return; } + _lastZoneValidateLocation.setXYZ(this); final ZoneRegion region = ZoneManager.getInstance().getRegion(this); if (region != null) diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 5a681af727..eb6e792671 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -1793,23 +1793,12 @@ public class PlayerInstance extends Playable return; } - // This function is called too often from movement code - if (force) + // This function is called too often from movement code. + if (!force && (calculateDistance3D(_lastZoneValidateLocation) < 100)) { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } + return; } + _lastZoneValidateLocation.setXYZ(this); ZoneManager.getInstance().getRegion(this).revalidateZones(this); diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/Creature.java index f671bfe3a9..c6d955d737 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -223,7 +223,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe private boolean _allSkillsDisabled; private final byte[] _zones = new byte[ZoneId.getZoneCount()]; - protected byte _zoneValidateCounter = 4; + protected final Location _lastZoneValidateLocation = new Location(getX(), getY(), getZ()); private final StampedLock _attackLock = new StampedLock(); @@ -3139,23 +3139,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe public void revalidateZone(boolean force) { - // This function is called too often from movement code - if (force) + // This function is called too often from movement code. + if (!force && (calculateDistance3D(_lastZoneValidateLocation) < (isNpc() && !isInCombat() ? Config.MAX_DRIFT_RANGE : 100))) { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } + return; } + _lastZoneValidateLocation.setXYZ(this); final ZoneRegion region = ZoneManager.getInstance().getRegion(this); if (region != null) diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index c63e3ae134..1d8f31bb58 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -1803,23 +1803,12 @@ public class PlayerInstance extends Playable return; } - // This function is called too often from movement code - if (force) + // This function is called too often from movement code. + if (!force && (calculateDistance3D(_lastZoneValidateLocation) < 100)) { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } + return; } + _lastZoneValidateLocation.setXYZ(this); ZoneManager.getInstance().getRegion(this).revalidateZones(this); diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/actor/Creature.java index cd2066a465..39c446b584 100644 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -223,7 +223,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe private boolean _allSkillsDisabled; private final byte[] _zones = new byte[ZoneId.getZoneCount()]; - protected byte _zoneValidateCounter = 4; + protected final Location _lastZoneValidateLocation = new Location(getX(), getY(), getZ()); private final StampedLock _attackLock = new StampedLock(); @@ -3139,23 +3139,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe public void revalidateZone(boolean force) { - // This function is called too often from movement code - if (force) + // This function is called too often from movement code. + if (!force && (calculateDistance3D(_lastZoneValidateLocation) < (isNpc() && !isInCombat() ? Config.MAX_DRIFT_RANGE : 100))) { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } + return; } + _lastZoneValidateLocation.setXYZ(this); final ZoneRegion region = ZoneManager.getInstance().getRegion(this); if (region != null) diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 7370fc7430..1c1694014d 100644 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -1796,23 +1796,12 @@ public class PlayerInstance extends Playable return; } - // This function is called too often from movement code - if (force) + // This function is called too often from movement code. + if (!force && (calculateDistance3D(_lastZoneValidateLocation) < 100)) { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } + return; } + _lastZoneValidateLocation.setXYZ(this); ZoneManager.getInstance().getRegion(this).revalidateZones(this); diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/Creature.java index cd2066a465..39c446b584 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -223,7 +223,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe private boolean _allSkillsDisabled; private final byte[] _zones = new byte[ZoneId.getZoneCount()]; - protected byte _zoneValidateCounter = 4; + protected final Location _lastZoneValidateLocation = new Location(getX(), getY(), getZ()); private final StampedLock _attackLock = new StampedLock(); @@ -3139,23 +3139,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe public void revalidateZone(boolean force) { - // This function is called too often from movement code - if (force) + // This function is called too often from movement code. + if (!force && (calculateDistance3D(_lastZoneValidateLocation) < (isNpc() && !isInCombat() ? Config.MAX_DRIFT_RANGE : 100))) { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } + return; } + _lastZoneValidateLocation.setXYZ(this); final ZoneRegion region = ZoneManager.getInstance().getRegion(this); if (region != null) diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 9d5ad51718..8b08ac9a89 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -1796,23 +1796,12 @@ public class PlayerInstance extends Playable return; } - // This function is called too often from movement code - if (force) + // This function is called too often from movement code. + if (!force && (calculateDistance3D(_lastZoneValidateLocation) < 100)) { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } + return; } + _lastZoneValidateLocation.setXYZ(this); ZoneManager.getInstance().getRegion(this).revalidateZones(this); diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/Creature.java index cd2066a465..39c446b584 100644 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -223,7 +223,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe private boolean _allSkillsDisabled; private final byte[] _zones = new byte[ZoneId.getZoneCount()]; - protected byte _zoneValidateCounter = 4; + protected final Location _lastZoneValidateLocation = new Location(getX(), getY(), getZ()); private final StampedLock _attackLock = new StampedLock(); @@ -3139,23 +3139,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe public void revalidateZone(boolean force) { - // This function is called too often from movement code - if (force) + // This function is called too often from movement code. + if (!force && (calculateDistance3D(_lastZoneValidateLocation) < (isNpc() && !isInCombat() ? Config.MAX_DRIFT_RANGE : 100))) { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } + return; } + _lastZoneValidateLocation.setXYZ(this); final ZoneRegion region = ZoneManager.getInstance().getRegion(this); if (region != null) diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 6ca2112120..effd38b23d 100644 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -1796,23 +1796,12 @@ public class PlayerInstance extends Playable return; } - // This function is called too often from movement code - if (force) + // This function is called too often from movement code. + if (!force && (calculateDistance3D(_lastZoneValidateLocation) < 100)) { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } + return; } + _lastZoneValidateLocation.setXYZ(this); ZoneManager.getInstance().getRegion(this).revalidateZones(this); diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Creature.java index 229bf285b1..780bad2e23 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -223,7 +223,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe private boolean _allSkillsDisabled; private final byte[] _zones = new byte[ZoneId.getZoneCount()]; - protected byte _zoneValidateCounter = 4; + protected final Location _lastZoneValidateLocation = new Location(getX(), getY(), getZ()); private final StampedLock _attackLock = new StampedLock(); @@ -3138,23 +3138,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe public void revalidateZone(boolean force) { - // This function is called too often from movement code - if (force) + // This function is called too often from movement code. + if (!force && (calculateDistance3D(_lastZoneValidateLocation) < (isNpc() && !isInCombat() ? Config.MAX_DRIFT_RANGE : 100))) { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } + return; } + _lastZoneValidateLocation.setXYZ(this); final ZoneRegion region = ZoneManager.getInstance().getRegion(this); if (region != null) diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 22d7987fc4..e011ce37d1 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -1808,23 +1808,12 @@ public class PlayerInstance extends Playable return; } - // This function is called too often from movement code - if (force) + // This function is called too often from movement code. + if (!force && (calculateDistance3D(_lastZoneValidateLocation) < 100)) { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } + return; } + _lastZoneValidateLocation.setXYZ(this); ZoneManager.getInstance().getRegion(this).revalidateZones(this); diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/actor/Creature.java index c6af00fbdd..fd7cca66cc 100644 --- a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -223,7 +223,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe private boolean _allSkillsDisabled; private final byte[] _zones = new byte[ZoneId.getZoneCount()]; - protected byte _zoneValidateCounter = 4; + protected final Location _lastZoneValidateLocation = new Location(getX(), getY(), getZ()); private final StampedLock _attackLock = new StampedLock(); @@ -3138,23 +3138,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe public void revalidateZone(boolean force) { - // This function is called too often from movement code - if (force) + // This function is called too often from movement code. + if (!force && (calculateDistance3D(_lastZoneValidateLocation) < (isNpc() && !isInCombat() ? Config.MAX_DRIFT_RANGE : 100))) { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } + return; } + _lastZoneValidateLocation.setXYZ(this); final ZoneRegion region = ZoneManager.getInstance().getRegion(this); if (region != null) diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index f567cc9eb8..74537fa06c 100644 --- a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -1803,23 +1803,12 @@ public class PlayerInstance extends Playable return; } - // This function is called too often from movement code - if (force) + // This function is called too often from movement code. + if (!force && (calculateDistance3D(_lastZoneValidateLocation) < 100)) { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } + return; } + _lastZoneValidateLocation.setXYZ(this); ZoneManager.getInstance().getRegion(this).revalidateZones(this); diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Creature.java index c6af00fbdd..fd7cca66cc 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -223,7 +223,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe private boolean _allSkillsDisabled; private final byte[] _zones = new byte[ZoneId.getZoneCount()]; - protected byte _zoneValidateCounter = 4; + protected final Location _lastZoneValidateLocation = new Location(getX(), getY(), getZ()); private final StampedLock _attackLock = new StampedLock(); @@ -3138,23 +3138,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe public void revalidateZone(boolean force) { - // This function is called too often from movement code - if (force) + // This function is called too often from movement code. + if (!force && (calculateDistance3D(_lastZoneValidateLocation) < (isNpc() && !isInCombat() ? Config.MAX_DRIFT_RANGE : 100))) { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } + return; } + _lastZoneValidateLocation.setXYZ(this); final ZoneRegion region = ZoneManager.getInstance().getRegion(this); if (region != null) diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index f567cc9eb8..74537fa06c 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -1803,23 +1803,12 @@ public class PlayerInstance extends Playable return; } - // This function is called too often from movement code - if (force) + // This function is called too often from movement code. + if (!force && (calculateDistance3D(_lastZoneValidateLocation) < 100)) { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } + return; } + _lastZoneValidateLocation.setXYZ(this); ZoneManager.getInstance().getRegion(this).revalidateZones(this); diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/Creature.java index 2e35ce23bb..da93ed9bd7 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -200,6 +200,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder private boolean _blocked; private boolean _meditated; private final byte[] _zones = new byte[ZoneId.getZoneCount()]; + protected final Location _lastZoneValidateLocation = new Location(getX(), getY(), getZ()); private boolean _advanceFlag = false; private int _advanceMultiplier = 1; @@ -584,8 +585,6 @@ public abstract class Creature extends WorldObject implements ISkillsHolder revalidateZone(true); } - protected byte _zoneValidateCounter = 4; - /** * Revalidate zone. * @param force the force @@ -598,23 +597,13 @@ public abstract class Creature extends WorldObject implements ISkillsHolder return; } - // This function is called too often from movement code - if (force) + // This function is called too often from movement code. + if (!force && (getDistanceSq(_lastZoneValidateLocation.getX(), _lastZoneValidateLocation.getY(), _lastZoneValidateLocation.getZ()) < (isNpc() && !isInCombat() ? Config.MAX_DRIFT_RANGE * Config.MAX_DRIFT_RANGE : 10000))) { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } + return; } + _lastZoneValidateLocation.setXYZ(getX(), getY(), getZ()); + region.revalidateZones(this); } diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 893b1eb157..65cb6fdcd5 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -115,6 +115,7 @@ import org.l2jmobius.gameserver.model.Timestamp; import org.l2jmobius.gameserver.model.TradeList; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.WorldObject; +import org.l2jmobius.gameserver.model.WorldRegion; import org.l2jmobius.gameserver.model.actor.Attackable; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Playable; @@ -304,7 +305,6 @@ public class PlayerInstance extends Playable private long _pvpFlagLasts; private byte _siegeState = 0; private int _curWeightPenalty = 0; - private byte _zoneValidateCounter = 4; private boolean _isIn7sDungeon = false; private int _heroConsecutiveKillCount = 0; private boolean _isPvpHero = false; @@ -1720,35 +1720,25 @@ public class PlayerInstance extends Playable public void revalidateZone(boolean force) { // Cannot validate if not in a world region (happens during teleport) - if (getWorldRegion() == null) + final WorldRegion region = getWorldRegion(); + if (region == null) { return; } + // This function is called too often from movement code. + if (!force && (getDistanceSq(_lastZoneValidateLocation.getX(), _lastZoneValidateLocation.getY(), _lastZoneValidateLocation.getZ()) < 10000)) + { + return; + } + _lastZoneValidateLocation.setXYZ(getX(), getY(), getZ()); + + region.revalidateZones(this); + if (Config.ALLOW_WATER) { checkWaterState(); } - - // This function is called very often from movement code - if (force) - { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } - } - - getWorldRegion().revalidateZones(this); } /** diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/Creature.java index 5942d36a25..5f51aa18e3 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -202,6 +202,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder private boolean _blocked; private boolean _meditated; private final byte[] _zones = new byte[ZoneId.getZoneCount()]; + protected final Location _lastZoneValidateLocation = new Location(getX(), getY(), getZ()); private boolean _advanceFlag = false; private int _advanceMultiplier = 1; @@ -586,8 +587,6 @@ public abstract class Creature extends WorldObject implements ISkillsHolder revalidateZone(true); } - protected byte _zoneValidateCounter = 4; - /** * Revalidate zone. * @param force the force @@ -600,23 +599,13 @@ public abstract class Creature extends WorldObject implements ISkillsHolder return; } - // This function is called too often from movement code - if (force) + // This function is called too often from movement code. + if (!force && (getDistanceSq(_lastZoneValidateLocation.getX(), _lastZoneValidateLocation.getY(), _lastZoneValidateLocation.getZ()) < (isNpc() && !isInCombat() ? Config.MAX_DRIFT_RANGE * Config.MAX_DRIFT_RANGE : 10000))) { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } + return; } + _lastZoneValidateLocation.setXYZ(getX(), getY(), getZ()); + region.revalidateZones(this); } diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index a71afe66e4..bd951b09ce 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -118,6 +118,7 @@ import org.l2jmobius.gameserver.model.Timestamp; import org.l2jmobius.gameserver.model.TradeList; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.WorldObject; +import org.l2jmobius.gameserver.model.WorldRegion; import org.l2jmobius.gameserver.model.actor.Attackable; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Playable; @@ -313,7 +314,6 @@ public class PlayerInstance extends Playable private byte _siegeState = 0; private int _curWeightPenalty = 0; private int _lastCompassZone; // the last compass zone update send to the client - private byte _zoneValidateCounter = 4; private boolean _isIn7sDungeon = false; private int _heroConsecutiveKillCount = 0; private boolean _isPvpHero = false; @@ -1734,36 +1734,26 @@ public class PlayerInstance extends Playable public void revalidateZone(boolean force) { // Cannot validate if not in a world region (happens during teleport) - if (getWorldRegion() == null) + final WorldRegion region = getWorldRegion(); + if (region == null) { return; } + // This function is called too often from movement code. + if (!force && (getDistanceSq(_lastZoneValidateLocation.getX(), _lastZoneValidateLocation.getY(), _lastZoneValidateLocation.getZ()) < 10000)) + { + return; + } + _lastZoneValidateLocation.setXYZ(getX(), getY(), getZ()); + + region.revalidateZones(this); + if (Config.ALLOW_WATER) { checkWaterState(); } - // This function is called very often from movement code - if (force) - { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } - } - - getWorldRegion().revalidateZones(this); - if (isInsideZone(ZoneId.SIEGE)) { if (_lastCompassZone == ExSetCompassZoneCode.SIEGEWARZONE2) diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/Creature.java index d4d2a64c78..b372d18c59 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -227,7 +227,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe private boolean _allSkillsDisabled; private final byte[] _zones = new byte[ZoneId.getZoneCount()]; - protected byte _zoneValidateCounter = 4; + protected final Location _lastZoneValidateLocation = new Location(getX(), getY(), getZ()); private final StampedLock _attackLock = new StampedLock(); @@ -4073,23 +4073,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe public void revalidateZone(boolean force) { - // This function is called too often from movement code - if (force) + // This function is called too often from movement code. + if (!force && (calculateDistance3D(_lastZoneValidateLocation) < (isNpc() && !isInCombat() ? Config.MAX_DRIFT_RANGE : 100))) { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } + return; } + _lastZoneValidateLocation.setXYZ(this); final ZoneRegion region = ZoneManager.getInstance().getRegion(this); if (region != null) diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 3fa4a44092..ec4d442887 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -1701,23 +1701,12 @@ public class PlayerInstance extends Playable return; } - // This function is called too often from movement code - if (force) + // This function is called too often from movement code. + if (!force && (calculateDistance3D(_lastZoneValidateLocation) < 100)) { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } + return; } + _lastZoneValidateLocation.setXYZ(this); ZoneManager.getInstance().getRegion(this).revalidateZones(this); diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Creature.java index 1d2e5452aa..1ad8ee70f4 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -228,7 +228,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe private boolean _allSkillsDisabled; private final byte[] _zones = new byte[ZoneId.getZoneCount()]; - protected byte _zoneValidateCounter = 4; + protected final Location _lastZoneValidateLocation = new Location(getX(), getY(), getZ()); private final StampedLock _attackLock = new StampedLock(); @@ -4075,23 +4075,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe public void revalidateZone(boolean force) { - // This function is called too often from movement code - if (force) + // This function is called too often from movement code. + if (!force && (calculateDistance3D(_lastZoneValidateLocation) < (isNpc() && !isInCombat() ? Config.MAX_DRIFT_RANGE : 100))) { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } + return; } + _lastZoneValidateLocation.setXYZ(this); final ZoneRegion region = ZoneManager.getInstance().getRegion(this); if (region != null) diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 44e0081947..b32fbc644c 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -1722,23 +1722,12 @@ public class PlayerInstance extends Playable return; } - // This function is called too often from movement code - if (force) + // This function is called too often from movement code. + if (!force && (calculateDistance3D(_lastZoneValidateLocation) < 100)) { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } + return; } + _lastZoneValidateLocation.setXYZ(this); ZoneManager.getInstance().getRegion(this).revalidateZones(this); diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/Creature.java index e588e65e42..54d72f38a3 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -223,7 +223,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe private boolean _allSkillsDisabled; private final byte[] _zones = new byte[ZoneId.getZoneCount()]; - protected byte _zoneValidateCounter = 4; + protected final Location _lastZoneValidateLocation = new Location(getX(), getY(), getZ()); private final StampedLock _attackLock = new StampedLock(); @@ -3139,23 +3139,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe public void revalidateZone(boolean force) { - // This function is called too often from movement code - if (force) + // This function is called too often from movement code. + if (!force && (calculateDistance3D(_lastZoneValidateLocation) < (isNpc() && !isInCombat() ? Config.MAX_DRIFT_RANGE : 100))) { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } + return; } + _lastZoneValidateLocation.setXYZ(this); final ZoneRegion region = ZoneManager.getInstance().getRegion(this); if (region != null) diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 4e7e025cef..974f7bd923 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -1749,23 +1749,12 @@ public class PlayerInstance extends Playable return; } - // This function is called too often from movement code - if (force) + // This function is called too often from movement code. + if (!force && (calculateDistance3D(_lastZoneValidateLocation) < 100)) { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } + return; } + _lastZoneValidateLocation.setXYZ(this); ZoneManager.getInstance().getRegion(this).revalidateZones(this); diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/Creature.java index e588e65e42..54d72f38a3 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -223,7 +223,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe private boolean _allSkillsDisabled; private final byte[] _zones = new byte[ZoneId.getZoneCount()]; - protected byte _zoneValidateCounter = 4; + protected final Location _lastZoneValidateLocation = new Location(getX(), getY(), getZ()); private final StampedLock _attackLock = new StampedLock(); @@ -3139,23 +3139,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe public void revalidateZone(boolean force) { - // This function is called too often from movement code - if (force) + // This function is called too often from movement code. + if (!force && (calculateDistance3D(_lastZoneValidateLocation) < (isNpc() && !isInCombat() ? Config.MAX_DRIFT_RANGE : 100))) { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } + return; } + _lastZoneValidateLocation.setXYZ(this); final ZoneRegion region = ZoneManager.getInstance().getRegion(this); if (region != null) diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 7520e0ac49..c457d440ad 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -1749,23 +1749,12 @@ public class PlayerInstance extends Playable return; } - // This function is called too often from movement code - if (force) + // This function is called too often from movement code. + if (!force && (calculateDistance3D(_lastZoneValidateLocation) < 100)) { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } + return; } + _lastZoneValidateLocation.setXYZ(this); ZoneManager.getInstance().getRegion(this).revalidateZones(this); diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/Creature.java index 03730467aa..8d790c7460 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -223,7 +223,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe private boolean _allSkillsDisabled; private final byte[] _zones = new byte[ZoneId.getZoneCount()]; - protected byte _zoneValidateCounter = 4; + protected final Location _lastZoneValidateLocation = new Location(getX(), getY(), getZ()); private final StampedLock _attackLock = new StampedLock(); @@ -3139,23 +3139,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe public void revalidateZone(boolean force) { - // This function is called too often from movement code - if (force) + // This function is called too often from movement code. + if (!force && (calculateDistance3D(_lastZoneValidateLocation) < (isNpc() && !isInCombat() ? Config.MAX_DRIFT_RANGE : 100))) { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } + return; } + _lastZoneValidateLocation.setXYZ(this); final ZoneRegion region = ZoneManager.getInstance().getRegion(this); if (region != null) diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 353445c799..e87fad7616 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -1747,23 +1747,12 @@ public class PlayerInstance extends Playable return; } - // This function is called too often from movement code - if (force) + // This function is called too often from movement code. + if (!force && (calculateDistance3D(_lastZoneValidateLocation) < 100)) { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } + return; } + _lastZoneValidateLocation.setXYZ(this); ZoneManager.getInstance().getRegion(this).revalidateZones(this); diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/Creature.java index 35bf66cd37..ea4e3fbcc7 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -224,7 +224,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe private boolean _allSkillsDisabled; private final byte[] _zones = new byte[ZoneId.getZoneCount()]; - protected byte _zoneValidateCounter = 4; + protected final Location _lastZoneValidateLocation = new Location(getX(), getY(), getZ()); private final StampedLock _attackLock = new StampedLock(); @@ -3152,23 +3152,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe public void revalidateZone(boolean force) { - // This function is called too often from movement code - if (force) + // This function is called too often from movement code. + if (!force && (calculateDistance3D(_lastZoneValidateLocation) < (isNpc() && !isInCombat() ? Config.MAX_DRIFT_RANGE : 100))) { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } + return; } + _lastZoneValidateLocation.setXYZ(this); final ZoneRegion region = ZoneManager.getInstance().getRegion(this); if (region != null) diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 5ea9875ba3..b7078ef22f 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -1757,23 +1757,12 @@ public class PlayerInstance extends Playable return; } - // This function is called too often from movement code - if (force) + // This function is called too often from movement code. + if (!force && (calculateDistance3D(_lastZoneValidateLocation) < 100)) { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } + return; } + _lastZoneValidateLocation.setXYZ(this); ZoneManager.getInstance().getRegion(this).revalidateZones(this); diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/Creature.java index 35bf66cd37..ea4e3fbcc7 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -224,7 +224,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe private boolean _allSkillsDisabled; private final byte[] _zones = new byte[ZoneId.getZoneCount()]; - protected byte _zoneValidateCounter = 4; + protected final Location _lastZoneValidateLocation = new Location(getX(), getY(), getZ()); private final StampedLock _attackLock = new StampedLock(); @@ -3152,23 +3152,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe public void revalidateZone(boolean force) { - // This function is called too often from movement code - if (force) + // This function is called too often from movement code. + if (!force && (calculateDistance3D(_lastZoneValidateLocation) < (isNpc() && !isInCombat() ? Config.MAX_DRIFT_RANGE : 100))) { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } + return; } + _lastZoneValidateLocation.setXYZ(this); final ZoneRegion region = ZoneManager.getInstance().getRegion(this); if (region != null) diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index e428c1b0b1..8dd39b694e 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -1757,23 +1757,12 @@ public class PlayerInstance extends Playable return; } - // This function is called too often from movement code - if (force) + // This function is called too often from movement code. + if (!force && (calculateDistance3D(_lastZoneValidateLocation) < 100)) { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } + return; } + _lastZoneValidateLocation.setXYZ(this); ZoneManager.getInstance().getRegion(this).revalidateZones(this); diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Creature.java index b875281eee..670cc177ed 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -224,7 +224,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe private boolean _allSkillsDisabled; private final byte[] _zones = new byte[ZoneId.getZoneCount()]; - protected byte _zoneValidateCounter = 4; + protected final Location _lastZoneValidateLocation = new Location(getX(), getY(), getZ()); private final StampedLock _attackLock = new StampedLock(); @@ -3151,23 +3151,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe public void revalidateZone(boolean force) { - // This function is called too often from movement code - if (force) + // This function is called too often from movement code. + if (!force && (calculateDistance3D(_lastZoneValidateLocation) < (isNpc() && !isInCombat() ? Config.MAX_DRIFT_RANGE : 100))) { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } + return; } + _lastZoneValidateLocation.setXYZ(this); final ZoneRegion region = ZoneManager.getInstance().getRegion(this); if (region != null) diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 9107de6039..8ec9ddd575 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -1770,23 +1770,12 @@ public class PlayerInstance extends Playable return; } - // This function is called too often from movement code - if (force) + // This function is called too often from movement code. + if (!force && (calculateDistance3D(_lastZoneValidateLocation) < 100)) { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } + return; } + _lastZoneValidateLocation.setXYZ(this); ZoneManager.getInstance().getRegion(this).revalidateZones(this); diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/Creature.java index e588e65e42..54d72f38a3 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -223,7 +223,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe private boolean _allSkillsDisabled; private final byte[] _zones = new byte[ZoneId.getZoneCount()]; - protected byte _zoneValidateCounter = 4; + protected final Location _lastZoneValidateLocation = new Location(getX(), getY(), getZ()); private final StampedLock _attackLock = new StampedLock(); @@ -3139,23 +3139,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe public void revalidateZone(boolean force) { - // This function is called too often from movement code - if (force) + // This function is called too often from movement code. + if (!force && (calculateDistance3D(_lastZoneValidateLocation) < (isNpc() && !isInCombat() ? Config.MAX_DRIFT_RANGE : 100))) { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } + return; } + _lastZoneValidateLocation.setXYZ(this); final ZoneRegion region = ZoneManager.getInstance().getRegion(this); if (region != null) diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index fb6ba00c56..77a2bafdc4 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -1751,23 +1751,12 @@ public class PlayerInstance extends Playable return; } - // This function is called too often from movement code - if (force) + // This function is called too often from movement code. + if (!force && (calculateDistance3D(_lastZoneValidateLocation) < 100)) { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } + return; } + _lastZoneValidateLocation.setXYZ(this); ZoneManager.getInstance().getRegion(this).revalidateZones(this); diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/Creature.java index de485971aa..5566043572 100644 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -224,7 +224,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe private boolean _allSkillsDisabled; private final byte[] _zones = new byte[ZoneId.getZoneCount()]; - protected byte _zoneValidateCounter = 4; + protected final Location _lastZoneValidateLocation = new Location(getX(), getY(), getZ()); private final StampedLock _attackLock = new StampedLock(); @@ -3154,23 +3154,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe public void revalidateZone(boolean force) { - // This function is called too often from movement code - if (force) + // This function is called too often from movement code. + if (!force && (calculateDistance3D(_lastZoneValidateLocation) < (isNpc() && !isInCombat() ? Config.MAX_DRIFT_RANGE : 100))) { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } + return; } + _lastZoneValidateLocation.setXYZ(this); final ZoneRegion region = ZoneManager.getInstance().getRegion(this); if (region != null) diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 058614dd0c..0fe6c62d6c 100644 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -1806,23 +1806,12 @@ public class PlayerInstance extends Playable return; } - // This function is called too often from movement code - if (force) + // This function is called too often from movement code. + if (!force && (calculateDistance3D(_lastZoneValidateLocation) < 100)) { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } + return; } + _lastZoneValidateLocation.setXYZ(this); ZoneManager.getInstance().getRegion(this).revalidateZones(this); diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/actor/Creature.java index 292a6875d3..eed3800fb8 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -224,7 +224,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe private boolean _allSkillsDisabled; private final byte[] _zones = new byte[ZoneId.getZoneCount()]; - protected byte _zoneValidateCounter = 4; + protected final Location _lastZoneValidateLocation = new Location(getX(), getY(), getZ()); private final StampedLock _attackLock = new StampedLock(); @@ -3161,23 +3161,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe public void revalidateZone(boolean force) { - // This function is called too often from movement code - if (force) + // This function is called too often from movement code. + if (!force && (calculateDistance3D(_lastZoneValidateLocation) < (isNpc() && !isInCombat() ? Config.MAX_DRIFT_RANGE : 100))) { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } + return; } + _lastZoneValidateLocation.setXYZ(this); final ZoneRegion region = ZoneManager.getInstance().getRegion(this); if (region != null) diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 6d630ad626..b0412543cf 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -1806,23 +1806,12 @@ public class PlayerInstance extends Playable return; } - // This function is called too often from movement code - if (force) + // This function is called too often from movement code. + if (!force && (calculateDistance3D(_lastZoneValidateLocation) < 100)) { - _zoneValidateCounter = 4; - } - else - { - _zoneValidateCounter--; - if (_zoneValidateCounter < 0) - { - _zoneValidateCounter = 4; - } - else - { - return; - } + return; } + _lastZoneValidateLocation.setXYZ(this); ZoneManager.getInstance().getRegion(this).revalidateZones(this);