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

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

View File

@@ -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);
}
/**