Lump Type Handling
Added in the ability for us to detect Vertex lump types. Every lump is no longer being flagged as a LumpType::Unknown. Also added in the testing framework to make sure that we are loading up the correct number of vertex lumps from the wad file.
This commit is contained in:
@@ -37,7 +37,10 @@ impl WADFile {
|
||||
let lump_offset = read_u32_le(&file_buffer[startpos..startpos + 4]);
|
||||
let size = read_u32_le(&file_buffer[startpos + 4..startpos + 8]);
|
||||
let name = read_ascii(&file_buffer[startpos + 8..startpos + 16]);
|
||||
let lump_type = LumpType::Unknown;
|
||||
let lump_type = match name.as_str() {
|
||||
"VERTEXES" => LumpType::Vertex,
|
||||
_ => LumpType::Unknown,
|
||||
};
|
||||
lump_dir.push(Lump {
|
||||
name,
|
||||
offset: lump_offset,
|
||||
@@ -56,12 +59,12 @@ impl WADFile {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_vertex_lump(&self, lump: Lump) -> VertexLump {
|
||||
pub fn get_vertex_lump(&self, lump: &Lump) -> VertexLump {
|
||||
let lump_offset = lump.offset as usize;
|
||||
let lump_size = lump.size as usize;
|
||||
let lump_data = &self.data[lump_offset..lump_offset + lump_size];
|
||||
let lump_entries: usize = lump_size / 4;
|
||||
let mut vertexes: Vec<Vertex> = Vec::with_capacity(lump_size / 4);
|
||||
let mut vertexes: Vec<Vertex> = Vec::with_capacity(lump_entries);
|
||||
|
||||
for entry in 0..lump_entries {
|
||||
let startpos = entry * 4;
|
||||
|
||||
Reference in New Issue
Block a user