mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-26 05:50:22 +00:00
Set default version ID for gen3 pkm templates
ur welcome matt
This commit is contained in:
parent
d7473db6af
commit
96aed1e3c5
2 changed files with 24 additions and 6 deletions
|
@ -18,9 +18,7 @@ public static class EntityTemplates
|
|||
if (pk.Format >= 4)
|
||||
pk.MetDate = EncounterDate.GetDate(pk.Context.GetConsole());
|
||||
|
||||
if (tr.Game >= 0)
|
||||
pk.Version = tr.Game;
|
||||
|
||||
pk.Version = GetTemplateVersion(tr);
|
||||
pk.Species = GetTemplateSpecies(pk, tr);
|
||||
pk.Language = GetTemplateLanguage(tr);
|
||||
pk.Gender = pk.GetSaneGender();
|
||||
|
@ -41,6 +39,25 @@ public static class EntityTemplates
|
|||
pk.RefreshChecksum();
|
||||
}
|
||||
|
||||
private static int GetTemplateVersion(ITrainerInfo tr)
|
||||
{
|
||||
GameVersion version = (GameVersion)tr.Game;
|
||||
if (version.IsValidSavedVersion())
|
||||
return (int)version;
|
||||
|
||||
if (tr is IVersion v)
|
||||
{
|
||||
version = v.Version;
|
||||
if (version.IsValidSavedVersion())
|
||||
return (int)version;
|
||||
version = v.GetSingleVersion();
|
||||
if (version.IsValidSavedVersion())
|
||||
return (int)version;
|
||||
}
|
||||
|
||||
return default; // 0
|
||||
}
|
||||
|
||||
private static void ApplyTrashBytes(PKM pk, ITrainerInfo tr)
|
||||
{
|
||||
// Copy OT trash bytes for sensitive games (Gen1/2)
|
||||
|
|
|
@ -22,11 +22,12 @@ public static partial class Extensions
|
|||
return ver.GetSingleVersion();
|
||||
}
|
||||
|
||||
private static GameVersion GetSingleVersion(this IVersion ver)
|
||||
public static GameVersion GetSingleVersion(this IVersion ver)
|
||||
{
|
||||
const int max = (int)GameUtil.HighestGameID;
|
||||
if ((int)ver.Version <= max)
|
||||
return ver.Version;
|
||||
var v = ver.Version;
|
||||
if (v.IsValidSavedVersion())
|
||||
return v;
|
||||
var rnd = Util.Rand;
|
||||
while (true) // this isn't optimal, but is low maintenance
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue