forked from StrafesNET/strafe-client
source and roblox map loading feature flags
This commit is contained in:
parent
685e74575a
commit
4863605af7
10
Cargo.toml
10
Cargo.toml
@ -8,6 +8,10 @@ description = "StrafesNET game client for bhop and surf."
|
||||
authors = ["Rhys Lloyd <krakow20@gmail.com>"]
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
[features]
|
||||
default = []
|
||||
source = ["dep:strafesnet_deferred_loader", "dep:strafesnet_bsp_loader"]
|
||||
roblox = ["dep:strafesnet_deferred_loader", "dep:strafesnet_rbx_loader"]
|
||||
|
||||
[dependencies]
|
||||
bytemuck = { version = "1.13.1", features = ["derive"] }
|
||||
@ -17,10 +21,10 @@ glam = "0.28.0"
|
||||
id = { version = "0.1.0", registry = "strafesnet" }
|
||||
parking_lot = "0.12.1"
|
||||
pollster = "0.3.0"
|
||||
strafesnet_bsp_loader = { version = "0.1.3", registry = "strafesnet" }
|
||||
strafesnet_bsp_loader = { version = "0.1.3", registry = "strafesnet", optional = true }
|
||||
strafesnet_common = { version = "0.2.0", registry = "strafesnet" }
|
||||
strafesnet_deferred_loader = { version = "0.3.1", features = ["legacy"], registry = "strafesnet" }
|
||||
strafesnet_rbx_loader = { version = "0.3.2", registry = "strafesnet" }
|
||||
strafesnet_deferred_loader = { version = "0.3.1", features = ["legacy"], registry = "strafesnet", optional = true }
|
||||
strafesnet_rbx_loader = { version = "0.3.2", registry = "strafesnet", optional = true }
|
||||
strafesnet_snf = { version = "0.1.0", registry = "strafesnet" }
|
||||
wgpu = "22.0.0"
|
||||
winit = "0.30.4"
|
||||
|
@ -2,7 +2,9 @@ use std::io::Read;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum ReadError{
|
||||
#[cfg(feature="roblox")]
|
||||
Roblox(strafesnet_rbx_loader::ReadError),
|
||||
#[cfg(feature="source")]
|
||||
Source(strafesnet_bsp_loader::ReadError),
|
||||
StrafesNET(strafesnet_snf::Error),
|
||||
StrafesNETMap(strafesnet_snf::map::Error),
|
||||
@ -17,7 +19,9 @@ impl std::fmt::Display for ReadError{
|
||||
impl std::error::Error for ReadError{}
|
||||
|
||||
pub enum DataStructure{
|
||||
#[cfg(feature="roblox")]
|
||||
Roblox(strafesnet_rbx_loader::Dom),
|
||||
#[cfg(feature="source")]
|
||||
Source(strafesnet_bsp_loader::Bsp),
|
||||
StrafesNET(strafesnet_common::map::CompleteMap),
|
||||
}
|
||||
@ -26,7 +30,9 @@ 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]{
|
||||
#[cfg(feature="roblox")]
|
||||
b"<rob"=>Ok(DataStructure::Roblox(strafesnet_rbx_loader::read(buf).map_err(ReadError::Roblox)?)),
|
||||
#[cfg(feature="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)?
|
||||
@ -54,6 +60,7 @@ pub fn load<P:AsRef<std::path::Path>>(path:P)->Result<strafesnet_common::map::Co
|
||||
let file=std::fs::File::open(path).map_err(LoadError::File)?;
|
||||
match read(file).map_err(LoadError::ReadError)?{
|
||||
DataStructure::StrafesNET(map)=>Ok(map),
|
||||
#[cfg(feature="roblox")]
|
||||
DataStructure::Roblox(dom)=>{
|
||||
let mut loader=strafesnet_deferred_loader::roblox_legacy();
|
||||
|
||||
@ -86,6 +93,7 @@ pub fn load<P:AsRef<std::path::Path>>(path:P)->Result<strafesnet_common::map::Co
|
||||
|
||||
Ok(map)
|
||||
},
|
||||
#[cfg(feature="source")]
|
||||
DataStructure::Source(bsp)=>{
|
||||
let mut loader=strafesnet_deferred_loader::source_legacy();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user