From 52c1b04fc82b88569db7c479bd001d0b5801f409 Mon Sep 17 00:00:00 2001 From: el-u <109771707+el-u@users.noreply.github.com> Date: Thu, 18 Apr 2024 18:34:26 +0200 Subject: [PATCH] lufia2ac: prevent 0 byte reads (#3168) --- worlds/lufia2ac/Client.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/worlds/lufia2ac/Client.py b/worlds/lufia2ac/Client.py index 9025a1137b..3c05e6395d 100644 --- a/worlds/lufia2ac/Client.py +++ b/worlds/lufia2ac/Client.py @@ -118,10 +118,11 @@ class L2ACSNIClient(SNIClient): snes_buffered_write(ctx, L2AC_TX_ADDR + 8, total_blue_chests_checked.to_bytes(2, "little")) location_ids: List[int] = [locations_start_id + i for i in range(total_blue_chests_checked)] - loc_data: Optional[bytes] = await snes_read(ctx, L2AC_TX_ADDR + 32, snes_other_locations_checked * 2) - if loc_data is not None: - location_ids.extend(locations_start_id + int.from_bytes(loc_data[2 * i:2 * i + 2], "little") - for i in range(snes_other_locations_checked)) + if snes_other_locations_checked: + loc_data: Optional[bytes] = await snes_read(ctx, L2AC_TX_ADDR + 32, snes_other_locations_checked * 2) + if loc_data is not None: + location_ids.extend(locations_start_id + int.from_bytes(loc_data[2 * i:2 * i + 2], "little") + for i in range(snes_other_locations_checked)) if new_location_ids := [loc_id for loc_id in location_ids if loc_id not in ctx.locations_checked]: await ctx.send_msgs([{"cmd": "LocationChecks", "locations": new_location_ids}])