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: add correct flags to precollected items #2059

Closed
wants to merge 11 commits into from

Conversation

kindasneaki
Copy link
Collaborator

What is this fixing or adding?

precollected items just had a default flag

How was this tested?

ran generate and multiserver to test the changes

Why I added this

While the flags aren't being used anywhere at the moment I am working on a web based text client that I would like to use the flags to correctly color the precollected items. I think the Archipelago tracker could eventually use this information as well.

MultiServer.py Outdated Show resolved Hide resolved
Co-authored-by: Aaron Wagener <[email protected]>
@Berserker66
Copy link
Member

With only looking at it, and not testing it, I'm pretty sure this will fail to load old multidata files.

@alwaysintreble
Copy link
Collaborator

Tested it, and the flags work correctly on receipt, but yeah it does fail to load old multidata.

@kindasneaki
Copy link
Collaborator Author

Im not sure if this is the greatest way to do it. If not can I get some info on a better way?

MultiServer.py Outdated Show resolved Hide resolved
@ThePhar ThePhar added is: enhancement Issues requesting new features or pull requests implementing new features. affects: core Issues/PRs that touch core and may need additional validation. labels Jul 31, 2023
@ScipioWright ScipioWright added the waiting-on: core-review Issue/PR has been peer-reviewed and is ready to be merged or needs input from a core maintainer. label Feb 16, 2024
Copy link
Member

@black-sliver black-sliver left a comment

Choose a reason for hiding this comment

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

Generating a seed with this and uploading to archipelago.gg will fail as well. You would have to bump the version to 0.4.5 and set multidata's ["minimum_versions"]["server"] to 0.4.5.

I would instead suggest adding decoded_obj["precollected_flags"] and use zip() to iterate over both items and flags at the same time.

--
also this has conflicts now :(

--
i would like to have this in 0.4.5 fwiw

MultiServer.py Outdated Show resolved Hide resolved
@black-sliver black-sliver added waiting-on: author Issue/PR is waiting for feedback or changes from its author. and removed waiting-on: core-review Issue/PR has been peer-reviewed and is ready to be merged or needs input from a core maintainer. labels Feb 22, 2024
@kindasneaki
Copy link
Collaborator Author

Generating a seed with this and uploading to archipelago.gg will fail as well. You would have to bump the version to 0.4.5 and set multidata's ["minimum_versions"]["server"] to 0.4.5.

This doesn't fail when you upload to archipelago.gg but the TODO was outdated for sure 😐

I would instead suggest adding decoded_obj["precollected_flags"] and use zip() to iterate over both items and flags at the same time.

I'm not quite sure what you mean with doing this

@black-sliver
Copy link
Member

This doesn't fail when you upload to archipelago.gg

I have not tested it, but

if items and isinstance(items[0], tuple):

this code does not exist on current archipelago.gg, so by generating a multidata that has a tuple there, the current WebHost will run the old code path, which does

self.start_inventory[slot] = [NetworkItem(item_code, -2, 0) for item_code in item_codes]

where item_code is now a tuple instead of a number, breaking the game.

The way to solve this imo is by providing two separate entries in the multidata:
one is just the codes (as before, fully back compat), and another is just the flags. To get nice-looking code, you can zip the two lists using https://docs.python.org/3/library/itertools.html#itertools.zip_longest , something like

for slot, items in decoded_obj["precollected_items"].items():
    for item_code, item_flags in zip_longest(items, decoded_obj.get("precollected_flags", {}).get(slot, []), fillvalue=0):
        ...

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: enhancement Issues requesting new features or pull requests implementing new features. waiting-on: author Issue/PR is waiting for feedback or changes from its author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants