Paranoid updates to maybe fix air duplication

This commit is contained in:
Putnam
2021-03-20 22:02:47 -07:00
parent c230fda10e
commit f1e55f2df0
19 changed files with 68 additions and 33 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -1,7 +1,7 @@
/// Percentage of tick to leave for master controller to run
#define MAPTICK_MC_MIN_RESERVE 70
/// internal_tick_usage is updated every tick by extools
#define MAPTICK_LAST_INTERNAL_TICK_USAGE ((world.map_cpu / world.tick_lag) * 100)
#define MAPTICK_LAST_INTERNAL_TICK_USAGE world.map_cpu
/// Tick limit while running normally
#define TICK_BYOND_RESERVE 2
#define TICK_LIMIT_RUNNING (max(100 - TICK_BYOND_RESERVE - MAPTICK_LAST_INTERNAL_TICK_USAGE, MAPTICK_MC_MIN_RESERVE))

View File

@@ -22,6 +22,7 @@ SUBSYSTEM_DEF(air)
var/list/networks = list()
var/list/pipenets_needing_rebuilt = list()
var/list/deferred_airs = list()
var/max_deferred_airs = 0
var/list/obj/machinery/atmos_machinery = list()
var/list/obj/machinery/atmos_air_machinery = list()
var/list/pipe_init_dirs_cache = list()
@@ -70,6 +71,7 @@ SUBSYSTEM_DEF(air)
msg += "HS:[hotspots.len]|"
msg += "PN:[networks.len]|"
msg += "HP:[high_pressure_delta.len]|"
msg += "DF:[max_deferred_airs]"
msg += "GA:[get_amt_gas_mixes()]|"
msg += "MG:[get_max_gas_mixes()]|"
return ..()
@@ -80,10 +82,12 @@ SUBSYSTEM_DEF(air)
setup_atmos_machinery()
setup_pipenets()
gas_reactions = init_gas_reactions()
auxtools_update_reactions()
return ..()
/datum/controller/subsystem/air/proc/extools_update_ssair()
//datum/controller/subsystem/air/proc/extools_update_reactions()
/datum/controller/subsystem/air/proc/auxtools_update_reactions()
/datum/controller/subsystem/air/proc/thread_running()
return FALSE
@@ -233,6 +237,7 @@ SUBSYSTEM_DEF(air)
pipenets_needing_rebuilt += atmos_machine
/datum/controller/subsystem/air/proc/process_deferred_airs(resumed = 0)
max_deferred_airs = max(deferred_airs.len,max_deferred_airs)
while(deferred_airs.len)
var/list/cur_op = deferred_airs[deferred_airs.len]
deferred_airs.len--

View File

@@ -182,10 +182,21 @@
/obj/item/clothing/head/mob_holder/remove_air(amount)
var/atom/location = loc
if(!loc)
return //null
return null
var/turf/T = get_turf(loc)
while(location != T)
location = location.loc
if(ismob(location))
return location.loc.remove_air(amount)
return location.remove_air(amount)
/obj/item/clothing/head/mob_holder/remove_air_ratio(ratio)
var/atom/location = loc
if(!loc)
return null
var/turf/T = get_turf(loc)
while(location != T)
location = location.loc
if(ismob(location))
return location.loc.remove_air_ratio(ratio)
return location.remove_air_ratio(ratio)

View File

@@ -376,6 +376,9 @@
/atom/proc/remove_air(amount)
return null
/atom/proc/remove_air_ratio(ratio)
return null
/atom/proc/return_air()
if(loc)
return loc.return_air()

View File

@@ -810,6 +810,11 @@
return cabin_air.remove(amount)
return ..()
/obj/mecha/remove_air_ratio(ratio)
if(use_internal_tank)
return cabin_air.remove_ratio(ratio)
return ..()
/obj/mecha/return_air()
if(use_internal_tank)
return cabin_air

View File

@@ -234,6 +234,9 @@
/obj/item/tank/remove_air(amount)
return air_contents.remove(amount)
/obj/item/tank/remove_air_ratio(ratio)
return air_contents.remove_ratio(ratio)
/obj/item/tank/return_air()
return air_contents

View File

@@ -102,6 +102,12 @@
else
return null
/obj/remove_air_ratio(ratio)
if(loc)
return loc.remove_air_ratio(ratio)
else
return null
/obj/return_air()
if(loc)
return loc.return_air()
@@ -116,8 +122,7 @@
if(breath_request>0)
var/datum/gas_mixture/environment = return_air()
var/breath_percentage = BREATH_VOLUME / environment.return_volume()
return remove_air(environment.total_moles() * breath_percentage)
return remove_air_ratio(BREATH_VOLUME / environment.return_volume())
else
return null

View File

@@ -156,6 +156,9 @@
/obj/structure/transit_tube_pod/remove_air(amount)
return air_contents.remove(amount)
/obj/structure/transit_tube_pod/remove_air_ratio(ratio)
return air_contents.remove_ratio(ratio)
/obj/structure/transit_tube_pod/relaymove(mob/mob, direction)
if(istype(mob) && mob.client)
if(!moving)

View File

@@ -100,6 +100,9 @@
/turf/open/space/remove_air(amount)
return null
/turf/open/space/remove_air_ratio(amount)
return null
/turf/open/space/proc/update_starlight()
if(CONFIG_GET(flag/starlight))
for(var/t in RANGE_TURFS(1,src)) //RANGE_TURFS is in code\__HELPERS\game.dm

View File

@@ -61,6 +61,12 @@
update_visuals()
return removed
/turf/open/remove_air_ratio(ratio)
var/datum/gas_mixture/ours = return_air()
var/datum/gas_mixture/removed = ours.remove_ratio(ratio)
update_visuals()
return removed
/turf/open/proc/copy_air_with_tile(turf/open/T)
if(istype(T))
air.copy_from(T.air)

View File

@@ -15,6 +15,7 @@
if (!reaction_key || initial(reaction_key.rarity) > initial(req_gas.rarity))
reaction_key = req_gas
reaction.major_gas = reaction_key
message_admins("\ref[reaction]")
. += reaction
sortTim(., /proc/cmp_gas_reaction)

View File

@@ -30,23 +30,10 @@
var/pressure_delta = abs(external_pressure - internal_pressure)
if(pressure_delta > 0.5)
if(external_pressure < internal_pressure)
var/air_temperature = (external.return_temperature() > 0) ? external.return_temperature() : internal.return_temperature()
var/transfer_moles = (pressure_delta * external.return_volume()) / (air_temperature * R_IDEAL_GAS_EQUATION)
var/datum/gas_mixture/removed = internal.remove(transfer_moles)
external.merge(removed)
else
var/air_temperature = (internal.return_temperature() > 0) ? internal.return_temperature() : external.return_temperature()
var/transfer_moles = (pressure_delta * internal.return_volume()) / (air_temperature * R_IDEAL_GAS_EQUATION)
transfer_moles = min(transfer_moles, external.total_moles() * internal.return_volume() / external.return_volume())
var/datum/gas_mixture/removed = external.remove(transfer_moles)
if(isnull(removed))
return
internal.merge(removed)
equalize_all_gases_in_list(list(internal,external))
active = TRUE
active = internal.temperature_share(external, OPEN_HEAT_TRANSFER_COEFFICIENT) ? TRUE : active
active = internal.temperature_share(external, OPEN_HEAT_TRANSFER_COEFFICIENT) || active
if(active)
air_update_turf()

View File

@@ -156,10 +156,8 @@
return FALSE
if(scrubbing & SCRUBBING)
var/transfer_moles = min(1, volume_rate/environment.return_volume())*environment.total_moles()
//Take a gas sample
var/datum/gas_mixture/removed = tile.remove_air(transfer_moles)
var/datum/gas_mixture/removed = tile.remove_air_ratio(volume_rate/environment.return_volume())
//Nothing left to remove from the tile
if(isnull(removed))
@@ -173,9 +171,7 @@
else //Just siphoning all air
var/transfer_moles = environment.total_moles()*(volume_rate/environment.return_volume())
var/datum/gas_mixture/removed = tile.remove_air(transfer_moles)
var/datum/gas_mixture/removed = tile.remove_air_ratio((volume_rate/environment.return_volume()))
air_contents.merge(removed)
tile.air_update_turf()

View File

@@ -54,6 +54,9 @@
/obj/machinery/atmospherics/pipe/remove_air(amount)
return parent.air.remove(amount)
/obj/machinery/atmospherics/pipe/remove_air_ratio(ratio)
return parent.air.remove_ratio(ratio)
/obj/machinery/atmospherics/pipe/attackby(obj/item/W, mob/user, params)
if(istype(W, /obj/item/pipe_meter))
var/obj/item/pipe_meter/meter = W

View File

@@ -115,11 +115,11 @@
breath = loc_as_obj.handle_internal_lifeform(src, BREATH_VOLUME)
else if(isturf(loc)) //Breathe from loc as turf
var/breath_moles = 0
var/breath_ratio = 0
if(environment)
breath_moles = environment.total_moles()*BREATH_PERCENTAGE
breath_ratio = BREATH_VOLUME/environment.return_volume()
breath = loc.remove_air(breath_moles)
breath = loc.remove_air_ratio(breath_ratio)
else //Breathe from loc as obj again
if(istype(loc, /obj/))
var/obj/loc_as_obj = loc

View File

@@ -753,6 +753,12 @@
else
return null
/mob/living/simple_animal/bot/mulebot/remove_air_ratio(ratio)
if(loc)
return loc.remove_air_ratio(ratio)
else
return null
/mob/living/simple_animal/bot/mulebot/do_resist()
. = ..()
if(load)

View File

@@ -128,12 +128,10 @@
cut_overlays()
rpm = 0.9* rpm + 0.1 * rpmtarget
var/datum/gas_mixture/environment = inturf.return_air()
// It's a simplified version taking only 1/10 of the moles from the turf nearby. It should be later changed into a better version
// above todo 7 years and counting
var/transfer_moles = environment.total_moles()/10
var/datum/gas_mixture/removed = inturf.remove_air(transfer_moles)
var/datum/gas_mixture/removed = inturf.remove_air_ratio(0.1)
gas_contained.merge(removed)
// RPM function to include compression friction - be advised that too low/high of a compfriction value can make things screwy