From 5597d0bf31d361ed3b9563ede745902e005c9e8c Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Sat, 16 Nov 2024 19:50:09 +0800 Subject: [PATCH] fix arrows drawing out of bounds --- .../src/forge/screens/match/MatchScreen.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/forge-gui-mobile/src/forge/screens/match/MatchScreen.java b/forge-gui-mobile/src/forge/screens/match/MatchScreen.java index 41528cf4aaa..1d245df8c6a 100644 --- a/forge-gui-mobile/src/forge/screens/match/MatchScreen.java +++ b/forge-gui-mobile/src/forge/screens/match/MatchScreen.java @@ -466,22 +466,35 @@ public class MatchScreen extends FScreen { final GameView game = MatchController.instance.getGameView(); try { for (PlayerView p : game.getPlayers()) { - if (p != null && playerPanelsList.contains(getPlayerPanel(p))) { + if (p == null) + continue; + VPlayerPanel playerPanel = getPlayerPanel(p); + if (playerPanel != null && playerPanelsList.contains(playerPanel)) { playerViewSet.add(p); if (p.getBattlefield() != null) { for (CardView c : p.getBattlefield()) { - endpoints.put(c.getId(), CardAreaPanel.get(c).getTargetingArrowOrigin()); + CardAreaPanel panel = CardAreaPanel.get(c); + Vector2 origin = panel.getTargetingArrowOrigin(); + //outside left bounds + if (origin.x < playerPanel.getField().getLeft()) + continue; + //outside right bounds + if (origin.x > playerPanel.getField().getRight()) + continue; + endpoints.put(c.getId(), origin); cardsonBattlefield.add(c); } } } } + if (endpoints.isEmpty()) + return; //draw arrows for combat final CombatView combat = game.getCombat(); for (CardView c : cardsonBattlefield) { TargetingOverlay.assembleArrows(g, c, endpoints, combat, playerViewSet); } - } catch (Exception e) { + } catch (Exception ignored) { } }