diff --git a/strafe-client/src/file.rs b/strafe-client/src/file.rs index 2f5263c..229f818 100644 --- a/strafe-client/src/file.rs +++ b/strafe-client/src/file.rs @@ -22,7 +22,7 @@ impl std::fmt::Display for ReadError{ } impl std::error::Error for ReadError{} -enum Format{ +pub enum ReadFormat{ #[cfg(feature="roblox")] Roblox(strafesnet_rbx_loader::Model), #[cfg(feature="source")] @@ -33,21 +33,21 @@ enum Format{ SNFB(strafesnet_snf::bot::Segment), } -pub fn read(input:R)->Result{ +pub fn read(input:R)->Result{ 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"Ok(Format::Roblox(strafesnet_rbx_loader::read(buf).map_err(ReadError::Roblox)?)), + b"Ok(ReadFormat::Roblox(strafesnet_rbx_loader::read(buf).map_err(ReadError::Roblox)?)), #[cfg(feature="source")] - b"VBSP"=>Ok(Format::Source(strafesnet_bsp_loader::read(buf).map_err(ReadError::Source)?)), + b"VBSP"=>Ok(ReadFormat::Source(strafesnet_bsp_loader::read(buf).map_err(ReadError::Source)?)), #[cfg(feature="snf")] - b"SNFM"=>Ok(Format::SNFM( + b"SNFM"=>Ok(ReadFormat::SNFM( strafesnet_snf::read_map(buf).map_err(ReadError::StrafesNET)? .into_complete_map().map_err(ReadError::StrafesNETMap)? )), #[cfg(feature="snf")] - b"SNFB"=>Ok(Format::SNFB( + b"SNFB"=>Ok(ReadFormat::SNFB( strafesnet_snf::read_bot(buf).map_err(ReadError::StrafesNET)? .read_all().map_err(ReadError::StrafesNETBot)? )), @@ -68,23 +68,23 @@ impl std::fmt::Display for LoadError{ } impl std::error::Error for LoadError{} -pub enum Format2{ +pub enum LoadFormat{ #[cfg(feature="snf")] Map(strafesnet_common::map::CompleteMap), #[cfg(feature="snf")] Bot(strafesnet_snf::bot::Segment), } -pub fn load>(path:P)->Result{ +pub fn load>(path:P)->Result{ //blocking because it's simpler... let file=std::fs::File::open(path).map_err(LoadError::File)?; match read(file).map_err(LoadError::ReadError)?{ #[cfg(feature="snf")] - Format::SNFB(bot)=>Ok(Format2::Bot(bot)), + ReadFormat::SNFB(bot)=>Ok(LoadFormat::Bot(bot)), #[cfg(feature="snf")] - Format::SNFM(map)=>Ok(Format2::Map(map)), + ReadFormat::SNFM(map)=>Ok(LoadFormat::Map(map)), #[cfg(feature="roblox")] - Format::Roblox(model)=>{ + ReadFormat::Roblox(model)=>{ let mut place=model.into_place(); place.run_scripts(); @@ -117,10 +117,10 @@ pub fn load>(path:P)->Result{ ) ); - Ok(Format2::Map(map)) + Ok(LoadFormat::Map(map)) }, #[cfg(feature="source")] - Format::Source(bsp)=>{ + ReadFormat::Source(bsp)=>{ let mut loader=strafesnet_deferred_loader::source_legacy(); let (texture_loader,mesh_loader)=loader.get_inner_mut(); @@ -156,7 +156,7 @@ pub fn load>(path:P)->Result{ ), ); - Ok(Format2::Map(map)) + Ok(LoadFormat::Map(map)) }, } } diff --git a/strafe-client/src/window.rs b/strafe-client/src/window.rs index 6c8719c..b9a73f1 100644 --- a/strafe-client/src/window.rs +++ b/strafe-client/src/window.rs @@ -1,7 +1,7 @@ use strafesnet_common::instruction::TimedInstruction; use strafesnet_common::session::{Time as SessionTime,TimeInner as SessionTimeInner}; use strafesnet_common::physics::{MiscInstruction,SetControlInstruction}; -use crate::file::Format2; +use crate::file::LoadFormat; use crate::physics_worker::Instruction as PhysicsWorkerInstruction; use crate::session::{SessionInputInstruction,SessionControlInstruction,SessionPlaybackInstruction}; @@ -30,8 +30,8 @@ impl WindowContext<'_>{ match event{ winit::event::WindowEvent::DroppedFile(path)=>{ match crate::file::load(path.as_path()){ - Ok(Format2::Map(map))=>self.physics_thread.send(TimedInstruction{time,instruction:PhysicsWorkerInstruction::ChangeMap(map)}).unwrap(), - Ok(Format2::Bot(bot))=>self.physics_thread.send(TimedInstruction{time,instruction:PhysicsWorkerInstruction::LoadReplay(bot)}).unwrap(), + Ok(LoadFormat::Map(map))=>self.physics_thread.send(TimedInstruction{time,instruction:PhysicsWorkerInstruction::ChangeMap(map)}).unwrap(), + Ok(LoadFormat::Bot(bot))=>self.physics_thread.send(TimedInstruction{time,instruction:PhysicsWorkerInstruction::LoadReplay(bot)}).unwrap(), Err(e)=>println!("Failed to load file: {e}"), } },