diff --git a/crates/auxcallback/src/lib.rs b/crates/auxcallback/src/lib.rs index 93fb167f..df87d4f4 100644 --- a/crates/auxcallback/src/lib.rs +++ b/crates/auxcallback/src/lib.rs @@ -36,7 +36,7 @@ fn process_callbacks() { .for_each(|e| { let error_string = format!("{e:?}").try_into().unwrap(); byondapi::global_call::call_global_id( - byond_string!("stack_trace"), + byond_string!("byondapi_stack_trace"), &[error_string], ) .unwrap(); @@ -46,14 +46,13 @@ fn process_callbacks() { /// Goes through every single outstanding callback and calls them, until a given time limit is reached. fn process_callbacks_for(duration: Duration) -> bool { - //let stack_trace = Proc::find("/proc/auxtools_stack_trace").unwrap(); let timer = Instant::now(); with_callback_receiver(|receiver| { for callback in receiver.try_iter() { if let Err(e) = callback() { let error_string = format!("{e:?}").try_into().unwrap(); byondapi::global_call::call_global_id( - byond_string!("stack_trace"), + byond_string!("byondapi_stack_trace"), &[error_string], ) .unwrap(); diff --git a/src/gas/types.rs b/src/gas/types.rs index dad051da..3491534b 100644 --- a/src/gas/types.rs +++ b/src/gas/types.rs @@ -234,7 +234,7 @@ pub fn destroy_gas_info_structs() { gas_ids.clear(); }); } - +/// For registering gases, do not touch this. #[byondapi::bind("/proc/_auxtools_register_gas")] fn hook_register_gas(gas: ByondValue) -> Result { let gas_id = gas.read_string_id(byond_string!("id"))?; @@ -273,6 +273,7 @@ fn hook_register_gas(gas: ByondValue) -> Result { Ok(ByondValue::null()) } +/// Registers gases, and get reaction infos for auxmos, only call when ssair is initing. #[byondapi::bind("/proc/auxtools_atmos_init")] fn hook_init(gas_data: ByondValue) -> Result { let data = gas_data.read_var_id(byond_string!("datums"))?; @@ -317,6 +318,7 @@ fn get_reaction_info() -> BTreeMap { reaction_cache } +/// For updating reaction informations for auxmos, only call this when it is changed. #[byondapi::bind("/datum/controller/subsystem/air/proc/auxtools_update_reactions")] fn update_reactions() -> Result { *REACTION_INFO.write() = Some(get_reaction_info()); @@ -419,7 +421,7 @@ pub fn update_gas_refs() { } }); } - +/// For updating reagent gas fire products, do not use for now. #[byondapi::bind("/proc/finalize_gas_refs")] fn finalize_gas_refs() -> Result { update_gas_refs(); diff --git a/src/lib.rs b/src/lib.rs index b72d5201..189bb76c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -306,7 +306,7 @@ fn adjust_multi_hook() -> Result { } } -///Args: (amount). Adds the given amount to each gas. +/// Args: (amount). Adds the given amount to each gas. #[byondapi::bind("/datum/gas_mixture/proc/add")] fn add_hook(src: ByondValue, num_val: ByondValue) -> Result { let vf = num_val.get_number().unwrap_or_default(); @@ -316,7 +316,7 @@ fn add_hook(src: ByondValue, num_val: ByondValue) -> Result { }) } -///Args: (amount). Subtracts the given amount from each gas. +/// Args: (amount). Subtracts the given amount from each gas. #[byondapi::bind("/datum/gas_mixture/proc/subtract")] fn subtract_hook(src: ByondValue, num_val: ByondValue) -> Result { let vf = num_val.get_number().unwrap_or_default(); @@ -326,7 +326,7 @@ fn subtract_hook(src: ByondValue, num_val: ByondValue) -> Result { }) } -///Args: (coefficient). Multiplies all gases by this amount. +/// Args: (coefficient). Multiplies all gases by this amount. #[byondapi::bind("/datum/gas_mixture/proc/multiply")] fn multiply_hook(src: ByondValue, num_val: ByondValue) -> Result { let vf = num_val.get_number().unwrap_or(1.0); @@ -336,7 +336,7 @@ fn multiply_hook(src: ByondValue, num_val: ByondValue) -> Result { }) } -///Args: (coefficient). Divides all gases by this amount. +/// Args: (coefficient). Divides all gases by this amount. #[byondapi::bind("/datum/gas_mixture/proc/divide")] fn divide_hook(src: ByondValue, num_val: ByondValue) -> Result { let vf = num_val.get_number().unwrap_or(1.0).recip(); @@ -346,7 +346,7 @@ fn divide_hook(src: ByondValue, num_val: ByondValue) -> Result { }) } -///Args: (mixture, flag, amount). Takes `amount` from src that have the given `flag` and puts them into the given `mixture`. Returns: 0 if gas didn't have any with that flag, 1 if it did. +/// Args: (mixture, flag, amount). Takes `amount` from src that have the given `flag` and puts them into the given `mixture`. Returns: 0 if gas didn't have any with that flag, 1 if it did. #[byondapi::bind("/datum/gas_mixture/proc/__remove_by_flag")] fn remove_by_flag_hook( src: ByondValue, @@ -372,7 +372,7 @@ fn remove_by_flag_hook( Ok(true.into()) }) } -///Args: (flag). As get_gases(), but only returns gases with the given flag. +/// Args: (flag). As get_gases(), but only returns gases with the given flag. #[byondapi::bind("/datum/gas_mixture/proc/get_by_flag")] fn get_by_flag_hook(src: ByondValue, flag_val: ByondValue) -> Result { let flag = flag_val.get_number().map_or(0, |n: f32| n as u32); @@ -637,7 +637,7 @@ fn hook_amt_gas_mixes() -> Result { fn hook_max_gas_mixes() -> Result { Ok((tot_gases() as f32).into()) } - +/// Returns: true. Parses gas strings like "o2=2500;plasma=5000;TEMP=370" and turns src mixes into the parsed gas mixture, invalid patterns will be ignored #[byondapi::bind("/datum/gas_mixture/proc/__auxtools_parse_gas_string")] fn parse_gas_string(src: ByondValue, string: ByondValue) -> Result { let actual_string = string.get_string()?; diff --git a/src/turfs.rs b/src/turfs.rs index 43904ec9..40b74f3c 100644 --- a/src/turfs.rs +++ b/src/turfs.rs @@ -415,6 +415,7 @@ where f(PLANETARY_ATMOS.upgradable_read()) } +/// Returns: null. Updates turf air infos, whether the turf is closed, is space or a regular turf, or even a planet turf is decided here. #[byondapi::bind("/turf/proc/update_air_ref")] fn hook_register_turf(src: ByondValue, flag: ByondValue) -> Result { let id = src.get_ref()?; @@ -498,7 +499,7 @@ fn determine_turf_flag(src: &ByondValue) -> i32 { } } */ - +/// Updates adjacency infos for turfs, only use this in immediateupdateturfs. #[byondapi::bind("/turf/proc/__update_auxtools_turf_adjacency_info")] fn hook_infos(src: ByondValue) -> Result { let id = src.get_ref()?; diff --git a/src/turfs/groups.rs b/src/turfs/groups.rs index 7445422d..45edf679 100644 --- a/src/turfs/groups.rs +++ b/src/turfs/groups.rs @@ -16,7 +16,7 @@ fn with_groups(f: impl Fn(Option>) -> T) -> T { pub fn send_to_groups(sent: BTreeSet) { GROUPS_CHANNEL.try_lock().map(|mut opt| opt.replace(sent)); } - +/// Returns: If this cycle is interrupted by overtiming or not. Starts a processing excited groups cycle, does nothing if process_turfs isn't ran. #[byondapi::bind("/datum/controller/subsystem/air/proc/process_excited_groups_auxtools")] fn groups_hook(mut src: ByondValue, remaining: ByondValue) -> Result { let group_pressure_goal = src diff --git a/src/turfs/katmos.rs b/src/turfs/katmos.rs index d4df1741..bf0448dd 100644 --- a/src/turfs/katmos.rs +++ b/src/turfs/katmos.rs @@ -716,6 +716,7 @@ fn send_pressure_differences( } } +/// Returns: If this cycle is interrupted by overtiming or not. Starts a katmos equalize cycle, does nothing if process_turfs isn't ran. #[byondapi::bind("/datum/controller/subsystem/air/proc/process_turf_equalize_auxtools")] fn equalize_hook(mut src: ByondValue, remaining: ByondValue) -> Result { let equalize_hard_turf_limit = src diff --git a/src/turfs/processing.rs b/src/turfs/processing.rs index 62f1ca23..a165fbd2 100644 --- a/src/turfs/processing.rs +++ b/src/turfs/processing.rs @@ -7,16 +7,18 @@ use parking_lot::RwLock; use std::collections::{BTreeMap, BTreeSet}; use tinyvec::TinyVec; +/// Returns: If a processing thread is running or not. #[byondapi::bind("/datum/controller/subsystem/air/proc/thread_running")] fn thread_running_hook() -> Result { Ok(TASKS.try_write().is_none().into()) } +/// Returns: If this cycle is interrupted by overtiming or not. Calls all outstanding callbacks created by other processes, usually ones that can't run on other threads and only the main thread. #[byondapi::bind("/datum/controller/subsystem/air/proc/finish_turf_processing_auxtools")] fn finish_process_turfs(time_remaining: ByondValue) -> Result { Ok(process_callbacks_for_millis(time_remaining.get_number()? as u64).into()) } - +/// Returns: If this cycle is interrupted by overtiming or not. Starts a processing turfs cycle. #[byondapi::bind("/datum/controller/subsystem/air/proc/process_turfs_auxtools")] fn process_turf_hook(src: ByondValue, remaining: ByondValue) -> Result { let remaining_time = Duration::from_millis(remaining.get_number().unwrap_or(50.0) as u64);