Lag War Day 4: Under Pressure, High Voltage (#21878)

Replace /datum/gas_mixture/proc/return_pressure with XGM_PRESSURE(xgm)
macro. Having such a relatively simple statement contributing proc
overhead to procs called millions of times is ridiculous

Rename /datum/gas_mixture/proc/zburn to react, deleting the old react
which was just an alias for it. Free proc overhead

Turn check_combustibility into a macro CHECK_COMBUSTIBLE(is_cmb, xgm).
also rewrite it slightly so that it only needs to do one pass. Its a bit
nasty so I apologize for that, but speeeeed.

Delete most powernet and obj/machinery/power procs for handling power,
replacing them with macros. The fact that we were unironically calling a
draw_power() on APCs to call draw_power() on their terminals to call
draw_power() on their powernet every single process tick was insane.

Turn `between` into a macro alias for clamp() since the param order is
different

turn `Percent` into a macro AS_PCT

Rewrite significant chunks of update_canmove so its not quite as
horrifying of a proc and hopefully doesn't eat the entire mob subsystem
every movement now
This commit is contained in:
Wildkins
2026-02-27 00:35:41 +00:00
committed by GitHub
parent 52e1a34575
commit e1770df81e
131 changed files with 676 additions and 736 deletions
@@ -165,7 +165,7 @@
var/obj/item/organ/external/E = A
if(BP_IS_ROBOTIC(E))
continue
for(var/datum/wound/W in E.wounds)
for(var/datum/wound/W as anything in E.wounds)
if(W.germ_level < INFECTION_LEVEL_ONE)
W.germ_level = INFECTION_LEVEL_ONE
W.germ_level += rand(10, 50)
+3 -3
View File
@@ -328,8 +328,8 @@
/obj/effect/overmap/visitable/sector/exoplanet/proc/adapt_seed(var/datum/seed/S)
SET_SEED_TRAIT_BOUNDED(S, TRAIT_IDEAL_HEAT, atmosphere.temperature + rand(-5,5), 800, 70, null)
SET_SEED_TRAIT_BOUNDED(S, TRAIT_HEAT_TOLERANCE, GET_SEED_TRAIT(S, TRAIT_HEAT_TOLERANCE) + rand(-5,5), 800, 70, null)
SET_SEED_TRAIT_BOUNDED(S, TRAIT_LOWKPA_TOLERANCE, atmosphere.return_pressure() + rand(-5,-50), 80, 0, null)
SET_SEED_TRAIT_BOUNDED(S, TRAIT_HIGHKPA_TOLERANCE, atmosphere.return_pressure() + rand(5,50), 500, 110, null)
SET_SEED_TRAIT_BOUNDED(S, TRAIT_LOWKPA_TOLERANCE, XGM_PRESSURE(atmosphere) + rand(-5,-50), 80, 0, null)
SET_SEED_TRAIT_BOUNDED(S, TRAIT_HIGHKPA_TOLERANCE, XGM_PRESSURE(atmosphere) + rand(5,50), 500, 110, null)
SET_SEED_TRAIT(S, TRAIT_SPREAD, 0)
if(S.exude_gasses)
S.exude_gasses -= badgas
@@ -508,7 +508,7 @@
gases += gas_data.name[g]
extra_data += "<b>Atmosphere composition:</b> [english_list(gases)]"
var/inaccuracy = rand(8,12)/10
extra_data += "<b>Atmosphere pressure:</b> [atmosphere.return_pressure()*inaccuracy] kPa, <b>temperature:</b> [atmosphere.temperature*inaccuracy] K"
extra_data += "<b>Atmosphere pressure:</b> [XGM_PRESSURE(atmosphere)*inaccuracy] kPa, <b>temperature:</b> [atmosphere.temperature*inaccuracy] K"
if(seeds.len)
extra_data += "<br>Unrecognized xenoflora detected."
@@ -21,7 +21,7 @@
water.SetTransform(rotation = rand(0, 360))
skybox_image.overlays += water
if (atmosphere && atmosphere.return_pressure() > SOUND_MINIMUM_PRESSURE)
if (SAFE_XGM_PRESSURE(atmosphere) > SOUND_MINIMUM_PRESSURE)
var/atmo_color = get_atmosphere_color()
if (!atmo_color)
@@ -462,7 +462,7 @@
var/turf/T=get_turf(src)
if(istype(T))
var/datum/gas_mixture/environment = T.return_air()
if(environment && environment.return_pressure() > MINIMUM_PRESSURE_DIFFERENCE_TO_SUSPEND)
if(SAFE_XGM_PRESSURE(environment) > MINIMUM_PRESSURE_DIFFERENCE_TO_SUSPEND)
return 0
return 1
@@ -170,7 +170,7 @@
.+= "Propellant total mass: [round(air_contents.get_mass(),0.01)] kg."
.+= "Propellant used per burn: [round(air_contents.get_mass() * volume_per_burn * thrust_limit / air_contents.volume,0.01)] kg."
.+= "Propellant pressure: [round(air_contents.return_pressure()/1000,0.1)] MPa."
.+= "Propellant pressure: [round(XGM_PRESSURE(air_contents)/1000,0.1)] MPa."
. = jointext(.,"<br>")
/obj/machinery/atmospherics/unary/engine/power_change()
@@ -241,10 +241,12 @@
T = get_step(T, exhaust_dir)
if(T)
T.assume_air(removed)
new/obj/effect/engine_exhaust(T, dir, air_contents.check_combustibility() && air_contents.temperature >= PHORON_MINIMUM_BURN_TEMPERATURE)
var/is_cmb = 0
CHECK_COMBUSTIBLE(is_cmb, air_contents)
new/obj/effect/engine_exhaust(T, dir, is_cmb && air_contents.temperature >= PHORON_MINIMUM_BURN_TEMPERATURE)
/obj/machinery/atmospherics/unary/engine/proc/calculate_thrust(datum/gas_mixture/propellant, used_part = 1)
return round(sqrt(propellant.get_mass() * used_part * sqrt(air_contents.return_pressure()/200)),0.1)
return round(sqrt(propellant.get_mass() * used_part * sqrt(XGM_PRESSURE(air_contents)/200)),0.1)
//Exhaust effect
/obj/effect/engine_exhaust