From c0fe3f71cc100ebef3cb0f626dda18c1364e8923 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Thu, 25 Jul 2024 17:47:55 -0700 Subject: [PATCH] read snf map --- src/file.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/file.rs b/src/file.rs index 27243fc..8262949 100644 --- a/src/file.rs +++ b/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(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]{ b"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>(path:P)->ResultOk(map), DataStructure::Roblox(dom)=>{ let mut loader=strafesnet_deferred_loader::roblox_legacy(); @@ -117,4 +125,4 @@ pub fn load>(path:P)->Result