From b0eee743348adde2b80ebdb62545b421f1909948 Mon Sep 17 00:00:00 2001 From: Greg Edwards Date: Tue, 6 Nov 2018 03:01:22 -0500 Subject: [PATCH] Added abstract GtsRecordBase.Validate(is_exchanged) --- gts/pokemondpds.ashx.cs | 4 ++-- gts/syachi2ds.ashx.cs | 4 ++-- library/Structures/GtsRecord4.cs | 2 +- library/Structures/GtsRecord5.cs | 2 +- library/Structures/GtsRecordBase.cs | 4 +++- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/gts/pokemondpds.ashx.cs b/gts/pokemondpds.ashx.cs index ab155ea8..796b436f 100644 --- a/gts/pokemondpds.ashx.cs +++ b/gts/pokemondpds.ashx.cs @@ -226,7 +226,7 @@ namespace PkmnFoundations.GTS byte[] recordBinary = new byte[292]; Array.Copy(data, 0, recordBinary, 0, 292); GtsRecord4 record = new GtsRecord4(pokedex, recordBinary); - if (!record.Validate()) + if (!record.Validate(false)) { // hack check failed SessionManager.Remove(session); @@ -357,7 +357,7 @@ namespace PkmnFoundations.GTS } // enforce request requirements server side - if (!upload.Validate() || !upload.CanTrade(result)) + if (!upload.Validate(true) || !upload.CanTrade(result)) { // todo: find the correct codes for these SessionManager.Remove(session); diff --git a/gts/syachi2ds.ashx.cs b/gts/syachi2ds.ashx.cs index 66eec0b2..7e014ea8 100644 --- a/gts/syachi2ds.ashx.cs +++ b/gts/syachi2ds.ashx.cs @@ -222,7 +222,7 @@ namespace PkmnFoundations.GTS // appears to be 4 bytes of 00, 128 bytes of stuff, 4 bytes of 80 00 00 00 // probably a pkvldtprod signature - if (!record.Validate()) + if (!record.Validate(false)) { // hack check failed // todo: test that 0c 00 is the correct code for GenV @@ -356,7 +356,7 @@ namespace PkmnFoundations.GTS } // enforce request requirements server side - if (!upload.Validate() || !upload.CanTrade(result)) + if (!upload.Validate(true) || !upload.CanTrade(result)) { // todo: find the correct codes for these SessionManager.Remove(session); diff --git a/library/Structures/GtsRecord4.cs b/library/Structures/GtsRecord4.cs index 20909ef9..e91491f2 100644 --- a/library/Structures/GtsRecord4.cs +++ b/library/Structures/GtsRecord4.cs @@ -191,7 +191,7 @@ namespace PkmnFoundations.Structures return new GtsRecord4(m_pokedex, Save()); } - public bool Validate() + public override bool Validate(bool is_exchanged) { // todo: a. legitimacy check, and b. check that pkm data matches metadata return true; diff --git a/library/Structures/GtsRecord5.cs b/library/Structures/GtsRecord5.cs index 184eb7f6..7b4ebb9a 100644 --- a/library/Structures/GtsRecord5.cs +++ b/library/Structures/GtsRecord5.cs @@ -198,7 +198,7 @@ namespace PkmnFoundations.Structures return new GtsRecord5(m_pokedex, Save()); } - public bool Validate() + public override bool Validate(bool is_exchanged) { // todo: a. legitimacy check, and b. check that pkm data matches metadata return true; diff --git a/library/Structures/GtsRecordBase.cs b/library/Structures/GtsRecordBase.cs index 7accf2c0..94f75196 100644 --- a/library/Structures/GtsRecordBase.cs +++ b/library/Structures/GtsRecordBase.cs @@ -69,7 +69,7 @@ namespace PkmnFoundations.Structures public byte TrainerRegion; public byte TrainerClass; - public abstract String TrainerName + public abstract string TrainerName { get; set; @@ -80,6 +80,8 @@ namespace PkmnFoundations.Structures public byte TrainerVersion; public byte TrainerLanguage; + public abstract bool Validate(bool is_exchanged); + public static bool CheckLevels(byte min, byte max, byte other) { if (max == 0) max = 255;