From a3ec4817a2dfbda5a010e1d03313e6a6fd9fac6c Mon Sep 17 00:00:00 2001 From: Hans Mackowiak Date: Mon, 30 Nov 2020 11:59:19 +0100 Subject: [PATCH] Fixed mindSlaveMaster == controller causing StackoverflowError --- forge-game/src/main/java/forge/game/GameEntityViewMap.java | 6 +++++- forge-game/src/main/java/forge/game/card/CardView.java | 2 +- .../src/main/java/forge/player/PlayerControllerHuman.java | 6 ++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/forge-game/src/main/java/forge/game/GameEntityViewMap.java b/forge-game/src/main/java/forge/game/GameEntityViewMap.java index e30161405bc..7107a47319e 100644 --- a/forge-game/src/main/java/forge/game/GameEntityViewMap.java +++ b/forge-game/src/main/java/forge/game/GameEntityViewMap.java @@ -37,13 +37,17 @@ public class GameEntityViewMap views, List list) { + public List addToList(Iterable views, List list) { + if (views == null) { + return list; + } for (View view : views) { Entity entity = get(view); if (entity != null) { list.add(entity); } } + return list; } public TrackableCollection getTrackableKeys() { diff --git a/forge-game/src/main/java/forge/game/card/CardView.java b/forge-game/src/main/java/forge/game/card/CardView.java index 4132509142a..1ebbda591b5 100644 --- a/forge-game/src/main/java/forge/game/card/CardView.java +++ b/forge-game/src/main/java/forge/game/card/CardView.java @@ -449,7 +449,7 @@ public class CardView extends GameEntityView { //if viewer is controlled by another player, also check if card can be shown to that player PlayerView mindSlaveMaster = controller.getMindSlaveMaster(); - if (mindSlaveMaster != null && mindSlaveMaster == viewer) { + if (mindSlaveMaster != null && mindSlaveMaster != controller && mindSlaveMaster == viewer) { return canBeShownTo(controller); } return false; diff --git a/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java b/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java index 474390ac626..0f5a509bb12 100644 --- a/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java +++ b/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java @@ -788,13 +788,11 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont GameEntityViewMap gameCacheManipulate = GameEntityView.getMap(cards); gameCacheManipulate.putAll(manipulable); List views = getGui().manipulateCardList(title, CardView.getCollection(cards), CardView.getCollection(manipulable), toTop, toBottom, toAnywhere); - List result = new CardCollection(); - gameCacheManipulate.addToList(views, result); - return result; + return gameCacheManipulate.addToList(views, new CardCollection()); } public ImmutablePair arrangeForMove(final String title, final FCollectionView cards, final List manipulable, final boolean topOK, final boolean bottomOK) { - List result = manipulateCardList(localizer.getMessage("lblMoveCardstoToporBbottomofLibrary"), cards, manipulable, topOK, bottomOK, false); + List result = manipulateCardList(title, cards, manipulable, topOK, bottomOK, false); CardCollection toBottom = new CardCollection(); CardCollection toTop = new CardCollection(); for (int i = 0; i