Skip to content

Commit

Permalink
Revert "Initialize Atmospherics much faster (ParadiseSS13#27862)"
Browse files Browse the repository at this point in the history
This reverts commit 24f6787
  • Loading branch information
m-dzianishchyts committed Jan 12, 2025
1 parent 6490b53 commit d903f25
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 114 deletions.
5 changes: 0 additions & 5 deletions code/__DEFINES/rust.dm
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,6 @@
/proc/milla_init_z(z)
return RUSTLIB_CALL(milla_initialize, z)

/proc/milla_load_turfs(turf/low_corner, turf/high_corner)
ASSERT(istype(low_corner))
ASSERT(istype(high_corner))
return RUSTLIB_CALL(milla_load_turfs, "milla_data", low_corner, high_corner)

/proc/set_tile_atmos(turf/T, airtight_north, airtight_east, airtight_south, airtight_west, atmos_mode, environment_id, oxygen, carbon_dioxide, nitrogen, toxins, sleeping_agent, agent_b, temperature, innate_heat_capacity, hotspot_temperature, hotspot_volume)
return RUSTLIB_CALL(milla_set_tile, T, airtight_north, airtight_east, airtight_south, airtight_west, atmos_mode, environment_id, oxygen, carbon_dioxide, nitrogen, toxins, sleeping_agent, agent_b, temperature, innate_heat_capacity, hotspot_temperature, hotspot_volume)

Expand Down
13 changes: 9 additions & 4 deletions code/controllers/subsystem/SSair.dm
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ SUBSYSTEM_DEF(air)
in_milla_safe_code = TRUE

setup_overlays() // Assign icons and such for gas-turf-overlays
setup_turfs()
setup_allturfs()
setup_write_to_milla()
setup_atmos_machinery(GLOB.machines)
setup_pipenets(GLOB.machines)
for(var/obj/machinery/atmospherics/A in machinery_to_construct)
Expand Down Expand Up @@ -613,10 +614,14 @@ SUBSYSTEM_DEF(air)
last_bound_mixtures = length(bound_mixtures)
return

/datum/controller/subsystem/air/proc/setup_turfs(turf/low_corner = locate(1, 1, 1), turf/high_corner = locate(world.maxx, world.maxy, world.maxz))
for(var/turf/T as anything in block(low_corner, high_corner))
/datum/controller/subsystem/air/proc/setup_allturfs(list/turfs_to_init = block(locate(1, 1, 1), locate(world.maxx, world.maxy, world.maxz)))
for(var/turf/T as anything in turfs_to_init)
T.Initialize_Atmos(times_fired)
CHECK_TICK

/datum/controller/subsystem/air/proc/setup_allturfs_sleepless(list/turfs_to_init = block(locate(1, 1, 1), locate(world.maxx, world.maxy, world.maxz)))
for(var/turf/T as anything in turfs_to_init)
T.Initialize_Atmos(times_fired)
milla_load_turfs(low_corner, high_corner)

/datum/controller/subsystem/air/proc/setup_write_to_milla()
var/watch = start_watch()
Expand Down
4 changes: 2 additions & 2 deletions code/datums/helper_datums/map_template.dm
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@
catch(var/exception/e)
GLOB.space_manager.remove_dirt(placement.z)
var/datum/milla_safe/late_setup_level/milla = new()
milla.invoke_async(bot_left, top_right, block(ST_bot_left, ST_top_right))
milla.invoke_async(block(bot_left, top_right), block(ST_bot_left, ST_top_right))
message_admins("Map template [name] threw an error while loading. Safe exit attempted, but check for errors at [ADMIN_COORDJMP(placement)].")
log_admin("Map template [name] threw an error while loading. Safe exit attempted.")
throw e
GLOB.space_manager.remove_dirt(placement.z)
var/datum/milla_safe/late_setup_level/milla = new()
milla.invoke_async(bot_left, top_right, block(ST_bot_left, ST_top_right))
milla.invoke_async(block(bot_left, top_right), block(ST_bot_left, ST_top_right))

