-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: add support for reading wad v3.4 #11
Open
Crauzer
wants to merge
4
commits into
main
Choose a base branch
from
feat/wad-3-4-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
#![feature(exclusive_range_pattern)] | ||
Crauzer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
pub mod core; | ||
pub mod util; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#[derive(Clone, Copy, Debug, PartialEq, Eq)] | ||
#[allow(non_camel_case_types)] | ||
pub struct u24 { | ||
lo: u8, | ||
mi: u8, | ||
hi: u8, | ||
} | ||
|
||
impl u24 { | ||
pub fn new(value: u32) -> Self { | ||
Self { | ||
lo: (value & 0xFF) as u8, | ||
mi: ((value >> 8) & 0xFF) as u8, | ||
hi: ((value >> 16) & 0xFF) as u8, | ||
} | ||
} | ||
} | ||
|
||
impl From<u32> for u24 { | ||
fn from(value: u32) -> Self { | ||
Self::new(value) | ||
} | ||
} | ||
|
||
impl From<u24> for u32 { | ||
fn from(value: u24) -> Self { | ||
(value.hi as u32) << 16 | (value.mi as u32) << 8 | (value.lo as u32) | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn test_u24_new() { | ||
let value = u24::new(0x123456); | ||
assert_eq!(value.hi, 0x12); | ||
assert_eq!(value.mi, 0x34); | ||
assert_eq!(value.lo, 0x56); | ||
} | ||
|
||
#[test] | ||
fn test_u24_from_u32() { | ||
let value: u24 = 0x123456_u32.into(); | ||
assert_eq!(value.hi, 0x12); | ||
assert_eq!(value.mi, 0x34); | ||
assert_eq!(value.lo, 0x56); | ||
} | ||
|
||
#[test] | ||
fn test_u32_from_u24() { | ||
let u24_value = u24::new(0x123456); | ||
let u32_value: u32 = u24_value.into(); | ||
assert_eq!(u32_value, 0x123456); | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
source: crates/league-toolkit/tests/wad.rs | ||
expression: wad.chunks() | ||
--- | ||
{ | ||
2227312568830940929: WadChunk( | ||
path_hash: 2227312568830940929, | ||
data_offset: 10911, | ||
compressed_size: 23023, | ||
uncompressed_size: 131084, | ||
compression_type: Zstd, | ||
is_duplicated: false, | ||
frame_count: 0, | ||
start_frame: 0, | ||
checksum: 3922618146135880204, | ||
), | ||
3349600290122526159: WadChunk( | ||
path_hash: 3349600290122526159, | ||
data_offset: 33934, | ||
compressed_size: 20786, | ||
uncompressed_size: 131084, | ||
compression_type: Zstd, | ||
is_duplicated: false, | ||
frame_count: 0, | ||
start_frame: 0, | ||
checksum: 13212711047613655776, | ||
), | ||
11042693609879973350: WadChunk( | ||
path_hash: 11042693609879973350, | ||
data_offset: 368, | ||
compressed_size: 10543, | ||
uncompressed_size: 32780, | ||
compression_type: Zstd, | ||
is_duplicated: false, | ||
frame_count: 0, | ||
start_frame: 0, | ||
checksum: 3841611443327106610, | ||
), | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
use insta::assert_ron_snapshot; | ||
use league_toolkit::core::wad::Wad; | ||
use std::io::Cursor; | ||
|
||
#[test] | ||
fn read() { | ||
let r = Cursor::new(include_bytes!("wads/UI.en_US.wad.client.v3-4")); | ||
let wad = Wad::mount(r).unwrap(); | ||
|
||
insta::with_settings!({sort_maps => true}, { | ||
assert_ron_snapshot!(wad.chunks()); | ||
}); | ||
} |
Binary file not shown.
Oops, something went wrong.
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.
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 is a mixed endian in order from first byte to last: hi, lo, mi