diff --git a/src/file.rs b/src/file.rs index f1bf2b0..d9e6979 100644 --- a/src/file.rs +++ b/src/file.rs @@ -5,7 +5,7 @@ use binrw::{binrw, BinReaderExt, io::TakeSeekExt}; pub enum Error{ InvalidHeader(binrw::Error), UnexpectedEOF, - InvalidBlockId(usize), + InvalidBlockId(u64), Seek(std::io::Error), } @@ -64,7 +64,8 @@ struct Header{ block_location:Vec, } -pub struct BlockId(usize); +#[derive(Clone,Copy,Hash,Eq,PartialEq)] +pub struct BlockId(u64); pub(crate) struct File{ header:Header, @@ -80,11 +81,11 @@ impl File{ }) } pub(crate) fn take_block(&mut self,block_id:BlockId)->Result,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)) } - let block_start=self.header.block_location[block_id.0]; - let block_end=self.header.block_location[block_id.0+1]; + let block_start=self.header.block_location[block_id.0 as usize]; + 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))?; Ok((&mut self.data).take_seek(block_end-block_start)) } diff --git a/src/map.rs b/src/map.rs index 910cede..666f46e 100644 --- a/src/map.rs +++ b/src/map.rs @@ -1,5 +1,5 @@ -use strafesnet_common::model; -use strafesnet_common::gameplay_modes; +//use strafesnet_common::model; +//use strafesnet_common::gameplay_modes; use binrw::{BinReaderExt, binrw}; pub enum Error{ @@ -60,6 +60,15 @@ for model_id in 0..num_models{ //error hiding mock code +mod gameplay_modes{ + pub struct Modes{} +} +mod model{ + pub struct IndexedModel{} + #[super::binrw] + #[brw(little)] + pub struct Model{} +} mod image{ pub struct Image{} } @@ -102,7 +111,7 @@ impl StreamableMap{ let region:Region=block.read_le().map_err(|e|Error::InvalidRegion(e))?; Ok(region.models) } - pub fn load_resource(&mut self,resource_id:ResourceId)->Resource{ - // - } + // pub fn load_resource(&mut self,resource_id:ResourceId)->Resource{ + // // + // } } \ No newline at end of file