fix decompile template generation & decompilation + write correct data to final file

This commit is contained in:
Quaternions 2024-01-24 16:58:46 -08:00
parent 56899fa7da
commit 658266aa89

View File

@ -858,7 +858,7 @@ async fn write_files(config:WriteConfig,mut context:DecompiledContext)->AResult<
file.push("template");
assert!(file.set_extension("rbxlx"));
let output=std::io::BufWriter::new(std::fs::File::create(file)?);
rbx_xml::to_writer_default(output,&context.dom,&[context.dom.root_ref()])?;
rbx_xml::to_writer_default(output,&context.dom,context.dom.root().children())?;
}
Ok(())
@ -1469,7 +1469,7 @@ async fn compile(config:CompileConfig)->AResult<()>{
//add in scripts and models
let mut folder=config.input_folder.clone();
folder.push("src");
let mut stack:Vec<CompileStackInstruction>=dom.get_by_ref(dom.root().children()[0]).unwrap().children().into_iter().map(|&referent|CompileStackInstruction::TraverseReferent(referent)).collect();
let mut stack:Vec<CompileStackInstruction>=dom.root().children().into_iter().map(|&referent|CompileStackInstruction::TraverseReferent(referent)).collect();
while let Some(instruction)=stack.pop(){
match instruction{
CompileStackInstruction::TraverseReferent(item_ref)=>{
@ -1542,6 +1542,7 @@ async fn compile(config:CompileConfig)->AResult<()>{
output_place.push("place.rbxl");
}
let output=std::io::BufWriter::new(std::fs::File::create(output_place)?);
rbx_binary::to_writer(output,&dom,&[dom.root_ref()])?;
//write inner objects
rbx_binary::to_writer(output,&dom,dom.root().children())?;
Ok(())
}