join threads to see errors
This commit is contained in:
parent
6606d3be51
commit
b561ffdfc6
15
src/main.rs
15
src/main.rs
@ -1056,6 +1056,7 @@ fn extract_textures(paths:Vec<std::path::PathBuf>,vpk_path:std::path::PathBuf)->
|
|||||||
let mut zippyt=bsp.pack.into_zip().into_inner().unwrap();
|
let mut zippyt=bsp.pack.into_zip().into_inner().unwrap();
|
||||||
let tree=&vpk_index.tree;
|
let tree=&vpk_index.tree;
|
||||||
std::thread::scope(move|s|{
|
std::thread::scope(move|s|{
|
||||||
|
let mut thread_handles=Vec::new();
|
||||||
for texture_name in deduplicate{
|
for texture_name in deduplicate{
|
||||||
let mut texture_file_name=std::path::PathBuf::from("materials");
|
let mut texture_file_name=std::path::PathBuf::from("materials");
|
||||||
//lower case
|
//lower case
|
||||||
@ -1084,7 +1085,7 @@ fn extract_textures(paths:Vec<std::path::PathBuf>,vpk_path:std::path::PathBuf)->
|
|||||||
}{
|
}{
|
||||||
found_texture=true;
|
found_texture=true;
|
||||||
let texture_name=texture_name.clone();
|
let texture_name=texture_name.clone();
|
||||||
s.spawn(move||{
|
thread_handles.push(s.spawn(move||{
|
||||||
let image=vtf::from_bytes(&mut stuff)?.highres_image.decode(0)?.to_rgba8();
|
let image=vtf::from_bytes(&mut stuff)?.highres_image.decode(0)?.to_rgba8();
|
||||||
|
|
||||||
let format=if image.width()%4!=0||image.height()%4!=0{
|
let format=if image.width()%4!=0||image.height()%4!=0{
|
||||||
@ -1108,7 +1109,7 @@ fn extract_textures(paths:Vec<std::path::PathBuf>,vpk_path:std::path::PathBuf)->
|
|||||||
let mut writer = std::io::BufWriter::new(std::fs::File::create(dest)?);
|
let mut writer = std::io::BufWriter::new(std::fs::File::create(dest)?);
|
||||||
dds.write(&mut writer)?;
|
dds.write(&mut writer)?;
|
||||||
Ok::<(),anyhow::Error>(())
|
Ok::<(),anyhow::Error>(())
|
||||||
});
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@ -1123,7 +1124,7 @@ fn extract_textures(paths:Vec<std::path::PathBuf>,vpk_path:std::path::PathBuf)->
|
|||||||
}{
|
}{
|
||||||
found_texture=true;
|
found_texture=true;
|
||||||
let texture_name=texture_name.clone();
|
let texture_name=texture_name.clone();
|
||||||
s.spawn(move||{
|
thread_handles.push(s.spawn(move||{
|
||||||
let image=vtf::from_bytes(&mut stuff)?.highres_image.decode(0)?.to_rgba8();
|
let image=vtf::from_bytes(&mut stuff)?.highres_image.decode(0)?.to_rgba8();
|
||||||
|
|
||||||
let format=if image.width()%4!=0||image.height()%4!=0{
|
let format=if image.width()%4!=0||image.height()%4!=0{
|
||||||
@ -1147,13 +1148,19 @@ fn extract_textures(paths:Vec<std::path::PathBuf>,vpk_path:std::path::PathBuf)->
|
|||||||
let mut writer = std::io::BufWriter::new(std::fs::File::create(dest)?);
|
let mut writer = std::io::BufWriter::new(std::fs::File::create(dest)?);
|
||||||
dds.write(&mut writer)?;
|
dds.write(&mut writer)?;
|
||||||
Ok::<(),anyhow::Error>(())
|
Ok::<(),anyhow::Error>(())
|
||||||
});
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !found_texture{
|
if !found_texture{
|
||||||
println!("no data");
|
println!("no data");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for thread in thread_handles{
|
||||||
|
match thread.join(){
|
||||||
|
Ok(a)=>a?,
|
||||||
|
Err(e)=>println!("error: {:?}",e),
|
||||||
|
}
|
||||||
|
}
|
||||||
Ok::<(),anyhow::Error>(())
|
Ok::<(),anyhow::Error>(())
|
||||||
})?
|
})?
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user