make it build

This commit is contained in:
Quaternions 2024-02-01 20:27:12 -08:00
parent 40e7717aec
commit 0532b47fec
2 changed files with 20 additions and 10 deletions

View File

@ -5,7 +5,7 @@ use binrw::{binrw, BinReaderExt, io::TakeSeekExt};
pub enum Error{ pub enum Error{
InvalidHeader(binrw::Error), InvalidHeader(binrw::Error),
UnexpectedEOF, UnexpectedEOF,
InvalidBlockId(usize), InvalidBlockId(u64),
Seek(std::io::Error), Seek(std::io::Error),
} }
@ -64,7 +64,8 @@ struct Header{
block_location:Vec<u64>, block_location:Vec<u64>,
} }
pub struct BlockId(usize); #[derive(Clone,Copy,Hash,Eq,PartialEq)]
pub struct BlockId(u64);
pub(crate) struct File<R:BinReaderExt>{ pub(crate) struct File<R:BinReaderExt>{
header:Header, header:Header,
@ -80,11 +81,11 @@ impl<R:BinReaderExt> File<R>{
}) })
} }
pub(crate) fn take_block(&mut self,block_id:BlockId)->Result<binrw::io::TakeSeek<&mut R>,Error>{ pub(crate) fn take_block(&mut self,block_id:BlockId)->Result<binrw::io::TakeSeek<&mut R>,Error>{
if self.header.block_location.len()<=block_id.0{ if self.header.block_location.len() as u64<=block_id.0{
return Err(Error::InvalidBlockId(block_id.0)) return Err(Error::InvalidBlockId(block_id.0))
} }
let block_start=self.header.block_location[block_id.0]; let block_start=self.header.block_location[block_id.0 as usize];
let block_end=self.header.block_location[block_id.0+1]; let block_end=self.header.block_location[block_id.0 as usize+1];
self.data.seek(std::io::SeekFrom::Start(block_start)).map_err(|e|Error::Seek(e))?; self.data.seek(std::io::SeekFrom::Start(block_start)).map_err(|e|Error::Seek(e))?;
Ok((&mut self.data).take_seek(block_end-block_start)) Ok((&mut self.data).take_seek(block_end-block_start))
} }

View File

@ -1,5 +1,5 @@
use strafesnet_common::model; //use strafesnet_common::model;
use strafesnet_common::gameplay_modes; //use strafesnet_common::gameplay_modes;
use binrw::{BinReaderExt, binrw}; use binrw::{BinReaderExt, binrw};
pub enum Error{ pub enum Error{
@ -60,6 +60,15 @@ for model_id in 0..num_models{
//error hiding mock code //error hiding mock code
mod gameplay_modes{
pub struct Modes{}
}
mod model{
pub struct IndexedModel{}
#[super::binrw]
#[brw(little)]
pub struct Model{}
}
mod image{ mod image{
pub struct Image{} pub struct Image{}
} }
@ -102,7 +111,7 @@ impl<R:BinReaderExt> StreamableMap<R>{
let region:Region=block.read_le().map_err(|e|Error::InvalidRegion(e))?; let region:Region=block.read_le().map_err(|e|Error::InvalidRegion(e))?;
Ok(region.models) Ok(region.models)
} }
pub fn load_resource(&mut self,resource_id:ResourceId)->Resource{ // pub fn load_resource(&mut self,resource_id:ResourceId)->Resource{
// // //
} // }
} }