Add support for old-type Wads

png-branch
an 2018-09-10 10:30:38 -04:00
parent 55195368e2
commit 0f5e4c7258
1 changed files with 6 additions and 5 deletions

View File

@ -66,7 +66,7 @@ impl<'a> Wad<'a>
4 => Ver::MI,
2 => Ver::M2HasOvr,
1 => Ver::M2HasDir,
0 => panic!("old wad type unsupported"), //Ver::M1,
0 => Ver::M1,
_ => panic!("invalid wad version"),
};
@ -81,7 +81,7 @@ impl<'a> Wad<'a>
let len = b_u32b(&b[p+4..p+ 8]) as usize;
let ind = if n {i as u16}
else {b_u16b(&b[p+8..p+10])};
let ent = Entry{map: get_chunks(&b[ofs..ofs+len]),
let ent = Entry{map: get_chunks(&b[ofs..ofs+len], n),
ext: &b[p+h..p+h+ext]};
map.insert(ind, ent);
@ -95,10 +95,11 @@ impl<'a> Wad<'a>
}
}
fn get_chunks(b: &[u8]) -> ChunkMap
fn get_chunks(b: &[u8], n: bool) -> ChunkMap
{
let mut p = 0;
let mut map = ChunkMap::new();
let h = if n {12} else {16};
while p < b.len()
{
@ -106,8 +107,8 @@ fn get_chunks(b: &[u8]) -> ChunkMap
// nx = b_u32b(&b[p+ 4..p+ 8]);
let l = b_u32b(&b[p+ 8..p+12]) as usize;
// o = b_u32b(&b[p+12..p+16]);
map.insert(k, &b[p+16..p+16+l]);
p += l + 16;
map.insert(k, &b[p+h ..p+h+l]);
p += l + h;
}
map