Skip to content

Commit

Permalink
Merge pull request Putnam3145#7 from austation/au
Browse files Browse the repository at this point in the history
stuff
  • Loading branch information
jupyterkat committed Sep 4, 2021
2 parents 3b99779 + ec3aa4d commit 389c49f
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 22 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/auxmos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
with:
toolchain: stable
command: build
args: --target i686-pc-windows-msvc --release --features trit_fire_hook,plasma_fire_hook,generic_fire_hook,xenomedes_fusion,slow_decompression
args: --target i686-pc-windows-msvc --release --features trit_fire_hook,plasma_fire_hook,generic_fire_hook,xenomedes_fusion,explosive_decompression
- name: Upload artifact
uses: actions/upload-artifact@v1
with:
Expand Down Expand Up @@ -52,7 +52,7 @@ jobs:
with:
toolchain: stable
command: build
args: --target i686-unknown-linux-gnu --release --features trit_fire_hook,plasma_fire_hook,generic_fire_hook,xenomedes_fusion,slow_decompression
args: --target i686-unknown-linux-gnu --release --features trit_fire_hook,plasma_fire_hook,generic_fire_hook,xenomedes_fusion,explosive_decompression
- name: Upload artifact
uses: actions/upload-artifact@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
sudo apt update
sudo apt install g++-multilib -y
- name: Build auxmos
run: cargo build --target=i686-unknown-linux-gnu --release --features trit_fire_hook,plasma_fire_hook,generic_fire_hook,xenomedes_fusion,slow_decompression
run: cargo build --target=i686-unknown-linux-gnu --release --features trit_fire_hook,plasma_fire_hook,generic_fire_hook,xenomedes_fusion,explosive_decompression
- uses: actions/upload-artifact@v2
with:
name: Linux compile
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ jobs:
sudo apt update
sudo apt install g++-multilib -y
- name: Check auxmos build
run: cargo check --target=i686-unknown-linux-gnu --release --features trit_fire_hook,plasma_fire_hook,generic_fire_hook,xenomedes_fusion,slow_decompression
run: cargo check --target=i686-unknown-linux-gnu --release --features trit_fire_hook,plasma_fire_hook,generic_fire_hook,xenomedes_fusion,explosive_decompression
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ xenomedes_fusion = []
generic_fire_hook = ["reaction_hooks"]
all_reaction_hooks = ["fusion_hook", "trit_fire_hook", "plasma_fire_hook", "generic_fire_hook"]
explosive_decompression = ["monstermos"]
slow_decompression = ["explosive_decompression"]
putnamos_decompression = ["putnamos"]

[lib]
Expand Down
16 changes: 16 additions & 0 deletions src/turfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,20 @@ static mut TURF_GASES: Option<DashMap<TurfID, TurfMixture, FxBuildHasher>> = Non
static mut TURF_TEMPERATURES: Option<DashMap<TurfID, ThermalInfo, FxBuildHasher>> = None;
// We store planetary atmos by hash of the initial atmos string here for speed.
static mut PLANETARY_ATMOS: Option<DashMap<u32, Mixture, FxBuildHasher>> = None;
// Turfs with firelocks are stored for explosive decompression speed
#[cfg(feature = "explosive_decompression")]
static mut FIRELOCK_TURFS: Option<DashMap<TurfID, (), FxBuildHasher>> = None;

#[init(partial)]
fn _initialize_turf_statics() -> Result<(), String> {
unsafe {
TURF_GASES = Some(DashMap::with_hasher(FxBuildHasher::default()));
TURF_TEMPERATURES = Some(DashMap::with_hasher(FxBuildHasher::default()));
PLANETARY_ATMOS = Some(DashMap::with_hasher(FxBuildHasher::default()));
#[cfg(feature = "explosive_decompression")]
{
FIRELOCK_TURFS = Some(DashMap::with_hasher(FxBuildHasher::default()));
}
};
Ok(())
}
Expand All @@ -174,6 +181,10 @@ fn _shutdown_turfs() {
TURF_GASES = None;
TURF_TEMPERATURES = None;
PLANETARY_ATMOS = None;
#[cfg(feature = "explosive_decompression")]
{
FIRELOCK_TURFS = None;
}
};
}
// this would lead to undefined info if it were possible for something to put a None on it during operation, but nothing's going to do that
Expand All @@ -189,6 +200,11 @@ fn turf_temperatures() -> &'static DashMap<TurfID, ThermalInfo, FxBuildHasher> {
unsafe { TURF_TEMPERATURES.as_ref().unwrap() }
}

