Better pacing method for revalidate zones.

This commit is contained in:
MobiusDevelopment
2021-03-16 23:00:53 +00:00
parent 0997eff21b
commit 510bb0fc2b
46 changed files with 225 additions and 729 deletions

View File

@@ -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)

View File

@@ -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);