Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core: Make excluded locations and priority locations excluded and remove unreachable code #3424

Merged
merged 3 commits into from
Jul 26, 2024

Conversation

Exempt-Medic
Copy link
Member

What is this fixing or adding?

If a location's progress_type was set to EXCLUDED and it was in a user's priority_locations, it would end up prioritized. In contrast, if something is in both exclude_locations and priority_locations, it ends up excluded. This makes it so that dev/world-excluded locations stay excluded and are removed from priority_locations (matching the behavior of using both excluded and priority through user-facing options) and a warning is logged if this overrides a user's priority_locations option.

This also simplifies part of an exception that could not be reached because of an earlier key verification exception with LocationSet key verfication.

How was this tested?

Generations with games that set progress_type and viewing spoiler logs.

@github-actions github-actions bot added affects: core Issues/PRs that touch core and may need additional validation. waiting-on: peer-review Issue/PR has not been reviewed by enough people yet. labels May 31, 2024
@alwaysintreble
Copy link
Collaborator

i would much rather you remove the try except than pass on an exception which could have very bad implications

@Exempt-Medic
Copy link
Member Author

Exempt-Medic commented May 31, 2024

i would much rather you remove the try except than pass on an exception which could have very bad implications

I'm not sure how you can do that, since removing the try/except causes get_location to throw a KeyError for locations that are in the datapackage but do not exist in that particular world. Could make it only pass on KeyError?

@Exempt-Medic Exempt-Medic added the is: bug/fix Issues that are reporting bugs or pull requests that are fixing bugs. label May 31, 2024
Copy link
Collaborator

@ScipioWright ScipioWright left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks fine, a player probably shouldn't get to priority a location if the world has excluded it so the change is good

@Exempt-Medic Exempt-Medic added waiting-on: core-review Issue/PR has been peer-reviewed and is ready to be merged or needs input from a core maintainer. and removed waiting-on: peer-review Issue/PR has not been reviewed by enough people yet. labels Jul 21, 2024
Copy link
Collaborator

@alwaysintreble alwaysintreble left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i still don't like that this is ignoring exceptions. why are you removing handling of user error? world_excluded_locations also seems unnecessary. you can just remove directly from the priority locations set instead of creating another set just to use for removal.

@Exempt-Medic
Copy link
Member Author

i still don't like that this is ignoring exceptions. why are you removing handling of user error? world_excluded_locations also seems unnecessary. you can just remove directly from the priority locations set instead of creating another set just to use for removal.

If you want to do that, feel free. It threw an error for me about modifying while iterating. This is also the same as what the error did earlier, so it's not making it worse

@Exempt-Medic
Copy link
Member Author

Exempt-Medic commented Jul 22, 2024

i still don't like that this is ignoring exceptions. why are you removing handling of user error? world_excluded_locations also seems unnecessary. you can just remove directly from the priority locations set instead of creating another set just to use for removal.

And like I said earlier, this isn't removing user-error, this is handling that fact that locations that fail get_location but are still in the datapackage are supposed to be valid. If you have a better alternative, that maintains this behavior, feel free to PR it

@alwaysintreble
Copy link
Collaborator

And like I said earlier, this isn't removing user-error, this is handling that fact that locations that fail get_location but are still in the datapackage are supposed to be valid. If you have a better alternative, that maintains this behavior, feel free to PR it

According to the diff that's the old behavior which you're removing here?

@Exempt-Medic
Copy link
Member Author

Exempt-Medic commented Jul 22, 2024

i still don't like that this is ignoring exceptions. why are you removing handling of user error? world_excluded_locations also seems unnecessary. you can just remove directly from the priority locations set instead of creating another set just to use for removal.

I keep thinking of new points, so sorry for the third reply, but can you give any example of a user error that does anything here? Every possible error is already covered, as explained in the PR's description. If a user includes a location that doesn't exist at all, it errors far earlier, and if a user includes a location that does exist but not for this particular instance of the game it shouldn't error, and so the continue happens instead.

@alwaysintreble
Copy link
Collaborator

Ah right, the options system validates the names way before this. It still feels wrong to have a try except where we just ignore the exception though. I wonder if it makes sense to at least log a warning?

@Exempt-Medic
Copy link
Member Author

Exempt-Medic commented Jul 22, 2024

Ah right, the options system validates the names way before this. It still feels wrong to have a try except where we just ignore the exception though. I wonder if it makes sense to at least log a warning?

I could add logger.warning(f"Unable to prioritize location \"{location_name}\" in player {player}'s world because it does not exist.") but then excluded locations wouldn't have the same behavior

@ScipioWright
Copy link
Collaborator

I could add logger.warning(f"Unable to prioritize location \"{location_name}\" in player {player}'s world because it does not exist.") but then excluded locations wouldn't have the same behavior

If you did this, would it log an error for each location in a location group?

@Exempt-Medic
Copy link
Member Author

I could add logger.warning(f"Unable to prioritize location \"{location_name}\" in player {player}'s world because it does not exist.") but then excluded locations wouldn't have the same behavior

If you did this, would it log an error for each location in a location group?

Yes, but it handling different from every other thing such as excluded locations, start hints, start location hints, etc. makes me not want to add it, at least not in this PR

@NewSoupVi
Copy link
Member

I am perfectly fine with the try-except with continue and nothing else.

@NewSoupVi NewSoupVi merged commit 6994f86 into ArchipelagoMW:main Jul 26, 2024
16 checks passed
@Exempt-Medic Exempt-Medic deleted the patch-19 branch July 26, 2024 23:58
AustinSumigray pushed a commit to AustinSumigray/Archipelago that referenced this pull request Jan 4, 2025
…ove unreachable code (ArchipelagoMW#3424)

* Make excluded and priority locations excluded

* Only pass on KeyError

* Alternative/Clearer format
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects: core Issues/PRs that touch core and may need additional validation. is: bug/fix Issues that are reporting bugs or pull requests that are fixing bugs. waiting-on: core-review Issue/PR has been peer-reviewed and is ready to be merged or needs input from a core maintainer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants