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

new deku #747

Merged
merged 6 commits into from
Jan 24, 2025
Merged

new deku #747

merged 6 commits into from
Jan 24, 2025

Conversation

magcius
Copy link
Owner

@magcius magcius commented Jan 22, 2025

No description provided.

rust/Cargo.toml Outdated Show resolved Hide resolved
rust/src/unity/types/binary.rs Show resolved Hide resolved
rust/src/unity/types/common.rs Outdated Show resolved Hide resolved
rust/src/unity/types/common.rs Outdated Show resolved Hide resolved
rust/src/unity/types/common.rs Outdated Show resolved Hide resolved
rust/src/unity/types/wasm.rs Outdated Show resolved Hide resolved
rust/src/wow/db.rs Outdated Show resolved Hide resolved
{
let v_bytes = v.to_le_bytes();
let (_, result) = T::read(BitSlice::from_slice(&v_bytes), ())?;
reader.seek(std::io::SeekFrom::Start(old)).unwrap();
Copy link
Collaborator

Choose a reason for hiding this comment

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

not entirely sure, but can you use reader.seek_last_read() here?

Copy link
Owner Author

Choose a reason for hiding this comment

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

don't think so, we're seeking and then skipping


fn read_field_to_u32<R: deku::no_std_io::Read + deku::no_std_io::Seek>(reader: &mut Reader<R>, field_offset_bits: usize, field_size_bits: usize) -> Result<u32, DekuError> {
// Assumes the reader points to the start of the record
let old = reader.seek(std::io::SeekFrom::Current(0i64)).unwrap();
Copy link
Collaborator

Choose a reason for hiding this comment

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

looks like they implemented From<Error> for DekuError, so i think you should be able to just do:

Suggested change
let old = reader.seek(std::io::SeekFrom::Current(0i64)).unwrap();
let old = reader.seek(std::io::SeekFrom::Current(0))?;

Copy link
Owner Author

Choose a reason for hiding this comment

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

Do I need to import a trait or something?

error[E0277]: `?` couldn't convert the error to `deku::DekuError`
   --> src\wow\db.rs:215:61
    |
215 |         let old = reader.seek(std::io::SeekFrom::Current(0))?;
    |                                                             ^ the trait `From<std::io::Error>` is not implemented for `deku::DekuError`, which is required by `std::result::Result<String, deku::DekuError>: FromResidual<std::result::Result<Infallible, std::io::Error>>`
    |
    = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
    = help: the following other types implement trait `From<T>`:
              <deku::DekuError as From<Infallible>>
              <deku::DekuError as From<TryFromSliceError>>
              <deku::DekuError as From<std::num::TryFromIntError>>
    = note: required for `std::result::Result<String, deku::DekuError>` to implement `FromResidual<std::result::Result<Infallible, std::io::Error>>` 

Copy link
Collaborator

Choose a reason for hiding this comment

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

oh i'm dumb, they implemented From<DekuError> for Error lol. looks like one thing you could do is

    let old = reader.seek(std::io::SeekFrom::Current(0))
        .map_err(|err| DekuError::Io(error.kind()))?;

light_param_ids: [u16; 8],
pub unk: u16,
Copy link
Collaborator

Choose a reason for hiding this comment

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

interesting, does this not throw things off?

Copy link
Owner Author

Choose a reason for hiding this comment

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

we're always advancing according to header.record_size and seeking within the record ourselves now

@magcius magcius force-pushed the new-deku branch 2 times, most recently from b9e415b to 63270d9 Compare January 23, 2025 02:15
This was the cause of all of our WoW rendering failures with new-deku. Unfortunate we can't (yet?) use Deku for this part, but honestly I think the shift + mask is better than a loop anyway.
The deku::byte_offset trick we do for alignment requires reader.bits_read to be correct, as that's the number we pad by. In our PackedVec implementations, we read a u8, and then later skip over it, which double-counts from the perspective of reader.bits_read. Fix this by adjusting after we read it.
@magcius magcius marked this pull request as ready for review January 24, 2025 05:49
@magcius
Copy link
Owner Author

magcius commented Jan 24, 2025

I think this should be ready for review. I fixed both WoW and Unity loading.

@magcius magcius merged commit b5b857d into main Jan 24, 2025
2 checks passed
@magcius magcius deleted the new-deku branch January 24, 2025 08:10
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