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
@@ -201,15 +201,16 @@
if(should_act) // We're gonna give or take from the net.
if(drawing)
var/to_transfer = min(throughput, (assembly.battery.maxcharge - assembly.battery.charge) / CELLRATE) // So we don't need to draw 10kW if the cell needs much less.
var/amount = IO.draw_power(to_transfer)
var/amount = POWER_DRAW(IO, to_transfer)
DRAW_POWER(IO, amount)
assembly.give_power(amount)
else
var/amount = assembly.draw_power(throughput)
IO.add_avail(amount)
ADD_TO_POWERNET(IO, amount)
set_pin_data(IC_OUTPUT, 1, IO.avail())
set_pin_data(IC_OUTPUT, 2, IO.surplus())
set_pin_data(IC_OUTPUT, 3, -IO.surplus()-IO.avail()) // we don't have a viewload() proc on machines and i'm lazy
set_pin_data(IC_OUTPUT, 1, POWER_AVAIL(IO))
set_pin_data(IC_OUTPUT, 2, POWER_SURPLUS(IO))
set_pin_data(IC_OUTPUT, 3, POWER_LOAD(IO))
// Internal power machine for interacting with the powernet.
// It needs a bit of special code since base /machinery/power assumes loc will be a tile.
@@ -629,7 +629,7 @@
return
var/datum/gas_mixture/environment = T.return_air()
var/pressure = environment.return_pressure()
var/pressure = XGM_PRESSURE(environment)
var/total_moles = environment.total_moles
if (total_moles)
@@ -707,7 +707,7 @@
return
var/datum/gas_mixture/environment = T.return_air()
var/pressure = environment.return_pressure()
var/pressure = XGM_PRESSURE(environment)
var/total_moles = environment.total_moles
if (total_moles)