Skip to content

Commit

Permalink
cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
jupyterkat committed Jan 16, 2024
1 parent de6f041 commit aa31f3a
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 51 deletions.
20 changes: 10 additions & 10 deletions src/gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl GasArena {
let gas_mixtures = lock.as_ref().unwrap();
let mix = gas_mixtures
.get(id)
.ok_or_else(|| eyre::eyre!("No gas mixture with ID {} exists!", id))?
.ok_or_else(|| eyre::eyre!("No gas mixture with ID {id} exists!"))?
.read();
f(&mix)
}
Expand All @@ -94,7 +94,7 @@ impl GasArena {
let gas_mixtures = lock.as_ref().unwrap();
let mut mix = gas_mixtures
.get(id)
.ok_or_else(|| eyre::eyre!("No gas mixture with ID {} exists!", id))?
.ok_or_else(|| eyre::eyre!("No gas mixture with ID {id} exists!"))?
.write();
f(&mut mix)
}
Expand All @@ -111,11 +111,11 @@ impl GasArena {
let gas_mixtures = lock.as_ref().unwrap();
let src_gas = gas_mixtures
.get(src)
.ok_or_else(|| eyre::eyre!("No gas mixture with ID {} exists!", src))?
.ok_or_else(|| eyre::eyre!("No gas mixture with ID {src} exists!"))?
.read();
let arg_gas = gas_mixtures
.get(arg)
.ok_or_else(|| eyre::eyre!("No gas mixture with ID {} exists!", arg))?
.ok_or_else(|| eyre::eyre!("No gas mixture with ID {arg} exists!"))?
.read();
f(&src_gas, &arg_gas)
}
Expand All @@ -133,7 +133,7 @@ impl GasArena {
if src == arg {
let mut entry = gas_mixtures
.get(src)
.ok_or_else(|| eyre::eyre!("No gas mixture with ID {} exists!", src))?
.ok_or_else(|| eyre::eyre!("No gas mixture with ID {src} exists!"))?
.write();
let mix = &mut entry;
let mut copied = mix.clone();
Expand All @@ -142,11 +142,11 @@ impl GasArena {
f(
&mut gas_mixtures
.get(src)
.ok_or_else(|| eyre::eyre!("No gas mixture with ID {} exists!", src))?
.ok_or_else(|| eyre::eyre!("No gas mixture with ID {src} exists!"))?
.write(),
&mut gas_mixtures
.get(arg)
.ok_or_else(|| eyre::eyre!("No gas mixture with ID {} exists!", arg))?
.ok_or_else(|| eyre::eyre!("No gas mixture with ID {arg} exists!"))?
.write(),
)
}
Expand All @@ -165,17 +165,17 @@ impl GasArena {
if src == arg {
let entry = gas_mixtures
.get(src)
.ok_or_else(|| eyre::eyre!("No gas mixture with ID {} exists!", src))?;
.ok_or_else(|| eyre::eyre!("No gas mixture with ID {src} exists!"))?;
let gas_copy = entry.read().clone();
f(entry, &RwLock::new(gas_copy))
} else {
f(
gas_mixtures
.get(src)
.ok_or_else(|| eyre::eyre!("No gas mixture with ID {} exists!", src))?,
.ok_or_else(|| eyre::eyre!("No gas mixture with ID {src} exists!"))?,
gas_mixtures
.get(arg)
.ok_or_else(|| eyre::eyre!("No gas mixture with ID {} exists!", arg))?,
.ok_or_else(|| eyre::eyre!("No gas mixture with ID {arg} exists!"))?,
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/gas/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ pub fn gas_idx_from_string(id: &str) -> Result<GasIDX> {
.as_ref()
.ok_or_else(|| eyre::eyre!("Gases not loaded yet! Uh oh!"))?
.get(id)
.ok_or_else(|| eyre::eyre!("Invalid gas ID: {}", id))?
.ok_or_else(|| eyre::eyre!("Invalid gas ID: {id}"))?
.idx)
}

Expand Down
25 changes: 0 additions & 25 deletions src/init_shutdown.rs
Original file line number Diff line number Diff line change
@@ -1,28 +1,3 @@
use byondapi::prelude::*;

//#[byondapi_binds::bind("/proc/__auxmos_init")]
//pub fn auxmos_init() {
// super::gas::initialize_gases();
// super::types::initialize_gas_info_structs();
// super::turfs::initialize_turfs();
// Ok(ByondValue::null())
//}

byondapi::inventory::submit! {byondapi::InitFunc(super::gas::initialize_gases)}
byondapi::inventory::submit! {byondapi::InitFunc(super::types::initialize_gas_info_structs)}
byondapi::inventory::submit! {byondapi::InitFunc(super::turfs::initialize_turfs)}

#[byondapi_binds::bind("/proc/__auxmos_shutdown")]
pub fn auxmos_shutdown() {
super::gas::shut_down_gases();
super::types::destroy_gas_info_structs();
super::turfs::shutdown_turfs();
super::turfs::groups::flush_groups_channel();
super::reaction::clean_up_reaction_values();
auxcallback::clean_callbacks();
#[cfg(feature = "katmos")]
{
super::turfs::katmos::flush_equalize_channel();
}
Ok(ByondValue::null())
}
7 changes: 0 additions & 7 deletions src/reaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,6 @@ thread_local! {
static REACTION_VALUES: RefCell<HashMap<ReactionIdentifier, ReactionSide, FxBuildHasher>> = Default::default();
}

pub fn clean_up_reaction_values() {
crate::turfs::wait_for_tasks();
REACTION_VALUES.with_borrow_mut(|reaction_values| {
reaction_values.clear();
});
}

/// Runs a reaction given a `ReactionIdentifier`. Returns the result of the reaction, error or success.
/// # Errors
/// If the reaction itself has a runtime.
Expand Down
9 changes: 1 addition & 8 deletions src/turfs/groups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,7 @@ fn groups_hook(mut src: ByondValue, remaining: ByondValue) {
let bench = start_time.elapsed().as_millis();
let prev_cost = src
.read_number_id(byond_string!("cost_groups"))
.map_err(|_| {
eyre::eyre!(
"Attempt to interpret non-number value as number {} {}:{}",
std::file!(),
std::line!(),
std::column!()
)
})?;
.map_err(|_| eyre::eyre!("Attempt to interpret non-number value as number"))?;
src.write_var_id(
byond_string!("cost_groups"),
&(0.8 * prev_cost + 0.2 * (bench as f32)).into(),
Expand Down

0 comments on commit aa31f3a

Please sign in to comment.