Processing Audit Part 1 (#22803)

Oh look at that, every modular computer in existence was always
processing at all times, regardless of if it was actually needed.
There's a couple more small examples I caught in my first pass, but all
of the rest are very low incidence. There are of course a very large
number of modular computers at any one point in time.
This commit is contained in:
VMSolidus
2026-07-09 21:03:42 +00:00
committed by GitHub
parent 25d8b2e6ae
commit 30fb0f69a0
7 changed files with 22 additions and 29 deletions
+5 -5
View File
@@ -21,14 +21,13 @@
charge = maxcharge
if(self_charge_percentage)
if(self_charge_percentage && charge < maxcharge)
START_PROCESSING(SSprocessing, src)
update_icon()
/obj/item/cell/Destroy()
if(self_charge_percentage)
STOP_PROCESSING(SSprocessing, src)
STOP_PROCESSING(SSprocessing, src)
return ..()
/obj/item/cell/process(seconds_per_tick)
@@ -41,6 +40,8 @@
var/recharge_for_this_process = round(recharge_amount_per_second * (seconds_per_tick / 10)) // divides seconds_per_tick by 10 to turn deciseconds into seconds
// finally, charge the cell
give(recharge_for_this_process)
if (charge >= maxcharge)
return PROCESS_KILL // No need to constantly process self-charging cells that are full.
/obj/item/cell/Created()
//Newly built cells spawn with no charge to prevent power exploits
@@ -51,13 +52,12 @@
return src
/obj/item/cell/drain_power(var/drain_check, var/surge, var/power = 0)
if(drain_check)
return 1
if(charge <= 0)
return 0
START_PROCESSING(SSprocessing, src) // Always attempt at least one process if the battery level is ever reduced.
var/cell_amt = power * CELLRATE
return use(cell_amt) / CELLRATE