container calculation: fix overflow computing ge price
This commit is contained in:
@@ -86,7 +86,7 @@ class ContainerCalculation
|
||||
final long storePrice = itemManager.getItemComposition(id).getPrice();
|
||||
final long alchPrice = (long) (storePrice * Constants.HIGH_ALCHEMY_MULTIPLIER);
|
||||
alch += alchPrice * qty;
|
||||
ge += itemManager.getItemPrice(id) * qty;
|
||||
ge += (long) itemManager.getItemPrice(id) * qty;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -81,11 +81,13 @@ public class ContainerCalculationTest
|
||||
.thenReturn(7); // 7 * .6 = 4, 4 * 1m overflows
|
||||
when(itemManager.getItemComposition(ItemID.ABYSSAL_WHIP))
|
||||
.thenReturn(whipComp);
|
||||
when(itemManager.getItemPrice(ItemID.ABYSSAL_WHIP))
|
||||
.thenReturn(3); // 1b * 3 overflows
|
||||
|
||||
final ContainerPrices prices = containerCalculation.calculate(items);
|
||||
assertNotNull(prices);
|
||||
|
||||
long value = prices.getHighAlchPrice();
|
||||
assertTrue(value > Integer.MAX_VALUE);
|
||||
assertTrue(prices.getHighAlchPrice() > Integer.MAX_VALUE);
|
||||
assertTrue(prices.getGePrice() > Integer.MAX_VALUE);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user