Better pacing method for revalidate zones.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user