maraiah: fix old wad type entry headers

master
an 2019-07-01 01:23:27 -04:00
parent b16b2a7ff1
commit 9dcf487d18
1 changed files with 15 additions and 4 deletions

View File

@ -8,18 +8,29 @@ use std::collections::BTreeMap;
pub fn read(map: &head::Map, i: usize) -> ResultS<(u16, Entry<'_>)>
{
let size = map.head().size_entry();
let b = map.dir();
let sta = size * i;
read_data! {
endian: BIG, buf: map.dir(), size: size, start: size * i, data {
endian: BIG, buf: b, size: size, start: sta, data {
let offset = u32[0] usize;
let dsize = u32[4] usize;
let index = u16[8];
let app_data = u8[10; map.head().size_appl()];
}
}
let (index, app_data) = if !map.head().old_wad() {
read_data! {
endian: BIG, buf: b, size: size, start: sta, data {
let index = u16[8];
let app_data = u8[10; map.head().size_appl()];
}
}
(index, app_data)
} else {
(i as u16, &b[0..0])
};
let data = &map.data()[offset..offset + dsize];
let index = if map.head().old_wad() {i as u16} else {index};
Ok((index, Entry{data, app_data}))
}