make it build
This commit is contained in:
parent
40e7717aec
commit
0532b47fec
11
src/file.rs
11
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<u64>,
|
||||
}
|
||||
|
||||
pub struct BlockId(usize);
|
||||
#[derive(Clone,Copy,Hash,Eq,PartialEq)]
|
||||
pub struct BlockId(u64);
|
||||
|
||||
pub(crate) struct File<R:BinReaderExt>{
|
||||
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>{
|
||||
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))
|
||||
}
|
||||
|
19
src/map.rs
19
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<R:BinReaderExt> StreamableMap<R>{
|
||||
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{
|
||||
// //
|
||||
// }
|
||||
}
|
Loading…
Reference in New Issue
Block a user