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