diff --git a/PKHeX.Core/Legality/Encounters/Templates/GO/EncounterSlot8GO.cs b/PKHeX.Core/Legality/Encounters/Templates/GO/EncounterSlot8GO.cs index 13a82f841..413b8f8a2 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/GO/EncounterSlot8GO.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/GO/EncounterSlot8GO.cs @@ -139,7 +139,7 @@ public PKM ConvertToPKM(ITrainerInfo tr, EncounterCriteria criteria) } SetPINGA(pk, criteria); EncounterUtil.SetEncounterMoves(pk, Version, LevelMin); - pk.Nickname = SpeciesName.GetSpeciesNameGeneration(Species, lang, Generation); + pk.Nickname = SpeciesName.GetSpeciesNameImportHOME(Species, lang, Generation); SetEncounterMoves(pk, LevelMin); if (pk is IScaledSize s2) diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen3/EncounterTrade3.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen3/EncounterTrade3.cs index 666b9b893..0b73b1f99 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Gen3/EncounterTrade3.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen3/EncounterTrade3.cs @@ -186,6 +186,8 @@ public bool IsNicknameMatch(PKM pk, ReadOnlySpan nickname, int language) Span tmp = stackalloc char[name.Length]; StringConverter345.TransferGlyphs34(name, language, tmp); + if (pk.Context == EntityContext.Gen5) + StringConverter345.TransferGlyphs45(tmp); // Apostrophe ' vs ’ return nickname.SequenceEqual(tmp); } diff --git a/PKHeX.Core/PKM/HOME/GameDataPK8.cs b/PKHeX.Core/PKM/HOME/GameDataPK8.cs index 6c620c660..c7b7b0b85 100644 --- a/PKHeX.Core/PKM/HOME/GameDataPK8.cs +++ b/PKHeX.Core/PKM/HOME/GameDataPK8.cs @@ -114,7 +114,7 @@ public void CopyFrom(PK7 pk, PKH pkh) pkh.MarkingValue &= 0b1111_1111_1111; if (!pk.IsNicknamed) - pkh.Nickname = SpeciesName.GetSpeciesNameGeneration(pk.Species, pk.Language, 8); + pkh.Nickname = SpeciesName.GetSpeciesNameImportHOME(pk.Species, pk.Language, 8); if (FormInfo.IsTotemForm(pk.Species, pk.Form)) pkh.Form = FormInfo.GetTotemBaseForm(pk.Species, pk.Form); } diff --git a/PKHeX.Core/PKM/Strings/StringConverter345.cs b/PKHeX.Core/PKM/Strings/StringConverter345.cs index 4761cc804..2ae05381e 100644 --- a/PKHeX.Core/PKM/Strings/StringConverter345.cs +++ b/PKHeX.Core/PKM/Strings/StringConverter345.cs @@ -100,6 +100,8 @@ public static void TransferGlyphs45(Span input) { if (IsInvalid45(input[i])) input[i] = '?'; + if (input[i] == '’') // Farfetch’d and CH’DING nicknames + input[i] = '\''; // Wrong apostrophe, nice. Only is corrected when converted to Gen6. } } @@ -120,6 +122,8 @@ public static void TransferGlyphs56(Span input) var c = ReadUInt16LittleEndian(span); if (IsPrivateUseChar(c)) WriteUInt16LittleEndian(span, GetMigratedPrivateChar(c)); + else if (c is '\'') // Fix all apostrophes. ' -> ’ + WriteUInt16LittleEndian(span, '’'); } } diff --git a/PKHeX.Core/PKM/Util/SpeciesName.cs b/PKHeX.Core/PKM/Util/SpeciesName.cs index 495b95514..a53918ff1 100644 --- a/PKHeX.Core/PKM/Util/SpeciesName.cs +++ b/PKHeX.Core/PKM/Util/SpeciesName.cs @@ -62,8 +62,8 @@ public static class SpeciesName var result = new Dictionary[names.Count]; for (int i = 0; i < result.Length; i++) { - var dict = new Dictionary(); var speciesList = names[i]; + var dict = new Dictionary(speciesList.Count - 1); for (ushort species = 1; species < speciesList.Count; species++) { var name = speciesList[species]; @@ -97,6 +97,8 @@ public static string GetSpeciesName(ushort species, int language) return arr[species]; } + private static bool IsApostropheFarfetchdLanguage(int language) => language is 2 or 4 or 7; + /// /// Gets a Pokémon's default name for the desired language ID and generation. /// @@ -107,10 +109,26 @@ public static string GetSpeciesName(ushort species, int language) public static string GetSpeciesNameGeneration(ushort species, int language, byte generation) => generation switch { <= 4 => GetSpeciesName1234(species, language, generation), + 5 when species is (int)Species.Farfetchd && IsApostropheFarfetchdLanguage(language) => "Farfetch'd", // Gen5 does not have slanted apostrophes. 7 when language == (int) LanguageID.ChineseS => GetSpeciesName7ZH(species, language), _ => GetSpeciesName(species, language), }; + /// + /// + /// Gets the initial Species name for HOME imports. + /// + public static string GetSpeciesNameImportHOME(ushort species, int language, byte generation) + { + // Default fetched names have the wrong apostrophes. + var result = GetSpeciesNameGeneration(species, language, generation); + if (species is (int)Species.Farfetchd && IsApostropheFarfetchdLanguage(language)) + return "Farfetch'd"; + if (species is (int)Species.Sirfetchd && IsApostropheFarfetchdLanguage(language)) + return "Sirfetch'd"; + return result; + } + /// /// Gets a Pokémon's egg name for the desired language ID and generation. ///