Skip to content

Commit 25a1ca6

Browse files
el-uqwint
authored andcommitted
lufia2ac: prevent 0 byte reads (ArchipelagoMW#3168)
1 parent 9732059 commit 25a1ca6

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

worlds/lufia2ac/Client.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,11 @@ async def game_watcher(self, ctx: SNIContext) -> None:
118118
snes_buffered_write(ctx, L2AC_TX_ADDR + 8, total_blue_chests_checked.to_bytes(2, "little"))
119119
location_ids: List[int] = [locations_start_id + i for i in range(total_blue_chests_checked)]
120120

121-
loc_data: Optional[bytes] = await snes_read(ctx, L2AC_TX_ADDR + 32, snes_other_locations_checked * 2)
122-
if loc_data is not None:
123-
location_ids.extend(locations_start_id + int.from_bytes(loc_data[2 * i:2 * i + 2], "little")
124-
for i in range(snes_other_locations_checked))
121+
if snes_other_locations_checked:
122+
loc_data: Optional[bytes] = await snes_read(ctx, L2AC_TX_ADDR + 32, snes_other_locations_checked * 2)
123+
if loc_data is not None:
124+
location_ids.extend(locations_start_id + int.from_bytes(loc_data[2 * i:2 * i + 2], "little")
125+
for i in range(snes_other_locations_checked))
125126

126127
if new_location_ids := [loc_id for loc_id in location_ids if loc_id not in ctx.locations_checked]:
127128
await ctx.send_msgs([{"cmd": "LocationChecks", "locations": new_location_ids}])

0 commit comments

Comments
 (0)