-
-
Notifications
You must be signed in to change notification settings - Fork 9
001 adt binrw refactor #33
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
Merged
Merged
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
- Implement run-length encoding decompression - Integrate with existing compression pipeline - Add RLE to supported compression algorithms
- Implement PTCH header parsing and validation - Add COPY patch type for file replacement - Add BSD0 patch type with bsdiff40 algorithm - Include MD5 verification for patch integrity - Export patch module from library root Patch files are used in Cataclysm+ for binary updates to base files.
- Add automatic PTCH patch detection and application - Transparently apply patches during file reads - Improve error handling for patch files - Better integration with Archive API - Enhanced priority-based file resolution with patch support
- Add check_patch_flags example for flag verification - Add test_patch_chain examples for patch chain testing - Add test_read_patch for direct patch parsing - Add integration tests for patch functionality - Include StormLib reference tests for validation
- Document PTCH format and automatic patch handling - Add patch chain usage examples with CLI - Explain COPY and BSD0 patch types - Update feature documentation
- Add ChunkHeader abstraction for consistent chunk handling - Add ChunkId type-safe identifier with validation - Implement ChunkDiscovery for fast chunk enumeration - Add FileType detection for root/tex0/obj0/lod files This establishes the foundation for two-phase parsing: Phase 1 (discovery) scans for chunks, Phase 2 parses selectively.
Add chunk-specific modules with declarative parsing: - mcnk/ - MCNK terrain chunks with all subchunks (header, mcvt, mcnr, mcly, mcal, mcsh, mccv, etc.) - mh2o/ - Water chunks (header, instance, vertex) - placement.rs - Doodad and WMO placement (MDDF, MODF) - simple.rs - Header-only chunks (MVER, MHDR, etc.) - strings.rs - String tables (MWMO, MMDX) - blend_mesh.rs - Blend mesh chunks (MBMH, MBBB, MBNV) All parsers use BinRead for type safety and maintainability.
- RootParser for root ADT files with MCNK chunks - SplitParser for tex0 and obj0 split files - Two-phase parsing: discovery then selective chunk parsing - Version-aware parsing for different WoW expansions - Proper handling of Cataclysm+ split file architecture
- Add RootAdt, Tex0Adt, Obj0Adt, LodAdt typed APIs - Add AdtSet for loading complete split file sets - Add merger utilities for combining split files - Add SplitFileSet for automatic split file discovery High-level APIs replace low-level chunk map access with type-safe interfaces for better ergonomics and safety.
- AdtBuilder for programmatic ADT construction - BuiltAdt intermediate representation - Binary serializer for writing ADT files - Pre-serialization validation Enables creation of new ADT files from code with proper structure validation before serialization.
- Update lib.rs to export new modular architecture - Enhance error types with chunk-level context - Improve version detection for split files - Fix Cataclysm split root file detection - Add ParsedAdt enum for type-safe parsing results Core changes to integrate BinRead-based parsing throughout.
- Split compliance tests: vanilla, tbc, wotlk, cataclysm, mop - Remove old trinitycore.rs consolidated test file - Update integration tests for new parser architecture - All Cataclysm tests now passing with split file support Better organization enables targeted testing per expansion.
- Add builder tests for ADT construction - Add modification tests for ADT editing - Include test data for validation
Examples: - load_split_adt - Demonstrate split file loading and merging - selective_parsing - Show performance-optimized chunk parsing Benchmarks: - discovery - Benchmark chunk discovery phase - parsing - Benchmark typed chunk parsing Remove old parser_benchmark.rs replaced by focused benchmarks.
Replaced by focused discovery.rs and parsing.rs benchmarks.
- Update dependencies for BinRead support - Add benchmark configurations - Update package metadata
- Update for new BinRead-based parser architecture - Support for split file loading via AdtSet - Improved error handling with chunk context - Better version detection and reporting
- Better patch chain handling in extraction - Improved error reporting for patch files - Enhanced file listing with patch information
Remove temporary Python analysis utilities: - M2 parser and enhanced parser - Batch testing tools - Coordinate system utilities - Quaternion helpers - Validation tools These were development utilities no longer needed after M2 format fixes were completed.
- Update workspace dependencies - Cleanup Cargo.lock (2,272 lines reduced) - Update .gitignore for new build artifacts - Update CLI workspace configuration
Main CHANGELOG: - ADT BinRead-based parser rewrite with two-phase architecture - MPQ PTCH patch file support for Cataclysm+ - Expanded test coverage and new examples - Removed Python M2 analysis tools wow-mpq CHANGELOG: - PTCH patch file support (COPY and BSD0 patches) - RLE compression algorithm - Enhanced PatchChain with automatic patch application - Comprehensive test coverage wow-adt CHANGELOG: - Complete BinRead-based parser rewrite (v0.7.0) - New modular architecture with 15+ modules - High-level type-safe APIs - Enhanced split file support - Test suite reorganized by expansion - All Cataclysm tests passing
Update test_jenkins_hashlittle2_attributes to expect 0xE2 instead of 0xE9 for the '(attributes)' test case with 48-bit hash. The previous expected value was incorrect.
Fix critical bug in apply_bsd0_patch where control blocks, data blocks, and extra blocks were being extracted from compressed data (patch.data) instead of decompressed data (bsdiff_data). This caused incorrect values to be read from wrong offsets in the compressed data. For example, mov_data_length was being read as 512 instead of the correct value of 1. Changes: - Extract ctrl_block from bsdiff_data instead of patch.data (line 181) - Extract data_block from bsdiff_data instead of patch.data (line 182) - Extract extra_block from bsdiff_data instead of patch.data (line 183) - Update validation to check bsdiff_data.len() instead of patch.data.len() All 5 BSD0 patch tests now pass.
Fix incorrect placeholder size when reserving space for MCNK headers during serialization. The McnkHeader struct is 136 bytes when serialized, so the total placeholder needs to be 8 (chunk header) + 136 (MCNK header) = 144 bytes, not 8 + 128 = 136 bytes as previously allocated. This caused the serializer to not reserve enough space for the header, leading to offset calculation errors when parsing serialized ADT files. Changes: - write_minimal_mcnk_chunk: Changed placeholder from vec![0u8; 8 + 128] to vec![0u8; 8 + 136] (line 274) - write_mcnk_chunk: Changed placeholder from vec![0u8; 8 + 128] to vec![0u8; 8 + 136] (line 410) - Updated comments to reflect correct sizes Fixes 3 ADT integration tests: - test_mcnk_subchunk_offset_verification - test_modify_terrain_heights_round_trip - test_modify_multiple_mcnk_chunks
Fix 3 doctest compilation errors caused by type mismatches and missing imports: 1. adt_builder.rs (line 615): ParsedAdt::Root returns Box<RootAdt>, so unbox it with *root before passing to from_parsed() 2. merger.rs (line 46): Same issue - unbox *root before passing to merge_split_files() 3. split_set.rs (line 69): Add PathBuf to imports since it's used in the doctest example All 96 wow-adt doc tests now pass.
Fix incorrect MogpHeader size calculation that was using std::mem::size_of::<MogpHeader>() which returns 88 bytes (due to Vec fields using extra space in memory layout) instead of the actual serialized size of 68 bytes. This caused the parser to read from the wrong offset when extracting nested chunks from MOGP data, preventing MORB and other nested chunks from being parsed correctly. Changes: - group_parser.rs (line 204): Replace std::mem::size_of calculation with hardcoded 68 bytes and add explanatory comment - group_parser_test.rs (line 77): Update test to use correct size of 68 bytes instead of 88 Fixes: - MORB chunk parsing (additional render batches) - test_morb_chunk_parsing - test_parse_group_header
Apply consistent formatting to examples, source files, and tests across wow-mpq, wow-adt, and warcraft-rs CLI. Changes include line length adjustments, import organization, and whitespace normalization.
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.
Pull Request
Summary
This PR implements two major feature sets: MPQ patch file support for Cataclysm+ archives and a complete ADT parser rewrite using BinRead with a two-phase architecture. The MPQ enhancements enable transparent patch chain handling with RLE compression and PTCH format support. The ADT refactor replaces manual byte manipulation with declarative parsing, adds full split file support (root/tex0/obj0/lod), and provides high-level type-safe APIs for all WoW expansions (1.12.1-5.4.8).
Type of Change
Changes Made
MPQ Format Enhancements
ADT Parser Complete Rewrite (v0.7.0)
Testing & Quality Improvements
CLI Enhancements
Project Cleanup
Related Issues
Related to ongoing format support improvements for modern WoW versions (Cataclysm 4.3.4+).
Testing
Test Cases Added/Modified
Test Results
Tested On
WoW Versions Tested
All tests run against original Blizzard MPQ archives from local WoW installations.
Quality Assurance
Code Quality
Required Checks
cargo fmt --all- Code is formattedcargo clippy --all-targets --all-features- No clippy warningscargo test --all-features- All tests passcargo test --no-default-features- Tests pass without featurescargo deny check- No security/license issuescargo doc --workspace --open)Compatibility
Documentation
docs/(format specifications)Benchmarks
Performance Impact
Benchmark Results
Two-phase parsing architecture enables significant performance improvements:
Discovery Phase Benefits:
Selective Parsing Benefits:
Example: Loading heightmap data only (MCVT chunks):
Breaking Changes
API Changes
ADT crate (v0.7.0) - Internal refactor, improved external API:
RootAdt,Tex0Adt,Obj0Adt,AdtSetAdtBuilderfor programmatic constructionMPQ crate - Additive only (no breaking changes):
Migration Guide
For users of the ADT crate:
Old approach (pre-v0.7.0):
New approach (v0.7.0+):
Builder pattern (new in v0.7.0):
Security Considerations
Security Enhancements
Patch File Integrity:
Existing Security Maintained:
Additional Context
Dependencies
Added:
binrw(v0.13) - Declarative binary parsing frameworkUpdated:
Technical Decisions
Why BinRead for ADT parsing?
Why two-phase parsing architecture?
Why modular chunk organization?
Why split file architecture focus?
Known Limitations
None identified. All Cataclysm split file tests passing, full expansion coverage (1.12.1-5.4.8) validated with original Blizzard archives.
Screenshots/Examples
Load split ADT file set (Cataclysm+):
Selective chunk parsing example:
Patch chain handling:
Reviewer Notes
Areas of Focus
Patch file implementation (
file-formats/archives/wow-mpq/src/patch/)BinRead chunk parsers (
file-formats/world-data/wow-adt/src/chunks/)Split file merging (
file-formats/world-data/wow-adt/src/merger.rs)API ergonomics (
file-formats/world-data/wow-adt/src/api/)Test coverage (
file-formats/world-data/wow-adt/tests/compliance/)Questions for Reviewers
Architecture Highlights
This refactor establishes patterns for future format work:
The patch file infrastructure enables Cataclysm+ archive handling, critical for modern WoW private server development.
By submitting this PR, I confirm that: