From 21d918ebc34c24e4044423f393ecb3f1be4fd249 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Fri, 6 Jul 2018 20:38:11 +1000 Subject: $ Fixed an error in XSTR.java where the maximum bound for nextInt(x) could be 0. $ Fixed some Aboriginal Trader Logic. --- src/Java/gtPlusPlus/api/objects/random/XSTR.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/Java/gtPlusPlus/api/objects/random') diff --git a/src/Java/gtPlusPlus/api/objects/random/XSTR.java b/src/Java/gtPlusPlus/api/objects/random/XSTR.java index 7f83df52c4..4b5b1298b6 100644 --- a/src/Java/gtPlusPlus/api/objects/random/XSTR.java +++ b/src/Java/gtPlusPlus/api/objects/random/XSTR.java @@ -213,9 +213,14 @@ public class XSTR extends Random { */ @Override public int nextInt(final int bound) { - //if (bound <= 0) { + final int newBound; + if (bound <= 0) { + newBound = 1; //throw new RuntimeException("BadBound"); - //} + } + else { + newBound = bound; + } /*int r = next(31); int m = bound - 1; @@ -234,7 +239,7 @@ public class XSTR extends Random { this.last ^= (this.last >>> 35); this.last ^= (this.last << 4); this.seed = this.last; - final int out = (int) this.last % bound; + final int out = (int) this.last % newBound; return (out < 0) ? -out : out; } @Override -- cgit