Fixes the loop issue that doesn't check all RAM addresses before it actually marks the location as "checked"

This commit is contained in:
MarioSpore
2025-08-25 17:03:48 -04:00
parent 7105187ad3
commit 9a6f6f7a75

View File

@@ -121,17 +121,19 @@ class GrinchClient(BizHawkClient):
continue continue
# Grinch ram data may have more than one address to update, so we are going to loop through all addresses in a location # Grinch ram data may have more than one address to update, so we are going to loop through all addresses in a location
# We use a list here to keep track of all our checks. If they are all true, then and only then do we mark that location as checked.
ram_checked_list: list[bool] = []
for addr_to_update in grinch_loc_ram_data.update_ram_addr: for addr_to_update in grinch_loc_ram_data.update_ram_addr:
is_binary = True if not addr_to_update.binary_bit_pos is None else False is_binary = True if not addr_to_update.binary_bit_pos is None else False
current_ram_address_value = int.from_bytes((await bizhawk.read(ctx.bizhawk_ctx, [( current_ram_address_value = int.from_bytes((await bizhawk.read(ctx.bizhawk_ctx, [(
addr_to_update.ram_address, addr_to_update.bit_size, "MainRAM")]))[0], "little") addr_to_update.ram_address, addr_to_update.bit_size, "MainRAM")]))[0], "little")
if is_binary: if is_binary:
if (current_ram_address_value & (1 << addr_to_update.binary_bit_pos)) > 0: ram_checked_list.append((current_ram_address_value & (1 << addr_to_update.binary_bit_pos)) > 0)
local_locations_checked.append(GrinchLocation.get_apid(grinch_loc_ram_data.id))
else: else:
expected_int_value = addr_to_update.value expected_int_value = addr_to_update.value
if expected_int_value == current_ram_address_value: ram_checked_list.append(expected_int_value == current_ram_address_value)
local_locations_checked.append(GrinchLocation.get_apid(grinch_loc_ram_data.id)) if all(ram_checked_list):
local_locations_checked.append(GrinchLocation.get_apid(grinch_loc_ram_data.id))
# Update the AP server with the locally checked list of locations (In other words, locations I found in Grinch) # Update the AP server with the locally checked list of locations (In other words, locations I found in Grinch)
await ctx.check_locations(local_locations_checked) await ctx.check_locations(local_locations_checked)