Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
8b2c8de6f6 | |||
77af5e386a |
18
src/v0.rs
18
src/v0.rs
@ -171,6 +171,7 @@ pub struct WorldEventReset{
|
||||
#[binrw]
|
||||
#[brw(little)]
|
||||
pub struct WorldEventButton{
|
||||
// TODO: figure out magic_after without a dummy field
|
||||
#[br(pad_after=8)]
|
||||
pub button_id:u32,
|
||||
}
|
||||
@ -279,8 +280,7 @@ pub enum FlagReason{
|
||||
Teleport,
|
||||
#[brw(magic=9u32)]
|
||||
Practice,
|
||||
// b"data"
|
||||
#[brw(magic=1635017060u32)]
|
||||
#[brw(magic=b"data")]
|
||||
None,
|
||||
}
|
||||
#[binrw]
|
||||
@ -390,12 +390,8 @@ struct EventChunkHeader{
|
||||
num_events:u32,
|
||||
}
|
||||
|
||||
// first time I've managed to write BinRead generics without this stupid T::Args<'a>:Required thing blocking me
|
||||
fn read_data_into_events<'a,R:BinReaderExt,T>(data:&mut R,events:&mut Vec<T>,num_events:usize)->binrw::BinResult<()>
|
||||
where
|
||||
T:binrw::BinRead,
|
||||
T::Args<'a>:binrw::__private::Required,
|
||||
{
|
||||
// binread args tech has been further refined
|
||||
fn read_data_into_events<'a,R:BinReaderExt,T:binrw::BinRead<Args<'a>=()>>(data:&mut R,events:&mut Vec<T>,num_events:usize)->binrw::BinResult<()>{
|
||||
// there is only supposed to be at most one of each type of event chunk per block, so no need to amortize.
|
||||
events.reserve_exact(num_events);
|
||||
for _ in 0..num_events{
|
||||
@ -403,11 +399,7 @@ where
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
fn read_data_into_events_amortized<'a,R:BinReaderExt,T>(data:&mut R,events:&mut Vec<T>,num_events:usize)->binrw::BinResult<()>
|
||||
where
|
||||
T:binrw::BinRead,
|
||||
T::Args<'a>:binrw::__private::Required,
|
||||
{
|
||||
fn read_data_into_events_amortized<'a,R:BinReaderExt,T:binrw::BinRead<Args<'a>=()>>(data:&mut R,events:&mut Vec<T>,num_events:usize)->binrw::BinResult<()>{
|
||||
// this is used when reading multiple blocks into a single object, so amortize the allocation cost.
|
||||
events.reserve(num_events);
|
||||
for _ in 0..num_events{
|
||||
|
Reference in New Issue
Block a user