From d7010956b36ffc4dd25c96077b06848daa742cc6 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Sat, 30 Sep 2023 02:53:25 -0700 Subject: [PATCH] match match lole I disliked how if Some else None repeated twice looked, but I'm not sure if this is better --- src/main.rs | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/main.rs b/src/main.rs index 73c60c33..8b229b16 100644 --- a/src/main.rs +++ b/src/main.rs @@ -775,22 +775,24 @@ impl framework::Example for GraphicsData { if let (Ok(()),Ok(()))=(std::io::Read::read_exact(&mut input, &mut first_8),std::io::Seek::rewind(&mut input)){ // if let Some(Ok((indexed_model_instances,spawn_point)))={ - if &first_8==b"{ + match match &first_8[4..8]{ + b"lox!"=>rbx_binary::from_reader(input).map_err(|e|format!("{:?}",e)), + b"lox "=>rbx_xml::from_reader(input,rbx_xml::DecodeOptions::default()).map_err(|e|format!("{:?}",e)), + other=>Err(format!("Unknown Roblox file type {:?}",other)), + }{ + Ok(dom)=>Some(load_roblox::generate_indexed_models_roblox(dom)), + Err(e)=>{ + println!("Error loading roblox file:{:?}",e); + None + }, + } + }, + //b"VBSP"=>load_valve::generate_indexed_models_valve(input), + //b"SNFM"=>sniffer::generate_indexed_models(input), + //b"SNFB"=>sniffer::load_bot(input), + _=>None, } }{ //if generate_indexed_models succeeds, clear the previous ones