From d6c7a043162812f2c3e3f033a650807aefa9b827 Mon Sep 17 00:00:00 2001 From: MarioSpore Date: Fri, 12 Sep 2025 21:27:11 -0400 Subject: [PATCH] Fixed negative int bug --- worlds/grinch/Client.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/worlds/grinch/Client.py b/worlds/grinch/Client.py index 08af824d..ed316e13 100644 --- a/worlds/grinch/Client.py +++ b/worlds/grinch/Client.py @@ -379,9 +379,10 @@ class GrinchClient(BizHawkClient): async def ring_link_input(self, egg_amount: int, ctx: "BizHawkClientContext"): from CommonClient import logger - current_egg_count = int.from_bytes( + game_egg_count = int.from_bytes( (await bizhawk.read(ctx.bizhawk_ctx, [(EGG_COUNT_ADDR, EGG_ADDR_BYTESIZE, "MainRAM")]))[0], "little") - current_egg_count = min(current_egg_count + egg_amount, MAX_EGGS) + non_neg_eggs = game_egg_count + egg_amount if game_egg_count + egg_amount > 0 else 0 + current_egg_count = min(non_neg_eggs, MAX_EGGS) await bizhawk.write(ctx.bizhawk_ctx, [(EGG_COUNT_ADDR, int(current_egg_count).to_bytes(EGG_ADDR_BYTESIZE, "little"), "MainRAM")]) self.previous_egg_count = current_egg_count