Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
f81ce21bdc | |||
c0fe3f71cc |
14
src/file.rs
14
src/file.rs
@ -4,6 +4,8 @@ use std::io::Read;
|
||||
pub enum ReadError{
|
||||
Roblox(strafesnet_rbx_loader::ReadError),
|
||||
Source(strafesnet_bsp_loader::ReadError),
|
||||
StrafesNET(strafesnet_snf::Error),
|
||||
StrafesNETMap(strafesnet_snf::map::Error),
|
||||
Io(std::io::Error),
|
||||
UnknownFileFormat,
|
||||
}
|
||||
@ -16,15 +18,20 @@ impl std::error::Error for ReadError{}
|
||||
|
||||
pub enum DataStructure{
|
||||
Roblox(strafesnet_rbx_loader::Dom),
|
||||
Source(strafesnet_bsp_loader::Bsp)
|
||||
Source(strafesnet_bsp_loader::Bsp),
|
||||
StrafesNET(strafesnet_common::map::CompleteMap),
|
||||
}
|
||||
|
||||
pub fn read<R:Read>(input:R)->Result<DataStructure,ReadError>{
|
||||
pub fn read<R:Read+std::io::Seek>(input:R)->Result<DataStructure,ReadError>{
|
||||
let mut buf=std::io::BufReader::new(input);
|
||||
let peek=std::io::BufRead::fill_buf(&mut buf).map_err(ReadError::Io)?;
|
||||
match &peek[0..4]{
|
||||
b"<rob"=>Ok(DataStructure::Roblox(strafesnet_rbx_loader::read(buf).map_err(ReadError::Roblox)?)),
|
||||
b"VBSP"=>Ok(DataStructure::Source(strafesnet_bsp_loader::read(buf).map_err(ReadError::Source)?)),
|
||||
b"SNFM"=>Ok(DataStructure::StrafesNET(
|
||||
strafesnet_snf::read_map(buf).map_err(ReadError::StrafesNET)?
|
||||
.into_complete_map().map_err(ReadError::StrafesNETMap)?
|
||||
)),
|
||||
_=>Err(ReadError::UnknownFileFormat),
|
||||
}
|
||||
}
|
||||
@ -46,6 +53,7 @@ pub fn load<P:AsRef<std::path::Path>>(path:P)->Result<strafesnet_common::map::Co
|
||||
//blocking because it's simpler...
|
||||
let file=std::fs::File::open(path).map_err(LoadError::File)?;
|
||||
match read(file).map_err(LoadError::ReadError)?{
|
||||
DataStructure::StrafesNET(map)=>Ok(map),
|
||||
DataStructure::Roblox(dom)=>{
|
||||
let mut loader=strafesnet_deferred_loader::roblox_legacy();
|
||||
|
||||
@ -117,4 +125,4 @@ pub fn load<P:AsRef<std::path::Path>>(path:P)->Result<strafesnet_common::map::Co
|
||||
Ok(map)
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
/run/media/quat/Files/Documents/map-files/verify-scripts/textures/dds/
|
||||
/run/media/quat/Files/Documents/map-files/verify-scripts/textures
|
Loading…
Reference in New Issue
Block a user