read snf map

This commit is contained in:
Quaternions 2024-07-25 17:47:55 -07:00
parent 33cc2e1a45
commit 4a4ede36ed
3 changed files with 52 additions and 31 deletions

60
Cargo.lock generated
View File

@ -326,9 +326,9 @@ dependencies = [
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.1.6" version = "1.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2aba8f4e9906c7ce3c73463f62a7f0c65183ada1a2d47e397cc8810827f9694f" checksum = "26a5c3fd7bfa1ce3897a3a3501d362b2d87b7f2583ebcb4a949ec25911025cbc"
dependencies = [ dependencies = [
"jobserver", "jobserver",
"libc", "libc",
@ -843,9 +843,9 @@ checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130"
[[package]] [[package]]
name = "jobserver" name = "jobserver"
version = "0.1.31" version = "0.1.32"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2b099aaa34a9751c5bf0878add70444e1ed2dd73f347be99003d4577277de6e" checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0"
dependencies = [ dependencies = [
"libc", "libc",
] ]
@ -878,9 +878,9 @@ checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc"
[[package]] [[package]]
name = "lazy-regex" name = "lazy-regex"
version = "3.1.0" version = "3.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d12be4595afdf58bd19e4a9f4e24187da2a66700786ff660a418e9059937a4c" checksum = "576c8060ecfdf2e56995cf3274b4f2d71fa5e4fa3607c1c0b63c10180ee58741"
dependencies = [ dependencies = [
"lazy-regex-proc_macros", "lazy-regex-proc_macros",
"once_cell", "once_cell",
@ -889,9 +889,9 @@ dependencies = [
[[package]] [[package]]
name = "lazy-regex-proc_macros" name = "lazy-regex-proc_macros"
version = "3.1.0" version = "3.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44bcd58e6c97a7fcbaffcdc95728b393b8d98933bfadad49ed4097845b57ef0b" checksum = "9efb9e65d4503df81c615dc33ff07042a9408ac7f26b45abee25566f7fbfd12c"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -1109,18 +1109,18 @@ dependencies = [
[[package]] [[package]]
name = "num_enum" name = "num_enum"
version = "0.7.2" version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "02339744ee7253741199f897151b38e72257d13802d4ee837285cc2990a90845" checksum = "4e613fc340b2220f734a8595782c551f1250e969d87d3be1ae0579e8d4065179"
dependencies = [ dependencies = [
"num_enum_derive", "num_enum_derive",
] ]
[[package]] [[package]]
name = "num_enum_derive" name = "num_enum_derive"
version = "0.7.2" version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56"
dependencies = [ dependencies = [
"proc-macro-crate", "proc-macro-crate",
"proc-macro2", "proc-macro2",
@ -1890,15 +1890,16 @@ dependencies = [
"strafesnet_common", "strafesnet_common",
"strafesnet_deferred_loader", "strafesnet_deferred_loader",
"strafesnet_rbx_loader", "strafesnet_rbx_loader",
"strafesnet_snf",
"wgpu", "wgpu",
"winit", "winit",
] ]
[[package]] [[package]]
name = "strafesnet_bsp_loader" name = "strafesnet_bsp_loader"
version = "0.1.2" version = "0.1.3"
source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/" source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/"
checksum = "c3891b86fae658a904a38dc3e746987ae480898d355daca741e7ba6b10c50094" checksum = "6d4af68c422b5f57febbaa218f44ba02d413fd25e84afff9e45e557a8caee2ce"
dependencies = [ dependencies = [
"glam", "glam",
"strafesnet_common", "strafesnet_common",
@ -1908,9 +1909,9 @@ dependencies = [
[[package]] [[package]]
name = "strafesnet_common" name = "strafesnet_common"
version = "0.1.3" version = "0.2.0"
source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/" source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/"
checksum = "10a7e3b69506893bbdde90ce8a9d75cd56d280c0424d2dfdf98f8520179d0c1b" checksum = "74580c59a09194ce39db49cd814a5c2fc2d61513c88c6b811b5b40c0da6de057"
dependencies = [ dependencies = [
"bitflags 2.6.0", "bitflags 2.6.0",
"glam", "glam",
@ -1919,9 +1920,9 @@ dependencies = [
[[package]] [[package]]
name = "strafesnet_deferred_loader" name = "strafesnet_deferred_loader"
version = "0.3.0" version = "0.3.1"
source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/" source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/"
checksum = "737954ffff299d244b0267b8101092034935d98fff7694628dbe438151579c3a" checksum = "c3891dcbdbc20b03cf561786b810e839ae7c11dd8810fd005f2474805ee9cccc"
dependencies = [ dependencies = [
"lazy-regex", "lazy-regex",
"strafesnet_common", "strafesnet_common",
@ -1930,9 +1931,9 @@ dependencies = [
[[package]] [[package]]
name = "strafesnet_rbx_loader" name = "strafesnet_rbx_loader"
version = "0.3.1" version = "0.3.2"
source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/" source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/"
checksum = "462e941b20f0d41b6ed138a8bd7d7e17a09c62b3817074a6c935798daa786697" checksum = "21ea93b0170063dd2a063a138c41e6f7a6c14a82c6553fa4ba32df65a26efc6e"
dependencies = [ dependencies = [
"bytemuck", "bytemuck",
"glam", "glam",
@ -1945,6 +1946,17 @@ dependencies = [
"strafesnet_common", "strafesnet_common",
] ]
[[package]]
name = "strafesnet_snf"
version = "0.1.0"
source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/"
checksum = "50acdfdc5423577e7acb2c361c370753217f49bd567bf3e42c7375851080ccee"
dependencies = [
"binrw 0.14.0",
"id",
"strafesnet_common",
]
[[package]] [[package]]
name = "strict-num" name = "strict-num"
version = "0.1.1" version = "0.1.1"
@ -2040,9 +2052,9 @@ dependencies = [
[[package]] [[package]]
name = "toml_datetime" name = "toml_datetime"
version = "0.6.6" version = "0.6.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" checksum = "f8fb9f64314842840f1d940ac544da178732128f1c78c21772e876579e0da1db"
[[package]] [[package]]
name = "toml_edit" name = "toml_edit"
@ -2151,9 +2163,9 @@ dependencies = [
[[package]] [[package]]
name = "version_check" name = "version_check"
version = "0.9.4" version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
[[package]] [[package]]
name = "vmdl" name = "vmdl"

View File

@ -17,10 +17,11 @@ glam = "0.28.0"
id = { version = "0.1.0", registry = "strafesnet" } id = { version = "0.1.0", registry = "strafesnet" }
parking_lot = "0.12.1" parking_lot = "0.12.1"
pollster = "0.3.0" pollster = "0.3.0"
strafesnet_bsp_loader = { version = "0.1.2", registry = "strafesnet" } strafesnet_bsp_loader = { version = "0.1.3", registry = "strafesnet" }
strafesnet_common = { version = "0.1.3", registry = "strafesnet" } strafesnet_common = { version = "0.2.0", registry = "strafesnet" }
strafesnet_deferred_loader = { version = "0.3.0", features = ["legacy"], registry = "strafesnet" } strafesnet_deferred_loader = { version = "0.3.1", features = ["legacy"], registry = "strafesnet" }
strafesnet_rbx_loader = { version = "0.3.1", registry = "strafesnet" } strafesnet_rbx_loader = { version = "0.3.2", registry = "strafesnet" }
strafesnet_snf = { version = "0.1.0", registry = "strafesnet" }
wgpu = "22.0.0" wgpu = "22.0.0"
winit = "0.30.4" winit = "0.30.4"

View File

@ -4,6 +4,8 @@ use std::io::Read;
pub enum ReadError{ pub enum ReadError{
Roblox(strafesnet_rbx_loader::ReadError), Roblox(strafesnet_rbx_loader::ReadError),
Source(strafesnet_bsp_loader::ReadError), Source(strafesnet_bsp_loader::ReadError),
StrafesNET(strafesnet_snf::Error),
StrafesNETMap(strafesnet_snf::map::Error),
Io(std::io::Error), Io(std::io::Error),
UnknownFileFormat, UnknownFileFormat,
} }
@ -16,15 +18,20 @@ impl std::error::Error for ReadError{}
pub enum DataStructure{ pub enum DataStructure{
Roblox(strafesnet_rbx_loader::Dom), 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 mut buf=std::io::BufReader::new(input);
let peek=std::io::BufRead::fill_buf(&mut buf).map_err(ReadError::Io)?; let peek=std::io::BufRead::fill_buf(&mut buf).map_err(ReadError::Io)?;
match &peek[0..4]{ match &peek[0..4]{
b"<rob"=>Ok(DataStructure::Roblox(strafesnet_rbx_loader::read(buf).map_err(ReadError::Roblox)?)), 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"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), _=>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... //blocking because it's simpler...
let file=std::fs::File::open(path).map_err(LoadError::File)?; let file=std::fs::File::open(path).map_err(LoadError::File)?;
match read(file).map_err(LoadError::ReadError)?{ match read(file).map_err(LoadError::ReadError)?{
DataStructure::StrafesNET(map)=>Ok(map),
DataStructure::Roblox(dom)=>{ DataStructure::Roblox(dom)=>{
let mut loader=strafesnet_deferred_loader::roblox_legacy(); let mut loader=strafesnet_deferred_loader::roblox_legacy();