From dc1da4e88b4268ba12f6fd8b4a1ce362b4e9eebf Mon Sep 17 00:00:00 2001 From: Bryce Wilson Date: Tue, 1 Oct 2024 12:08:43 -0700 Subject: [PATCH] Pokemon Emerald: Another wonder trade fix (#4014) * Pokemon Emerald: Another guarded write on wonder trades * Pokemon Emerald: Reorder sending wonder trade and erasing data In case the guarded write fails --- worlds/pokemon_emerald/client.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/worlds/pokemon_emerald/client.py b/worlds/pokemon_emerald/client.py index c91b7d3e..4405b340 100644 --- a/worlds/pokemon_emerald/client.py +++ b/worlds/pokemon_emerald/client.py @@ -545,11 +545,12 @@ class PokemonEmeraldClient(BizHawkClient): if trade_is_sent == 0 and wonder_trade_pokemon_data[19] == 2: # Game has wonder trade data to send. Send it to data storage, remove it from the game's memory, # and mark that the game is waiting on receiving a trade - Utils.async_start(self.wonder_trade_send(ctx, pokemon_data_to_json(wonder_trade_pokemon_data))) - await bizhawk.write(ctx.bizhawk_ctx, [ + success = await bizhawk.guarded_write(ctx.bizhawk_ctx, [ (sb1_address + 0x377C, bytes(0x50), "System Bus"), (sb1_address + 0x37CC, [1], "System Bus"), - ]) + ], [guards["SAVE BLOCK 1"]]) + if success: + Utils.async_start(self.wonder_trade_send(ctx, pokemon_data_to_json(wonder_trade_pokemon_data))) elif trade_is_sent != 0 and wonder_trade_pokemon_data[19] != 2: # Game is waiting on receiving a trade. if self.queued_received_trade is not None: