From f13b55db4e2ebf881a325ad5f5512e1901243a48 Mon Sep 17 00:00:00 2001 From: Katherine Kiefer Date: Fri, 24 Nov 2023 23:59:03 +1100 Subject: [PATCH] some things --- Cargo.lock | 12 ++++++------ Cargo.toml | 2 +- bindings.dm | 36 +++++++++++++++++------------------ crates/auxcallback/Cargo.toml | 2 +- src/gas/types.rs | 2 +- src/reaction.rs | 2 +- src/turfs/katmos.rs | 30 ++++++++++++++++++----------- 7 files changed, 47 insertions(+), 39 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0205b4b..98e60ab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -124,7 +124,7 @@ checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" [[package]] name = "byondapi" version = "0.2.1" -source = "git+https://github.com/jupyterkat/byondapi-rs#3ac193f0945e52f2217ac2cc324db5dfc0a7625f" +source = "git+https://github.com/jupyterkat/byondapi-rs#e4fb95cae12eb6a665472e198f5e01b9929e79db" 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#3ac193f0945e52f2217ac2cc324db5dfc0a7625f" +source = "git+https://github.com/jupyterkat/byondapi-rs#e4fb95cae12eb6a665472e198f5e01b9929e79db" dependencies = [ "bindgen", "libloading 0.8.1", @@ -286,9 +286,9 @@ dependencies = [ [[package]] name = "eyre" -version = "0.6.8" +version = "0.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c2b6b5a29c02cdc822728b7d7b8ae1bab3e3b05d44522770ddd49722eeac7eb" +checksum = "80f656be11ddf91bd709454d15d5bd896fbaf4cc3314e69349e4d1569f5b46cd" dependencies = [ "indenter", "once_cell", @@ -685,9 +685,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.24" +version = "0.38.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ad981d6c340a49cdc40a1028d9c6084ec7e9fa33fcb839cab656a267071e234" +checksum = "dc99bc2d4f1fed22595588a013687477aedf3cdcfb26558c559edb67b4d9b22e" dependencies = [ "bitflags 2.4.1", "errno", diff --git a/Cargo.toml b/Cargo.toml index 7625836..cd118a4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -57,7 +57,7 @@ bitflags = "2.4.1" nom = "7.1.3" coarsetime = "0.1.33" mimalloc = { version = "0.1.39", default-features = false } -eyre = "0.6.8" +eyre = "0.6.9" [dependencies.tinyvec] version = "1.6.0" diff --git a/bindings.dm b/bindings.dm index a9f3b20..4343b3a 100644 --- a/bindings.dm +++ b/bindings.dm @@ -6,27 +6,12 @@ else return "auxmos" -/proc/finalize_gas_refs() - return call_ext(AUXMOS, "byond:finalize_gas_refs_ffi")() - -/datum/controller/subsystem/air/proc/auxtools_update_reactions() - return call_ext(AUXMOS, "byond:update_reactions_ffi")() - -/proc/auxtools_atmos_init(gas_data) - return call_ext(AUXMOS, "byond:hook_init_ffi")(gas_data) - -/proc/_auxtools_register_gas(gas) - return call_ext(AUXMOS, "byond:hook_register_gas_ffi")(gas) - /turf/proc/__update_auxtools_turf_adjacency_info() return call_ext(AUXMOS, "byond:hook_infos_ffi")(src) /turf/proc/update_air_ref(flag) return call_ext(AUXMOS, "byond:hook_register_turf_ffi")(src, flag) -/datum/controller/subsystem/air/proc/process_excited_groups_auxtools(remaining) - return call_ext(AUXMOS, "byond:groups_hook_ffi")(src, remaining) - /datum/gas_mixture/proc/__auxtools_parse_gas_string(string) return call_ext(AUXMOS, "byond:parse_gas_string_ffi")(src, string) @@ -166,6 +151,24 @@ /proc/process_atmos_callbacks(remaining) return call_ext(AUXMOS, "byond:atmos_callback_handle_ffi")(remaining) +/datum/controller/subsystem/air/proc/process_turf_equalize_auxtools(remaining) + return call_ext(AUXMOS, "byond:equalize_hook_ffi")(src, remaining) + +/datum/controller/subsystem/air/proc/process_excited_groups_auxtools(remaining) + return call_ext(AUXMOS, "byond:groups_hook_ffi")(src, remaining) + +/proc/finalize_gas_refs() + return call_ext(AUXMOS, "byond:finalize_gas_refs_ffi")() + +/datum/controller/subsystem/air/proc/auxtools_update_reactions() + return call_ext(AUXMOS, "byond:update_reactions_ffi")() + +/proc/auxtools_atmos_init(gas_data) + return call_ext(AUXMOS, "byond:hook_init_ffi")(gas_data) + +/proc/_auxtools_register_gas(gas) + return call_ext(AUXMOS, "byond:hook_register_gas_ffi")(gas) + /proc/__auxmos_shutdown() return call_ext(AUXMOS, "byond:auxmos_shutdown_ffi")() @@ -178,6 +181,3 @@ /datum/controller/subsystem/air/proc/thread_running() return call_ext(AUXMOS, "byond:thread_running_hook_ffi")() -/datum/controller/subsystem/air/proc/process_turf_equalize_auxtools(remaining) - return call_ext(AUXMOS, "byond:equalize_hook_ffi")(src, remaining) - diff --git a/crates/auxcallback/Cargo.toml b/crates/auxcallback/Cargo.toml index ef89c4b..bcb5e02 100644 --- a/crates/auxcallback/Cargo.toml +++ b/crates/auxcallback/Cargo.toml @@ -13,4 +13,4 @@ crate-type = ["lib"] flume = "0.11.0" coarsetime = "0.1.33" byondapi = { git = "https://github.com/jupyterkat/byondapi-rs", package = "byondapi" } -eyre = "0.6.8" +eyre = "0.6.9" diff --git a/src/gas/types.rs b/src/gas/types.rs index 44b81a9..6df4cd6 100644 --- a/src/gas/types.rs +++ b/src/gas/types.rs @@ -466,7 +466,7 @@ pub fn gas_idx_to_id(idx: GasIDX) -> ByondValue { stuff .get(&idx) .unwrap_or_else(|| panic!("Invalid gas index: {idx}")) - .as_bytes(), + .as_ref(), ) .unwrap_or_else(|_| panic!("Cannot convert gas index to byond string: {idx}")) }) diff --git a/src/reaction.rs b/src/reaction.rs index 248bb5e..9052af9 100644 --- a/src/reaction.rs +++ b/src/reaction.rs @@ -15,7 +15,7 @@ pub type ReactionIdentifier = u64; use eyre::{Context, Result}; -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct Reaction { id: ReactionIdentifier, priority: ReactionPriority, diff --git a/src/turfs/katmos.rs b/src/turfs/katmos.rs index 5625ad4..3d9a4b9 100644 --- a/src/turfs/katmos.rs +++ b/src/turfs/katmos.rs @@ -327,10 +327,13 @@ fn take_from_givers( } } -fn explosively_depressurize( - initial_index: NodeIndex, - equalize_hard_turf_limit: usize, -) -> Result<()> { +fn explosively_depressurize(initial_index: TurfID, equalize_hard_turf_limit: usize) -> Result<()> { + let initial_index = with_turf_gases_read(|arena| arena.get_id(initial_index)); + if initial_index.is_none() { + return Ok(()); + } + let initial_index = initial_index.unwrap(); + //1st floodfill let (space_turfs, warned_about_planet_atmos) = { let mut cur_queue_idx = 0; @@ -440,8 +443,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 = hpd.get_list()?; + let mut hpd = byondapi::global_call::call_global("get_hpds", &[])?; for &cur_index in progression_order.iter().rev() { let cur_orig = info.entry(cur_index).or_default(); @@ -461,8 +463,7 @@ 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.write_list(&hpd_list)?; + hpd.push_list(byond_turf)?; } let adj_index = cur_info.curr_transfer_dir.unwrap(); @@ -532,6 +533,7 @@ fn flood_fill_zones( let mut ignore_zone = false; while let Some(cur_index) = border_turfs.pop_front() { let cur_turf = arena.get(cur_index).unwrap(); + let cur_turf_id = cur_turf.id; total_moles += cur_turf.total_moles(); @@ -557,7 +559,7 @@ fn flood_fill_zones( // NOT ONE OF YOU IS GONNA SURVIVE THIS // (I just made explosions less laggy, you're welcome) drop(sender.try_send(Box::new(move || { - explosively_depressurize(cur_index, equalize_hard_turf_limit) + explosively_depressurize(cur_turf_id, equalize_hard_turf_limit) }))); ignore_zone = true; } @@ -566,7 +568,7 @@ fn flood_fill_zones( && weight.contains(AdjacentFlags::ATMOS_ADJACENT_FIRELOCK) { drop(sender.try_send(Box::new(move || { - planet_equalize(cur_index, equalize_hard_turf_limit) + planet_equalize(cur_turf_id, equalize_hard_turf_limit) }))); ignore_zone = true; } @@ -576,7 +578,13 @@ fn flood_fill_zones( (!ignore_zone).then_some((turf_graph, total_moles)) } -fn planet_equalize(initial_index: NodeIndex, equalize_hard_turf_limit: usize) -> Result<()> { +fn planet_equalize(initial_index: TurfID, equalize_hard_turf_limit: usize) -> Result<()> { + let initial_index = with_turf_gases_read(|arena| arena.get_id(initial_index)); + if initial_index.is_none() { + return Ok(()); + } + let initial_index = initial_index.unwrap(); + let mut cur_queue_idx = 0; let mut warned_about_space = false; let mut planet_turfs: IndexSet = Default::default();