This commit is contained in:
Quaternions 2024-07-26 16:52:47 -07:00
parent 5ec99a75dc
commit e0725cba8a

View File

@ -231,18 +231,30 @@ fn read_modes<R:BinReaderExt>(len:usize,input:&mut R)->Result<Vec<newtypes::game
}
fn read_map_header<R:BinReaderExt>(input:&mut R)->Result<MapHeader,binrw::Error>{
let p=input.stream_position().unwrap();
println!("read_map_header pos={}",p);
let num_spacial_blocks:u32=input.read_le()?;
println!("map_header.num_spacial_blocks pos={}",input.stream_position().unwrap()-p);
let num_resource_blocks:u32=input.read_le()?;
println!("map_header.num_resource_blocks pos={}",input.stream_position().unwrap()-p);
//let num_resources_external:u32=input.read_le()?;
let num_modes:u32=input.read_le()?;
println!("map_header.num_modes pos={}",input.stream_position().unwrap()-p);
let num_attributes:u32=input.read_le()?;
println!("map_header.num_attributes pos={}",input.stream_position().unwrap()-p);
let num_render_configs:u32=input.read_le()?;
println!("map_header.num_render_configs pos={}",input.stream_position().unwrap()-p);
let spacial_blocks:Vec<SpacialBlockHeader>=read_vec(num_spacial_blocks as usize,input)?;
println!("map_header.spacial_blocks pos={}",input.stream_position().unwrap()-p);
let resource_blocks:Vec<ResourceBlockHeader>=read_vec(num_resource_blocks as usize,input)?;
println!("map_header.resource_blocks pos={}",input.stream_position().unwrap()-p);
//let external_resources:Vec<ResourceExternalHeader>=read_vec(num_resources_external as usize,input)?;
let modes:Vec<newtypes::gameplay_modes::Mode>=read_modes(num_modes as usize,input)?;
println!("map_header.modes pos={}",input.stream_position().unwrap()-p);
let attributes:Vec<newtypes::gameplay_attributes::CollisionAttributes>=read_vec(num_attributes as usize,input)?;
println!("map_header.attributes pos={} len={}",input.stream_position().unwrap()-p,num_attributes);
let render_configs:Vec<newtypes::model::RenderConfig>=read_vec(num_render_configs as usize,input)?;
println!("map_header.render_configs pos={} len={}",input.stream_position().unwrap()-p,num_render_configs);
Ok(MapHeader{
num_spacial_blocks,
num_resource_blocks,
@ -406,17 +418,17 @@ impl<R:BinReaderExt> StreamableMap<R>{
use binrw::BinWrite;
fn write_mode<W:std::io::Seek+std::io::Write>(mode:&newtypes::gameplay_modes::Mode,output:&mut W)->Result<(),binrw::Error>{
println!("write_mode pos={}",output.stream_position().unwrap());
//println!("write_mode pos={}",output.stream_position().unwrap());
mode.header.write_le(output)?;
println!("mode.header pos={}",output.stream_position().unwrap());
//println!("mode.header pos={}",output.stream_position().unwrap());
mode.style.write_le(output)?;
println!("mode.style pos={}",output.stream_position().unwrap());
//println!("mode.style pos={}",output.stream_position().unwrap());
mode.start.write_le(output)?;
println!("mode.start pos={}",output.stream_position().unwrap());
//println!("mode.start pos={}",output.stream_position().unwrap());
mode.zones.write_le(output)?;
println!("mode.zones pos={}",output.stream_position().unwrap());
//println!("mode.zones pos={}",output.stream_position().unwrap());
mode.stages.write_le(output)?;
println!("mode.stages pos={}",output.stream_position().unwrap());
//println!("mode.stages pos={}",output.stream_position().unwrap());
mode.elements.write_le(output)?;
Ok(())
}
@ -429,18 +441,29 @@ fn write_modes<W:std::io::Seek+std::io::Write>(modes:&Vec<newtypes::gameplay_mod
}
fn write_map_header<W:std::io::Seek+std::io::Write>(map_header:&MapHeader,output:&mut W)->Result<(),binrw::Error>{
println!("write_map_header pos={}",output.stream_position().unwrap());
map_header.num_spacial_blocks.write_le(output)?;
println!("map_header.num_spacial_blocks pos={}",output.stream_position().unwrap());
map_header.num_resource_blocks.write_le(output)?;
println!("map_header.num_resource_blocks pos={}",output.stream_position().unwrap());
//map_header.num_resources_external.write_le(output)?;
map_header.num_modes.write_le(output)?;
println!("map_header.num_modes pos={}",output.stream_position().unwrap());
map_header.num_attributes.write_le(output)?;
println!("map_header.num_attributes pos={}",output.stream_position().unwrap());
map_header.num_render_configs.write_le(output)?;
println!("map_header.num_render_configs pos={}",output.stream_position().unwrap());
map_header.spacial_blocks.write_le(output)?;
println!("map_header.spacial_blocks pos={}",output.stream_position().unwrap());
map_header.resource_blocks.write_le(output)?;
println!("map_header.resource_blocks pos={}",output.stream_position().unwrap());
//map_header.external_resources.write_le(output)?;
write_modes(&map_header.modes,output)?;
println!("map_header.modes pos={}",output.stream_position().unwrap());
map_header.attributes.write_le(output)?;
println!("map_header.attributes pos={}",output.stream_position().unwrap());
map_header.render_configs.write_le(output)?;
println!("map_header.render_configs pos={}",output.stream_position().unwrap());
Ok(())
}