Misc languageID legality checking update

Checks for max language ID on transferred pkm (gen5 pkm on gen7 can't
have CHS/CHT etc)
handles edge case for JPN B/W ingame trades
update pk5->pk6 transfer logic to bump langID 0 to 1.
Thanks HaxAras & Britty for providing samples!
This commit is contained in:
Kurt
2017-09-15 17:43:31 -07:00
parent fa14c794c0
commit aa3393e5b2
9 changed files with 35 additions and 19 deletions

View File

@@ -181,14 +181,10 @@ private void VerifyNickname()
if (!Encounter.Valid)
return;
if (pkm.Format <= 6 && pkm.Language > 8)
int maxLanguageID = Legal.GetMaxLanguageID(Info.Generation);
if (pkm.Language == 6 || pkm.Language > maxLanguageID)
{
AddLine(Severity.Indeterminate, V4, CheckIdentifier.Language);
return;
}
if (pkm.Format <= 7 && pkm.Language > 10)
{
AddLine(Severity.Indeterminate, V5, CheckIdentifier.Language);
AddLine(Severity.Indeterminate, string.Format(V5, "<=" + maxLanguageID, pkm.Language), CheckIdentifier.Language);
return;
}
@@ -321,7 +317,11 @@ private void VerifyNicknameTrade()
return;
}
else if (3 <= Info.Generation && Info.Generation <= 5)
{
{
// Trades for JPN games have language ID of 0, not 1.
if (pkm.BW && pkm.Format == 5 && pkm.Language == 1)
AddLine(Severity.Invalid, string.Format(V5, 0, 1), CheckIdentifier.Language);
// Suppressing temporarily
return;
}

View File

@@ -1101,6 +1101,23 @@ internal static IEnumerable<int> GetFutureGenEvolutions(int generation)
}
}
internal static int GetMaxLanguageID(int generation)
{
switch (generation)
{
case 1:
case 2:
case 7:
return 10; // VC -> Gen7
case 3:
return 7; // 1-7 except 6
case 4:
case 5:
case 6:
return 8;
}
return -1;
}
private static bool[] GetReleasedHeldItems(int generation)
{
switch (generation)

View File

@@ -883,7 +883,9 @@ private static IEnumerable<EncounterTrade> GetValidEncounterTrades(PKM pkm, Game
}
int lang = pkm.Language;
if (lang == 0 || lang == 6)
if (lang == 6) // invalid language
yield break;
if (lang == 0 && (pkm.Format != 5 || !pkm.BW)) // Japanese trades in BW have no language ID
yield break;
int lvl = GetMinLevelEncounter(pkm);

View File

@@ -108,9 +108,8 @@ public static class LegalityCheckStrings
public static string V11 {get; set;} = "Ingame Trade OT and Nickname have not been altered."; // Valid
public static string V1 {get; set;} = "Nickname too long."; // Invalid
public static string V2 {get; set;} = "Nickname is empty."; // Invalid
public static string V4 {get; set;} = "Language ID > 8."; // Invalid
public static string V5 {get; set;} = "Language ID > 10."; // Invalid
public static string V222 { get; set; } = "Cannot be given this Nickname."; // Invalid
public static string V5 {get; set;} = "Language ID should be {0}, not {1}."; // Invalid
public static string V222 {get; set;} = "Cannot be given this Nickname."; // Invalid
public static string V3 {get; set;} = "Species index invalid for Nickname comparison."; // Invalid
public static string V20 {get; set;} = "Nickname does not match species name."; // Invalid
public static string V13 {get; set;} = "Egg name does not match language Egg name."; // Invalid

View File

@@ -310,7 +310,7 @@ public PK6 ConvertToPK6()
else pk6.AbilityNumber = Gen5 ? 1 << (int)(PID >> 16 & 1) : 1 << (int)(PID & 1);
}
pk6.Markings = Markings;
pk6.Language = Language;
pk6.Language = Math.Max(1, Language); // Hacked or Bad IngameTrade (Japanese B/W)
pk6.CNT_Cool = CNT_Cool;
pk6.CNT_Beauty = CNT_Beauty;

View File

@@ -292,6 +292,7 @@ private byte[] Write()
public bool FRLG => Version == (int)GameVersion.FR || Version == (int)GameVersion.LG;
public bool Pt => (int)GameVersion.Pt == Version;
public bool HGSS => Version == (int)GameVersion.HG || Version == (int)GameVersion.SS;
public bool BW => Version == (int)GameVersion.B || Version == (int)GameVersion.W;
public bool B2W2 => Version == (int)GameVersion.B2 || Version == (int)GameVersion.W2;
public bool XY => Version == (int)GameVersion.X || Version == (int)GameVersion.Y;
public bool AO => Version == (int)GameVersion.AS || Version == (int)GameVersion.OR;

View File

@@ -69,8 +69,7 @@ V19 = Nickname matches demo language name.
V11 = Ingame Trade OT and Nickname have not been altered.
V1 = Nickname too long.
V2 = Nickname is empty.
V4 = Language ID > 8.
V5 = Language ID > 10.
V5 = Language ID should be {0}, not {1}.
V222 = Cannot be given this Nickname.
V3 = Species index invalid for Nickname comparison.
V20 = Nickname does not match species name.

View File

@@ -69,8 +69,7 @@ V19 = 이름이 언어별 데모 이름과 일치합니다.
V11 = 게임 내 교환의 어버이와 이름이 달라졌습니다.
V1 = 이름이 너무 깁니다.
V2 = 이름이 비어 있습니다.
V4 = 언어 ID가 8을 초과합니다.
V5 = 언어 ID가 10을 초과합니다.
V5 = 언어 ID should be {0}, not {1}.
V222 = 이 이름은 사용할 수 없습니다.
V3 = 이름 비교에 사용할 포켓몬 종류 인덱스가 잘못되었습니다.
V20 = 이름이 포켓몬 종류와 일치하지 않습니다.

View File

@@ -69,8 +69,7 @@ V19 = 昵称与体验版语言一致。
V11 = 游戏内连接交换的初训家和昵称未被修改。
V1 = 昵称太长。
V2 = 昵称为空。
V4 = 语言ID > 8
V5 = 语言ID > 10。
V5 = 语言ID should be {0}, not {1}
V222 = 无法给宝可梦取中文昵称。
V3 = 宝可梦种类无法用于昵称对比
V20 = 昵称与种类名不一致。