Skip to content

Commit

Permalink
some things
Browse files Browse the repository at this point in the history
  • Loading branch information
jupyterkat committed Nov 24, 2023
1 parent fa49dcf commit f13b55d
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 39 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
36 changes: 18 additions & 18 deletions bindings.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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")()

Expand All @@ -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)

2 changes: 1 addition & 1 deletion crates/auxcallback/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion src/gas/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}"))
})
Expand Down
2 changes: 1 addition & 1 deletion src/reaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub type ReactionIdentifier = u64;

use eyre::{Context, Result};

#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct Reaction {
id: ReactionIdentifier,
priority: ReactionPriority,
Expand Down
30 changes: 19 additions & 11 deletions src/turfs/katmos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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();

Expand Down Expand Up @@ -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();

Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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<NodeIndex, FxBuildHasher> = Default::default();
Expand Down

0 comments on commit f13b55d

Please sign in to comment.