2018-06-24 05:00:01 +00:00
|
|
|
|
using System;
|
2020-01-19 03:11:29 +00:00
|
|
|
|
using System.Collections.Generic;
|
2021-10-06 05:46:21 +00:00
|
|
|
|
using System.Linq;
|
2018-06-24 05:00:01 +00:00
|
|
|
|
using static PKHeX.Core.LegalityCheckStrings;
|
PKHeX.Core Nullable cleanup (#2401)
* Handle some nullable cases
Refactor MysteryGift into a second abstract class (backed by a byte array, or fake data)
Make some classes have explicit constructors instead of { } initialization
* Handle bits more obviously without null
* Make SaveFile.BAK explicitly readonly again
* merge constructor methods to have readonly fields
* Inline some properties
* More nullable handling
* Rearrange box actions
define straightforward classes to not have any null properties
* Make extrabyte reference array immutable
* Move tooltip creation to designer
* Rearrange some logic to reduce nesting
* Cache generated fonts
* Split mystery gift album purpose
* Handle more tooltips
* Disallow null setters
* Don't capture RNG object, only type enum
* Unify learnset objects
Now have readonly properties which are never null
don't new() empty learnsets (>800 Learnset objects no longer created,
total of 2400 objects since we also new() a move & level array)
optimize g1/2 reader for early abort case
* Access rewrite
Initialize blocks in a separate object, and get via that object
removes a couple hundred "might be null" warnings since blocks are now readonly getters
some block references have been relocated, but interfaces should expose all that's needed
put HoF6 controls in a groupbox, and disable
* Readonly personal data
* IVs non nullable for mystery gift
* Explicitly initialize forced encounter moves
* Make shadow objects readonly & non-null
Put murkrow fix in binary data resource, instead of on startup
* Assign dex form fetch on constructor
Fixes legality parsing edge cases
also handle cxd parse for valid; exit before exception is thrown in FrameGenerator
* Remove unnecessary null checks
* Keep empty value until init
SetPouch sets the value to an actual one during load, but whatever
* Readonly team lock data
* Readonly locks
Put locked encounters at bottom (favor unlocked)
* Mail readonly data / offset
Rearrange some call flow and pass defaults
Add fake classes for SaveDataEditor mocking
Always party size, no need to check twice in stat editor
use a fake save file as initial data for savedata editor, and for
gamedata (wow i found a usage)
constrain eventwork editor to struct variable types (uint, int, etc),
thus preventing null assignment errors
2019-10-17 01:47:31 +00:00
|
|
|
|
using static PKHeX.Core.LanguageID;
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
|
|
|
|
namespace PKHeX.Core
|
|
|
|
|
{
|
2018-07-02 02:17:37 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Verifies the <see cref="PKM.Nickname"/>.
|
|
|
|
|
/// </summary>
|
2018-06-24 05:00:01 +00:00
|
|
|
|
public sealed class NicknameVerifier : Verifier
|
|
|
|
|
{
|
|
|
|
|
protected override CheckIdentifier Identifier => CheckIdentifier.Nickname;
|
|
|
|
|
|
|
|
|
|
public override void Verify(LegalityAnalysis data)
|
|
|
|
|
{
|
|
|
|
|
var pkm = data.pkm;
|
|
|
|
|
|
|
|
|
|
// If the Pokémon is not nicknamed, it should match one of the language strings.
|
2021-01-31 20:37:03 +00:00
|
|
|
|
var nickname = pkm.Nickname;
|
|
|
|
|
if (nickname.Length == 0)
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetInvalid(LNickLengthShort));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2019-09-19 02:58:23 +00:00
|
|
|
|
if (pkm.Species > SpeciesName.SpeciesLang[0].Count)
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(Get(LNickLengthShort, Severity.Indeterminate));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-11 02:15:33 +00:00
|
|
|
|
var enc = data.EncounterOriginal;
|
2021-02-02 02:35:37 +00:00
|
|
|
|
if (enc is ILangNicknamedTemplate n)
|
|
|
|
|
{
|
|
|
|
|
VerifyFixedNicknameEncounter(data, n, enc, pkm, nickname);
|
2021-11-20 02:23:49 +00:00
|
|
|
|
if (pkm.IsEgg)
|
|
|
|
|
VerifyNicknameEgg(data);
|
2021-02-02 02:35:37 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-08 21:01:36 +00:00
|
|
|
|
if (pkm.Format <= 7 && pkm.IsNicknamed) // can nickname afterwards
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
2020-10-08 21:01:36 +00:00
|
|
|
|
if (pkm.VC)
|
2021-06-30 03:58:06 +00:00
|
|
|
|
VerifyG1NicknameWithinBounds(data, nickname.AsSpan());
|
2021-01-11 02:15:33 +00:00
|
|
|
|
else if (enc is MysteryGift {IsEgg: false})
|
2020-10-08 21:01:36 +00:00
|
|
|
|
data.AddLine(Get(LEncGiftNicknamed, ParseSettings.NicknamedMysteryGift));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-01-11 02:15:33 +00:00
|
|
|
|
if (enc is EncounterTrade t)
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
2018-10-27 20:37:03 +00:00
|
|
|
|
VerifyNicknameTrade(data, t);
|
2021-01-02 09:02:59 +00:00
|
|
|
|
if (t.HasNickname)
|
|
|
|
|
return;
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pkm.IsEgg)
|
|
|
|
|
{
|
|
|
|
|
VerifyNicknameEgg(data);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (VerifyUnNicknamedEncounter(data, pkm, nickname))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// Non-nicknamed strings have already been checked.
|
2018-10-09 00:57:34 +00:00
|
|
|
|
if (ParseSettings.CheckWordFilter && pkm.IsNicknamed)
|
|
|
|
|
{
|
|
|
|
|
if (WordFilter.IsFiltered(nickname, out string bad))
|
PKHeX.Core Nullable cleanup (#2401)
* Handle some nullable cases
Refactor MysteryGift into a second abstract class (backed by a byte array, or fake data)
Make some classes have explicit constructors instead of { } initialization
* Handle bits more obviously without null
* Make SaveFile.BAK explicitly readonly again
* merge constructor methods to have readonly fields
* Inline some properties
* More nullable handling
* Rearrange box actions
define straightforward classes to not have any null properties
* Make extrabyte reference array immutable
* Move tooltip creation to designer
* Rearrange some logic to reduce nesting
* Cache generated fonts
* Split mystery gift album purpose
* Handle more tooltips
* Disallow null setters
* Don't capture RNG object, only type enum
* Unify learnset objects
Now have readonly properties which are never null
don't new() empty learnsets (>800 Learnset objects no longer created,
total of 2400 objects since we also new() a move & level array)
optimize g1/2 reader for early abort case
* Access rewrite
Initialize blocks in a separate object, and get via that object
removes a couple hundred "might be null" warnings since blocks are now readonly getters
some block references have been relocated, but interfaces should expose all that's needed
put HoF6 controls in a groupbox, and disable
* Readonly personal data
* IVs non nullable for mystery gift
* Explicitly initialize forced encounter moves
* Make shadow objects readonly & non-null
Put murkrow fix in binary data resource, instead of on startup
* Assign dex form fetch on constructor
Fixes legality parsing edge cases
also handle cxd parse for valid; exit before exception is thrown in FrameGenerator
* Remove unnecessary null checks
* Keep empty value until init
SetPouch sets the value to an actual one during load, but whatever
* Readonly team lock data
* Readonly locks
Put locked encounters at bottom (favor unlocked)
* Mail readonly data / offset
Rearrange some call flow and pass defaults
Add fake classes for SaveDataEditor mocking
Always party size, no need to check twice in stat editor
use a fake save file as initial data for savedata editor, and for
gamedata (wow i found a usage)
constrain eventwork editor to struct variable types (uint, int, etc),
thus preventing null assignment errors
2019-10-17 01:47:31 +00:00
|
|
|
|
data.AddLine(GetInvalid($"Word Filter: {bad}"));
|
2018-10-09 00:57:34 +00:00
|
|
|
|
if (TrainerNameVerifier.ContainsTooManyNumbers(nickname, data.Info.Generation))
|
PKHeX.Core Nullable cleanup (#2401)
* Handle some nullable cases
Refactor MysteryGift into a second abstract class (backed by a byte array, or fake data)
Make some classes have explicit constructors instead of { } initialization
* Handle bits more obviously without null
* Make SaveFile.BAK explicitly readonly again
* merge constructor methods to have readonly fields
* Inline some properties
* More nullable handling
* Rearrange box actions
define straightforward classes to not have any null properties
* Make extrabyte reference array immutable
* Move tooltip creation to designer
* Rearrange some logic to reduce nesting
* Cache generated fonts
* Split mystery gift album purpose
* Handle more tooltips
* Disallow null setters
* Don't capture RNG object, only type enum
* Unify learnset objects
Now have readonly properties which are never null
don't new() empty learnsets (>800 Learnset objects no longer created,
total of 2400 objects since we also new() a move & level array)
optimize g1/2 reader for early abort case
* Access rewrite
Initialize blocks in a separate object, and get via that object
removes a couple hundred "might be null" warnings since blocks are now readonly getters
some block references have been relocated, but interfaces should expose all that's needed
put HoF6 controls in a groupbox, and disable
* Readonly personal data
* IVs non nullable for mystery gift
* Explicitly initialize forced encounter moves
* Make shadow objects readonly & non-null
Put murkrow fix in binary data resource, instead of on startup
* Assign dex form fetch on constructor
Fixes legality parsing edge cases
also handle cxd parse for valid; exit before exception is thrown in FrameGenerator
* Remove unnecessary null checks
* Keep empty value until init
SetPouch sets the value to an actual one during load, but whatever
* Readonly team lock data
* Readonly locks
Put locked encounters at bottom (favor unlocked)
* Mail readonly data / offset
Rearrange some call flow and pass defaults
Add fake classes for SaveDataEditor mocking
Always party size, no need to check twice in stat editor
use a fake save file as initial data for savedata editor, and for
gamedata (wow i found a usage)
constrain eventwork editor to struct variable types (uint, int, etc),
thus preventing null assignment errors
2019-10-17 01:47:31 +00:00
|
|
|
|
data.AddLine(GetInvalid("Word Filter: Too many numbers."));
|
2018-10-09 00:57:34 +00:00
|
|
|
|
}
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-02-02 02:35:37 +00:00
|
|
|
|
private void VerifyFixedNicknameEncounter(LegalityAnalysis data, ILangNicknamedTemplate n, IEncounterTemplate enc, PKM pkm, string nickname)
|
|
|
|
|
{
|
|
|
|
|
var nick = n.GetNickname(pkm.Language);
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(nick))
|
|
|
|
|
{
|
2021-02-03 03:14:38 +00:00
|
|
|
|
if (n is WC8 {IsHOMEGift: true})
|
|
|
|
|
{
|
|
|
|
|
VerifyHomeGiftNickname(data, enc, pkm, nickname);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-03 06:12:36 +00:00
|
|
|
|
if (n.CanHandleOT(pkm.Language))
|
|
|
|
|
return;
|
|
|
|
|
|
2021-10-06 05:46:21 +00:00
|
|
|
|
if (n is WC3 && pkm.Format != 3)
|
|
|
|
|
{
|
|
|
|
|
// Gen3 gifts transferred to Generation 4 from another language can set the nickname flag.
|
|
|
|
|
var evos = data.Info.EvoChainsAllGens[3];
|
|
|
|
|
bool matchAny = evos.Any(evo => !SpeciesName.IsNicknamedAnyLanguage(evo.Species, nickname, 3));
|
|
|
|
|
if (matchAny)
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-02 02:35:37 +00:00
|
|
|
|
if (pkm.IsNicknamed)
|
|
|
|
|
data.AddLine(Get(LEncGiftNicknamed, Severity.Invalid));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!pkm.IsNicknamed)
|
|
|
|
|
{
|
|
|
|
|
// Check if it had a nickname at all
|
|
|
|
|
var orig = SpeciesName.GetSpeciesNameGeneration(enc.Species, pkm.Language, enc.Generation);
|
|
|
|
|
if (orig == nick)
|
|
|
|
|
{
|
|
|
|
|
// Didn't have a nickname. Ensure that the language matches the current nickname string.
|
|
|
|
|
if (!SpeciesName.IsNicknamed(pkm.Species, nickname, pkm.Language, pkm.Format))
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Should have a nickname present.
|
|
|
|
|
data.AddLine(GetInvalid(LNickMatchLanguageFail));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Encounter has a nickname, and PKM should have it.
|
|
|
|
|
var severity = nick != nickname || !pkm.IsNicknamed ? Severity.Invalid : Severity.Valid;
|
|
|
|
|
data.AddLine(Get(LEncGiftNicknamed, severity));
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-03 03:14:38 +00:00
|
|
|
|
private void VerifyHomeGiftNickname(LegalityAnalysis data, IEncounterTemplate enc, ILangNick pkm, string nickname)
|
|
|
|
|
{
|
|
|
|
|
// can nickname on redemption
|
|
|
|
|
if (!pkm.IsNicknamed)
|
|
|
|
|
return;
|
2021-02-03 03:21:17 +00:00
|
|
|
|
|
|
|
|
|
// Can't nickname everything.
|
|
|
|
|
if (enc.Species == (int) Species.Melmetal)
|
|
|
|
|
{
|
|
|
|
|
data.AddLine(GetInvalid(LEncGiftNicknamed));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Ensure the nickname does not match species name
|
2021-02-03 03:14:38 +00:00
|
|
|
|
var orig = SpeciesName.GetSpeciesNameGeneration(enc.Species, pkm.Language, enc.Generation);
|
|
|
|
|
if (nickname == orig)
|
|
|
|
|
data.AddLine(GetInvalid(LNickMatchLanguageFlag));
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-24 05:00:01 +00:00
|
|
|
|
private bool VerifyUnNicknamedEncounter(LegalityAnalysis data, PKM pkm, string nickname)
|
|
|
|
|
{
|
|
|
|
|
if (pkm.IsNicknamed)
|
|
|
|
|
{
|
2021-01-31 20:37:03 +00:00
|
|
|
|
if (data.Info.Generation >= 8)
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
2021-01-31 20:37:03 +00:00
|
|
|
|
// Can only nickname if it matches your language.
|
|
|
|
|
// Setting the nickname to the same as the species name does not set the Nickname flag (equals unmodified, no flag)
|
2021-02-01 04:12:46 +00:00
|
|
|
|
if (!SpeciesName.IsNicknamed(pkm.Species, nickname, pkm.Language, pkm.Format))
|
2021-01-31 20:37:03 +00:00
|
|
|
|
{
|
|
|
|
|
data.AddLine(Get(LNickMatchLanguageFlag, Severity.Invalid));
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (int i = 0; i < SpeciesName.SpeciesDict.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
if (!SpeciesName.SpeciesDict[i].TryGetValue(nickname, out int species))
|
2018-06-24 05:00:01 +00:00
|
|
|
|
continue;
|
2021-01-31 20:37:03 +00:00
|
|
|
|
var msg = species == pkm.Species && i != pkm.Language ? LNickMatchNoOthersFail : LNickMatchLanguageFlag;
|
|
|
|
|
data.AddLine(Get(msg, ParseSettings.NicknamedAnotherSpecies));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
2020-12-29 08:37:59 +00:00
|
|
|
|
if (pkm.Format <= 7 && StringConverter.HasEastAsianScriptCharacters(nickname) && pkm is not PB7) // East Asian Scripts
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetInvalid(LNickInvalidChar));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
2018-10-27 23:06:06 +00:00
|
|
|
|
if (nickname.Length > Legal.GetMaxLengthNickname(data.Info.Generation, (LanguageID)pkm.Language))
|
2018-08-15 03:13:15 +00:00
|
|
|
|
{
|
2019-11-16 01:34:18 +00:00
|
|
|
|
var severe = pkm.Format >= 8 || (data.EncounterOriginal.EggEncounter && pkm.WasTradedEgg && nickname.Length <= Legal.GetMaxLengthNickname(data.Info.Generation, English))
|
2018-11-18 02:29:05 +00:00
|
|
|
|
? Severity.Fishy
|
|
|
|
|
: Severity.Invalid;
|
|
|
|
|
data.AddLine(Get(LNickLengthLong, severe));
|
2018-08-15 03:13:15 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetValid(LNickMatchNoOthers));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
|
|
|
|
else if (pkm.Format < 3)
|
|
|
|
|
{
|
|
|
|
|
// pk1/pk2 IsNicknamed getter checks for match, logic should only reach here if matches.
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetValid(LNickMatchLanguage));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2021-01-11 02:15:33 +00:00
|
|
|
|
var enc = data.EncounterOriginal;
|
|
|
|
|
bool valid = IsNicknameValid(pkm, enc, nickname);
|
2018-09-01 21:11:12 +00:00
|
|
|
|
var result = valid ? GetValid(LNickMatchLanguage) : GetInvalid(LNickMatchLanguageFail);
|
2018-08-31 01:09:52 +00:00
|
|
|
|
data.AddLine(result);
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
2021-07-14 00:33:23 +00:00
|
|
|
|
private static bool IsNicknameValid(PKM pkm, IEncounterTemplate enc, string nickname)
|
2018-08-31 01:09:52 +00:00
|
|
|
|
{
|
2020-10-08 21:01:36 +00:00
|
|
|
|
int species = pkm.Species;
|
|
|
|
|
int format = pkm.Format;
|
|
|
|
|
int language = pkm.Language;
|
|
|
|
|
if (SpeciesName.GetSpeciesNameGeneration(species, language, format) == nickname)
|
2018-08-31 01:09:52 +00:00
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
// Can't have another language name if it hasn't evolved or wasn't a language-traded egg.
|
2020-10-08 21:01:36 +00:00
|
|
|
|
// Starting in Generation 8, hatched language-traded eggs will take the Language from the trainer that hatched it.
|
2020-10-08 21:14:59 +00:00
|
|
|
|
// Also in Generation 8, evolving in a foreign language game will retain the original language as the source for the newly evolved species name.
|
2020-10-08 21:01:36 +00:00
|
|
|
|
// Transferring from Gen7->Gen8 realigns the Nickname string to the Language, if not nicknamed.
|
2021-01-31 20:37:03 +00:00
|
|
|
|
bool canHaveAnyLanguage = format <= 7 && (enc.Species != species || pkm.WasTradedEgg) && !pkm.GG;
|
2020-10-08 21:01:36 +00:00
|
|
|
|
if (canHaveAnyLanguage && !SpeciesName.IsNicknamedAnyLanguage(species, nickname, format))
|
2018-08-31 01:09:52 +00:00
|
|
|
|
return true;
|
|
|
|
|
|
2021-01-11 02:15:33 +00:00
|
|
|
|
switch (enc)
|
2018-08-31 01:09:52 +00:00
|
|
|
|
{
|
|
|
|
|
case WC7 wc7 when wc7.IsAshGreninjaWC7(pkm):
|
|
|
|
|
return true;
|
|
|
|
|
case ILangNick loc:
|
2020-10-08 21:01:36 +00:00
|
|
|
|
if (loc.Language != 0 && !loc.IsNicknamed && !SpeciesName.IsNicknamedAnyLanguage(species, nickname, format))
|
2018-08-31 01:09:52 +00:00
|
|
|
|
return true; // fixed language without nickname, nice job event maker!
|
|
|
|
|
break;
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
2018-08-31 01:09:52 +00:00
|
|
|
|
|
2020-12-30 21:08:15 +00:00
|
|
|
|
if (format == 5 && !pkm.IsNative) // transfer
|
2018-08-31 01:09:52 +00:00
|
|
|
|
{
|
2019-07-12 05:55:41 +00:00
|
|
|
|
if (canHaveAnyLanguage)
|
2020-10-08 21:01:36 +00:00
|
|
|
|
return !SpeciesName.IsNicknamedAnyLanguage(species, nickname, 4);
|
|
|
|
|
return SpeciesName.GetSpeciesNameGeneration(species, language, 4) == nickname;
|
2018-08-31 01:09:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-06-24 05:00:01 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-03 19:04:19 +00:00
|
|
|
|
private static void VerifyNicknameEgg(LegalityAnalysis data)
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
|
|
|
|
var Info = data.Info;
|
|
|
|
|
var pkm = data.pkm;
|
2021-11-28 22:32:41 +00:00
|
|
|
|
|
|
|
|
|
bool flagState = EggStateLegality.IsNicknameFlagSet(Info.EncounterMatch, pkm);
|
|
|
|
|
if (pkm.IsNicknamed != flagState)
|
2021-11-28 22:34:28 +00:00
|
|
|
|
data.AddLine(GetInvalid(flagState ? LNickFlagEggYes : LNickFlagEggNo, CheckIdentifier.Egg));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
2020-12-30 21:08:15 +00:00
|
|
|
|
var nick = pkm.Nickname;
|
2021-11-28 22:32:41 +00:00
|
|
|
|
if (pkm.Format == 2 && !SpeciesName.IsNicknamedAnyLanguage(0, nick, 2))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetValid(LNickMatchLanguageEgg, CheckIdentifier.Egg));
|
2020-12-30 21:08:15 +00:00
|
|
|
|
else if (nick != SpeciesName.GetSpeciesNameGeneration(0, pkm.Language, Info.Generation))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetInvalid(LNickMatchLanguageEggFail, CheckIdentifier.Egg));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
else
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetValid(LNickMatchLanguageEgg, CheckIdentifier.Egg));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2021-08-20 20:42:25 +00:00
|
|
|
|
private static void VerifyNicknameTrade(LegalityAnalysis data, EncounterTrade t)
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
|
|
|
|
switch (data.Info.Generation)
|
|
|
|
|
{
|
2021-12-12 06:23:05 +00:00
|
|
|
|
case 8 when t is EncounterTrade8b b: VerifyTrade8b(data, b); return;
|
2021-11-30 23:16:04 +00:00
|
|
|
|
|
2020-11-23 00:19:03 +00:00
|
|
|
|
case 1: VerifyTrade12(data, t); return;
|
|
|
|
|
case 2: return; // already checked all relevant properties when fetching with getValidEncounterTradeVC2
|
2018-10-27 20:37:03 +00:00
|
|
|
|
case 3: VerifyTrade3(data, t); return;
|
|
|
|
|
case 4: VerifyTrade4(data, t); return;
|
|
|
|
|
case 5: VerifyTrade5(data, t); return;
|
|
|
|
|
case 6:
|
2019-09-23 23:56:47 +00:00
|
|
|
|
case 7:
|
|
|
|
|
case 8:
|
|
|
|
|
VerifyTrade(data, t, data.pkm.Language); return;
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-30 03:58:06 +00:00
|
|
|
|
private void VerifyG1NicknameWithinBounds(LegalityAnalysis data, ReadOnlySpan<char> str)
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
|
|
|
|
var pkm = data.pkm;
|
2019-03-21 04:50:44 +00:00
|
|
|
|
if (StringConverter12.GetIsG1English(str))
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
|
|
|
|
if (str.Length > 10)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetInvalid(LNickLengthLong));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
2019-03-21 04:50:44 +00:00
|
|
|
|
else if (StringConverter12.GetIsG1Japanese(str))
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
|
|
|
|
if (str.Length > 5)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetInvalid(LNickLengthLong));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
2019-03-21 04:50:44 +00:00
|
|
|
|
else if (pkm.Korean && StringConverter2KOR.GetIsG2Korean(str))
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
|
|
|
|
if (str.Length > 5)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetInvalid(LNickLengthLong));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetInvalid(LG1CharNick));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
PKHeX.Core Nullable cleanup (#2401)
* Handle some nullable cases
Refactor MysteryGift into a second abstract class (backed by a byte array, or fake data)
Make some classes have explicit constructors instead of { } initialization
* Handle bits more obviously without null
* Make SaveFile.BAK explicitly readonly again
* merge constructor methods to have readonly fields
* Inline some properties
* More nullable handling
* Rearrange box actions
define straightforward classes to not have any null properties
* Make extrabyte reference array immutable
* Move tooltip creation to designer
* Rearrange some logic to reduce nesting
* Cache generated fonts
* Split mystery gift album purpose
* Handle more tooltips
* Disallow null setters
* Don't capture RNG object, only type enum
* Unify learnset objects
Now have readonly properties which are never null
don't new() empty learnsets (>800 Learnset objects no longer created,
total of 2400 objects since we also new() a move & level array)
optimize g1/2 reader for early abort case
* Access rewrite
Initialize blocks in a separate object, and get via that object
removes a couple hundred "might be null" warnings since blocks are now readonly getters
some block references have been relocated, but interfaces should expose all that's needed
put HoF6 controls in a groupbox, and disable
* Readonly personal data
* IVs non nullable for mystery gift
* Explicitly initialize forced encounter moves
* Make shadow objects readonly & non-null
Put murkrow fix in binary data resource, instead of on startup
* Assign dex form fetch on constructor
Fixes legality parsing edge cases
also handle cxd parse for valid; exit before exception is thrown in FrameGenerator
* Remove unnecessary null checks
* Keep empty value until init
SetPouch sets the value to an actual one during load, but whatever
* Readonly team lock data
* Readonly locks
Put locked encounters at bottom (favor unlocked)
* Mail readonly data / offset
Rearrange some call flow and pass defaults
Add fake classes for SaveDataEditor mocking
Always party size, no need to check twice in stat editor
use a fake save file as initial data for savedata editor, and for
gamedata (wow i found a usage)
constrain eventwork editor to struct variable types (uint, int, etc),
thus preventing null assignment errors
2019-10-17 01:47:31 +00:00
|
|
|
|
private static void VerifyTrade12(LegalityAnalysis data, EncounterTrade t)
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
2020-11-23 00:19:03 +00:00
|
|
|
|
var t1 = (EncounterTrade1)t;
|
|
|
|
|
if (!t1.IsNicknameValid(data.pkm))
|
|
|
|
|
data.AddLine(GetInvalid(LEncTradeChangedNickname, CheckIdentifier.Nickname));
|
|
|
|
|
if (!t1.IsTrainerNameValid(data.pkm))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetInvalid(LEncTradeChangedOT, CheckIdentifier.Trainer));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
PKHeX.Core Nullable cleanup (#2401)
* Handle some nullable cases
Refactor MysteryGift into a second abstract class (backed by a byte array, or fake data)
Make some classes have explicit constructors instead of { } initialization
* Handle bits more obviously without null
* Make SaveFile.BAK explicitly readonly again
* merge constructor methods to have readonly fields
* Inline some properties
* More nullable handling
* Rearrange box actions
define straightforward classes to not have any null properties
* Make extrabyte reference array immutable
* Move tooltip creation to designer
* Rearrange some logic to reduce nesting
* Cache generated fonts
* Split mystery gift album purpose
* Handle more tooltips
* Disallow null setters
* Don't capture RNG object, only type enum
* Unify learnset objects
Now have readonly properties which are never null
don't new() empty learnsets (>800 Learnset objects no longer created,
total of 2400 objects since we also new() a move & level array)
optimize g1/2 reader for early abort case
* Access rewrite
Initialize blocks in a separate object, and get via that object
removes a couple hundred "might be null" warnings since blocks are now readonly getters
some block references have been relocated, but interfaces should expose all that's needed
put HoF6 controls in a groupbox, and disable
* Readonly personal data
* IVs non nullable for mystery gift
* Explicitly initialize forced encounter moves
* Make shadow objects readonly & non-null
Put murkrow fix in binary data resource, instead of on startup
* Assign dex form fetch on constructor
Fixes legality parsing edge cases
also handle cxd parse for valid; exit before exception is thrown in FrameGenerator
* Remove unnecessary null checks
* Keep empty value until init
SetPouch sets the value to an actual one during load, but whatever
* Readonly team lock data
* Readonly locks
Put locked encounters at bottom (favor unlocked)
* Mail readonly data / offset
Rearrange some call flow and pass defaults
Add fake classes for SaveDataEditor mocking
Always party size, no need to check twice in stat editor
use a fake save file as initial data for savedata editor, and for
gamedata (wow i found a usage)
constrain eventwork editor to struct variable types (uint, int, etc),
thus preventing null assignment errors
2019-10-17 01:47:31 +00:00
|
|
|
|
private static void VerifyTrade3(LegalityAnalysis data, EncounterTrade t)
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
|
|
|
|
var pkm = data.pkm;
|
2018-10-27 20:37:03 +00:00
|
|
|
|
int lang = pkm.Language;
|
2019-12-09 01:39:19 +00:00
|
|
|
|
if (t.Species == (int)Species.Jynx) // FRLG Jynx
|
2018-10-27 20:37:03 +00:00
|
|
|
|
lang = DetectTradeLanguageG3DANTAEJynx(pkm, lang);
|
|
|
|
|
VerifyTrade(data, t, lang);
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
PKHeX.Core Nullable cleanup (#2401)
* Handle some nullable cases
Refactor MysteryGift into a second abstract class (backed by a byte array, or fake data)
Make some classes have explicit constructors instead of { } initialization
* Handle bits more obviously without null
* Make SaveFile.BAK explicitly readonly again
* merge constructor methods to have readonly fields
* Inline some properties
* More nullable handling
* Rearrange box actions
define straightforward classes to not have any null properties
* Make extrabyte reference array immutable
* Move tooltip creation to designer
* Rearrange some logic to reduce nesting
* Cache generated fonts
* Split mystery gift album purpose
* Handle more tooltips
* Disallow null setters
* Don't capture RNG object, only type enum
* Unify learnset objects
Now have readonly properties which are never null
don't new() empty learnsets (>800 Learnset objects no longer created,
total of 2400 objects since we also new() a move & level array)
optimize g1/2 reader for early abort case
* Access rewrite
Initialize blocks in a separate object, and get via that object
removes a couple hundred "might be null" warnings since blocks are now readonly getters
some block references have been relocated, but interfaces should expose all that's needed
put HoF6 controls in a groupbox, and disable
* Readonly personal data
* IVs non nullable for mystery gift
* Explicitly initialize forced encounter moves
* Make shadow objects readonly & non-null
Put murkrow fix in binary data resource, instead of on startup
* Assign dex form fetch on constructor
Fixes legality parsing edge cases
also handle cxd parse for valid; exit before exception is thrown in FrameGenerator
* Remove unnecessary null checks
* Keep empty value until init
SetPouch sets the value to an actual one during load, but whatever
* Readonly team lock data
* Readonly locks
Put locked encounters at bottom (favor unlocked)
* Mail readonly data / offset
Rearrange some call flow and pass defaults
Add fake classes for SaveDataEditor mocking
Always party size, no need to check twice in stat editor
use a fake save file as initial data for savedata editor, and for
gamedata (wow i found a usage)
constrain eventwork editor to struct variable types (uint, int, etc),
thus preventing null assignment errors
2019-10-17 01:47:31 +00:00
|
|
|
|
private static void VerifyTrade4(LegalityAnalysis data, EncounterTrade t)
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
|
|
|
|
var pkm = data.pkm;
|
|
|
|
|
if (pkm.TID == 1000)
|
|
|
|
|
{
|
2018-10-27 20:37:03 +00:00
|
|
|
|
VerifyTradeOTOnly(data, t);
|
2018-06-24 05:00:01 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2018-10-27 20:37:03 +00:00
|
|
|
|
int lang = pkm.Language;
|
|
|
|
|
switch (t.Species)
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
2019-06-01 17:22:49 +00:00
|
|
|
|
case (int)Species.Pikachu: // HGSS Pikachu
|
2018-10-27 20:37:03 +00:00
|
|
|
|
lang = DetectTradeLanguageG4SurgePikachu(pkm, t, lang);
|
|
|
|
|
// flag korean on gen4 saves since the pkm.Language is German
|
|
|
|
|
FlagKoreanIncompatibleSameGenTrade(data, pkm, lang);
|
|
|
|
|
break;
|
2019-06-01 17:22:49 +00:00
|
|
|
|
case (int)Species.Magikarp: // DPPt Magikarp
|
2018-10-27 20:37:03 +00:00
|
|
|
|
lang = DetectTradeLanguageG4MeisterMagikarp(pkm, t, lang);
|
|
|
|
|
// flag korean on gen4 saves since the pkm.Language is German
|
|
|
|
|
FlagKoreanIncompatibleSameGenTrade(data, pkm, lang);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
2021-03-21 17:34:00 +00:00
|
|
|
|
if (pkm.Version is (int)GameVersion.D or (int)GameVersion.P && t is EncounterTrade4PID) // mainline DP
|
2018-10-27 20:37:03 +00:00
|
|
|
|
{
|
2021-03-21 17:34:00 +00:00
|
|
|
|
// DP English origin are Japanese lang. Can't have LanguageID 2
|
|
|
|
|
if (lang == 2)
|
|
|
|
|
{
|
|
|
|
|
data.AddLine(GetInvalid(string.Format(LOTLanguage, Japanese, English), CheckIdentifier.Language));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Since two locales (JPN/ENG) can have the same LanguageID, check which we should be validating with.
|
|
|
|
|
if (lang == 1 && pkm.OT_Name != t.GetOT(1)) // not Japanese
|
|
|
|
|
lang = 2; // verify strings with English locale instead.
|
2018-10-27 20:37:03 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
2018-10-27 20:37:03 +00:00
|
|
|
|
VerifyTrade(data, t, lang);
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-12 06:23:05 +00:00
|
|
|
|
private static void VerifyTrade8b(LegalityAnalysis data, EncounterTrade8b t)
|
2021-11-20 02:23:49 +00:00
|
|
|
|
{
|
|
|
|
|
var pkm = data.pkm;
|
|
|
|
|
int lang = pkm.Language;
|
|
|
|
|
if (t.Species == (int)Species.Magikarp)
|
2021-12-12 06:23:05 +00:00
|
|
|
|
lang = DetectTradeLanguageG8MeisterMagikarp(pkm, t, lang);
|
2021-11-20 02:23:49 +00:00
|
|
|
|
VerifyTrade(data, t, lang);
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-12 06:23:05 +00:00
|
|
|
|
private static int DetectTradeLanguageG8MeisterMagikarp(PKM pkm, EncounterTrade8b t, int currentLanguageID)
|
|
|
|
|
{
|
|
|
|
|
if (currentLanguageID is 5)
|
|
|
|
|
return 1;
|
|
|
|
|
if (currentLanguageID is 1)
|
|
|
|
|
return 5;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-27 20:37:03 +00:00
|
|
|
|
private static void FlagKoreanIncompatibleSameGenTrade(LegalityAnalysis data, PKM pkm, int lang)
|
|
|
|
|
{
|
PKHeX.Core Nullable cleanup (#2401)
* Handle some nullable cases
Refactor MysteryGift into a second abstract class (backed by a byte array, or fake data)
Make some classes have explicit constructors instead of { } initialization
* Handle bits more obviously without null
* Make SaveFile.BAK explicitly readonly again
* merge constructor methods to have readonly fields
* Inline some properties
* More nullable handling
* Rearrange box actions
define straightforward classes to not have any null properties
* Make extrabyte reference array immutable
* Move tooltip creation to designer
* Rearrange some logic to reduce nesting
* Cache generated fonts
* Split mystery gift album purpose
* Handle more tooltips
* Disallow null setters
* Don't capture RNG object, only type enum
* Unify learnset objects
Now have readonly properties which are never null
don't new() empty learnsets (>800 Learnset objects no longer created,
total of 2400 objects since we also new() a move & level array)
optimize g1/2 reader for early abort case
* Access rewrite
Initialize blocks in a separate object, and get via that object
removes a couple hundred "might be null" warnings since blocks are now readonly getters
some block references have been relocated, but interfaces should expose all that's needed
put HoF6 controls in a groupbox, and disable
* Readonly personal data
* IVs non nullable for mystery gift
* Explicitly initialize forced encounter moves
* Make shadow objects readonly & non-null
Put murkrow fix in binary data resource, instead of on startup
* Assign dex form fetch on constructor
Fixes legality parsing edge cases
also handle cxd parse for valid; exit before exception is thrown in FrameGenerator
* Remove unnecessary null checks
* Keep empty value until init
SetPouch sets the value to an actual one during load, but whatever
* Readonly team lock data
* Readonly locks
Put locked encounters at bottom (favor unlocked)
* Mail readonly data / offset
Rearrange some call flow and pass defaults
Add fake classes for SaveDataEditor mocking
Always party size, no need to check twice in stat editor
use a fake save file as initial data for savedata editor, and for
gamedata (wow i found a usage)
constrain eventwork editor to struct variable types (uint, int, etc),
thus preventing null assignment errors
2019-10-17 01:47:31 +00:00
|
|
|
|
if (pkm.Format != 4 || lang != (int)Korean)
|
2018-10-27 20:37:03 +00:00
|
|
|
|
return; // transferred or not appropriate
|
PKHeX.Core Nullable cleanup (#2401)
* Handle some nullable cases
Refactor MysteryGift into a second abstract class (backed by a byte array, or fake data)
Make some classes have explicit constructors instead of { } initialization
* Handle bits more obviously without null
* Make SaveFile.BAK explicitly readonly again
* merge constructor methods to have readonly fields
* Inline some properties
* More nullable handling
* Rearrange box actions
define straightforward classes to not have any null properties
* Make extrabyte reference array immutable
* Move tooltip creation to designer
* Rearrange some logic to reduce nesting
* Cache generated fonts
* Split mystery gift album purpose
* Handle more tooltips
* Disallow null setters
* Don't capture RNG object, only type enum
* Unify learnset objects
Now have readonly properties which are never null
don't new() empty learnsets (>800 Learnset objects no longer created,
total of 2400 objects since we also new() a move & level array)
optimize g1/2 reader for early abort case
* Access rewrite
Initialize blocks in a separate object, and get via that object
removes a couple hundred "might be null" warnings since blocks are now readonly getters
some block references have been relocated, but interfaces should expose all that's needed
put HoF6 controls in a groupbox, and disable
* Readonly personal data
* IVs non nullable for mystery gift
* Explicitly initialize forced encounter moves
* Make shadow objects readonly & non-null
Put murkrow fix in binary data resource, instead of on startup
* Assign dex form fetch on constructor
Fixes legality parsing edge cases
also handle cxd parse for valid; exit before exception is thrown in FrameGenerator
* Remove unnecessary null checks
* Keep empty value until init
SetPouch sets the value to an actual one during load, but whatever
* Readonly team lock data
* Readonly locks
Put locked encounters at bottom (favor unlocked)
* Mail readonly data / offset
Rearrange some call flow and pass defaults
Add fake classes for SaveDataEditor mocking
Always party size, no need to check twice in stat editor
use a fake save file as initial data for savedata editor, and for
gamedata (wow i found a usage)
constrain eventwork editor to struct variable types (uint, int, etc),
thus preventing null assignment errors
2019-10-17 01:47:31 +00:00
|
|
|
|
if (ParseSettings.ActiveTrainer.Language != (int)Korean && ParseSettings.ActiveTrainer.Language >= 0)
|
2018-10-27 20:37:03 +00:00
|
|
|
|
data.AddLine(GetInvalid(string.Format(LTransferOriginFInvalid0_1, L_XKorean, L_XKoreanNon), CheckIdentifier.Language));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static int DetectTradeLanguage(string OT, EncounterTrade t, int currentLanguageID)
|
|
|
|
|
{
|
|
|
|
|
var names = t.TrainerNames;
|
2020-01-19 03:11:29 +00:00
|
|
|
|
for (int lang = 1; lang < names.Count; lang++)
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
2018-10-27 20:37:03 +00:00
|
|
|
|
if (names[lang] != OT)
|
|
|
|
|
continue;
|
|
|
|
|
return lang;
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
2018-10-27 20:37:03 +00:00
|
|
|
|
return currentLanguageID;
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-10-27 20:37:03 +00:00
|
|
|
|
private static int DetectTradeLanguageG3DANTAEJynx(PKM pk, int currentLanguageID)
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
PKHeX.Core Nullable cleanup (#2401)
* Handle some nullable cases
Refactor MysteryGift into a second abstract class (backed by a byte array, or fake data)
Make some classes have explicit constructors instead of { } initialization
* Handle bits more obviously without null
* Make SaveFile.BAK explicitly readonly again
* merge constructor methods to have readonly fields
* Inline some properties
* More nullable handling
* Rearrange box actions
define straightforward classes to not have any null properties
* Make extrabyte reference array immutable
* Move tooltip creation to designer
* Rearrange some logic to reduce nesting
* Cache generated fonts
* Split mystery gift album purpose
* Handle more tooltips
* Disallow null setters
* Don't capture RNG object, only type enum
* Unify learnset objects
Now have readonly properties which are never null
don't new() empty learnsets (>800 Learnset objects no longer created,
total of 2400 objects since we also new() a move & level array)
optimize g1/2 reader for early abort case
* Access rewrite
Initialize blocks in a separate object, and get via that object
removes a couple hundred "might be null" warnings since blocks are now readonly getters
some block references have been relocated, but interfaces should expose all that's needed
put HoF6 controls in a groupbox, and disable
* Readonly personal data
* IVs non nullable for mystery gift
* Explicitly initialize forced encounter moves
* Make shadow objects readonly & non-null
Put murkrow fix in binary data resource, instead of on startup
* Assign dex form fetch on constructor
Fixes legality parsing edge cases
also handle cxd parse for valid; exit before exception is thrown in FrameGenerator
* Remove unnecessary null checks
* Keep empty value until init
SetPouch sets the value to an actual one during load, but whatever
* Readonly team lock data
* Readonly locks
Put locked encounters at bottom (favor unlocked)
* Mail readonly data / offset
Rearrange some call flow and pass defaults
Add fake classes for SaveDataEditor mocking
Always party size, no need to check twice in stat editor
use a fake save file as initial data for savedata editor, and for
gamedata (wow i found a usage)
constrain eventwork editor to struct variable types (uint, int, etc),
thus preventing null assignment errors
2019-10-17 01:47:31 +00:00
|
|
|
|
if (currentLanguageID != (int)Italian)
|
2018-10-27 20:37:03 +00:00
|
|
|
|
return currentLanguageID;
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
|
|
|
|
if (pk.Version == (int)GameVersion.LG)
|
PKHeX.Core Nullable cleanup (#2401)
* Handle some nullable cases
Refactor MysteryGift into a second abstract class (backed by a byte array, or fake data)
Make some classes have explicit constructors instead of { } initialization
* Handle bits more obviously without null
* Make SaveFile.BAK explicitly readonly again
* merge constructor methods to have readonly fields
* Inline some properties
* More nullable handling
* Rearrange box actions
define straightforward classes to not have any null properties
* Make extrabyte reference array immutable
* Move tooltip creation to designer
* Rearrange some logic to reduce nesting
* Cache generated fonts
* Split mystery gift album purpose
* Handle more tooltips
* Disallow null setters
* Don't capture RNG object, only type enum
* Unify learnset objects
Now have readonly properties which are never null
don't new() empty learnsets (>800 Learnset objects no longer created,
total of 2400 objects since we also new() a move & level array)
optimize g1/2 reader for early abort case
* Access rewrite
Initialize blocks in a separate object, and get via that object
removes a couple hundred "might be null" warnings since blocks are now readonly getters
some block references have been relocated, but interfaces should expose all that's needed
put HoF6 controls in a groupbox, and disable
* Readonly personal data
* IVs non nullable for mystery gift
* Explicitly initialize forced encounter moves
* Make shadow objects readonly & non-null
Put murkrow fix in binary data resource, instead of on startup
* Assign dex form fetch on constructor
Fixes legality parsing edge cases
also handle cxd parse for valid; exit before exception is thrown in FrameGenerator
* Remove unnecessary null checks
* Keep empty value until init
SetPouch sets the value to an actual one during load, but whatever
* Readonly team lock data
* Readonly locks
Put locked encounters at bottom (favor unlocked)
* Mail readonly data / offset
Rearrange some call flow and pass defaults
Add fake classes for SaveDataEditor mocking
Always party size, no need to check twice in stat editor
use a fake save file as initial data for savedata editor, and for
gamedata (wow i found a usage)
constrain eventwork editor to struct variable types (uint, int, etc),
thus preventing null assignment errors
2019-10-17 01:47:31 +00:00
|
|
|
|
currentLanguageID = (int)English; // translation error; OT was not localized => same as English
|
2018-10-27 20:37:03 +00:00
|
|
|
|
return currentLanguageID;
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-10-27 20:37:03 +00:00
|
|
|
|
private static int DetectTradeLanguageG4MeisterMagikarp(PKM pkm, EncounterTrade t, int currentLanguageID)
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
PKHeX.Core Nullable cleanup (#2401)
* Handle some nullable cases
Refactor MysteryGift into a second abstract class (backed by a byte array, or fake data)
Make some classes have explicit constructors instead of { } initialization
* Handle bits more obviously without null
* Make SaveFile.BAK explicitly readonly again
* merge constructor methods to have readonly fields
* Inline some properties
* More nullable handling
* Rearrange box actions
define straightforward classes to not have any null properties
* Make extrabyte reference array immutable
* Move tooltip creation to designer
* Rearrange some logic to reduce nesting
* Cache generated fonts
* Split mystery gift album purpose
* Handle more tooltips
* Disallow null setters
* Don't capture RNG object, only type enum
* Unify learnset objects
Now have readonly properties which are never null
don't new() empty learnsets (>800 Learnset objects no longer created,
total of 2400 objects since we also new() a move & level array)
optimize g1/2 reader for early abort case
* Access rewrite
Initialize blocks in a separate object, and get via that object
removes a couple hundred "might be null" warnings since blocks are now readonly getters
some block references have been relocated, but interfaces should expose all that's needed
put HoF6 controls in a groupbox, and disable
* Readonly personal data
* IVs non nullable for mystery gift
* Explicitly initialize forced encounter moves
* Make shadow objects readonly & non-null
Put murkrow fix in binary data resource, instead of on startup
* Assign dex form fetch on constructor
Fixes legality parsing edge cases
also handle cxd parse for valid; exit before exception is thrown in FrameGenerator
* Remove unnecessary null checks
* Keep empty value until init
SetPouch sets the value to an actual one during load, but whatever
* Readonly team lock data
* Readonly locks
Put locked encounters at bottom (favor unlocked)
* Mail readonly data / offset
Rearrange some call flow and pass defaults
Add fake classes for SaveDataEditor mocking
Always party size, no need to check twice in stat editor
use a fake save file as initial data for savedata editor, and for
gamedata (wow i found a usage)
constrain eventwork editor to struct variable types (uint, int, etc),
thus preventing null assignment errors
2019-10-17 01:47:31 +00:00
|
|
|
|
if (currentLanguageID == (int)English)
|
|
|
|
|
return (int)German;
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
|
|
|
|
// All have German, regardless of origin version.
|
2018-10-27 20:37:03 +00:00
|
|
|
|
var lang = DetectTradeLanguage(pkm.OT_Name, t, currentLanguageID);
|
PKHeX.Core Nullable cleanup (#2401)
* Handle some nullable cases
Refactor MysteryGift into a second abstract class (backed by a byte array, or fake data)
Make some classes have explicit constructors instead of { } initialization
* Handle bits more obviously without null
* Make SaveFile.BAK explicitly readonly again
* merge constructor methods to have readonly fields
* Inline some properties
* More nullable handling
* Rearrange box actions
define straightforward classes to not have any null properties
* Make extrabyte reference array immutable
* Move tooltip creation to designer
* Rearrange some logic to reduce nesting
* Cache generated fonts
* Split mystery gift album purpose
* Handle more tooltips
* Disallow null setters
* Don't capture RNG object, only type enum
* Unify learnset objects
Now have readonly properties which are never null
don't new() empty learnsets (>800 Learnset objects no longer created,
total of 2400 objects since we also new() a move & level array)
optimize g1/2 reader for early abort case
* Access rewrite
Initialize blocks in a separate object, and get via that object
removes a couple hundred "might be null" warnings since blocks are now readonly getters
some block references have been relocated, but interfaces should expose all that's needed
put HoF6 controls in a groupbox, and disable
* Readonly personal data
* IVs non nullable for mystery gift
* Explicitly initialize forced encounter moves
* Make shadow objects readonly & non-null
Put murkrow fix in binary data resource, instead of on startup
* Assign dex form fetch on constructor
Fixes legality parsing edge cases
also handle cxd parse for valid; exit before exception is thrown in FrameGenerator
* Remove unnecessary null checks
* Keep empty value until init
SetPouch sets the value to an actual one during load, but whatever
* Readonly team lock data
* Readonly locks
Put locked encounters at bottom (favor unlocked)
* Mail readonly data / offset
Rearrange some call flow and pass defaults
Add fake classes for SaveDataEditor mocking
Always party size, no need to check twice in stat editor
use a fake save file as initial data for savedata editor, and for
gamedata (wow i found a usage)
constrain eventwork editor to struct variable types (uint, int, etc),
thus preventing null assignment errors
2019-10-17 01:47:31 +00:00
|
|
|
|
if (lang == (int)English) // possible collision with FR/ES/DE. Check nickname
|
|
|
|
|
return pkm.Nickname == t.Nicknames[(int)French] ? (int)French : (int)Spanish; // Spanish is same as English
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
|
|
|
|
return lang;
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-10-27 20:37:03 +00:00
|
|
|
|
private static int DetectTradeLanguageG4SurgePikachu(PKM pkm, EncounterTrade t, int currentLanguageID)
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
PKHeX.Core Nullable cleanup (#2401)
* Handle some nullable cases
Refactor MysteryGift into a second abstract class (backed by a byte array, or fake data)
Make some classes have explicit constructors instead of { } initialization
* Handle bits more obviously without null
* Make SaveFile.BAK explicitly readonly again
* merge constructor methods to have readonly fields
* Inline some properties
* More nullable handling
* Rearrange box actions
define straightforward classes to not have any null properties
* Make extrabyte reference array immutable
* Move tooltip creation to designer
* Rearrange some logic to reduce nesting
* Cache generated fonts
* Split mystery gift album purpose
* Handle more tooltips
* Disallow null setters
* Don't capture RNG object, only type enum
* Unify learnset objects
Now have readonly properties which are never null
don't new() empty learnsets (>800 Learnset objects no longer created,
total of 2400 objects since we also new() a move & level array)
optimize g1/2 reader for early abort case
* Access rewrite
Initialize blocks in a separate object, and get via that object
removes a couple hundred "might be null" warnings since blocks are now readonly getters
some block references have been relocated, but interfaces should expose all that's needed
put HoF6 controls in a groupbox, and disable
* Readonly personal data
* IVs non nullable for mystery gift
* Explicitly initialize forced encounter moves
* Make shadow objects readonly & non-null
Put murkrow fix in binary data resource, instead of on startup
* Assign dex form fetch on constructor
Fixes legality parsing edge cases
also handle cxd parse for valid; exit before exception is thrown in FrameGenerator
* Remove unnecessary null checks
* Keep empty value until init
SetPouch sets the value to an actual one during load, but whatever
* Readonly team lock data
* Readonly locks
Put locked encounters at bottom (favor unlocked)
* Mail readonly data / offset
Rearrange some call flow and pass defaults
Add fake classes for SaveDataEditor mocking
Always party size, no need to check twice in stat editor
use a fake save file as initial data for savedata editor, and for
gamedata (wow i found a usage)
constrain eventwork editor to struct variable types (uint, int, etc),
thus preventing null assignment errors
2019-10-17 01:47:31 +00:00
|
|
|
|
if (currentLanguageID == (int)French)
|
|
|
|
|
return (int)English;
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
|
|
|
|
// All have English, regardless of origin version.
|
2018-10-27 20:37:03 +00:00
|
|
|
|
var lang = DetectTradeLanguage(pkm.OT_Name, t, currentLanguageID);
|
2018-06-24 05:00:01 +00:00
|
|
|
|
if (lang == 2) // possible collision with ES/IT. Check nickname
|
PKHeX.Core Nullable cleanup (#2401)
* Handle some nullable cases
Refactor MysteryGift into a second abstract class (backed by a byte array, or fake data)
Make some classes have explicit constructors instead of { } initialization
* Handle bits more obviously without null
* Make SaveFile.BAK explicitly readonly again
* merge constructor methods to have readonly fields
* Inline some properties
* More nullable handling
* Rearrange box actions
define straightforward classes to not have any null properties
* Make extrabyte reference array immutable
* Move tooltip creation to designer
* Rearrange some logic to reduce nesting
* Cache generated fonts
* Split mystery gift album purpose
* Handle more tooltips
* Disallow null setters
* Don't capture RNG object, only type enum
* Unify learnset objects
Now have readonly properties which are never null
don't new() empty learnsets (>800 Learnset objects no longer created,
total of 2400 objects since we also new() a move & level array)
optimize g1/2 reader for early abort case
* Access rewrite
Initialize blocks in a separate object, and get via that object
removes a couple hundred "might be null" warnings since blocks are now readonly getters
some block references have been relocated, but interfaces should expose all that's needed
put HoF6 controls in a groupbox, and disable
* Readonly personal data
* IVs non nullable for mystery gift
* Explicitly initialize forced encounter moves
* Make shadow objects readonly & non-null
Put murkrow fix in binary data resource, instead of on startup
* Assign dex form fetch on constructor
Fixes legality parsing edge cases
also handle cxd parse for valid; exit before exception is thrown in FrameGenerator
* Remove unnecessary null checks
* Keep empty value until init
SetPouch sets the value to an actual one during load, but whatever
* Readonly team lock data
* Readonly locks
Put locked encounters at bottom (favor unlocked)
* Mail readonly data / offset
Rearrange some call flow and pass defaults
Add fake classes for SaveDataEditor mocking
Always party size, no need to check twice in stat editor
use a fake save file as initial data for savedata editor, and for
gamedata (wow i found a usage)
constrain eventwork editor to struct variable types (uint, int, etc),
thus preventing null assignment errors
2019-10-17 01:47:31 +00:00
|
|
|
|
return pkm.Nickname == t.Nicknames[(int)Italian] ? (int)Italian : (int)Spanish;
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
|
|
|
|
return lang;
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
PKHeX.Core Nullable cleanup (#2401)
* Handle some nullable cases
Refactor MysteryGift into a second abstract class (backed by a byte array, or fake data)
Make some classes have explicit constructors instead of { } initialization
* Handle bits more obviously without null
* Make SaveFile.BAK explicitly readonly again
* merge constructor methods to have readonly fields
* Inline some properties
* More nullable handling
* Rearrange box actions
define straightforward classes to not have any null properties
* Make extrabyte reference array immutable
* Move tooltip creation to designer
* Rearrange some logic to reduce nesting
* Cache generated fonts
* Split mystery gift album purpose
* Handle more tooltips
* Disallow null setters
* Don't capture RNG object, only type enum
* Unify learnset objects
Now have readonly properties which are never null
don't new() empty learnsets (>800 Learnset objects no longer created,
total of 2400 objects since we also new() a move & level array)
optimize g1/2 reader for early abort case
* Access rewrite
Initialize blocks in a separate object, and get via that object
removes a couple hundred "might be null" warnings since blocks are now readonly getters
some block references have been relocated, but interfaces should expose all that's needed
put HoF6 controls in a groupbox, and disable
* Readonly personal data
* IVs non nullable for mystery gift
* Explicitly initialize forced encounter moves
* Make shadow objects readonly & non-null
Put murkrow fix in binary data resource, instead of on startup
* Assign dex form fetch on constructor
Fixes legality parsing edge cases
also handle cxd parse for valid; exit before exception is thrown in FrameGenerator
* Remove unnecessary null checks
* Keep empty value until init
SetPouch sets the value to an actual one during load, but whatever
* Readonly team lock data
* Readonly locks
Put locked encounters at bottom (favor unlocked)
* Mail readonly data / offset
Rearrange some call flow and pass defaults
Add fake classes for SaveDataEditor mocking
Always party size, no need to check twice in stat editor
use a fake save file as initial data for savedata editor, and for
gamedata (wow i found a usage)
constrain eventwork editor to struct variable types (uint, int, etc),
thus preventing null assignment errors
2019-10-17 01:47:31 +00:00
|
|
|
|
private static void VerifyTrade5(LegalityAnalysis data, EncounterTrade t)
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
|
|
|
|
var pkm = data.pkm;
|
2018-10-27 20:37:03 +00:00
|
|
|
|
int lang = pkm.Language;
|
2018-06-24 05:00:01 +00:00
|
|
|
|
// Trades for JPN games have language ID of 0, not 1.
|
|
|
|
|
if (pkm.BW)
|
|
|
|
|
{
|
PKHeX.Core Nullable cleanup (#2401)
* Handle some nullable cases
Refactor MysteryGift into a second abstract class (backed by a byte array, or fake data)
Make some classes have explicit constructors instead of { } initialization
* Handle bits more obviously without null
* Make SaveFile.BAK explicitly readonly again
* merge constructor methods to have readonly fields
* Inline some properties
* More nullable handling
* Rearrange box actions
define straightforward classes to not have any null properties
* Make extrabyte reference array immutable
* Move tooltip creation to designer
* Rearrange some logic to reduce nesting
* Cache generated fonts
* Split mystery gift album purpose
* Handle more tooltips
* Disallow null setters
* Don't capture RNG object, only type enum
* Unify learnset objects
Now have readonly properties which are never null
don't new() empty learnsets (>800 Learnset objects no longer created,
total of 2400 objects since we also new() a move & level array)
optimize g1/2 reader for early abort case
* Access rewrite
Initialize blocks in a separate object, and get via that object
removes a couple hundred "might be null" warnings since blocks are now readonly getters
some block references have been relocated, but interfaces should expose all that's needed
put HoF6 controls in a groupbox, and disable
* Readonly personal data
* IVs non nullable for mystery gift
* Explicitly initialize forced encounter moves
* Make shadow objects readonly & non-null
Put murkrow fix in binary data resource, instead of on startup
* Assign dex form fetch on constructor
Fixes legality parsing edge cases
also handle cxd parse for valid; exit before exception is thrown in FrameGenerator
* Remove unnecessary null checks
* Keep empty value until init
SetPouch sets the value to an actual one during load, but whatever
* Readonly team lock data
* Readonly locks
Put locked encounters at bottom (favor unlocked)
* Mail readonly data / offset
Rearrange some call flow and pass defaults
Add fake classes for SaveDataEditor mocking
Always party size, no need to check twice in stat editor
use a fake save file as initial data for savedata editor, and for
gamedata (wow i found a usage)
constrain eventwork editor to struct variable types (uint, int, etc),
thus preventing null assignment errors
2019-10-17 01:47:31 +00:00
|
|
|
|
if (pkm.Format == 5 && lang == (int)Japanese)
|
|
|
|
|
data.AddLine(GetInvalid(string.Format(LOTLanguage, 0, Japanese), CheckIdentifier.Language));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
|
|
|
|
lang = Math.Max(lang, 1);
|
2018-10-27 20:37:03 +00:00
|
|
|
|
VerifyTrade(data, t, lang);
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
|
|
|
|
else // B2W2
|
|
|
|
|
{
|
2020-12-25 20:30:26 +00:00
|
|
|
|
if (t.TID is Encounters5.YancyTID or Encounters5.CurtisTID)
|
2018-10-27 20:37:03 +00:00
|
|
|
|
VerifyTradeOTOnly(data, t);
|
2018-06-24 05:00:01 +00:00
|
|
|
|
else
|
2018-10-27 20:37:03 +00:00
|
|
|
|
VerifyTrade(data, t, lang);
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-10-27 20:37:03 +00:00
|
|
|
|
private static void VerifyTradeOTOnly(LegalityAnalysis data, EncounterTrade t)
|
2018-07-27 02:34:27 +00:00
|
|
|
|
{
|
2018-10-27 20:37:03 +00:00
|
|
|
|
var result = CheckTradeOTOnly(data, t.TrainerNames);
|
2018-07-27 02:34:27 +00:00
|
|
|
|
data.AddLine(result);
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-19 03:11:29 +00:00
|
|
|
|
private static CheckResult CheckTradeOTOnly(LegalityAnalysis data, IReadOnlyList<string> validOT)
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
|
|
|
|
var pkm = data.pkm;
|
2020-10-31 03:31:12 +00:00
|
|
|
|
if (pkm.IsNicknamed && (pkm.Format < 8 || pkm.FatefulEncounter))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetInvalid(LEncTradeChangedNickname, CheckIdentifier.Nickname);
|
2018-06-24 05:00:01 +00:00
|
|
|
|
int lang = pkm.Language;
|
2020-01-19 03:11:29 +00:00
|
|
|
|
if (validOT.Count <= lang)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetInvalid(LEncTradeIndexBad, CheckIdentifier.Trainer);
|
2018-07-27 02:34:27 +00:00
|
|
|
|
if (validOT[lang] != pkm.OT_Name)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetInvalid(LEncTradeChangedOT, CheckIdentifier.Trainer);
|
|
|
|
|
return GetValid(LEncTradeUnchanged, CheckIdentifier.Nickname);
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-10-27 20:37:03 +00:00
|
|
|
|
private static void VerifyTrade(LegalityAnalysis data, EncounterTrade t, int language)
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
2018-10-27 20:37:03 +00:00
|
|
|
|
var ot = t.GetOT(language);
|
|
|
|
|
var nick = t.GetNickname(language);
|
2020-10-31 03:31:12 +00:00
|
|
|
|
if (string.IsNullOrEmpty(nick))
|
|
|
|
|
VerifyTradeOTOnly(data, t);
|
|
|
|
|
else
|
|
|
|
|
VerifyTradeOTNick(data, t, nick, ot);
|
2018-10-27 20:37:03 +00:00
|
|
|
|
}
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
2018-10-27 20:37:03 +00:00
|
|
|
|
private static void VerifyTradeOTNick(LegalityAnalysis data, EncounterTrade t, string nick, string OT)
|
|
|
|
|
{
|
2018-06-24 05:00:01 +00:00
|
|
|
|
var pkm = data.pkm;
|
2018-10-06 20:43:05 +00:00
|
|
|
|
// trades that are not nicknamed (but are present in a table with others being named)
|
2018-10-27 20:37:03 +00:00
|
|
|
|
var result = IsNicknameMatch(nick, pkm, t)
|
2018-10-06 20:43:05 +00:00
|
|
|
|
? GetValid(LEncTradeUnchanged, CheckIdentifier.Nickname)
|
|
|
|
|
: Get(LEncTradeChangedNickname, ParseSettings.NicknamedTrade, CheckIdentifier.Nickname);
|
|
|
|
|
data.AddLine(result);
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
|
|
|
|
if (OT != pkm.OT_Name)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetInvalid(LEncTradeChangedOT, CheckIdentifier.Trainer));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2021-01-11 02:15:33 +00:00
|
|
|
|
private static bool IsNicknameMatch(string nick, ILangNick pkm, EncounterTrade enc)
|
2018-07-27 02:34:27 +00:00
|
|
|
|
{
|
|
|
|
|
if (nick == "Quacklin’" && pkm.Nickname == "Quacklin'")
|
|
|
|
|
return true;
|
2021-01-11 02:15:33 +00:00
|
|
|
|
if (enc.IsNicknamed != pkm.IsNicknamed)
|
2018-08-27 01:32:39 +00:00
|
|
|
|
return false;
|
|
|
|
|
if (nick != pkm.Nickname) // if not match, must not be a nicknamed trade && not currently named
|
2021-01-11 02:15:33 +00:00
|
|
|
|
return !enc.IsNicknamed && !pkm.IsNicknamed;
|
2018-08-27 01:32:39 +00:00
|
|
|
|
return true;
|
2018-07-27 02:34:27 +00:00
|
|
|
|
}
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|