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

Add support for recs version 63.0 and above #112

Merged
merged 3 commits into from
Nov 14, 2024

Conversation

Kjir
Copy link
Contributor

@Kjir Kjir commented Oct 29, 2024

These changes allow the library to parse the newer save format for version 63.0.
There are many unknown things that were added and they are not parsed, but at least the parsing does not fail and the existing functionality is preserved.

There is a new action type, and some of the payload I managed to reverse-engineer, but not everything that is in it.

@@ -61,14 +61,16 @@
Embedded(IfThenElse(lambda ctx: ctx._.restore_time == 0,
Struct(
"objects"/RepeatUpTo(b'\x00', existing_object),
Const(b'\x00\x0b'),
Find(b'\x00\x0b', None), # Some additional data was added in 63.0, so the separator is not aligned anymore. Since we don't know what this data represents, we skip it.
Copy link
Owner

Choose a reason for hiding this comment

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

This will result in incorrectly parsing the objects. The separator is almost certainly still in place.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The separator is in place, but 3000-4000 bytes later than expected. The find simply skips the data in-between

Copy link
Owner

Choose a reason for hiding this comment

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

It's later than expected because the preceding objects are not being parsed correctly, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I dug deeper and was able to revert this part by correcting the parsing of combat actions. Something changed in case the AI is of type 15 or 17, whatever that means. I also moved around a byte to make some variables align correctly and get meaningful values.
This seems to be working for current files, but the tests seem to not work for older versions of the recs. I'll have to investigate further why that is. I probably forgot a conditional somewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Found and corrected the last remaining mistake - now it should be good

@Kjir
Copy link
Contributor Author

Kjir commented Nov 6, 2024

I tested the latest version of this pull request on a bunch of recs, old (still DE) and new. The current version of aoc-mgz parses without exception 237/362 recs (65.47%), whereas the version in this PR parses 292/362 recs (80.66%) using the fast parser (as in test_files.py)

@Kjir
Copy link
Contributor Author

Kjir commented Nov 7, 2024

Fixes #111

@happyleavesaoc
Copy link
Owner

Thanks, this looks good.

@happyleavesaoc
Copy link
Owner

It does look like the tests are failing though, which suggests these changes broke parsing older versions. The tests currently pass on the main branch.

@Kjir
Copy link
Contributor Author

Kjir commented Nov 13, 2024

This is very weird, the tests pass when I run them locally

@happyleavesaoc
Copy link
Owner

They fail locally for me as well.

@Kjir
Copy link
Contributor Author

Kjir commented Nov 14, 2024

I just realized that I forgot to push a commit where I fixed that specific issue 🤦

@happyleavesaoc happyleavesaoc merged commit 857d7c9 into happyleavesaoc:master Nov 14, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants