From a9cbc71c18f182235bd29cf455dcfa301e04c2ee Mon Sep 17 00:00:00 2001 From: Katherine Kiefer Date: Fri, 1 Dec 2023 23:25:51 +1100 Subject: [PATCH] nope, doesn't work --- src/gas.rs | 34 ++++++++++------------------------ src/lib.rs | 2 +- src/turfs.rs | 8 ++------ 3 files changed, 13 insertions(+), 31 deletions(-) diff --git a/src/gas.rs b/src/gas.rs index 651820c..533b8e1 100644 --- a/src/gas.rs +++ b/src/gas.rs @@ -195,7 +195,7 @@ impl GasArena { mix.write_var_id( byond_string!("_extools_pointer_gasmixture"), - &f32::from_bits(next_idx as u32).into(), + &(next_idx as f32).into(), ) .unwrap(); @@ -227,7 +227,7 @@ impl GasArena { .clear_with_vol(init_volume); mix.write_var_id( byond_string!("_extools_pointer_gasmixture"), - &f32::from_bits(idx as u32).into(), + &(idx as f32).into(), ) .unwrap(); } @@ -255,8 +255,7 @@ where F: FnOnce(&Mixture) -> Result, { GasArena::with_gas_mixture( - mix.read_number_id(byond_string!("_extools_pointer_gasmixture"))? - .to_bits() as usize, + mix.read_number_id(byond_string!("_extools_pointer_gasmixture"))? as usize, f, ) } @@ -269,8 +268,7 @@ where F: FnOnce(&mut Mixture) -> Result, { GasArena::with_gas_mixture_mut( - mix.read_number_id(byond_string!("_extools_pointer_gasmixture"))? - .to_bits() as usize, + mix.read_number_id(byond_string!("_extools_pointer_gasmixture"))? as usize, f, ) } @@ -283,12 +281,8 @@ where F: FnOnce(&Mixture, &Mixture) -> Result, { GasArena::with_gas_mixtures( - src_mix - .read_number_id(byond_string!("_extools_pointer_gasmixture"))? - .to_bits() as usize, - arg_mix - .read_number_id(byond_string!("_extools_pointer_gasmixture"))? - .to_bits() as usize, + src_mix.read_number_id(byond_string!("_extools_pointer_gasmixture"))? as usize, + arg_mix.read_number_id(byond_string!("_extools_pointer_gasmixture"))? as usize, f, ) } @@ -301,12 +295,8 @@ where F: FnOnce(&mut Mixture, &mut Mixture) -> Result, { GasArena::with_gas_mixtures_mut( - src_mix - .read_number_id(byond_string!("_extools_pointer_gasmixture"))? - .to_bits() as usize, - arg_mix - .read_number_id(byond_string!("_extools_pointer_gasmixture"))? - .to_bits() as usize, + src_mix.read_number_id(byond_string!("_extools_pointer_gasmixture"))? as usize, + arg_mix.read_number_id(byond_string!("_extools_pointer_gasmixture"))? as usize, f, ) } @@ -319,12 +309,8 @@ where F: FnMut(&RwLock, &RwLock) -> Result, { GasArena::with_gas_mixtures_custom( - src_mix - .read_number_id(byond_string!("_extools_pointer_gasmixture"))? - .to_bits() as usize, - arg_mix - .read_number_id(byond_string!("_extools_pointer_gasmixture"))? - .to_bits() as usize, + src_mix.read_number_id(byond_string!("_extools_pointer_gasmixture"))? as usize, + arg_mix.read_number_id(byond_string!("_extools_pointer_gasmixture"))? as usize, f, ) } diff --git a/src/lib.rs b/src/lib.rs index c91c5bd..6304599 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -570,7 +570,7 @@ fn equalize_all_hook(gas_list: ByondValue) { value .read_number_id(byond_string!("_extools_pointer_gasmixture")) .ok() - .map(|f| f.to_bits() as usize) + .map(|f| f as usize) }) .collect::>(); GasArena::with_all_mixtures(move |all_mixtures| { diff --git a/src/turfs.rs b/src/turfs.rs index 49c64e6..6a3f9ec 100644 --- a/src/turfs.rs +++ b/src/turfs.rs @@ -441,9 +441,7 @@ fn hook_register_turf(src: ByondValue, flag: ByondValue) { if flag >= 0 { let mut to_insert: TurfMixture = TurfMixture::default(); let air = src.read_var_id(byond_string!("air"))?; - to_insert.mix = air - .read_number_id(byond_string!("_extools_pointer_gasmixture"))? - .to_bits() as usize; + to_insert.mix = air.read_number_id(byond_string!("_extools_pointer_gasmixture"))? as usize; to_insert.flags = SimulationFlags::from_bits_truncate(flag as u8); to_insert.id = id; @@ -542,9 +540,7 @@ fn update_visuals(src: ByondValue) -> Result { let mut overlay_types = Vec::new(); let gas_overlays = byondapi::global_call::call_global_id(byond_string!("get_overlays"), &[])?; - let ptr = air - .read_number_id(byond_string!("_extools_pointer_gasmixture"))? - .to_bits() as usize; + let ptr = air.read_number_id(byond_string!("_extools_pointer_gasmixture"))? as usize; GasArena::with_gas_mixture(ptr, |mix| { mix.for_each_gas(|idx, moles| { if let Some(amt) = gas::types::gas_visibility(idx) {