log_game("[name] loaded at [min_x],[min_y],[placement.z]")
return 1
Expand Down
27 changes: 9 additions & 18 deletions code/game/turfs/turf.dm
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,6 @@
/// The effect used to render a pressure overlay from this tile.
var/obj/effect/pressure_overlay/pressure_overlay

var/list/milla_atmos_airtight = list(FALSE, FALSE, FALSE, FALSE)
var/list/milla_superconductivity = list(
OPEN_HEAT_TRANSFER_COEFFICIENT,
OPEN_HEAT_TRANSFER_COEFFICIENT,
OPEN_HEAT_TRANSFER_COEFFICIENT,
OPEN_HEAT_TRANSFER_COEFFICIENT)
var/list/milla_data = list()

new_attack_chain = TRUE

/turf/Initialize(mapload)
Expand Down Expand Up @@ -484,29 +476,28 @@
if(SSticker)
GLOB.cameranet.updateVisibility(src)

/turf/attack_by(obj/item/attacking, mob/user, params)
if(..())
return TRUE

/turf/attackby(obj/item/I, mob/user, params)
if(can_lay_cable())
if(istype(attacking, /obj/item/stack/cable_coil))
var/obj/item/stack/cable_coil/C = attacking
if(istype(I, /obj/item/stack/cable_coil))
var/obj/item/stack/cable_coil/C = I
for(var/obj/structure/cable/LC in src)
if(LC.d1 == 0 || LC.d2 == 0)
LC.attackby__legacy__attackchain(C, user)
return TRUE
return
C.place_turf(src, user)
return TRUE
else if(istype(attacking, /obj/item/rcl))
var/obj/item/rcl/R = attacking
else if(istype(I, /obj/item/rcl))
var/obj/item/rcl/R = I
if(R.loaded)
for(var/obj/structure/cable/LC in src)
if(LC.d1 == 0 || LC.d2 == 0)
LC.attackby__legacy__attackchain(R, user)
return TRUE
return
R.loaded.place_turf(src, user)
R.is_empty(user)

return FALSE

/turf/proc/can_have_cabling()
return TRUE

Expand Down
69 changes: 37 additions & 32 deletions code/modules/atmospherics/environmental/LINDA_turf_tile.dm
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,18 @@
#define INDEX_WEST 4

/turf/proc/Initialize_Atmos(times_fired)
// This is one of two places expected to call this otherwise-unsafe method.
private_unsafe_recalculate_atmos_connectivity()
var/list/air = list(oxygen, carbon_dioxide, nitrogen, toxins, sleeping_agent, agent_b, temperature)
milla_data = milla_atmos_airtight + list(atmos_mode, SSmapping.environments[atmos_environment]) + air + milla_superconductivity
recalculate_atmos_connectivity()

if(!blocks_air)
var/datum/gas_mixture/air = new()
air.set_oxygen(oxygen)
air.set_carbon_dioxide(carbon_dioxide)
air.set_nitrogen(nitrogen)
air.set_toxins(toxins)
air.set_sleeping_agent(sleeping_agent)
air.set_agent_b(agent_b)
air.set_temperature(temperature)
blind_set_air(air)

/turf/proc/recalculate_atmos_connectivity()
var/datum/milla_safe/recalculate_atmos_connectivity/milla = new()
Expand All @@ -184,51 +192,48 @@
/datum/milla_safe/recalculate_atmos_connectivity

/datum/milla_safe/recalculate_atmos_connectivity/on_run(turf/T)
if(!istype(T))
if(isnull(T))
return

// This is one of two places expected to call this otherwise-unsafe method.
T.private_unsafe_recalculate_atmos_connectivity()

set_tile_airtight(T, T.milla_atmos_airtight)
reset_superconductivity(T)
reduce_superconductivity(T, T.milla_superconductivity)

/// This method is unsafe to use because it only updates milla_* properties, but does not write them to MILLA. Use recalculate_atmos_connectivity() instead.
/turf/proc/private_unsafe_recalculate_atmos_connectivity()
if(blocks_air)
milla_atmos_airtight = list(TRUE, TRUE, TRUE, TRUE)
milla_superconductivity = list(0, 0, 0, 0)
if(T.blocks_air)
set_tile_airtight(T, list(TRUE, TRUE, TRUE, TRUE))
// Will be needed when we go back to having solid tile conductivity.
//reset_superconductivity(src)
reduce_superconductivity(T, list(0, 0, 0, 0))
return

milla_atmos_airtight = list(
!CanAtmosPass(NORTH, FALSE),
!CanAtmosPass(EAST, FALSE),
!CanAtmosPass(SOUTH, FALSE),
!CanAtmosPass(WEST, FALSE))
var/list/atmos_airtight = list(
!T.CanAtmosPass(NORTH, FALSE),
!T.CanAtmosPass(EAST, FALSE),
!T.CanAtmosPass(SOUTH, FALSE),
!T.CanAtmosPass(WEST, FALSE))

milla_superconductivity = list(
var/list/superconductivity = list(
OPEN_HEAT_TRANSFER_COEFFICIENT,
OPEN_HEAT_TRANSFER_COEFFICIENT,
OPEN_HEAT_TRANSFER_COEFFICIENT,
OPEN_HEAT_TRANSFER_COEFFICIENT)

for(var/obj/O in src)
for(var/obj/O in T)
if(istype(O, /obj/item))
// Items can't block atmos.
continue
if(!O.CanAtmosPass(NORTH))
milla_atmos_airtight[INDEX_NORTH] = TRUE
atmos_airtight[INDEX_NORTH] = TRUE
if(!O.CanAtmosPass(EAST))
milla_atmos_airtight[INDEX_EAST] = TRUE
atmos_airtight[INDEX_EAST] = TRUE
if(!O.CanAtmosPass(SOUTH))
milla_atmos_airtight[INDEX_SOUTH] = TRUE
atmos_airtight[INDEX_SOUTH] = TRUE
if(!O.CanAtmosPass(WEST))
milla_atmos_airtight[INDEX_WEST] = TRUE
milla_superconductivity[INDEX_NORTH] = min(milla_superconductivity[INDEX_NORTH], O.get_superconductivity(NORTH))
milla_superconductivity[INDEX_EAST] = min(milla_superconductivity[INDEX_EAST], O.get_superconductivity(EAST))
milla_superconductivity[INDEX_SOUTH] = min(milla_superconductivity[INDEX_SOUTH], O.get_superconductivity(SOUTH))
milla_superconductivity[INDEX_WEST] = min(milla_superconductivity[INDEX_WEST], O.get_superconductivity(WEST))
atmos_airtight[INDEX_WEST] = TRUE
superconductivity[INDEX_NORTH] = min(superconductivity[INDEX_NORTH], O.get_superconductivity(NORTH))
superconductivity[INDEX_EAST] = min(superconductivity[INDEX_EAST], O.get_superconductivity(EAST))
superconductivity[INDEX_SOUTH] = min(superconductivity[INDEX_SOUTH], O.get_superconductivity(SOUTH))
superconductivity[INDEX_WEST] = min(superconductivity[INDEX_WEST], O.get_superconductivity(WEST))

set_tile_airtight(T, atmos_airtight)
reset_superconductivity(T)
reduce_superconductivity(T, superconductivity)

/obj/effect/wind
anchored = TRUE
Expand Down
6 changes: 3 additions & 3 deletions code/modules/awaymissions/zlevel_helpers.dm
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/datum/milla_safe/late_setup_level

// Ensures that atmos and environment are set up.
/datum/milla_safe/late_setup_level/on_run(turf/bot_left, turf/top_right, smoothTurfs)
/datum/milla_safe/late_setup_level/on_run(turfs, smoothTurfs)
var/total_timer = start_watch()
var/subtimer = start_watch()
if(!smoothTurfs)
smoothTurfs = block(bot_left, top_right)
smoothTurfs = turfs

log_debug("Setting up atmos")
/* setup_allturfs is superfluous during server initialization because
* air subsystem will call subsequently call setup_allturfs with _every_
* turf in the world */
if(SSair && SSair.initialized)
SSair.setup_turfs(bot_left, top_right)
SSair.setup_allturfs_sleepless(turfs)
log_debug("\tTook [stop_watch(subtimer)]s")

subtimer = start_watch()
Expand Down
2 changes: 1 addition & 1 deletion modular_ss220/gateway/code/gateway_initialize.dm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
var/zlev = GLOB.space_manager.add_new_zlevel(AWAY_MISSION, linkage = UNAFFECTED, traits = list(AWAY_LEVEL, BLOCK_TELEPORT))
GLOB.space_manager.add_dirt(zlev)
GLOB.maploader.load_map(file, z_offset = zlev)
var/datum/milla_safe_must_sleep/late_setup_level/milla = new()
var/datum/milla_safe/late_setup_level/milla = new()
milla.invoke_async(block(locate(1, 1, zlev), locate(world.maxx, world.maxy, zlev)))
GLOB.space_manager.remove_dirt(zlev)
log_world("Away mission loaded: [map]")
Expand Down
49 changes: 0 additions & 49 deletions rust/src/milla/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use crate::milla::simulate;
use crate::milla::statics::*;
use crate::milla::tick;
use byondapi::global_call::call_global;
use byondapi::map::byond_block;
use byondapi::map::byond_xyz;
use byondapi::prelude::*;
use eyre::eyre;
Expand Down Expand Up @@ -98,54 +97,6 @@ pub(crate) fn internal_create_environment(
buffers.create_environment(tile)
}

/// BYOND API for loading a block of turfs into MILLA with their default air.
#[byondapi::bind]
fn milla_load_turfs(data_property: ByondValue, low_corner: ByondValue, high_corner: ByondValue) -> eyre::Result<ByondValue> {
let property_ref = data_property.get_strid()?;
for turf in byond_block(byond_xyz(&low_corner)?, byond_xyz(&high_corner)?)? {
let (x, y, z) = byond_xyz(&turf)?.coordinates();
let data = turf.read_var_id(property_ref)?.get_list_values()?;
if data.len() != 17 {
return Err(eyre!("data property has the wrong length: {} vs {}", data.len(), 17));
}

internal_set_tile(
x as i32 - 1,
y as i32 - 1,
z as i32 - 1,
conversion::byond_to_option_f32(data[0])?,
conversion::byond_to_option_f32(data[1])?,
conversion::byond_to_option_f32(data[2])?,
conversion::byond_to_option_f32(data[3])?,
conversion::byond_to_option_f32(data[4])?,
conversion::byond_to_option_f32(data[5])?,
conversion::bounded_byond_to_option_f32(data[6], 0.0, f32::INFINITY)?,
conversion::bounded_byond_to_option_f32(data[7], 0.0, f32::INFINITY)?,
conversion::bounded_byond_to_option_f32(data[8], 0.0, f32::INFINITY)?,
conversion::bounded_byond_to_option_f32(data[9], 0.0, f32::INFINITY)?,
conversion::bounded_byond_to_option_f32(data[10], 0.0, f32::INFINITY)?,
conversion::bounded_byond_to_option_f32(data[11], 0.0, f32::INFINITY)?,
conversion::bounded_byond_to_option_f32(data[12], 0.0, f32::INFINITY)?,
None,
Some(0.0),
Some(0.0),
Some(0.0),
)?;

internal_reset_superconductivity(x as i32 - 1, y as i32 - 1, z as i32 - 1)?;
internal_reduce_superconductivity(
x as i32 - 1,
y as i32 - 1,
z as i32 - 1,
conversion::bounded_byond_to_option_f32(data[13], 0.0, 1.0)?,
conversion::bounded_byond_to_option_f32(data[14], 0.0, 1.0)?,
conversion::bounded_byond_to_option_f32(data[15], 0.0, 1.0)?,
conversion::bounded_byond_to_option_f32(data[16], 0.0, 1.0)?,
)?;
}
Ok(ByondValue::null())
}

/// BYOND API for setting the atmos details of a tile.
#[byondapi::bind]
fn milla_set_tile(
Expand Down
Binary file modified rustlibs.dll
Binary file not shown.
Binary file modified rustlibs_prod.dll
Binary file not shown.
Binary file modified tools/ci/librustlibs_ci.so
Binary file not shown.

0 comments on commit d903f25

Please sign in to comment.