-
Notifications
You must be signed in to change notification settings - Fork 45
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
Conversation
mgz/header/initial.py
Outdated
@@ -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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
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) |
Fixes #111 |
Thanks, this looks good. |
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. |
This is very weird, the tests pass when I run them locally |
They fail locally for me as well. |
I just realized that I forgot to push a commit where I fixed that specific issue 🤦 |
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.