Added ability to read WAD directory
This commit is contained in:
21
src/wad/header.rs
Normal file
21
src/wad/header.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
pub struct Header {
|
||||
pub wad_id: String,
|
||||
pub num_lumps: u32,
|
||||
pub dir_offset: u32,
|
||||
}
|
||||
|
||||
use crate::utils::{read_ascii, read_u32_le};
|
||||
|
||||
impl Header {
|
||||
pub fn read_data(data: &[u8]) -> Self {
|
||||
let id = read_ascii(&data[..4]);
|
||||
let lumps = read_u32_le(&data[4..8]);
|
||||
let offset = read_u32_le(&data[8..12]);
|
||||
|
||||
Self {
|
||||
wad_id: id,
|
||||
num_lumps: lumps,
|
||||
dir_offset: offset,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user