#[cfg(feature = "explosive_decompression")]
fn firelock_turfs() -> &'static DashMap<TurfID, (), FxBuildHasher> {
unsafe { FIRELOCK_TURFS.as_ref().unwrap() }
}

#[hook("/turf/proc/update_air_ref")]
fn _hook_register_turf() {
let simulation_level = args[0].as_number().map_err(|_| {
Expand Down
47 changes: 30 additions & 17 deletions src/turfs/monstermos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,22 @@ type TransferInfo = [f32; 7];

type MixWithID = (TurfID, TurfMixture);

#[cfg(feature = "explosive_decompression")]
#[hook("/turf/proc/register_firelocks")]
fn _hook_register_firelocks() {
let id = unsafe { src.raw.data.id };
firelock_turfs().insert(id, ());
Ok(Value::null())
}

#[cfg(feature = "explosive_decompression")]
#[hook("/turf/proc/unregister_firelocks")]
fn _hook_unregister_firelocks() {
let id = unsafe { src.raw.data.id };
firelock_turfs().remove(&id);
Ok(Value::null())
}

#[derive(Copy, Clone, Default)]
struct MonstermosInfo {
transfer_dirs: TransferInfo,
Expand All @@ -25,7 +41,7 @@ struct MonstermosInfo {
const OPP_DIR_INDEX: [usize; 7] = [1, 0, 3, 2, 5, 4, 6];

//only used by slow decomp
const _DECOMP_REMOVE_RATIO: f32 = 5.0;
const DECOMP_REMOVE_RATIO: f32 = 4_f32;

impl MonstermosInfo {
fn adjust_eq_movement(&mut self, adjacent: &mut Self, dir_index: usize, amount: f32) {
Expand Down Expand Up @@ -203,10 +219,12 @@ fn explosively_depressurize(
insert_success = turfs.insert((loc, *adj_m))
};
if insert_success == true {
unsafe { Value::turf_by_id_unchecked(i) }.call(
"consider_firelocks",
&[&unsafe { Value::turf_by_id_unchecked(loc) }],
)?;
if firelock_turfs().contains_key(&loc) {
unsafe { Value::turf_by_id_unchecked(i) }.call(
"consider_firelocks",
&[&unsafe { Value::turf_by_id_unchecked(loc) }],
)?;
}
info.entry(loc).or_default().take();
}
}
Expand All @@ -219,8 +237,6 @@ fn explosively_depressurize(
let cur_info = info.entry(*i).or_default().get_mut();
cur_info.curr_transfer_dir = 6;
}
let spess_turfs_len = progression_order.len();
let mut total_moles: f64 = 0.0;
cur_queue_idx = 0;
while cur_queue_idx < progression_order.len() {
let (i, m) = progression_order[cur_queue_idx];
Expand All @@ -241,15 +257,15 @@ fn explosively_depressurize(
unsafe { Value::turf_by_id_unchecked(loc) }
.set(byond_string!("pressure_specific_target"), &cur_target_turf)?;
adj_orig.set(adj_info);
total_moles += adj_m.total_moles() as f64;
}
}
}
}
}
let _moles_sucked = (total_moles
/ ((progression_order.len() - spess_turfs_len) as f64)) as f32
/ _DECOMP_REMOVE_RATIO;
let mut slowable = false;
if progression_order.len() < 500 {
slowable = true
}
let hpd = auxtools::Value::globals()
.get(byond_string!("SSair"))?
.get_list(byond_string!("high_pressure_delta"))
Expand Down Expand Up @@ -318,14 +334,11 @@ fn explosively_depressurize(
)?;
}

#[cfg(not(feature = "slow_decompression"))]
{
if slowable == true {
m.clear_vol(m.total_moles() /DECOMP_REMOVE_RATIO);
} else {
m.clear_air();
}
#[cfg(feature = "slow_decompression")]
{
m.clear_vol(_moles_sucked);
}

byond_turf.call("handle_decompression_floor_rip", &[&Value::from(sum)])?;
}
Expand Down

0 comments on commit 389c49f

Please sign in to comment.