From 397e1a3ff51f25957a80521d5746efe8e02b87c5 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Thu, 27 Apr 2023 18:46:30 +0800 Subject: [PATCH 1/2] prevent OutOfMemoryError on chooseNumber --- .../src/main/java/forge/player/PlayerControllerHuman.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java b/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java index 53e7386d85e..22c348f140e 100644 --- a/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java +++ b/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java @@ -682,7 +682,10 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont return min; } final ImmutableList.Builder choices = ImmutableList.builder(); - for (int i = 0; i <= max - min; i++) { + //todo check for X cost or any max value for optional costs like multikicker, etc to determine the correct max value, + // fixes crash for word of command OutOfMemoryError since it will build from 0 to Integer.MAX_VALUE... + int size = max == Integer.MAX_VALUE ? 9 : max - min; + for (int i = 0; i <= size; i++) { choices.add(Integer.valueOf(i + min)); } return getGui().one(title, choices.build()).intValue(); From d9c59b80d1ad838b5a4b007ec405731924e01c7b Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Thu, 27 Apr 2023 18:49:47 +0800 Subject: [PATCH 2/2] update comment --- .../src/main/java/forge/player/PlayerControllerHuman.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java b/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java index 22c348f140e..17f3d55596f 100644 --- a/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java +++ b/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java @@ -682,8 +682,9 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont return min; } final ImmutableList.Builder choices = ImmutableList.builder(); - //todo check for X cost or any max value for optional costs like multikicker, etc to determine the correct max value, - // fixes crash for word of command OutOfMemoryError since it will build from 0 to Integer.MAX_VALUE... + // todo check for X cost or any max value for optional costs like multikicker, etc to determine the correct max value, + // fixes crash for word of command OutOfMemoryError when selecting a card with announce X or Multikicker since + // it will build from 0 to Integer.MAX_VALUE... int size = max == Integer.MAX_VALUE ? 9 : max - min; for (int i = 0; i <= size; i++) { choices.add(Integer.valueOf(i + min));