Show status 0x02 on exchange_finish.asp when the trade fails. This probably resolves #112.

This commit is contained in:
Greg Edwards
2022-07-31 23:59:13 -04:00
parent 8c3806f58d
commit 416d9bf05b
2 changed files with 17 additions and 6 deletions

View File

@@ -497,14 +497,25 @@ namespace PkmnFoundations.GTS
GamestatsSession prevSession = SessionManager.FindSession(pid, "/pokemondpds/worldexchange/exchange.asp");
if (prevSession == null)
{
response.Write(new byte[] { 0x00, 0x00 }, 0, 2);
// response codes:
// 0x00: I thought this meant fail but it also sometimes succeeds
// 0x01: Success (the normal success response)
// 0x02: Either the GTS is experiencing high traffic volumes or the service is down. Please wait a while and try again.
// 0x03: Success (apparently)
// 0x04: Success (apparently)
// 0x05: Success (apparently)
// 0x06: Success (apparently)
// ...
// 0x0f: Success (apparently)
// I'm going to reason that responses other than 0x02 will all succeed, at least on platinum
response.Write(new byte[] { 0x02, 0x00 }, 0, 2);
return;
}
SessionManager.Remove(prevSession);
if (prevSession.Tag == null)
{
response.Write(new byte[] { 0x00, 0x00 }, 0, 2);
response.Write(new byte[] { 0x02, 0x00 }, 0, 2);
return;
}
AssertHelper.Assert(prevSession.Tag is GtsRecord4[]);
@@ -517,7 +528,7 @@ namespace PkmnFoundations.GTS
if (Database.Instance.GtsTradePokemon4(upload, result, pid))
response.Write(new byte[] { 0x01, 0x00 }, 0, 2);
else
response.Write(new byte[] { 0x00, 0x00 }, 0, 2);
response.Write(new byte[] { 0x02, 0x00 }, 0, 2);
} break;
#endregion

View File

@@ -451,14 +451,14 @@ namespace PkmnFoundations.GTS
GamestatsSession prevSession = SessionManager.FindSession(pid, "/syachi2ds/web/worldexchange/exchange.asp");
if (prevSession == null)
{
response.Write(new byte[] { 0x00, 0x00 }, 0, 2);
response.Write(new byte[] { 0x02, 0x00 }, 0, 2);
return;
}
SessionManager.Remove(prevSession);
if (prevSession.Tag == null)
{
response.Write(new byte[] { 0x00, 0x00 }, 0, 2);
response.Write(new byte[] { 0x02, 0x00 }, 0, 2);
return;
}
AssertHelper.Assert(prevSession.Tag is GtsRecord5[]);
@@ -471,7 +471,7 @@ namespace PkmnFoundations.GTS
if (Database.Instance.GtsTradePokemon5(upload, result, pid))
response.Write(new byte[] { 0x01, 0x00 }, 0, 2);
else
response.Write(new byte[] { 0x00, 0x00 }, 0, 2);
response.Write(new byte[] { 0x02, 0x00 }, 0, 2);
} break;
#endregion