AHiT: Fix reconnecting rift access regions for starting and plando acts (#4200)

Reconnecting an act in a telescope to a time rift removes the entrances
to the time rift from its access regions because it will be accessible
from the telescope instead.

By doing so early on, as a starting act with insanity act randomizer or
as a plando-ed act, this can happen before the time rift itself has been
reconnected to an act or other time rift. In which case, when later
attempting to connect that time rift to an act or other time rift, the
entrances from the rift access regions will no longer exist, so must be
re-created. The original code was mistakenly re-creating the entrances
from the time rift being reconnected, instead of from the rift access
regions.
This commit is contained in:
Mysteryem 2024-11-22 23:13:57 +00:00 committed by GitHub
parent 2424b79626
commit ba50c947ba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 6 deletions

View File

@ -740,17 +740,20 @@ def is_valid_first_act(world: "HatInTimeWorld", act: Region) -> bool:
def connect_time_rift(world: "HatInTimeWorld", time_rift: Region, exit_region: Region): def connect_time_rift(world: "HatInTimeWorld", time_rift: Region, exit_region: Region):
i = 1 for i, access_region in enumerate(rift_access_regions[time_rift.name], start=1):
while i <= len(rift_access_regions[time_rift.name]): # Matches the naming convention and iteration order in `create_rift_connections()`.
name = f"{time_rift.name} Portal - Entrance {i}" name = f"{time_rift.name} Portal - Entrance {i}"
entrance: Entrance entrance: Entrance
try: try:
entrance = world.multiworld.get_entrance(name, world.player) entrance = world.get_entrance(name)
# Reconnect the rift access region to the new exit region.
reconnect_regions(entrance, entrance.parent_region, exit_region) reconnect_regions(entrance, entrance.parent_region, exit_region)
except KeyError: except KeyError:
time_rift.connect(exit_region, name) # The original entrance to the time rift has been deleted by already reconnecting a telescope act to the
# time rift, so create a new entrance from the original rift access region to the new exit region.
i += 1 # Normally, acts and time rifts are sorted such that time rifts are reconnected to acts/rifts first, but
# starting acts/rifts and act-plando can reconnect acts to time rifts before this happens.
world.get_region(access_region).connect(exit_region, name)
def get_shuffleable_act_regions(world: "HatInTimeWorld") -> List[Region]: def get_shuffleable_act_regions(world: "HatInTimeWorld") -> List[Region]: