Skip to content

Commit

Permalink
Fix Raid loading for old save file revisions
Browse files Browse the repository at this point in the history
  • Loading branch information
Manu098vm committed Sep 28, 2023
1 parent e0dfd75 commit 415a4ef
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
16 changes: 10 additions & 6 deletions TeraFinder.Plugins/Forms/EditorForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions TeraFinder.Plugins/TeraFinder.Plugins.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
<CopyLocalLockFileAssemblies>True</CopyLocalLockFileAssemblies>
<BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down

0 comments on commit 415a4ef

Please sign in to comment.