aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRaven Szewczyk <git@eigenraven.me>2022-09-21 16:43:50 +0100
committerGitHub <noreply@github.com>2022-09-21 17:43:50 +0200
commite36fec85566aecdd5f6b0320ebcfeb47d3c501bc (patch)
tree4381b3407cbcafb68c237b17610e99320d8e8283 /src
parentc9633115ac7a2deb5a2559b2738c3f340104a961 (diff)
downloadGT5-Unofficial-e36fec85566aecdd5f6b0320ebcfeb47d3c501bc.tar.gz
GT5-Unofficial-e36fec85566aecdd5f6b0320ebcfeb47d3c501bc.tar.bz2
GT5-Unofficial-e36fec85566aecdd5f6b0320ebcfeb47d3c501bc.zip
Fix integer overflow in PAss when overclocking beyond MAX (#82)
Diffstat (limited to 'src')
-rw-r--r--src/main/java/goodgenerator/blocks/tileEntity/PreciseAssembler.java10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/main/java/goodgenerator/blocks/tileEntity/PreciseAssembler.java b/src/main/java/goodgenerator/blocks/tileEntity/PreciseAssembler.java
index 6af5ee9115..58988a7805 100644
--- a/src/main/java/goodgenerator/blocks/tileEntity/PreciseAssembler.java
+++ b/src/main/java/goodgenerator/blocks/tileEntity/PreciseAssembler.java
@@ -162,16 +162,18 @@ public class PreciseAssembler extends GT_MetaTileEntity_TooltipMultiBlockBase_EM
super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ);
}
- protected void calculateOverclockedNessMultiPara(int aEUt, int aDuration, int mAmperage, long maxInputPower) {
+ protected void calculateOverclockedNessMultiPara(long aEUt, int aDuration, int mAmperage, long maxInputPower) {
+ // Prevent overclocking beyond MAX
+ maxInputPower = Math.min(maxInputPower, Integer.MAX_VALUE - 1);
while (aEUt <= maxInputPower && aDuration >= 1) {
aEUt = aEUt << 2;
aDuration = aDuration >> 1;
}
aEUt = aEUt >> 2;
aDuration = aDuration << 1;
- if (aDuration == 0) aDuration = 1;
- if (aEUt == maxInputPower) aEUt = (int) (maxInputPower * 0.9);
- this.mEUt = aEUt;
+ if (aDuration <= 0) aDuration = 1;
+ if (aEUt == maxInputPower) aEUt = (long) (maxInputPower * 0.9);
+ this.mEUt = GT_Utility.safeInt(aEUt);
this.mMaxProgresstime = aDuration;
}