diff --git a/Cargo.lock b/Cargo.lock index 3572647f..c0d0083c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,21 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "addr2line" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" -dependencies = [ - "gimli", -] - -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - [[package]] name = "ahash" version = "0.8.11" @@ -77,7 +62,6 @@ dependencies = [ "bitflags 2.5.0", "byondapi", "coarsetime", - "color-eyre", "dashmap", "eyre", "float-ord", @@ -92,25 +76,8 @@ dependencies = [ "parking_lot", "petgraph", "rayon", + "simple-eyre", "tinyvec", - "tracing", - "tracing-error", - "tracing-subscriber", -] - -[[package]] -name = "backtrace" -version = "0.3.71" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" -dependencies = [ - "addr2line", - "cc", - "cfg-if", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", ] [[package]] @@ -242,33 +209,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "color-eyre" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55146f5e46f237f7423d74111267d4597b59b0dad0ffaf7303bce9945d843ad5" -dependencies = [ - "backtrace", - "color-spantrace", - "eyre", - "indenter", - "once_cell", - "owo-colors", - "tracing-error", -] - -[[package]] -name = "color-spantrace" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd6be1b2a7e382e2b98b43b2adcca6bb0e465af0bdd38123873ae61eb17a72c2" -dependencies = [ - "once_cell", - "owo-colors", - "tracing-core", - "tracing-error", -] - [[package]] name = "crossbeam-deque" version = "0.8.5" @@ -396,9 +336,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.12" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +checksum = "a06fddc2749e0528d2813f95e050e87e52c8cbbae56223b9babf73b3e53b0cc6" dependencies = [ "cfg-if", "js-sys", @@ -407,12 +347,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "gimli" -version = "0.28.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" - [[package]] name = "glob" version = "0.3.1" @@ -560,15 +494,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" -[[package]] -name = "miniz_oxide" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" -dependencies = [ - "adler", -] - [[package]] name = "nanorand" version = "0.7.0" @@ -588,16 +513,6 @@ dependencies = [ "minimal-lexical", ] -[[package]] -name = "nu-ansi-term" -version = "0.46.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" -dependencies = [ - "overload", - "winapi", -] - [[package]] name = "num_enum" version = "0.7.2" @@ -619,33 +534,12 @@ dependencies = [ "syn", ] -[[package]] -name = "object" -version = "0.32.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" -dependencies = [ - "memchr", -] - [[package]] name = "once_cell" version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "overload" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" - -[[package]] -name = "owo-colors" -version = "3.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" - [[package]] name = "parking_lot" version = "0.12.1" @@ -721,12 +615,6 @@ dependencies = [ "siphasher", ] -[[package]] -name = "pin-project-lite" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" - [[package]] name = "prettyplease" version = "0.2.17" @@ -837,12 +725,6 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" -[[package]] -name = "rustc-demangle" -version = "0.1.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" - [[package]] name = "rustc-hash" version = "1.1.0" @@ -892,21 +774,22 @@ version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" -[[package]] -name = "sharded-slab" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" -dependencies = [ - "lazy_static", -] - [[package]] name = "shlex" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +[[package]] +name = "simple-eyre" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b561532e8ffe7ecf09108c4f662896a9ec3eac4999eba84015ec3dcb8cc630a" +dependencies = [ + "eyre", + "indenter", +] + [[package]] name = "siphasher" version = "0.3.11" @@ -930,25 +813,15 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.57" +version = "2.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11a6ae1e52eb25aab8f3fb9fca13be982a373b8f1157ca14b897a825ba4a2d35" +checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] -[[package]] -name = "thread_local" -version = "1.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" -dependencies = [ - "cfg-if", - "once_cell", -] - [[package]] name = "tinyvec" version = "1.6.0" @@ -981,85 +854,12 @@ dependencies = [ "winnow", ] -[[package]] -name = "tracing" -version = "0.1.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" -dependencies = [ - "pin-project-lite", - "tracing-attributes", - "tracing-core", -] - -[[package]] -name = "tracing-attributes" -version = "0.1.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tracing-core" -version = "0.1.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" -dependencies = [ - "once_cell", - "valuable", -] - -[[package]] -name = "tracing-error" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d686ec1c0f384b1277f097b2f279a2ecc11afe8c133c1aabf036a27cb4cd206e" -dependencies = [ - "tracing", - "tracing-subscriber", -] - -[[package]] -name = "tracing-log" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" -dependencies = [ - "log", - "once_cell", - "tracing-core", -] - -[[package]] -name = "tracing-subscriber" -version = "0.3.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" -dependencies = [ - "nu-ansi-term", - "sharded-slab", - "smallvec", - "thread_local", - "tracing-core", - "tracing-log", -] - [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" -[[package]] -name = "valuable" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" - [[package]] name = "version_check" version = "0.9.4" diff --git a/Cargo.toml b/Cargo.toml index 1dea080b..28622fe7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,11 +59,7 @@ petgraph = "0.6.4" bitflags = "2.5.0" nom = "7.1.3" mimalloc = { version = "0.1.39", default-features = false } -color-eyre = "0.6.3" - -tracing = "0.1.40" -tracing-subscriber = "0.3.18" -tracing-error = "0.2.0" +simple-eyre = "0.3.1" [dependencies.tinyvec] version = "1.6.0" diff --git a/src/lib.rs b/src/lib.rs index 931d08f6..cb35a7d5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,25 +22,10 @@ use gas::constants::{ReactionReturn, GAS_MIN_MOLES, MINIMUM_MOLES_DELTA_TO_MOVE} #[global_allocator] static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; -//#[byondapi::init] -//pub fn init_eyre() { -// use tracing_error::ErrorLayer; -// use tracing_subscriber::fmt; -// use tracing_subscriber::prelude::*; -// -// let fmt_layer = fmt::layer().with_target(false).compact(); -// -// tracing_subscriber::registry() -// .with(fmt_layer) -// .with(ErrorLayer::default()) -// .init(); -// -// color_eyre::config::HookBuilder::default() -// .capture_span_trace_by_default(true) -// .display_location_section(true) -// .install() -// .unwrap(); -//} +#[byondapi::init] +pub fn init_eyre() { + simple_eyre::install().unwrap(); +} /// Args: (ms). Runs callbacks until time limit is reached. If time limit is omitted, runs all callbacks. #[byondapi::bind("/proc/process_atmos_callbacks")] diff --git a/src/reaction.rs b/src/reaction.rs index dc11563b..8b6bdbbc 100644 --- a/src/reaction.rs +++ b/src/reaction.rs @@ -53,7 +53,9 @@ pub fn react_by_id( ReactionSide::ByondSide(val) => val .call_id(byond_string!("react"), &[src, holder]) .wrap_err("calling byond side react in react_by_id"), - ReactionSide::RustSide(func) => func(src, holder), + ReactionSide::RustSide(func) => { + func(src, holder).wrap_err("calling rust side react in react_by_id") + } }, ) }) diff --git a/src/turfs.rs b/src/turfs.rs index a06923d0..e332526a 100644 --- a/src/turfs.rs +++ b/src/turfs.rs @@ -33,7 +33,7 @@ use indexmap::IndexMap; use std::time::Duration; use std::{mem::drop, sync::atomic::AtomicU64}; -use eyre::Result; +use eyre::{Context, Result}; bitflags! { #[derive(Default, Clone, Copy, PartialEq, Eq)] @@ -537,10 +537,15 @@ fn update_visuals(src: ByondValue) -> Result { Ok(air) => { // gas_overlays: list( GAS_ID = list( VIS_FACTORS = OVERLAYS )) got it? I don't let gas_overlays = ByondValue::new_global_ref() - .read_var_id(byond_string!("GLOB"))? - .read_var_id(byond_string!("gas_data"))? - .read_var_id(byond_string!("overlays"))?; - let ptr = air.read_number_id(byond_string!("_extools_pointer_gasmixture"))? as usize; + .read_var_id(byond_string!("GLOB")) + .wrap_err("GLOB is null")? + .read_var_id(byond_string!("gas_data")) + .wrap_err("gas_data is null")? + .read_var_id(byond_string!("overlays")) + .wrap_err("overlays is null")?; + let ptr = air + .read_number_id(byond_string!("_extools_pointer_gasmixture")) + .wrap_err("Gas mixture doesn't have a valid pointer")? as usize; let overlay_types = GasArena::with_gas_mixture(ptr, |mix| { Ok(mix .enumerate() @@ -562,10 +567,12 @@ fn update_visuals(src: ByondValue) -> Result { .collect::>()) })?; - Ok(src.call_id( - byond_string!("set_visuals"), - &[overlay_types.as_slice().try_into()?], - )?) + Ok(src + .call_id( + byond_string!("set_visuals"), + &[overlay_types.as_slice().try_into()?], + ) + .wrap_err("Calling set_visuals")?) } } } diff --git a/src/turfs/katmos.rs b/src/turfs/katmos.rs index 439a1600..f535620a 100644 --- a/src/turfs/katmos.rs +++ b/src/turfs/katmos.rs @@ -24,7 +24,7 @@ use hashbrown::{HashMap, HashSet}; use parking_lot::{const_mutex, Mutex}; -use eyre::Result; +use eyre::{Context, Result}; static EQUALIZE_CHANNEL: Mutex>> = const_mutex(None); @@ -554,6 +554,7 @@ fn flood_fill_zones( // (I just made explosions less laggy, you're welcome) drop(sender.try_send(Box::new(move || { explosively_depressurize(cur_turf_id, equalize_hard_turf_limit) + .wrap_err("Decompressing") }))); ignore_zone = true; } @@ -563,6 +564,7 @@ fn flood_fill_zones( { drop(sender.try_send(Box::new(move || { planet_equalize(cur_turf_id, equalize_hard_turf_limit) + .wrap_err("Equalising planet air") }))); } } @@ -705,16 +707,13 @@ fn send_pressure_differences( drop(sender.try_send(Box::new(move || { let turf = ByondValue::new_ref(ValueType::Turf, cur_turf); let other_turf = ByondValue::new_ref(ValueType::Turf, adj_turf); - if let Err(e) = turf.call_id( - byond_string!("consider_pressure_difference"), - &[other_turf, amt.into()], - ) { - byondapi::global_call::call_global_id( - byond_string!("stack_trace"), - &[format!("{e:?}").try_into()?], - )?; - } - Ok(()) + Ok(turf + .call_id( + byond_string!("consider_pressure_difference"), + &[other_turf, amt.into()], + ) + .map(|_| ()) + .wrap_err("Katmos considering pressure differences")?) }))); } } diff --git a/src/turfs/processing.rs b/src/turfs/processing.rs index cedb54ae..6adf3b89 100644 --- a/src/turfs/processing.rs +++ b/src/turfs/processing.rs @@ -1,8 +1,9 @@ use byondapi::{byond_string, prelude::*}; +use eyre::Context; use super::*; -use crate::GasArena; +use crate::{react_hook, GasArena}; use auxcallback::{byond_callback_sender, process_callbacks_for_millis}; @@ -321,12 +322,17 @@ fn fdm( turf.call_id( byond_string!("consider_pressure_difference"), &[enemy_tile, diff.into()], - )?; + ) + .wrap_err("Processing consider pressure differences")?; } else if diff < -5.0 { - enemy_tile.call_id( - byond_string!("consider_pressure_difference"), - &[turf, (-diff).into()], - )?; + enemy_tile + .call_id( + byond_string!("consider_pressure_difference"), + &[turf, (-diff).into()], + ) + .wrap_err( + "Processing consider pressure differences", + )?; } } } @@ -390,16 +396,21 @@ fn post_process() { if should_react { drop(sender.try_send(Box::new(move || { let turf = ByondValue::new_ref(ValueType::Turf, id); - turf.read_var_id(byond_string!("air"))? - .call_id(byond_string!("react"), &[turf])?; + react_hook( + turf.read_var_id(byond_string!("air")).wrap_err_with(|| { + format!("Tried to call react on turf {turf:?} with invalid air!") + })?, + turf, + ) + .wrap_err("Reacting")?; Ok(()) }))); } if should_update_vis { - drop(sender.send(Box::new(move || { + drop(sender.try_send(Box::new(move || { let turf = ByondValue::new_ref(ValueType::Turf, id); - update_visuals(turf)?; + update_visuals(turf).wrap_err("Updating Visuals")?; Ok(()) }))); }