forked from StrafesNET/map-tool
search pak list
This commit is contained in:
parent
8c0f46007f
commit
cc4e80db8a
12
src/main.rs
12
src/main.rs
@ -45,7 +45,7 @@ fn main() -> AResult<()> {
|
|||||||
match cli.command {
|
match cli.command {
|
||||||
Commands::Download(map_list)=>download(map_list.maps),
|
Commands::Download(map_list)=>download(map_list.maps),
|
||||||
Commands::DownloadTextures(pathlist)=>download_textures(pathlist.paths),
|
Commands::DownloadTextures(pathlist)=>download_textures(pathlist.paths),
|
||||||
Commands::ExtractTextures(pathlist)=>extract_textures(pathlist.paths,cli.path.unwrap()),
|
Commands::ExtractTextures(pathlist)=>extract_textures(vec![cli.path.unwrap()],pathlist.paths),
|
||||||
Commands::VPKContents=>vpk_contents(cli.path.unwrap()),
|
Commands::VPKContents=>vpk_contents(cli.path.unwrap()),
|
||||||
Commands::BSPContents=>bsp_contents(cli.path.unwrap()),
|
Commands::BSPContents=>bsp_contents(cli.path.unwrap()),
|
||||||
Commands::ConvertTextures=>convert_textures(),
|
Commands::ConvertTextures=>convert_textures(),
|
||||||
@ -1116,8 +1116,8 @@ fn recursive_vmt_loader<F:Fn(String)->AResult<Option<Vec<u8>>>>(find_stuff:&F,ma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn extract_textures(paths:Vec<std::path::PathBuf>,vpk_path:std::path::PathBuf)->AResult<()>{
|
fn extract_textures(paths:Vec<std::path::PathBuf>,vpk_paths:Vec<std::path::PathBuf>)->AResult<()>{
|
||||||
let vpk_index=vpk::VPK::read(&vpk_path)?;
|
let vpk_list:Vec<vpk::VPK>=vpk_paths.into_iter().map(|vpk_path|vpk::VPK::read(&vpk_path).expect("vpk file does not exist")).collect();
|
||||||
for path in paths{
|
for path in paths{
|
||||||
let mut deduplicate=std::collections::HashSet::new();
|
let mut deduplicate=std::collections::HashSet::new();
|
||||||
let bsp=vbsp::Bsp::read(std::fs::read(path)?.as_ref())?;
|
let bsp=vbsp::Bsp::read(std::fs::read(path)?.as_ref())?;
|
||||||
@ -1162,7 +1162,7 @@ fn extract_textures(paths:Vec<std::path::PathBuf>,vpk_path:std::path::PathBuf)->
|
|||||||
}
|
}
|
||||||
|
|
||||||
let pack=&bsp.pack;
|
let pack=&bsp.pack;
|
||||||
let tree=&vpk_index.tree;
|
let vpk_list=&vpk_list;
|
||||||
std::thread::scope(move|s|{
|
std::thread::scope(move|s|{
|
||||||
let mut thread_handles=Vec::new();
|
let mut thread_handles=Vec::new();
|
||||||
for texture_name in deduplicate{
|
for texture_name in deduplicate{
|
||||||
@ -1200,8 +1200,8 @@ fn extract_textures(paths:Vec<std::path::PathBuf>,vpk_path:std::path::PathBuf)->
|
|||||||
_=>(),
|
_=>(),
|
||||||
}
|
}
|
||||||
//search pak list
|
//search pak list
|
||||||
for tree in [tree]{
|
for vpk_index in vpk_list{
|
||||||
if let Some(vpk_entry)=tree.get(search_file_name.as_str()){
|
if let Some(vpk_entry)=vpk_index.tree.get(search_file_name.as_str()){
|
||||||
return Ok(Some(vpk_entry.get()?.to_vec()));
|
return Ok(Some(vpk_entry.get()?.to_vec()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user