Merge pull request #1254 from Antifluxfield/overflow_fix

Fix overflow when charging ultimate battery
This commit is contained in:
Blood-Asp 2017-11-05 18:00:30 +01:00 committed by GitHub
commit c7851042b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -256,7 +256,8 @@ public abstract class GT_MetaBase_Item extends GT_Generic_Item implements ISpeci
Long[] tStats = getElectricStats(aStack);
if (tStats == null || tStats[2] > aTier || !(tStats[3] == -1 || tStats[3] == -3 || (tStats[3] < 0 && aCharge == Integer.MAX_VALUE)) || aStack.stackSize != 1)
return 0;
long tChargeBefore = getRealCharge(aStack), tNewCharge = aCharge == Integer.MAX_VALUE ? Long.MAX_VALUE : Math.min(Math.abs(tStats[0]), tChargeBefore + (aIgnoreTransferLimit ? (long) aCharge : Math.min(tStats[1], (long) aCharge)));
long tTransfer = aIgnoreTransferLimit ? (long) aCharge : Math.min(tStats[1], (long) aCharge);
long tChargeBefore = getRealCharge(aStack), tNewCharge = aCharge == Integer.MAX_VALUE ? Long.MAX_VALUE : Math.min(Math.abs(tStats[0]), Long.MAX_VALUE - tTransfer >= tChargeBefore ? tChargeBefore + tTransfer : Long.MAX_VALUE);
if (!aSimulate) setCharge(aStack, tNewCharge);
return tNewCharge - tChargeBefore;
}