From 781ec534dc6729d284f23ec310b525209b27b2a1 Mon Sep 17 00:00:00 2001 From: Exempt-Medic <60412657+Exempt-Medic@users.noreply.github.com> Date: Fri, 31 May 2024 14:56:05 -0400 Subject: [PATCH 1/3] Make excluded and priority locations excluded --- Main.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Main.py b/Main.py index de6b467f93d9..c0aac1771c9c 100644 --- a/Main.py +++ b/Main.py @@ -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 + except: + pass else: - location.progress_type = LocationProgressType.PRIORITY + 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: From 6ef626e3fe29d2a1ccdc2aeeb52edc50286861d9 Mon Sep 17 00:00:00 2001 From: Exempt-Medic <60412657+Exempt-Medic@users.noreply.github.com> Date: Fri, 31 May 2024 15:37:37 -0400 Subject: [PATCH 2/3] Only pass on KeyError --- Main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Main.py b/Main.py index c0aac1771c9c..2bad2e0c63cb 100644 --- a/Main.py +++ b/Main.py @@ -128,7 +128,7 @@ def main(args, seed=None, baked_server_options: Optional[Dict[str, object]] = No for location_name in multiworld.worlds[player].options.priority_locations.value: try: location = multiworld.get_location(location_name, player) - except: + except KeyError: pass else: if location.progress_type != LocationProgressType.EXCLUDED: From c3ed6be0608d67f983d696a87955816aa12171ba Mon Sep 17 00:00:00 2001 From: Exempt-Medic <60412657+Exempt-Medic@users.noreply.github.com> Date: Fri, 31 May 2024 22:37:21 -0400 Subject: [PATCH 3/3] Alternative/Clearer format --- Main.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Main.py b/Main.py index 2bad2e0c63cb..56b3a6545db2 100644 --- a/Main.py +++ b/Main.py @@ -129,13 +129,13 @@ def main(args, seed=None, baked_server_options: Optional[Dict[str, object]] = No try: location = multiworld.get_location(location_name, player) except KeyError: - pass + continue + + if location.progress_type != LocationProgressType.EXCLUDED: + location.progress_type = LocationProgressType.PRIORITY else: - 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) + 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.