mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-09-11 18:15:11 -05:00
Misc gen4 handling updates
Cross-game trading for egg locations (duh) Volt Tackle AND Fakeout pikachu from yellow forest Nidoran fullwidth handling in gen4 Thanks Britty! https://projectpokemon.org/home/forums/topic/41407-pkhex-legality-errors-on-gen-6-updated/?do=findComment&comment=220094 Replicate gen4's string setter for the bigendian variant
This commit is contained in:
@@ -627,7 +627,7 @@ private static void MarkHGSSEncounterTypeSlots(ref EncounterArea[] Areas)
|
||||
new EncounterStatic{ Species = 095, Gender = 1, Level = 05, Moves = new[]{088}, }, // Onix: Rock Throw
|
||||
new EncounterStatic{ Species = 025, Gender = 0, Level = 15, Moves = new[]{019}, }, // Pikachu: Fly
|
||||
new EncounterStatic{ Species = 025, Gender = 1, Level = 14, Moves = new[]{057}, }, // Pikachu: Surf
|
||||
new EncounterStatic{ Species = 025, Gender = 1, Level = 12, Moves = new[]{344}, }, // Pikachu: Volt Tackle
|
||||
new EncounterStatic{ Species = 025, Gender = 1, Level = 12, Moves = new[]{344, 252}, }, // Pikachu: Volt Tackle, Fake Out
|
||||
new EncounterStatic{ Species = 025, Gender = 0, Level = 13, Moves = new[]{175}, }, // Pikachu: Flail
|
||||
new EncounterStatic{ Species = 025, Gender = 0, Level = 10, }, // Pikachu
|
||||
new EncounterStatic{ Species = 025, Gender = 1, Level = 10, }, // Pikachu
|
||||
|
||||
@@ -189,7 +189,7 @@ private static CheckResult VerifyEncounterEgg3Transfer(PKM pkm)
|
||||
private static CheckResult VerifyEncounterEgg4(PKM pkm)
|
||||
{
|
||||
if (pkm.Format == 4)
|
||||
return VerifyEncounterEggLevelLoc(pkm, 0, pkm.HGSS ? Legal.ValidMet_HGSS : pkm.Pt ? Legal.ValidMet_Pt : Legal.ValidMet_DP);
|
||||
return VerifyEncounterEggLevelLoc(pkm, 0, Legal.Met_HGSS_0);
|
||||
if (pkm.IsEgg)
|
||||
return new CheckResult(Severity.Invalid, V57, CheckIdentifier.Encounter);
|
||||
// transferred
|
||||
|
||||
@@ -310,7 +310,7 @@ public static string GetBEString4(byte[] strdata, int offset, int count)
|
||||
if (chr == 0xFFFF) break;
|
||||
s += (char)chr;
|
||||
}
|
||||
return s;
|
||||
return SanitizeString(s);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -325,23 +325,18 @@ public static byte[] SetBEString4(string value, int maxLength, int padTo = 0, us
|
||||
{
|
||||
if (value.Length > maxLength)
|
||||
value = value.Substring(0, maxLength); // Hard cap
|
||||
byte[] strdata = new byte[value.Length * 2 + 2]; // +2 for 0xFFFF
|
||||
for (int i = 0; i < value.Length; i++)
|
||||
|
||||
string temp = UnSanitizeString(value, 4) // Replace Special Characters and add Terminator
|
||||
.PadRight(value.Length + 1, (char)0xFFFF) // Null Terminator
|
||||
.PadRight(padTo, (char)padWith); // Padding
|
||||
|
||||
byte[] strdata = new byte[temp.Length * 2];
|
||||
for (int i = 0; i < temp.Length; i++)
|
||||
{
|
||||
ushort chr = value[i];
|
||||
ushort chr = temp[i];
|
||||
ushort val = ConvertChar2ValueG4(chr);
|
||||
if (val == 0xFFFF || chr == 0xFFFF)
|
||||
{ Array.Resize(ref strdata, i * 2 + 2); break; }
|
||||
BigEndian.GetBytes(val).CopyTo(strdata, i * 2);
|
||||
}
|
||||
BitConverter.GetBytes((ushort)0xFFFF).CopyTo(strdata, strdata.Length - 2);
|
||||
if (padTo > strdata.Length)
|
||||
{
|
||||
int start = strdata.Length;
|
||||
Array.Resize(ref strdata, padTo);
|
||||
for (int i = start; i < padTo; i += 2)
|
||||
BitConverter.GetBytes(padWith).CopyTo(strdata, i);
|
||||
}
|
||||
return strdata;
|
||||
}
|
||||
|
||||
@@ -361,7 +356,7 @@ public static string GetString4(byte[] data, int offset, int count)
|
||||
if (chr == 0xFFFF) break;
|
||||
s.Append((char)chr);
|
||||
}
|
||||
return s.ToString();
|
||||
return SanitizeString(s.ToString());
|
||||
}
|
||||
|
||||
/// <summary>Gets the bytes for a 4th Generation String</summary>
|
||||
@@ -1937,7 +1932,7 @@ private static string UnSanitizeString(string str, int generation, int species =
|
||||
{
|
||||
var s = str.Replace("\u0027", "\u2019"); // farfetch'd
|
||||
|
||||
if (generation == 5)
|
||||
if (generation == 5 || generation == 4)
|
||||
{
|
||||
s = s.Replace("\u2640", "\u246E"); // ♀
|
||||
s = s.Replace("\u2642", "\u246D"); // ♂
|
||||
|
||||
Reference in New Issue
Block a user