SV TM/Fly cheats: do not modify non-existent blocks

New fly location and TM Machine flags do not exist on older save revisions, which would've thrown an exception
This commit is contained in:
sora10pls 2023-09-23 11:08:25 -04:00
parent 703e2ed5ad
commit 9510272149
2 changed files with 7 additions and 1 deletions

View file

@ -343,10 +343,12 @@ public sealed class SAV9SV : SaveFile, ISaveBlock9Main, ISCBlockArray, ISaveFile
public void UnlockAllTMRecipes()
{
for (int i = 1; i <= 201; i++)
for (int i = 1; i <= 229; i++)
{
var flag = $"FSYS_UI_WAZA_MACHINE_RELEASE_{i:000}";
var hash = (uint)FnvHash.HashFnv1a_64(flag);
if (!Accessor.HasBlock(hash))
continue;
var block = Accessor.GetBlock(hash);
block.ChangeBooleanType(SCTypeCode.Bool2);
}

View file

@ -276,7 +276,11 @@ public partial class SAV_Trainer9 : Form
};
var accessor = SAV.Accessor;
foreach (var block in blocks)
{
if (!accessor.HasBlock(block))
continue;
accessor.GetBlock(block).ChangeBooleanType(SCTypeCode.Bool2);
}
System.Media.SystemSounds.Asterisk.Play();
}