Fix vivillon comparisons

Fix template->pkm form fetch too; would return 0 for non-subregion
countries rather than the Country Specific form ID

https://projectpokemon.org/home/forums/topic/52800-invalid-internal-error-with-the-spewpa-evolution-line/
This commit is contained in:
Kurt 2019-05-16 22:01:11 -07:00
parent 73b61e5bf0
commit 7f9328e883

View file

@ -260,8 +260,8 @@ namespace PKHeX.Core
return false; // Country mismatch
var ct = Array.Find(RegionFormTable, t => t.CountryID == country);
if (ct.SubRegionForms == null) // empty struct = no forms referenced
return true; // No subregion table
if (ct == default(CountryTable)) // empty = one form for country
return true; // No subregion table, already checked if Country can have this form
if (ct.BaseForm == form)
return !ct.SubRegionForms.Any(e => e.Regions.Contains(region)); //true if Mainform not in other specific region
@ -277,8 +277,8 @@ namespace PKHeX.Core
public static int GetVivillonPattern(int country, int region)
{
var ct = Array.Find(RegionFormTable, t => t.CountryID == country);
if (ct.SubRegionForms == null) // empty struct = no forms referenced
return ct.BaseForm; // No subregion table
if (ct == default(CountryTable)) // empty = no forms referenced
return GetVivillonPattern(country);
foreach (var sub in ct.SubRegionForms)
{
@ -289,6 +289,12 @@ namespace PKHeX.Core
return ct.BaseForm;
}
private static int GetVivillonPattern(int country)
{
var form = Array.FindIndex(VivillonCountryTable, z => z.Contains(country));
return Math.Max(0, form);
}
/// <summary>
/// Compares the <see cref="PKM.ConsoleRegion"/> and <see cref="PKM.Country"/> to determine if the country is available within that region.
/// </summary>