From 17c682df588b32b8679e89fdbcddbd99d97f68e1 Mon Sep 17 00:00:00 2001 From: wwwwwwzx Date: Tue, 4 Apr 2017 23:11:47 -0700 Subject: [PATCH] Misc fixes (#1027) * Fix Chinese Characters mixup Some chinese characters are shared by tranditional CH and simplified CH, should be remapped as a whole. There is no chinese OT/HT. The remapping only happens at gen7 species nickname * Fix about HGSS Togepi gift egg Should upcase eggname when compare egg nickname at generation < 5 Remove unnecessary `wasegg`, it's checked before entering the function Get egg move from encounter table EncounterMatch should be as EncounterStatic type not a List. Remain only special move for in-game gift egg for order checking. Change default Static moves length to 0 Remove duplicate dratini * Avoid duplicate relearn move suggestion The move already in the move list above would be suggested again (was flagged) * Fix up some duplicate location strings Duplicate location string will affact location ID * Revert conflict parts to merge --- PKHeX/Game/GameInfo.cs | 2 ++ PKHeX/Legality/Analysis.cs | 1 + PKHeX/Legality/Checks.cs | 6 +++--- PKHeX/Legality/Tables4.cs | 5 ++--- PKHeX/PKM/PK7.cs | 4 ++-- PKHeX/PKM/PKX.cs | 16 ++++++++-------- PKHeX/Resources/text/zh/text_bw2_00000_zh.txt | 2 +- 7 files changed, 19 insertions(+), 17 deletions(-) diff --git a/PKHeX/Game/GameInfo.cs b/PKHeX/Game/GameInfo.cs index e76a1b506..ffb798fbd 100644 --- a/PKHeX/Game/GameInfo.cs +++ b/PKHeX/Game/GameInfo.cs @@ -179,6 +179,8 @@ private void Sanitize() metHGSS_02000[1] += " (NPC)"; // Anything from an NPC metHGSS_02000[2] += " (" + eggname + ")"; // Egg From Link Trade metBW2_00000[36] = metBW2_00000[84] + "/" + metBW2_00000[36]; // Cold Storage in BW = PWT in BW2 + metBW2_00000[40] += "(B/W)"; // Victory Road in BW + metBW2_00000[134] += "(B2/W2)"; // Victory Road in B2W2 // BW2 Entries from 76 to 105 are for Entralink in BW for (int i = 76; i < 106; i++) diff --git a/PKHeX/Legality/Analysis.cs b/PKHeX/Legality/Analysis.cs index 5076e12f0..4666b2772 100644 --- a/PKHeX/Legality/Analysis.cs +++ b/PKHeX/Legality/Analysis.cs @@ -306,6 +306,7 @@ public int[] getSuggestedRelearn() List window = new List(RelearnBase); window.AddRange(pkm.Moves.Where((v, i) => !vMoves[i].Valid || vMoves[i].Flag)); + window = window.Distinct().ToList(); if (window.Count < 4) window.AddRange(new int[4 - window.Count]); return window.Skip(window.Count - 4).ToArray(); diff --git a/PKHeX/Legality/Checks.cs b/PKHeX/Legality/Checks.cs index a775e6d65..ffed5d4d4 100644 --- a/PKHeX/Legality/Checks.cs +++ b/PKHeX/Legality/Checks.cs @@ -282,7 +282,7 @@ private void verifyNicknameEgg() { if (!pkm.IsNicknamed && (pkm.Format != 7)) AddLine(Severity.Invalid, V12, CheckIdentifier.Egg); - else if (PKX.SpeciesLang[pkm.Language][0] != pkm.Nickname) + else if (PKX.getSpeciesNameGeneration(0, pkm.Language, pkm.GenNumber) != pkm.Nickname) AddLine(Severity.Invalid, V13, CheckIdentifier.Egg); else AddLine(Severity.Valid, V14, CheckIdentifier.Egg); @@ -2511,11 +2511,11 @@ private CheckResult[] parseMovesWasEggPreRelearn(int[] Moves, List[] validL int splitctr = Legal.SplitBreed.Contains(pkm.Species) ? 1 : 0; foreach (var ver in Games) { - var EventEggMoves = pkm.WasEgg && !pkm.WasGiftEgg? Legal.getSpecialEggMoves(pkm, ver).ToArray() : new int[0]; + var EventEggMoves = !pkm.WasGiftEgg? Legal.getSpecialEggMoves(pkm, ver).ToArray() : new int[0]; for (int i = 0; i <= splitctr; i++) { var baseEggMoves = Legal.getBaseEggMoves(pkm, i, ver, 100)?.ToArray() ?? new int[0]; - var EggMoves = pkm.WasEgg && !pkm.WasGiftEgg ? Legal.getEggMoves(pkm, i, ver).ToArray() : new int[0]; + var EggMoves = pkm.WasGiftEgg ? (EncounterMatch as EncounterStatic)?.Moves ?? new int[0] : Legal.getEggMoves(pkm, i, ver).ToArray(); res = parseMoves(Moves, validLevelMoves, new int[0], validTMHM, validTutor, new int[0], baseEggMoves, EggMoves, EventEggMoves); diff --git a/PKHeX/Legality/Tables4.cs b/PKHeX/Legality/Tables4.cs index 8034bc9cc..f43be8608 100644 --- a/PKHeX/Legality/Tables4.cs +++ b/PKHeX/Legality/Tables4.cs @@ -490,10 +490,9 @@ public static partial class Legal new EncounterStatic { Gift = true, Species = 410, Level = 20, Location = 140, }, // Shieldon //Gift new EncounterStatic { Gift = true, Species = 133, Level = 05, Location = 131, }, // Eevee @ Goldenrod City - new EncounterStatic { Gift = true, Species = 147, Level = 15, Location = 222, Moves = new[] {245, 086, 239, 082}, }, // Dratini @ Dragon's Den (ExtremeSpeed) - new EncounterStatic { Gift = true, Species = 147, Level = 15, Location = 222, Moves = new[] {043, 086, 239, 082}, }, // Dratini @ Dragon's Den (Non-ExtremeSpeed) + new EncounterStatic { Gift = true, Species = 147, Level = 15, Location = 222, Moves = new[] {245}, }, // Dratini @ Dragon's Den (ExtremeSpeed) new EncounterStatic { Gift = true, Species = 236, Level = 10, Location = 216, }, // Tyrogue @ Mt. Mortar - new EncounterStatic { Gift = true, Species = 175, Level = 01, EggLocation = 2013, Moves = new[] {045, 204, 326},}, // Togepi Egg from Mr. Pokemon (Extrasensory as Egg move) + new EncounterStatic { Gift = true, Species = 175, Level = 01, EggLocation = 2013, Moves = new[] {326},}, // Togepi Egg from Mr. Pokemon (Extrasensory as Egg move) new EncounterStatic { Gift = true, Species = 179, Level = 01, EggLocation = 2014,}, // Mareep Egg from Primo new EncounterStatic { Gift = true, Species = 194, Level = 01, EggLocation = 2014,}, // Wooper Egg from Primo new EncounterStatic { Gift = true, Species = 218, Level = 01, EggLocation = 2014,}, // Slugma Egg from Primo diff --git a/PKHeX/PKM/PK7.cs b/PKHeX/PKM/PK7.cs index f6f9f1835..c8b93c760 100644 --- a/PKHeX/PKM/PK7.cs +++ b/PKHeX/PKM/PK7.cs @@ -217,12 +217,12 @@ public override uint PID #region Block B public override string Nickname { - get { return PKX.SanitizeString(Util.TrimFromZero(Encoding.Unicode.GetString(Data, 0x40, 24))); } + get { return PKX.bin2strG7_zh(PKX.SanitizeString(Util.TrimFromZero(Encoding.Unicode.GetString(Data, 0x40, 24)))); } set { if (value.Length > 12) value = value.Substring(0, 12); // Hard cap - string TempNick = PKX.UnSanitizeString(value) + string TempNick = PKX.str2binG7_zh(PKX.UnSanitizeString(value),Language == 10) .PadRight(value.Length + 1, '\0'); // Null Terminator Encoding.Unicode.GetBytes(TempNick).CopyTo(Data, 0x40); } diff --git a/PKHeX/PKM/PKX.cs b/PKHeX/PKM/PKX.cs index 980ae6efa..217432fe3 100644 --- a/PKHeX/PKM/PKX.cs +++ b/PKHeX/PKM/PKX.cs @@ -1051,7 +1051,6 @@ public static string SanitizeString(string str) var s = str.Replace("\u2019", "\u0027"); // farfetch'd s = s.Replace("\uE08F", "\u2640"); // ♀ s = s.Replace("\uE08E", "\u2642"); // ♂ - s = bin2strG7_zh(s); return s; } @@ -1065,7 +1064,6 @@ public static string SanitizeString(string str) public static string UnSanitizeString(string str, int species = -1, bool nicknamed = true) { var s = str.Replace("\u0027", "\u2019"); // farfetch'd - s = str2binG7_zh(s); bool foreign = true; if ((species == 029 || species == 032) && !nicknamed) @@ -1194,17 +1192,19 @@ public static int getUnownForm(uint PID) /// Converts a Unicode string to Generation 7 in-game chinese string. /// /// Unicode string. + /// Pkm language is Traditional Chinese. /// In-game chinese string. - public static string str2binG7_zh(string inputstr) + public static string str2binG7_zh(string inputstr, bool cht = false) { int index; string resultstr = ""; + bool IsCHT = inputstr.Any(chr => Gen7_CHT.Contains(chr) && !Gen7_CHS.Contains(chr)); + IsCHT |= cht && !inputstr.Any(chr => Gen7_CHT.Contains(chr) ^ Gen7_CHS.Contains(chr)); // CHS and CHT have the same display name + var table = IsCHT ? Gen7_CHT : Gen7_CHS; + ushort ofs = IsCHT ? Gen7_CHT_Ofs : Gen7_CHS_Ofs; foreach (char chr in inputstr) { - index = Array.IndexOf(Gen7_CHS, chr); - if (index > -1) - { resultstr += (char)(index + Gen7_CHS_Ofs); continue; } - index = Array.IndexOf(Gen7_CHT, chr); - resultstr += index > -1 ? (char)(index + Gen7_CHT_Ofs) : chr; + index = Array.IndexOf(table, chr); + resultstr += index > -1 ? (char)(ofs + index) : chr; } return resultstr; } diff --git a/PKHeX/Resources/text/zh/text_bw2_00000_zh.txt b/PKHeX/Resources/text/zh/text_bw2_00000_zh.txt index 7f400b2af..16bc39e0c 100644 --- a/PKHeX/Resources/text/zh/text_bw2_00000_zh.txt +++ b/PKHeX/Resources/text/zh/text_bw2_00000_zh.txt @@ -73,7 +73,7 @@ P2实验室 迷幻森林 试炼之室 引导之间 -潜入连接 +连入之森 雷文市 帆巴市 吹寄市