From 771a73970223746ce844426feffb6c3053bac7b6 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Tue, 2 May 2023 07:19:14 +0800 Subject: [PATCH] try to fix older gauntlet/tournament saves. - old saves with cards using old edition code always crash on newer version of Forge due to Edition updates/changes. Try to load it by getting replacement card with any edition first found in db since those are migration error and editing the extracted save file manually are not user friendly. --- .../src/main/java/forge/gamemodes/gauntlet/GauntletIO.java | 6 +++++- .../main/java/forge/gamemodes/tournament/TournamentIO.java | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/forge-gui/src/main/java/forge/gamemodes/gauntlet/GauntletIO.java b/forge-gui/src/main/java/forge/gamemodes/gauntlet/GauntletIO.java index 40ffba901c0..2c9bd835109 100644 --- a/forge-gui/src/main/java/forge/gamemodes/gauntlet/GauntletIO.java +++ b/forge-gui/src/main/java/forge/gamemodes/gauntlet/GauntletIO.java @@ -213,7 +213,11 @@ public class GauntletIO { final boolean foil = "1".equals(reader.getAttribute("foil")); PaperCard card = FModel.getMagicDb().getOrLoadCommonCard(name, set, index, foil); if (null == card) { - throw new RuntimeException("Unsupported card found in gauntlet save: " + name + " from edition " + set); + //get same replacement card from any edition due to Edition updates/changes if it exists (ie Ugin, the Ineffable from edition PSLD, Mana Crypt from edition FS, Timeless Lotus from edition ???). + card = FModel.getMagicDb().getCommonCards().getCard(name); + if (card == null) //if the card is not found, notify via log instead of crashing + System.err.println("Warning: Unsupported card found in gauntlet save: " + name + " from edition " + set +". It will be removed from the gauntlet save."); + //throw new RuntimeException("Unsupported card found in gauntlet save: " + name + " from edition " + set); } return card; } diff --git a/forge-gui/src/main/java/forge/gamemodes/tournament/TournamentIO.java b/forge-gui/src/main/java/forge/gamemodes/tournament/TournamentIO.java index 7e2af61a758..f793354400b 100644 --- a/forge-gui/src/main/java/forge/gamemodes/tournament/TournamentIO.java +++ b/forge-gui/src/main/java/forge/gamemodes/tournament/TournamentIO.java @@ -188,7 +188,11 @@ public class TournamentIO { final boolean foil = "1".equals(reader.getAttribute("foil")); PaperCard card = FModel.getMagicDb().getOrLoadCommonCard(name, set, index, foil); if (null == card) { - throw new RuntimeException("Unsupported card found in quest save: " + name + " from edition " + set); + //get same replacement card from any edition due to Edition updates/changes if it exists (ie Ugin, the Ineffable from edition PSLD, Mana Crypt from edition FS, Timeless Lotus from edition ???). + card = FModel.getMagicDb().getCommonCards().getCard(name); + if (card == null) //if the card is not found, notify via log instead of crashing + System.err.println("Warning: Unsupported card found in quest save: " + name + " from edition " + set +". It will be removed from the quest save."); + //throw new RuntimeException("Unsupported card found in quest save: " + name + " from edition " + set); } return card; }