rename functions

This commit is contained in:
Quaternions 2024-12-31 16:56:55 -08:00
parent 65cc20bdf9
commit dd8cf2544d

View File

@ -1,13 +1,13 @@
use binrw::{binrw,BinReaderExt,io::TakeSeekExt}; use binrw::{binrw,BinReaderExt,io::TakeSeekExt};
// the bit chunks are deposited in reverse // the bit chunks are deposited in reverse
fn trey_float(bits:u32)->f32{ fn read_trey_float(bits:u32)->f32{
let s=bits&1; let s=bits&1;
let e=(bits>>1)&((1<<8)-1); let e=(bits>>1)&((1<<8)-1);
let m=(bits>>(1+8))&((1<<23)-1); let m=(bits>>(1+8))&((1<<23)-1);
f32::from_bits(m|(e<<23)|(s<<31)) f32::from_bits(m|(e<<23)|(s<<31))
} }
fn trey_double(bits:u64)->f64{ fn read_trey_double(bits:u64)->f64{
let s=bits&1; let s=bits&1;
let e=(bits>>1)&((1<<11)-1); let e=(bits>>1)&((1<<11)-1);
let m=(bits>>(1+11))&((1<<52)-1); let m=(bits>>(1+11))&((1<<52)-1);
@ -17,19 +17,19 @@ fn trey_double(bits:u64)->f64{
#[binrw] #[binrw]
#[brw(little)] #[brw(little)]
pub struct Vector2{ pub struct Vector2{
#[br(map=trey_float)] #[br(map=read_trey_float)]
pub x:f32, pub x:f32,
#[br(map=trey_float)] #[br(map=read_trey_float)]
pub y:f32, pub y:f32,
} }
#[binrw] #[binrw]
#[brw(little)] #[brw(little)]
pub struct Vector3{ pub struct Vector3{
#[br(map=trey_float)] #[br(map=read_trey_float)]
pub x:f32, pub x:f32,
#[br(map=trey_float)] #[br(map=read_trey_float)]
pub y:f32, pub y:f32,
#[br(map=trey_float)] #[br(map=read_trey_float)]
pub z:f32, pub z:f32,
} }
@ -43,7 +43,7 @@ pub struct InputEvent{
#[binrw] #[binrw]
#[brw(little)] #[brw(little)]
pub struct TimedInputEvent{ pub struct TimedInputEvent{
#[br(map=trey_double)] #[br(map=read_trey_double)]
pub time:f64, pub time:f64,
pub event:InputEvent, pub event:InputEvent,
} }
@ -61,7 +61,7 @@ pub struct OutputEvent{
#[binrw] #[binrw]
#[brw(little)] #[brw(little)]
pub struct TimedOutputEvent{ pub struct TimedOutputEvent{
#[br(map=trey_double)] #[br(map=read_trey_double)]
pub time:f64, pub time:f64,
pub event:OutputEvent, pub event:OutputEvent,
} }
@ -76,7 +76,7 @@ pub struct SoundEvent{
#[binrw] #[binrw]
#[brw(little)] #[brw(little)]
pub struct TimedSoundEvent{ pub struct TimedSoundEvent{
#[br(map=trey_double)] #[br(map=read_trey_double)]
pub time:f64, pub time:f64,
pub event:SoundEvent, pub event:SoundEvent,
} }
@ -97,7 +97,7 @@ pub struct WorldEventButton{
#[binrw] #[binrw]
#[brw(little)] #[brw(little)]
pub struct WorldEventSetTime{ pub struct WorldEventSetTime{
#[br(map=trey_double)] #[br(map=read_trey_double)]
pub time:f64, pub time:f64,
#[brw(magic=b"data")] #[brw(magic=b"data")]
__:(), __:(),
@ -126,7 +126,7 @@ pub enum WorldEvent{
#[binrw] #[binrw]
#[brw(little)] #[brw(little)]
pub struct TimedWorldEvent{ pub struct TimedWorldEvent{
#[br(map=trey_double)] #[br(map=read_trey_double)]
pub time:f64, pub time:f64,
pub event:WorldEvent, pub event:WorldEvent,
} }
@ -140,7 +140,7 @@ pub struct GravityEvent{
#[binrw] #[binrw]
#[brw(little)] #[brw(little)]
pub struct TimedGravityEvent{ pub struct TimedGravityEvent{
#[br(map=trey_double)] #[br(map=read_trey_double)]
pub time:f64, pub time:f64,
pub event:GravityEvent, pub event:GravityEvent,
} }
@ -174,7 +174,7 @@ pub struct RunEvent{
#[binrw] #[binrw]
#[brw(little)] #[brw(little)]
pub struct TimedRunEvent{ pub struct TimedRunEvent{
#[br(map=trey_double)] #[br(map=read_trey_double)]
pub time:f64, pub time:f64,
pub event:RunEvent, pub event:RunEvent,
} }
@ -189,7 +189,7 @@ pub struct CameraEvent{
#[binrw] #[binrw]
#[brw(little)] #[brw(little)]
pub struct TimedCameraEvent{ pub struct TimedCameraEvent{
#[br(map=trey_double)] #[br(map=read_trey_double)]
pub time:f64, pub time:f64,
pub event:CameraEvent, pub event:CameraEvent,
} }
@ -199,13 +199,13 @@ pub struct TimedCameraEvent{
#[brw(little)] #[brw(little)]
pub struct SettingEvent{ pub struct SettingEvent{
pub setting_id:u32, pub setting_id:u32,
#[br(map=trey_double)] #[br(map=read_trey_double)]
pub value:f64, pub value:f64,
} }
#[binrw] #[binrw]
#[brw(little)] #[brw(little)]
pub struct TimedSettingEvent{ pub struct TimedSettingEvent{
#[br(map=trey_double)] #[br(map=read_trey_double)]
pub time:f64, pub time:f64,
pub event:SettingEvent, pub event:SettingEvent,
} }
@ -305,7 +305,7 @@ pub struct BlockId(#[br(map=|i:u32|i-1)]u32);
#[brw(little)] #[brw(little)]
#[derive(Debug,Clone,Copy)] #[derive(Debug,Clone,Copy)]
pub struct TimedBlockId{ pub struct TimedBlockId{
#[br(map=trey_double)] #[br(map=read_trey_double)]
pub time:f64, pub time:f64,
pub block_id:BlockId, pub block_id:BlockId,
} }