Skip to content

Commit

Permalink
Core: Make excluded locations and priority locations excluded and rem…
Browse files Browse the repository at this point in the history
…ove unreachable code (ArchipelagoMW#3424)

* Make excluded and priority locations excluded

* Only pass on KeyError

* Alternative/Clearer format
  • Loading branch information
Exempt-Medic authored Jul 26, 2024
1 parent 9d36ad0 commit 6994f86
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions Main.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,19 @@ def main(args, seed=None, baked_server_options: Optional[Dict[str, object]] = No
for player in multiworld.player_ids:
exclusion_rules(multiworld, player, multiworld.worlds[player].options.exclude_locations.value)
multiworld.worlds[player].options.priority_locations.value -= multiworld.worlds[player].options.exclude_locations.value
world_excluded_locations = set()
for location_name in multiworld.worlds[player].options.priority_locations.value:
try:
location = multiworld.get_location(location_name, player)
except KeyError as e: # failed to find the given location. Check if it's a legitimate location
if location_name not in multiworld.worlds[player].location_name_to_id:
raise Exception(f"Unable to prioritize location {location_name} in player {player}'s world.") from e
else:
except KeyError:
continue

if location.progress_type != LocationProgressType.EXCLUDED:
location.progress_type = LocationProgressType.PRIORITY
else:
logger.warning(f"Unable to prioritize location \"{location_name}\" in player {player}'s world because the world excluded it.")
world_excluded_locations.add(location_name)
multiworld.worlds[player].options.priority_locations.value -= world_excluded_locations

# Set local and non-local item rules.
if multiworld.players > 1:
Expand Down

0 comments on commit 6994f86

Please sign in to comment.