Skip to content

Commit

Permalink
Use 0x0 for default entrance
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam committed Jul 16, 2024
1 parent 1a63548 commit 0f6e538
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
7 changes: 2 additions & 5 deletions Dolphin scripts/Entrance Randomizer/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion Dolphin scripts/Entrance Randomizer/lib/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
12 changes: 6 additions & 6 deletions Dolphin scripts/Entrance Randomizer/lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -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(
Expand Down

0 comments on commit 0f6e538

Please sign in to comment.