Enable AI replay parsing and improve robustness#35
Open
liouh wants to merge 3 commits intoaoe2ct:mainfrom
Open
Enable AI replay parsing and improve robustness#35liouh wants to merge 3 commits intoaoe2ct:mainfrom
liouh wants to merge 3 commits intoaoe2ct:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR improves the reliability of the Age of Empires II replay parser and enables support for replay files with AI players, which previously caused parsing failures. This is achieved by implementing a more robust resynchronization mechanism and adding support for several previously unhandled operation types found in AI-driven matches.
Fixes issue #34
Key Changes
parse_operationsloop that validates operation magic numbers (range 1-100). If invalid data is encountered, the parser now attempts to "re-sync" by seeking back and trying the next byte instead of failing the entire match.Verification
Confirmed replays with AI players now parse correctly!
Added a new robust_tests module in
crates/aoe2rec/src/tests.rswith the following unit tests:test_parse_ai_operation: Confirms correct parsing of the new Ai operation.test_parse_operations_resync: Validates the byte-skipping and resynchronization logic when encountering garbage data.test_parse_action_with_failed_data: Ensures that a failure in ActionData parsing results in a None value rather than a parsing error.Verified tests by running:
cargo test -p aoe2rec robust_testsNote: Existing integration tests were left untouched to ensure backward compatibility and avoid dependency on local environment file
beargwyn_vs_kamlesh.aoe2record.