BizHawkClient: Add command to get size of memory domain (#4439)

* Mega Man 2: Remove mm2 commands from client if rom size too small
This commit is contained in:
Bryce Wilson
2025-01-11 23:03:31 -08:00
committed by GitHub
parent 70942eda8c
commit 4edca0ce54
3 changed files with 44 additions and 2 deletions

View File

@@ -214,10 +214,19 @@ class MegaMan2Client(BizHawkClient):
last_wily: Optional[int] = None # default to wily 1
async def validate_rom(self, ctx: "BizHawkClientContext") -> bool:
from worlds._bizhawk import RequestFailedError, read
from worlds._bizhawk import RequestFailedError, read, get_memory_size
from . import MM2World
try:
if (await get_memory_size(ctx.bizhawk_ctx, "PRG ROM")) < 0x3FFB0:
if "pool" in ctx.command_processor.commands:
ctx.command_processor.commands.pop("pool")
if "request" in ctx.command_processor.commands:
ctx.command_processor.commands.pop("request")
if "autoheal" in ctx.command_processor.commands:
ctx.command_processor.commands.pop("autoheal")
return False
game_name, version = (await read(ctx.bizhawk_ctx, [(0x3FFB0, 21, "PRG ROM"),
(0x3FFC8, 3, "PRG ROM")]))
if game_name[:3] != b"MM2" or version != bytes(MM2World.world_version):