diff --git a/Main.py b/Main.py index 61934050..92a4128e 100644 --- a/Main.py +++ b/Main.py @@ -26,7 +26,7 @@ from Fill import sell_potions, sell_keys, balance_multiworld_progression, balanc from ItemList import generate_itempool, difficulties, fill_prizes, customize_shops from Utils import output_path, parse_player_names -__version__ = '0.3.1.1-u' +__version__ = '0.3.1.0-u' class EnemizerError(RuntimeError): diff --git a/MultiClient.py b/MultiClient.py index 66c66e82..bf64a2d7 100644 --- a/MultiClient.py +++ b/MultiClient.py @@ -53,6 +53,11 @@ class Context: self.rom = None self.auth = None self.total_locations = None + self.mode_flags = None + self.key_drop_mode = False + self.shop_mode = False + self.retro_mode = False + self.ignore_count = 0 def color_code(*args): codes = {'reset': 0, 'bold': 1, 'underline': 4, 'black': 30, 'red': 31, 'green': 32, 'yellow': 33, 'blue': 34, @@ -88,7 +93,8 @@ SCOUTREPLY_LOCATION_ADDR = SAVEDATA_START + 0x4D8 # 1 byte SCOUTREPLY_ITEM_ADDR = SAVEDATA_START + 0x4D9 # 1 byte SCOUTREPLY_PLAYER_ADDR = SAVEDATA_START + 0x4DA # 1 byte SHOP_ADDR = SAVEDATA_START + 0x302 # 2 bytes? -DYNAMIC_TOTAL_ADDR = SAVEDATA_START + 0x33E +DYNAMIC_TOTAL_ADDR = SAVEDATA_START + 0x33E # 2 bytes +MODE_FLAGS = SAVEDATA_START + 0x33D # 1 byte SHOP_SRAM_LEN = 0x29 # 41 tracked items location_shop_order = [Regions.shop_to_location_table.keys()] + [Regions.retro_shops.keys()] @@ -776,7 +782,8 @@ async def console_loop(ctx : Context): get_location_name_from_address(item.location), index, len(ctx.items_received))) if command[0] == '/missing': - for location in [k for k, v in Regions.lookup_name_to_id.items() if type(v) is int]: + for location in [k for k, v in Regions.lookup_name_to_id.items() + if type(v) is int and not filter_location(ctx, k)]: if location not in ctx.locations_checked: logging.info('Missing: ' + location) if command[0] == '/getitem' and len(command) > 1: @@ -804,6 +811,16 @@ def get_location_name_from_address(address): return Regions.lookup_id_to_name.get(address, f'Unknown location (ID:{address})') +def filter_location(ctx, location): + if not ctx.key_drop_mode and ('Key Drop' in location or 'Pot Key' in location): + return True + if not ctx.shop_mode and location in Regions.flat_normal_shops: + return True + if not ctx.retro_mode and location in Regions.flat_retro_shops: + return True + return False + + async def track_locations(ctx : Context, roomid, roomdata): new_locations = [] @@ -813,10 +830,20 @@ async def track_locations(ctx : Context, roomid, roomdata): if ttl > 0: ctx.total_locations = ttl + if ctx.mode_flags is None: + flags = await snes_read(ctx, MODE_FLAGS, 1) + ctx.key_drop_mode = flags[0] & 0x1 + ctx.shop_mode = flags[0] & 0x2 + ctx.retro_mode = flags[0] & 0x4 + def new_check(location): ctx.locations_checked.add(location) - logging.info(f"New check: {location} ({len(ctx.locations_checked)}/{ctx.total_locations})") - new_locations.append(Regions.lookup_name_to_id[location]) + ignored = filter_location(ctx, location) + if ignored: + ctx.ignore_count += 1 + else: + logging.info(f"New check: {location} ({len(ctx.locations_checked)-ctx.ignore_count}/{ctx.total_locations})") + new_locations.append(Regions.lookup_name_to_id[location]) try: if roomid in location_shop_ids: diff --git a/Rom.py b/Rom.py index cefe7313..1430aec5 100644 --- a/Rom.py +++ b/Rom.py @@ -27,7 +27,7 @@ from EntranceShuffle import door_addresses, exit_ids JAP10HASH = '03a63945398191337e896e5771f77173' -RANDOMIZERBASEHASH = '0a34dc667a29125f09b10aeb1e06b83c' +RANDOMIZERBASEHASH = '0de33d06fdb9c8cac765047037b39363' class JsonRom(object): @@ -774,6 +774,9 @@ def patch_rom(world, rom, player, team, enemized, is_mystery=False): if world.keydropshuffle[player]: rom.write_byte(0x140000, 1) + multiClientFlags = ((0x1 if world.keydropshuffle[player] else 0) | (0x2 if world.shopsanity[player] else 0) + | (0x4 if world.retro[player] else 0)) + rom.write_byte(0x140001, multiClientFlags) write_int16(rom, 0x187010, credits_total) # dynamic credits if credits_total != 216: diff --git a/asm/keydropshuffle.asm b/asm/keydropshuffle.asm index a150774f..70e80047 100644 --- a/asm/keydropshuffle.asm +++ b/asm/keydropshuffle.asm @@ -26,7 +26,7 @@ Sprite_LoadProperties: org $288000 ;140000 ShuffleKeyDrops: db 0 -ShuffleKeyDropsReserved: +MultiClientFlags: ; 140001 -> stored in SRAM at 7ef33d db 0 LootTable: ;PC: 140002 diff --git a/data/base2current.bps b/data/base2current.bps index fabbaa26..f30bfa99 100644 Binary files a/data/base2current.bps and b/data/base2current.bps differ