minor optimizations for APC late_process (#95274)

## About The Pull Request

just some micro-opts for `/obj/machinery/power/apc/proc/late_process`,
ported from https://github.com/Monkestation/Monkestation2.0/pull/10529

firstly, i converted `if(!area || !area.requires_power)` to
`if(!area?.requires_power)`

secondly, when checking cell percentages, it called `cell.percent()`
repeatedly... instead of, y'know, just calling it once and setting it as
a var. i fixed that.

## Why It's Good For The Game

less proc overhead and less duplicate calls should be better

## Changelog
🆑
code: Minor code optimizations for APC processing.
/🆑
This commit is contained in:
Lucy
2026-03-01 17:31:35 -05:00
committed by GitHub
parent 155d18ebd0
commit 651d7f074a
+5 -4
View File
@@ -586,7 +586,7 @@
update_appearance()
if(machine_stat & (BROKEN|MAINT))
return
if(!area || !area.requires_power)
if(!area?.requires_power)
return
if(failure_timer)
failure_timer--
@@ -631,6 +631,7 @@
if(cell && !shorted) //need to check to make sure the cell is still there since rigged/corrupted cells can randomly explode after give().
// set channels depending on how much charge we have left
var/cell_percent = cell.percent()
if(cell.charge <= 0) // zero charge, turn all off
equipment = autoset(equipment, AUTOSET_FORCE_OFF)
lighting = autoset(lighting, AUTOSET_FORCE_OFF)
@@ -639,7 +640,7 @@
if(!nightshift_lights || (nightshift_lights && !low_power_nightshift_lights))
low_power_nightshift_lights = TRUE
INVOKE_ASYNC(src, PROC_REF(set_nightshift), TRUE)
else if(cell.percent() < APC_CHANNEL_LIGHT_TRESHOLD) // turn off lighting & equipment
else if(cell_percent < APC_CHANNEL_LIGHT_TRESHOLD) // turn off lighting & equipment
equipment = autoset(equipment, AUTOSET_OFF)
lighting = autoset(lighting, AUTOSET_OFF)
environ = autoset(environ, AUTOSET_ON)
@@ -647,7 +648,7 @@
if(!nightshift_lights || (nightshift_lights && !low_power_nightshift_lights))
low_power_nightshift_lights = TRUE
INVOKE_ASYNC(src, PROC_REF(set_nightshift), TRUE)
else if(cell.percent() < APC_CHANNEL_EQUIP_TRESHOLD) // turn off equipment
else if(cell_percent < APC_CHANNEL_EQUIP_TRESHOLD) // turn off equipment
equipment = autoset(equipment, AUTOSET_OFF)
lighting = autoset(lighting, AUTOSET_ON)
environ = autoset(environ, AUTOSET_ON)
@@ -663,7 +664,7 @@
low_power_nightshift_lights = FALSE
if(!SSnightshift.nightshift_active)
INVOKE_ASYNC(src, PROC_REF(set_nightshift), FALSE)
if(cell.percent() > APC_CHANNEL_ALARM_TRESHOLD)
if(cell_percent > APC_CHANNEL_ALARM_TRESHOLD)
alarm_manager.clear_alarm(ALARM_POWER)
else // no cell, switch everything off