Skip to content

Commit

Permalink
Adds sanity check on visuals update callback for turfs with null air …
Browse files Browse the repository at this point in the history
…mixes
  • Loading branch information
MarkSuckerberg committed Nov 15, 2024
1 parent 54c5db2 commit fc0c76f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/turfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,14 +533,16 @@ fn update_visuals(src: ByondValue) -> Result<ByondValue> {
// 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"))
.wrap_err("GLOB is null")?
.wrap_err("Unable to get GLOB from BYOND globals")?
.read_var_id(byond_string!("gas_data"))
.wrap_err("gas_data is null")?
.wrap_err("gas_data is undefined on GLOB")?
.read_var_id(byond_string!("overlays"))
.wrap_err("overlays is null")?;
.wrap_err("overlays is undefined in GLOB.gas_data")?;
let ptr = air
.read_number_id(byond_string!("_extools_pointer_gasmixture"))
.wrap_err("Gas mixture doesn't have a valid pointer")? as usize;
.read_var_id(byond_string!("_extools_pointer_gasmixture"))
.wrap_err("air is undefined on turf")?
.get_number()
.wrap_err("Gas mixture has invalid pointer")? as usize;
let overlay_types = GasArena::with_gas_mixture(ptr, |mix| {
Ok(mix
.enumerate()
Expand Down
9 changes: 9 additions & 0 deletions src/turfs/processing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,15 @@ fn post_process() {
if should_update_vis {
drop(sender.try_send(Box::new(move || {
let turf = ByondValue::new_ref(ValueType::Turf, id);

// Not valid for visuals updating if it doesn't have air defined now
if !turf
.read_var_id(byond_string!("air"))
.is_ok_and(|air| !air.is_null())
{
return Ok(());
}

update_visuals(turf).wrap_err("Updating Visuals")?;
Ok(())
})));
Expand Down

0 comments on commit fc0c76f

Please sign in to comment.