Avoid unlikely AggroInfo number limit memory overflows.
This commit is contained in:
@@ -23,6 +23,9 @@ import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
*/
|
||||
public class AggroInfo
|
||||
{
|
||||
private static final long MAX_VALUE = 1000000000000000L;
|
||||
private static final long MIN_VALUE = -1000000000000000L;
|
||||
|
||||
private final Creature _attacker;
|
||||
private long _hate = 0;
|
||||
private long _damage = 0;
|
||||
@@ -53,7 +56,19 @@ public class AggroInfo
|
||||
|
||||
public void addHate(long value)
|
||||
{
|
||||
_hate = Math.min(_hate + value, Long.MAX_VALUE);
|
||||
final long sum = _hate + value;
|
||||
if (sum > MAX_VALUE)
|
||||
{
|
||||
_hate = MAX_VALUE;
|
||||
}
|
||||
else if (sum < MIN_VALUE)
|
||||
{
|
||||
_hate = MIN_VALUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
_hate = sum;
|
||||
}
|
||||
}
|
||||
|
||||
public void stopHate()
|
||||
@@ -68,7 +83,19 @@ public class AggroInfo
|
||||
|
||||
public void addDamage(long value)
|
||||
{
|
||||
_damage = Math.min(_damage + value, Long.MAX_VALUE);
|
||||
final long sum = _damage + value;
|
||||
if (sum > MAX_VALUE)
|
||||
{
|
||||
_damage = MAX_VALUE;
|
||||
}
|
||||
else if (sum < MIN_VALUE)
|
||||
{
|
||||
_damage = MIN_VALUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
_damage = sum;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user