Просмотр исходного кода

Weight overflow fix, thanks jiv for idea.

_DS_ 16 лет назад
Родитель
Сommit
5e44bd8220

+ 2 - 2
L2_GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java

@@ -2095,8 +2095,8 @@ public final class L2PcInstance extends L2Playable
 		int maxLoad = getMaxLoad();
 		if (maxLoad > 0)
 		{
-			int weightproc = getCurrentLoad() * 1000 / maxLoad;
-			weightproc*=(int)calcStat(Stats.WEIGHT_LIMIT, 1, this, null);
+			long weightproc = (long)getCurrentLoad() * 1000 / maxLoad;
+			weightproc *= calcStat(Stats.WEIGHT_LIMIT, 1, this, null);
 			int newWeightPenalty;
 			if (weightproc < 500 || _dietMode)
 			{

+ 2 - 2
L2_GameServer/java/net/sf/l2j/gameserver/model/itemcontainer/Inventory.java

@@ -1440,14 +1440,14 @@ public abstract class Inventory extends ItemContainer
 	@Override
 	protected void refreshWeight()
 	{
-		int weight = 0;
+		long weight = 0;
 
 		for (L2ItemInstance item : _items)
 		{
 			if (item != null && item.getItem() != null)
 				weight += item.getItem().getWeight() * item.getCount();
 		}
-		_totalWeight = weight;
+		_totalWeight = (int)Math.min(weight, Integer.MAX_VALUE);
 	}
 
 	/**