1
0
Fork 0
mirror of https://codeberg.org/icewind/vbsp.git synced 2026-06-04 19:14:08 +02:00

fold BspVersion into Header, use binrw magic for FourCC

This commit is contained in:
Quaternions 2025-02-16 14:12:16 -08:00
commit d0a1666539
2 changed files with 9 additions and 19 deletions

View file

@ -11,23 +11,8 @@ pub struct BspFile<'a> {
impl<'a> BspFile<'a> {
pub fn new(data: &'a [u8]) -> BspResult<Self> {
const EXPECTED_HEADER: Header = Header {
v: b'V',
b: b'B',
s: b'S',
p: b'P',
};
// TODO: Use this to decide on the version to parse it as
const EXPECTED_VERSION: u32 = 0x14;
let mut cursor = Cursor::new(data);
let header: Header = cursor.read_le()?;
let version: u32 = cursor.read_le()?;
if header != EXPECTED_HEADER || version != EXPECTED_VERSION {
return Err(BspError::UnexpectedHeader(header));
}
let directories = cursor.read_le()?;
Ok(BspFile {