machinery_process() & auto_use_power efficiency tweaks (#2657)

changes:

Machinery now uses machinery_process() instead of process(), allowing machines to be put into SSprocessing-style lists in addition to the machinery list.
Automatic power calculations now involve less proc-calls.
This commit is contained in:
Lohikar
2017-06-12 19:09:36 +03:00
committed by skull132
parent 585a6c59dd
commit 0db557ac29
138 changed files with 204 additions and 179 deletions
+19 -5
View File
@@ -74,8 +74,8 @@
sortTim(cameranet.cameras, /proc/cmp_camera)
cameranet.cameras_unsorted = FALSE
var/list/curr_machinery = src.processing_machinery
var/list/curr_powersinks = src.processing_powersinks
var/list/curr_machinery = processing_machinery
var/list/curr_powersinks = processing_powersinks
while (curr_machinery.len)
var/obj/machinery/M = curr_machinery[curr_machinery.len]
@@ -90,7 +90,7 @@
if (M.machinery_processing)
processes_this_tick++
switch (M.process())
switch (M.machinery_process())
if (PROCESS_KILL)
remove_machine(M)
if (M_NO_PROCESS)
@@ -99,12 +99,26 @@
if (start_tick != world.time)
// Slept.
if (!slept_in_process[M.type])
log_debug("SSmachinery: Type '[M.type]' slept during process().")
log_debug("SSmachinery: Type '[M.type]' slept during machinery_process().")
slept_in_process[M.type] = TRUE
if (M.use_power)
powerusers_this_tick++
M.auto_use_power()
if (M.has_special_power_checks)
M.auto_use_power()
else
var/area/A = M.loc ? M.loc.loc : null
if (isarea(A))
var/chan = M.power_channel
if (A.powered(chan))
var/usage = 0
switch (M.use_power)
if (1)
usage = M.idle_power_usage
if (2)
usage = M.active_power_usage
A.use_power(usage, chan)
if (no_mc_tick)
CHECK_TICK