From fa49dcf2405fcf860b42552512ee167a1b509357 Mon Sep 17 00:00:00 2001 From: Katherine Kiefer Date: Thu, 16 Nov 2023 20:58:31 +1100 Subject: [PATCH] update byondapi --- Cargo.lock | 52 +++++++++++++++++------------------ Cargo.toml | 4 +-- crates/auxcallback/Cargo.toml | 2 +- crates/auxcallback/src/lib.rs | 8 +++--- src/gas.rs | 9 ++---- src/lib.rs | 7 +++-- src/turfs.rs | 7 ++--- src/turfs/groups.rs | 7 ++--- src/turfs/katmos.rs | 28 ++++++++----------- src/turfs/processing.rs | 4 +-- 10 files changed, 58 insertions(+), 70 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0d3ae62e..0205b4b9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -82,9 +82,9 @@ dependencies = [ [[package]] name = "bindgen" -version = "0.68.1" +version = "0.69.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "726e4313eb6ec35d2730258ad4e15b547ee75d6afaa1361a922e78e59b7d8078" +checksum = "9ffcebc3849946a7170a05992aac39da343a90676ab392c51a4280981d6379c2" dependencies = [ "bitflags 2.4.1", "cexpr", @@ -124,7 +124,7 @@ checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" [[package]] name = "byondapi" version = "0.2.1" -source = "git+https://github.com/jupyterkat/byondapi-rs#29712282912f6b797e93e338905d259f340f35d9" +source = "git+https://github.com/jupyterkat/byondapi-rs#3ac193f0945e52f2217ac2cc324db5dfc0a7625f" dependencies = [ "byondapi-sys", "inventory", @@ -154,7 +154,7 @@ dependencies = [ [[package]] name = "byondapi-sys" version = "0.10.1" -source = "git+https://github.com/jupyterkat/byondapi-rs#29712282912f6b797e93e338905d259f340f35d9" +source = "git+https://github.com/jupyterkat/byondapi-rs#3ac193f0945e52f2217ac2cc324db5dfc0a7625f" dependencies = [ "bindgen", "libloading 0.8.1", @@ -205,9 +205,9 @@ dependencies = [ [[package]] name = "coarsetime" -version = "0.1.29" +version = "0.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a73ef0d00d14301df35d0f13f5ea32344de6b00837485c358458f1e7f2d27db4" +checksum = "71367d3385c716342014ad17e3d19f7788ae514885a1f4c24f500260fb365e1a" dependencies = [ "libc", "once_cell", @@ -276,9 +276,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.5" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860" +checksum = "f258a7194e7f7c2a7837a8913aeab7fd8c383457034fa20ce4dd3dcb813e8eb8" dependencies = [ "libc", "windows-sys", @@ -341,9 +341,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" dependencies = [ "cfg-if", "js-sys", @@ -402,9 +402,9 @@ checksum = "0508c56cfe9bfd5dfeb0c22ab9a6abfda2f27bdca422132e494266351ed8d83c" [[package]] name = "itertools" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" +checksum = "25db6b064527c5d482d0423354fcd07a89a2dfe07b67892e62411946db7f07b0" dependencies = [ "either", ] @@ -432,9 +432,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.149" +version = "0.2.150" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" +checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" [[package]] name = "libloading" @@ -468,9 +468,9 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f" +checksum = "969488b55f8ac402214f3f5fd243ebb7206cf82de60d3172994707a4bcc2b829" [[package]] name = "lock_api" @@ -685,9 +685,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.21" +version = "0.38.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b426b0506e5d50a7d8dafcf2e81471400deb602392c7dd110815afb4eaf02a3" +checksum = "9ad981d6c340a49cdc40a1028d9c6084ec7e9fa33fcb839cab656a267071e234" dependencies = [ "bitflags 2.4.1", "errno", @@ -725,9 +725,9 @@ checksum = "a7cee0529a6d40f580e7a5e6c495c8fbfe21b7b52795ed4bb5e62cdf92bc6380" [[package]] name = "smallvec" -version = "1.11.1" +version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" +checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" [[package]] name = "spin" @@ -740,9 +740,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.38" +version = "2.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" +checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" dependencies = [ "proc-macro2", "quote", @@ -957,18 +957,18 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "zerocopy" -version = "0.7.21" +version = "0.7.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "686b7e407015242119c33dab17b8f61ba6843534de936d94368856528eae4dcc" +checksum = "e97e415490559a91254a2979b4829267a57d2fcd741a98eee8b722fb57289aa0" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.21" +version = "0.7.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "020f3dfe25dfc38dfea49ce62d5d45ecdd7f0d8a724fa63eb36b6eba4ec76806" +checksum = "dd7e48ccf166952882ca8bd778a43502c64f33bf94c12ebe2a7f08e5a0f6689f" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 2982c9e1..76258361 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,7 +40,7 @@ crate-type = ["cdylib"] auxcallback = { path = "./crates/auxcallback" } byondapi = { git = "https://github.com/jupyterkat/byondapi-rs", package = "byondapi" } byondapi-binds = { path = "./crates/byondapi-binds" } -itertools = "0.11.0" +itertools = "0.12.0" rayon = "1.8.0" float-ord = "0.3.2" flume = "0.11.0" @@ -55,7 +55,7 @@ atomic_float = "0.1.0" petgraph = "0.6.4" bitflags = "2.4.1" nom = "7.1.3" -coarsetime = "0.1.29" +coarsetime = "0.1.33" mimalloc = { version = "0.1.39", default-features = false } eyre = "0.6.8" diff --git a/crates/auxcallback/Cargo.toml b/crates/auxcallback/Cargo.toml index 1bf1b84d..ef89c4b8 100644 --- a/crates/auxcallback/Cargo.toml +++ b/crates/auxcallback/Cargo.toml @@ -11,6 +11,6 @@ crate-type = ["lib"] [dependencies] flume = "0.11.0" -coarsetime = "0.1.29" +coarsetime = "0.1.33" byondapi = { git = "https://github.com/jupyterkat/byondapi-rs", package = "byondapi" } eyre = "0.6.8" diff --git a/crates/auxcallback/src/lib.rs b/crates/auxcallback/src/lib.rs index 4896d4eb..e02338f2 100644 --- a/crates/auxcallback/src/lib.rs +++ b/crates/auxcallback/src/lib.rs @@ -1,4 +1,4 @@ -use std::convert::TryFrom; +use std::convert::TryInto; use byondapi::{prelude::*, typecheck_trait::ByondTypeCheck}; @@ -41,7 +41,7 @@ fn process_callbacks() { with_callback_receiver(|receiver| { for callback in receiver.try_iter() { if let Err(e) = callback() { - let error_string = ByondValue::try_from(::std::format!("{e:?}")).unwrap(); + let error_string = format!("{e:?}").try_into().unwrap(); byondapi::global_call::call_global("stack_trace", &[error_string]).unwrap(); } } @@ -55,7 +55,7 @@ fn process_callbacks_for(duration: Duration) -> bool { with_callback_receiver(|receiver| { for callback in receiver.try_iter() { if let Err(e) = callback() { - let error_string = ByondValue::try_from(::std::format!("{e:?}")).unwrap(); + let error_string = format!("{e:?}").try_into().unwrap(); byondapi::global_call::call_global("stack_trace", &[error_string]).unwrap(); } if timer.elapsed() >= duration { @@ -86,7 +86,7 @@ pub fn process_callbacks_for_millis(millis: u64) -> bool { pub fn callback_processing_hook(time_remaining: ByondValue) -> Result { if time_remaining.is_num() { let limit = time_remaining.get_number().unwrap() as u64; - Ok(ByondValue::from(process_callbacks_for_millis(limit))) + Ok(process_callbacks_for_millis(limit).into()) } else { process_callbacks(); Ok(ByondValue::null()) diff --git a/src/gas.rs b/src/gas.rs index 78a9dd01..489d8c7f 100644 --- a/src/gas.rs +++ b/src/gas.rs @@ -193,11 +193,8 @@ impl GasArena { let next_idx = gas_mixtures.len(); gas_mixtures.push(RwLock::new(Mixture::from_vol(init_volume))); - mix.write_var( - "_extools_pointer_gasmixture", - &ByondValue::from(next_idx as f32), - ) - .unwrap(); + mix.write_var("_extools_pointer_gasmixture", &(next_idx as f32).into()) + .unwrap(); let mut ids_lock = NEXT_GAS_IDS.write(); let cur_last = gas_mixtures.len(); @@ -225,7 +222,7 @@ impl GasArena { .unwrap() .write() .clear_with_vol(init_volume); - mix.write_var("_extools_pointer_gasmixture", &ByondValue::from(idx as f32)) + mix.write_var("_extools_pointer_gasmixture", &(idx as f32).into()) .unwrap(); } Ok(ByondValue::null()) diff --git a/src/lib.rs b/src/lib.rs index 8da25bfa..5da326b7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -155,14 +155,15 @@ fn temperature_share_hook() { #[byondapi_binds::bind("/datum/gas_mixture/proc/get_gases")] fn get_gases_hook(src: ByondValue) { with_mix(&src, |mix| { - let mut gases_list: ByondValueList = ByondValue::new_list()?.try_into().unwrap(); + let mut gases_list = ByondValue::new_list()?; mix.for_each_gas(|idx, gas| { if gas > GAS_MIN_MOLES { - gases_list.push(&gas_idx_to_id(idx))?; + gases_list.push_list(gas_idx_to_id(idx))?; } Ok(()) })?; - Ok(ByondValue::try_from(gases_list)?) + + Ok(gases_list) }) } diff --git a/src/turfs.rs b/src/turfs.rs index f1520a52..c514aceb 100644 --- a/src/turfs.rs +++ b/src/turfs.rs @@ -539,8 +539,7 @@ fn update_visuals(src: ByondValue) -> Result { match src.read_var("air") { Err(_) => Ok(ByondValue::null()), Ok(air) => { - let overlay_types = ByondValue::new_list()?; - let mut overlay_types: ByondValueList = overlay_types.try_into()?; + let mut overlay_types = Vec::new(); let gas_overlays = byondapi::global_call::call_global("get_overlays", &[])?; let ptr = air.read_number("_extools_pointer_gasmixture")? as usize; GasArena::with_gas_mixture(ptr, |mix| { @@ -552,7 +551,7 @@ fn update_visuals(src: ByondValue) -> Result { if let Ok(this_gas_overlay) = this_overlay_list .read_list_index(gas::mixture::visibility_step(moles) as f32) { - overlay_types.push(&this_gas_overlay)?; + overlay_types.push(this_gas_overlay); } } } @@ -560,7 +559,7 @@ fn update_visuals(src: ByondValue) -> Result { }) })?; - Ok(src.call("set_visuals", &[ByondValue::try_from(overlay_types)?])?) + Ok(src.call("set_visuals", &[overlay_types.as_slice().try_into()?])?) } } } diff --git a/src/turfs/groups.rs b/src/turfs/groups.rs index c9208546..3663d248 100644 --- a/src/turfs/groups.rs +++ b/src/turfs/groups.rs @@ -50,12 +50,9 @@ fn groups_hook(mut src: ByondValue, remaining: ByondValue) { })?; src.write_var( "cost_groups", - &ByondValue::from(0.8 * prev_cost + 0.2 * (bench as f32)), - )?; - src.write_var( - "num_group_turfs_processed", - &ByondValue::from(num_eq as f32), + &(0.8 * prev_cost + 0.2 * (bench as f32)).into(), )?; + src.write_var("num_group_turfs_processed", &(num_eq as f32).into())?; Ok(is_cancelled.into()) } diff --git a/src/turfs/katmos.rs b/src/turfs/katmos.rs index ffbdf8c8..5625ad48 100644 --- a/src/turfs/katmos.rs +++ b/src/turfs/katmos.rs @@ -441,7 +441,7 @@ fn explosively_depressurize( let _average_moles = total_moles / (progression_order.len() - space_turf_len) as f32; let hpd = byondapi::global_call::call_global("get_hpds", &[])?; - let mut hpd_list: ByondValueList = (&hpd).try_into()?; + let mut hpd_list = hpd.get_list()?; for &cur_index in progression_order.iter().rev() { let cur_orig = info.entry(cur_index).or_default(); @@ -461,7 +461,8 @@ fn explosively_depressurize( } let mut byond_turf = ByondValue::new_ref(TURF_TYPE, cur_mixture.id); if byondapi::map::byond_locatein(&byond_turf, &hpd)?.is_null() { - hpd_list.push(&byond_turf)?; + hpd_list.push(byond_turf); + hpd.write_list(&hpd_list)?; } let adj_index = cur_info.curr_transfer_dir.unwrap(); @@ -479,10 +480,8 @@ fn explosively_depressurize( let mut byond_turf_adj = ByondValue::new_ref(TURF_TYPE, cur_mixture.id); - byond_turf.write_var( - "pressure_difference", - &ByondValue::from(cur_info.curr_transfer_amount), - )?; + byond_turf + .write_var("pressure_difference", &cur_info.curr_transfer_amount.into())?; byond_turf.write_var( "pressure_direction", &byondapi::global_call::call_global( @@ -492,10 +491,8 @@ fn explosively_depressurize( )?; if adj_info.curr_transfer_dir.is_none() { - byond_turf_adj.write_var( - "pressure_difference", - &ByondValue::from(adj_info.curr_transfer_amount), - )?; + byond_turf_adj + .write_var("pressure_difference", &adj_info.curr_transfer_amount.into())?; byond_turf_adj.write_var( "pressure_direction", &byondapi::global_call::call_global( @@ -505,7 +502,7 @@ fn explosively_depressurize( )?; } - floor_rip_turfs.push((byond_turf, ByondValue::from(sum))); + floor_rip_turfs.push((byond_turf, sum.into())); } Ok(floor_rip_turfs) })?; @@ -713,10 +710,7 @@ fn send_pressure_differences( let turf = ByondValue::new_ref(TURF_TYPE, cur_turf); let other_turf = ByondValue::new_ref(TURF_TYPE, adj_turf); if let Err(e) = turf.call("consider_pressure_difference", &[other_turf, real_amount]) { - byondapi::global_call::call_global( - "stack_trace", - &[ByondValue::new_str(format!("{e:?}"))?], - )?; + byondapi::global_call::call_global("stack_trace", &[format!("{e:?}").try_into()?])?; } Ok(()) }))); @@ -748,9 +742,9 @@ fn equalize_hook(mut src: ByondValue, remaining: ByondValue) { let prev_cost = src.read_number("cost_equalize")?; src.write_var( "cost_equalize", - &ByondValue::from(0.8 * prev_cost + 0.2 * (bench as f32)), + &(0.8 * prev_cost + 0.2 * (bench as f32)).into(), )?; - src.write_var("num_equalize_processed", &ByondValue::from(num_eq as f32))?; + src.write_var("num_equalize_processed", &(num_eq as f32).into())?; Ok(is_cancelled.into()) } diff --git a/src/turfs/processing.rs b/src/turfs/processing.rs index 20fc9b36..767eff02 100644 --- a/src/turfs/processing.rs +++ b/src/turfs/processing.rs @@ -317,12 +317,12 @@ fn fdm( if diff > 5.0 { turf.call( "consider_pressure_difference", - &[enemy_tile, ByondValue::from(diff)], + &[enemy_tile, diff.into()], )?; } else if diff < -5.0 { enemy_tile.call( "consider_pressure_difference", - &[turf.clone(), ByondValue::from(-diff)], + &[turf.clone(), (-diff).into()], )?; } }