From 0f6e53859b49299723c04104a09d683572329829 Mon Sep 17 00:00:00 2001 From: Avasam Date: Tue, 16 Jul 2024 14:34:34 -0400 Subject: [PATCH] Use 0x0 for default entrance --- Dolphin scripts/Entrance Randomizer/__main__.py | 7 ++----- Dolphin scripts/Entrance Randomizer/lib/constants.py | 2 +- Dolphin scripts/Entrance Randomizer/lib/utils.py | 12 ++++++------ 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/Dolphin scripts/Entrance Randomizer/__main__.py b/Dolphin scripts/Entrance Randomizer/__main__.py index d76b96c..73e5d20 100644 --- a/Dolphin scripts/Entrance Randomizer/__main__.py +++ b/Dolphin scripts/Entrance Randomizer/__main__.py @@ -79,12 +79,9 @@ async def main_loop(): draw_text( f"From entrance addr: {hex(PreviousArea._previous_area_address).upper()} ", # noqa: SLF001 # pyright: ignore[reportPrivateUsage] ) - if previous_area_id != -1 or state.current_area_new in {starting_area, LevelCRC.MAIN_MENU}: + if previous_area_id or state.current_area_new in {starting_area, LevelCRC.MAIN_MENU}: previous_area_name = PreviousArea.get_name(previous_area_id) - draw_text( - f"From entrance: {hex(previous_area_id).upper()} " - + (f"({previous_area_name})" if previous_area_name else ""), - ) + draw_text(f"From entrance: {hex(previous_area_id).upper()} ({previous_area_name})") else: draw_text( "From entrance: NOT FOUND!!!\n" diff --git a/Dolphin scripts/Entrance Randomizer/lib/constants.py b/Dolphin scripts/Entrance Randomizer/lib/constants.py index a4ba055..dee62f2 100644 --- a/Dolphin scripts/Entrance Randomizer/lib/constants.py +++ b/Dolphin scripts/Entrance Randomizer/lib/constants.py @@ -250,7 +250,7 @@ class LevelCRC(IntEnum): SOFTLOCKABLE_ENTRANCES = { int(LevelCRC.FLOODED_COURTYARD): 8, # From st claire: 7 - int(LevelCRC.EYES_OF_DOOM): 9, + int(LevelCRC.EYES_OF_DOOM): 12, # From Scorpion Temple: 9 int(LevelCRC.VALLEY_OF_SPIRITS): 8, int(LevelCRC.COPACANTI_LAKE): 8, } diff --git a/Dolphin scripts/Entrance Randomizer/lib/utils.py b/Dolphin scripts/Entrance Randomizer/lib/utils.py index 2e25113..b94bff5 100644 --- a/Dolphin scripts/Entrance Randomizer/lib/utils.py +++ b/Dolphin scripts/Entrance Randomizer/lib/utils.py @@ -243,7 +243,7 @@ class PreviousArea: Some entrances are mapped to a different ID than the level the player actually comes from. This maps the fake ID to the real ID. """ - __ALL_LEVELS = ( + __ALL_ENTRANCE_IDS = ( ALL_TRANSITION_AREAS | set(CORRECTED_PREV_ID) | set(LevelCRC) @@ -280,13 +280,13 @@ def get_name(cls, area_id: int): If a "fake ID" is passed, it'll be mapped to the real "from level". """ area = TRANSITION_INFOS_DICT.get(cls.CORRECTED_PREV_ID.get(area_id, area_id)) - return area.name if area else "" + return area.name if area else "Default" @classmethod def __update_previous_area_address(cls): # First check that the current value is a sensible known level previous_area = memory.read_u32(cls._previous_area_address) - if previous_area in cls.__ALL_LEVELS: + if previous_area in cls.__ALL_ENTRANCE_IDS: return previous_area # If not, start iterating over 16-bit blocks, @@ -298,7 +298,7 @@ def __update_previous_area_address(cls): # Check if the current block is a valid level id block_address += 8 previous_area = memory.read_u32(block_address) - if previous_area in cls.__ALL_LEVELS: + if previous_area in cls.__ALL_ENTRANCE_IDS: # Valid id. Assume this is our address cls._previous_area_address = block_address return previous_area @@ -307,8 +307,8 @@ def __update_previous_area_address(cls): block_address += 8 next_prefix = memory.read_u32(block_address) if next_prefix != prefix: - return -1 # We went the entire dynamic data structure w/o finding a valid ID ! - return -1 + return 0 # We went the entire dynamic data structure w/o finding a valid ID ! + return 0 def dump_spoiler_logs(