OOT: Fix incorrect region accessibility after update_reachable_regions() (#3712)
`CollectionState.update_reachable_regions()` un-stales the state for all players, but when checking `OOTRegion.can_reach()`, it would only update OOT's age region accessibility when the state was stale, so if the state was always un-staled by `update_reachable_regions()` immediately before `OOTRegion.can_reach()`, OOT's age region accessibility would never update. This patch fixes the issue by replacing use of CollectionState.stale with a separate stale state dictionary specific to OOT that is only un-staled by `_oot_update_age_reachable_regions()`. OOT's collect() and remove() implementations have been updated to stale the new OOT-specific state.
This commit is contained in:
parent
96542fb2d8
commit
dae3fe188d
|
@ -64,7 +64,7 @@ class OOTRegion(Region):
|
|||
return None
|
||||
|
||||
def can_reach(self, state):
|
||||
if state.stale[self.player]:
|
||||
if state._oot_stale[self.player]:
|
||||
stored_age = state.age[self.player]
|
||||
state._oot_update_age_reachable_regions(self.player)
|
||||
state.age[self.player] = stored_age
|
||||
|
|
|
@ -8,12 +8,17 @@ from .Hints import HintArea
|
|||
from .Items import oot_is_item_of_type
|
||||
from .LocationList import dungeon_song_locations
|
||||
|
||||
from BaseClasses import CollectionState
|
||||
from BaseClasses import CollectionState, MultiWorld
|
||||
from worlds.generic.Rules import set_rule, add_rule, add_item_rule, forbid_item
|
||||
from ..AutoWorld import LogicMixin
|
||||
|
||||
|
||||
class OOTLogic(LogicMixin):
|
||||
def init_mixin(self, parent: MultiWorld):
|
||||
# Separate stale state for OOTRegion.can_reach() to use because CollectionState.update_reachable_regions() sets
|
||||
# `self.state[player] = False` for all players without updating OOT's age region accessibility.
|
||||
self._oot_stale = {player: True for player, world in parent.worlds.items()
|
||||
if parent.worlds[player].game == "Ocarina of Time"}
|
||||
|
||||
def _oot_has_stones(self, count, player):
|
||||
return self.has_group("stones", player, count)
|
||||
|
@ -92,9 +97,9 @@ class OOTLogic(LogicMixin):
|
|||
return False
|
||||
|
||||
# Store the age before calling this!
|
||||
def _oot_update_age_reachable_regions(self, player):
|
||||
self.stale[player] = False
|
||||
for age in ['child', 'adult']:
|
||||
def _oot_update_age_reachable_regions(self, player):
|
||||
self._oot_stale[player] = False
|
||||
for age in ['child', 'adult']:
|
||||
self.age[player] = age
|
||||
rrp = getattr(self, f'{age}_reachable_regions')[player]
|
||||
bc = getattr(self, f'{age}_blocked_connections')[player]
|
||||
|
|
|
@ -1301,6 +1301,7 @@ class OOTWorld(World):
|
|||
# the appropriate number of keys in the collection state when they are
|
||||
# picked up.
|
||||
def collect(self, state: CollectionState, item: OOTItem) -> bool:
|
||||
state._oot_stale[self.player] = True
|
||||
if item.advancement and item.special and item.special.get('alias', False):
|
||||
alt_item_name, count = item.special.get('alias')
|
||||
state.prog_items[self.player][alt_item_name] += count
|
||||
|
@ -1313,8 +1314,12 @@ class OOTWorld(World):
|
|||
state.prog_items[self.player][alt_item_name] -= count
|
||||
if state.prog_items[self.player][alt_item_name] < 1:
|
||||
del (state.prog_items[self.player][alt_item_name])
|
||||
state._oot_stale[self.player] = True
|
||||
return True
|
||||
return super().remove(state, item)
|
||||
changed = super().remove(state, item)
|
||||
if changed:
|
||||
state._oot_stale[self.player] = True
|
||||
return changed
|
||||
|
||||
|
||||
# Helper functions
|
||||
|
@ -1389,7 +1394,7 @@ class OOTWorld(World):
|
|||
# If free_scarecrow give Scarecrow Song
|
||||
if self.free_scarecrow:
|
||||
all_state.collect(self.create_item("Scarecrow Song"), prevent_sweep=True)
|
||||
all_state.stale[self.player] = True
|
||||
all_state._oot_stale[self.player] = True
|
||||
|
||||
return all_state
|
||||
|
||||
|
|
Loading…
Reference in New Issue