Skip to content

Commit

Permalink
12.6.24 -e
Browse files Browse the repository at this point in the history
- Species comparison clean
- Fix incorrect EC comparison
  • Loading branch information
bdawg1989 committed Dec 6, 2024
1 parent 1ef9e55 commit 8a98ba4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions SysBot.Pokemon/BDSP/BotTrade/PokeTradeBotBS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1317,10 +1317,10 @@ private async Task<PokeTradeResult> ProcessDumpTradeAsync(PokeTradeDetail<PB8> d

// If we detected a change, they offered something.
var pk = await ReadPokemon(LinkTradePokemonOffset, BoxFormatSlotSize, token).ConfigureAwait(false);
var newEC = await SwitchConnection.ReadBytesAbsoluteAsync(LinkTradePokemonOffset, 8, token).ConfigureAwait(false);
if (pk.Species < 1 || !pk.ChecksumValid || lastOffered.SequenceEqual(newEC))
var newECchk = await SwitchConnection.ReadBytesAbsoluteAsync(LinkTradePokemonOffset, 8, token).ConfigureAwait(false);
if (pk.Species == 0 || !pk.ChecksumValid || lastOffered.SequenceEqual(newECchk))
continue;
lastOffered = newEC;
lastOffered = newECchk;

// Send results from separate thread; the bot doesn't need to wait for things to be calculated.
if (DumpSetting.Dump)
Expand Down
6 changes: 3 additions & 3 deletions SysBot.Pokemon/LA/BotTrade/PokeTradeBotLA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ private async Task<PokeTradeResult> PerformBatchTrade(SAV8LA sav, PokeTradeDetai
Log("Checking offered Pokémon.");

var offered = await ReadUntilPresentPointer(Offsets.LinkTradePartnerPokemonPointer, 3_000, 0_050, BoxFormatSlotSize, token).ConfigureAwait(false);
if (offered == null || offered.Species < 1 || !offered.ChecksumValid)
if (offered == null || offered.Species == 0 || !offered.ChecksumValid)
{
if (completedTrades > 0)
poke.SendNotification(this, "Offered Pokemon was invalid. Remaining batch trades canceled.");
Expand Down Expand Up @@ -725,7 +725,7 @@ private async Task<PokeTradeResult> PerformLinkCodeTrade(SAV8LA sav, PokeTradeDe

// Wait for user input... Needs to be different from the previously offered Pokémon.
var offered = await ReadUntilPresentPointer(Offsets.LinkTradePartnerPokemonPointer, 3_000, 0_050, BoxFormatSlotSize, token).ConfigureAwait(false);
if (offered == null || offered.Species < 1 || !offered.ChecksumValid)
if (offered == null || offered.Species == 0 || !offered.ChecksumValid)
{
Log("Trade ended because trainer offer was rescinded too quickly.");
await ExitTrade(false, token).ConfigureAwait(false);
Expand Down Expand Up @@ -930,7 +930,7 @@ private async Task<PokeTradeResult> ProcessDumpTradeAsync(PokeTradeDetail<PA8> d

// Wait for user input... Needs to be different from the previously offered Pokémon.
var pk = await ReadUntilPresentPointer(Offsets.LinkTradePartnerPokemonPointer, 3_000, 0_050, BoxFormatSlotSize, token).ConfigureAwait(false);
if (pk == null || pk.Species < 1 || !pk.ChecksumValid || SearchUtil.HashByDetails(pk) == SearchUtil.HashByDetails(pkprev))
if (pk == null || pk.Species == 0 || !pk.ChecksumValid || SearchUtil.HashByDetails(pk) == SearchUtil.HashByDetails(pkprev))
continue;

// Save the new Pokémon for comparison next round.
Expand Down
6 changes: 3 additions & 3 deletions SysBot.Pokemon/SV/BotTrade/PokeTradeBotSV.cs
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ private async Task<PokeTradeResult> PerformBatchTrade(SAV9SV sav, PokeTradeDetai

var offered = await ReadUntilPresent(TradePartnerOfferedOffset, 25_000, 1_000, BoxFormatSlotSize, token).ConfigureAwait(false);
var oldEC = await SwitchConnection.ReadBytesAbsoluteAsync(TradePartnerOfferedOffset, 8, token).ConfigureAwait(false);
if (offered == null || offered.Species < 1 || !offered.ChecksumValid)
if (offered == null || offered.Species == 0 || !offered.ChecksumValid)
{
Log("Trade ended because a valid Pokémon was not offered.");
if (startingDetail.TotalBatchTrades > 1)
Expand Down Expand Up @@ -1225,7 +1225,7 @@ private async Task<PokeTradeResult> PerformNonBatchTrade(SAV9SV sav, PokeTradeDe
// Wait for user input...
var offered = await ReadUntilPresent(TradePartnerOfferedOffset, 25_000, 1_000, BoxFormatSlotSize, token).ConfigureAwait(false);
var oldEC = await SwitchConnection.ReadBytesAbsoluteAsync(TradePartnerOfferedOffset, 8, token).ConfigureAwait(false);
if (offered == null || offered.Species < 1 || !offered.ChecksumValid)
if (offered == null || offered.Species == 0 || !offered.ChecksumValid)
{
Log("Trade ended because a valid Pokémon was not offered.");
await ExitTradeToPortal(false, token).ConfigureAwait(false);
Expand Down Expand Up @@ -1418,7 +1418,7 @@ private async Task<PokeTradeResult> ProcessDumpTradeAsync(PokeTradeDetail<PK9> d

// Wait for user input... Needs to be different from the previously offered Pokémon.
var pk = await ReadUntilPresent(TradePartnerOfferedOffset, 3_000, 0_050, BoxFormatSlotSize, token).ConfigureAwait(false);
if (pk == null || pk.Species < 1 || !pk.ChecksumValid || SearchUtil.HashByDetails(pk) == SearchUtil.HashByDetails(pkprev))
if (pk == null || pk.Species == 0 || !pk.ChecksumValid || SearchUtil.HashByDetails(pk) == SearchUtil.HashByDetails(pkprev))
continue;

// Save the new Pokémon for comparison next round.
Expand Down
2 changes: 1 addition & 1 deletion SysBot.Pokemon/SWSH/BotTrade/PokeTradeBotSWSH.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,7 @@ private async Task<PokeTradeResult> ProcessDumpTradeAsync(PokeTradeDetail<PK8> d
await Click(B, 0_100, token).ConfigureAwait(false);

var pk = await ReadUntilPresent(LinkTradePartnerPokemonOffset, 3_000, 0_500, BoxFormatSlotSize, token).ConfigureAwait(false);
if (pk == null || pk.Species < 1 || !pk.ChecksumValid || SearchUtil.HashByDetails(pk) == SearchUtil.HashByDetails(pkprev))
if (pk == null || pk.Species == 0 || !pk.ChecksumValid || SearchUtil.HashByDetails(pk) == SearchUtil.HashByDetails(pkprev))
continue;

// Save the new Pokémon for comparison next round.
Expand Down

0 comments on commit 8a98ba4

Please sign in to comment.