Fixed a race condition allowing one Pokémon to go to two people.

(And the first offer gets overwritten.)
This commit is contained in:
Greg Edwards 2014-05-18 16:18:54 -04:00
parent 6d2cdf81d8
commit 123e665c7e
4 changed files with 6 additions and 2 deletions

View File

@ -377,7 +377,7 @@ namespace PkmnFoundations.GTS
int targetPid = BitConverter.ToInt32(data, 296);
GtsRecord4 result = DataAbstract.Instance.GtsDataForUser4(targetPid);
if (result == null)
if (result == null || result.IsExchanged != 0)
{
// Pokémon is traded (or was never here to begin with)
// todo: I only checked this on GenV. Check that this

View File

@ -386,7 +386,7 @@ namespace PkmnFoundations.GTS
int targetPid = BitConverter.ToInt32(data, 304);
GtsRecord5 result = DataAbstract.Instance.GtsDataForUser5(targetPid);
if (result == null)
if (result == null || result.IsExchanged != 0)
{
// Pokémon is traded (or was never here to begin with)
manager.Remove(session);

View File

@ -159,6 +159,8 @@ namespace PkmnFoundations.Structures
public bool CanTrade(GtsRecord4 other)
{
if (IsExchanged != 0 || other.IsExchanged != 0) return false;
if (Species != other.RequestedSpecies) return false;
if (other.RequestedGender != Genders.Either && Gender != other.RequestedGender) return false;
if (!CheckLevels(other.RequestedMinLevel, other.RequestedMaxLevel, Level)) return false;

View File

@ -173,6 +173,8 @@ namespace PkmnFoundations.Structures
public bool CanTrade(GtsRecord5 other)
{
if (IsExchanged != 0 || other.IsExchanged != 0) return false;
if (Species != other.RequestedSpecies) return false;
if (other.RequestedGender != Genders.Either && Gender != other.RequestedGender) return false;
if (!CheckLevels(other.RequestedMinLevel, other.RequestedMaxLevel, Level)) return false;