From 415a4efe024a8176fadfc3ad3311663098276898 Mon Sep 17 00:00:00 2001 From: Manu <52102823+Manu098vm@users.noreply.github.com> Date: Thu, 28 Sep 2023 21:20:37 +0200 Subject: [PATCH] Fix Raid loading for old save file revisions --- TeraFinder.Plugins/Forms/EditorForm.cs | 16 ++++++++++------ TeraFinder.Plugins/TeraFinder.Plugins.csproj | 1 + 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/TeraFinder.Plugins/Forms/EditorForm.cs b/TeraFinder.Plugins/Forms/EditorForm.cs index f12cf299..f8e1ce77 100644 --- a/TeraFinder.Plugins/Forms/EditorForm.cs +++ b/TeraFinder.Plugins/Forms/EditorForm.cs @@ -232,6 +232,10 @@ private void cmbMap_IndexChanged(object sender, EventArgs e) cmbDens.Items.Clear(); foreach (var name in UpdateRaidNameList()) cmbDens.Items.Add(name); + + if (cmbDens.Items.Count == 0) + cmbDens.Items.Add($""); + cmbDens.SelectedIndex = 0; Loaded = true; @@ -251,7 +255,7 @@ private void cmbDens_IndexChanged(object sender, EventArgs e) btnDx.Enabled = true; var spawnList = CurrMap is TeraRaidMapParent.Paldea ? SAV.RaidPaldea : SAV.RaidKitakami; - var raid = spawnList.GetRaid(cmbDens.SelectedIndex); + var raid = spawnList.GetAllRaids().Count() > 1 ? spawnList.GetRaid(cmbDens.SelectedIndex) : new TeraRaidDetail(new byte[32]); chkLP.Checked = raid.IsClaimedLeaguePoints; chkActive.Checked = raid.IsEnabled; @@ -278,7 +282,7 @@ private void chkActive_CheckedChanged(object sender, EventArgs e) if (Loaded) { var spawnList = CurrMap is TeraRaidMapParent.Paldea ? SAV.RaidPaldea : SAV.RaidKitakami; - var raid = spawnList.GetRaid(cmbDens.SelectedIndex); + var raid = spawnList.GetAllRaids().Count() > 1 ? spawnList.GetRaid(cmbDens.SelectedIndex) : new TeraRaidDetail(new byte[32]); if (chkActive.Checked) { raid.IsEnabled = true; @@ -298,7 +302,7 @@ private void chkLP_CheckedChanged(object sender, EventArgs e) if (Loaded) { var spawnList = CurrMap is TeraRaidMapParent.Paldea ? SAV.RaidPaldea : SAV.RaidKitakami; - var raid = spawnList.GetRaid(cmbDens.SelectedIndex); + var raid = spawnList.GetAllRaids().Count() > 1 ? spawnList.GetRaid(cmbDens.SelectedIndex) : new TeraRaidDetail(new byte[32]); if (chkLP.Checked) { raid.IsClaimedLeaguePoints = true; @@ -317,7 +321,7 @@ private void cmbContent_IndexChanged(object sender, EventArgs e) if (Loaded) { var spawnList = CurrMap is TeraRaidMapParent.Paldea ? SAV.RaidPaldea : SAV.RaidKitakami; - var raid = spawnList.GetRaid(cmbDens.SelectedIndex); + var raid = spawnList.GetAllRaids().Count() > 1 ? spawnList.GetRaid(cmbDens.SelectedIndex) : new TeraRaidDetail(new byte[32]); raid.Content = (TeraRaidContentType)cmbContent.SelectedIndex; Task.Run(UpdateRemote).Wait(); UpdatePKMInfo(raid); @@ -338,7 +342,7 @@ private void txtSeed_TextChanged(object sender, EventArgs e) if (!txtSeed.Text.Equals("")) { var spawnList = CurrMap is TeraRaidMapParent.Paldea ? SAV.RaidPaldea : SAV.RaidKitakami; - var raid = spawnList.GetRaid(cmbDens.SelectedIndex); + var raid = spawnList.GetAllRaids().Count() > 1 ? spawnList.GetRaid(cmbDens.SelectedIndex) : new TeraRaidDetail(new byte[32]); try { var seed = Convert.ToUInt32(txtSeed.Text, 16); @@ -579,8 +583,8 @@ private void ShinifyRaids(bool keepEncounter) var progressWindow = new ShinifyForm(0, Strings["ShinifyForm.lblValue"]); var spawnList = CurrMap is TeraRaidMapParent.Paldea ? SAV.RaidPaldea : SAV.RaidKitakami; - var raidCount = spawnList.GetAllRaids().Count(raid => raid.IsEnabled == true); var raidList = spawnList.GetAllRaids(); + var raidCount = raidList.Count(raid => raid.IsEnabled == true); foreach (var iterator in raidList.Select((value, i) => new { i, value })) { var raid = iterator.value; diff --git a/TeraFinder.Plugins/TeraFinder.Plugins.csproj b/TeraFinder.Plugins/TeraFinder.Plugins.csproj index d905fa7d..ba90d22e 100644 --- a/TeraFinder.Plugins/TeraFinder.Plugins.csproj +++ b/TeraFinder.Plugins/TeraFinder.Plugins.csproj @@ -17,6 +17,7 @@ LICENSE True True + obj\