-
Notifications
You must be signed in to change notification settings - Fork 264
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
Conversation
rust/src/wow/db.rs
Outdated
{ | ||
let v_bytes = v.to_le_bytes(); | ||
let (_, result) = T::read(BitSlice::from_slice(&v_bytes), ())?; | ||
reader.seek(std::io::SeekFrom::Start(old)).unwrap(); |
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.
not entirely sure, but can you use reader.seek_last_read()
here?
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.
don't think so, we're seeking and then skipping
rust/src/wow/db.rs
Outdated
|
||
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(); |
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.
looks like they implemented From<Error> for DekuError
, so i think you should be able to just do:
let old = reader.seek(std::io::SeekFrom::Current(0i64)).unwrap(); | |
let old = reader.seek(std::io::SeekFrom::Current(0))?; |
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.
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>>`
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.
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, |
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.
interesting, does this not throw things off?
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.
we're always advancing according to header.record_size and seeking within the record ourselves now
b9e415b
to
63270d9
Compare
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.
I think this should be ready for review. I fixed both WoW and Unity loading. |
No description provided.