mirror of
https://codeberg.org/icewind/vbsp.git
synced 2026-06-03 18:54:05 +02:00
assert that reading uses the correct amount of bytes
This commit is contained in:
parent
fedfccacda
commit
9398ea7cf5
2 changed files with 12 additions and 1 deletions
|
|
@ -299,6 +299,7 @@ pub struct Leaf {
|
|||
pub leaf_face_count: u16,
|
||||
pub first_leaf_brush: u16,
|
||||
pub leaf_brush_count: u16,
|
||||
#[br(pad_size_to = 4)]
|
||||
pub leaf_watter_data_id: i16,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
use crate::*;
|
||||
use binrw::BinReaderExt;
|
||||
use std::any::type_name;
|
||||
use std::borrow::Cow;
|
||||
use std::mem::size_of;
|
||||
|
||||
|
|
@ -44,7 +45,16 @@ impl<R: BinReaderExt + Read> LumpReader<R> {
|
|||
where
|
||||
T::Args: Default,
|
||||
{
|
||||
Ok(self.inner.read_le()?)
|
||||
let start = self.inner.stream_position().unwrap() as usize;
|
||||
let result = self.inner.read_le()?;
|
||||
let end = self.inner.stream_position().unwrap() as usize;
|
||||
debug_assert_eq!(
|
||||
end - start,
|
||||
size_of::<T>(),
|
||||
"Incorrect number of bytes consumed while reading a {}",
|
||||
type_name::<T>()
|
||||
);
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
pub fn read_visdata(&mut self) -> BspResult<VisData> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue