mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2025-12-24 17:11:22 +00:00
Machinery performance tweaks (#1744)
changes: Machines' process() has been separated from auto_use_power(). Lights no longer process() and instead use auto_use_power() for power calculations. Computers that didn't really need to process() no longer process(). Airlocks now use the scheduler to auto-close instead of process()ing. Fixed a bug where clicking on an AI Status display to set its status did not work.
This commit is contained in:
@@ -1,16 +1,39 @@
|
||||
/var/global/machinery_sort_required = 0
|
||||
/var/global/machinery_sort_required = 0
|
||||
var/global/list/power_using_machines = list()
|
||||
var/global/list/ticking_machines = list()
|
||||
|
||||
#define STAGE_NONE 0
|
||||
#define STAGE_MACHINERY 1
|
||||
#define STAGE_POWERNET 2
|
||||
#define STAGE_POWERSINK 3
|
||||
#define STAGE_PIPENET 4
|
||||
#define STAGE_MACHINERY_PROCESS 1
|
||||
#define STAGE_MACHINERY_POWER 2
|
||||
#define STAGE_POWERNET 3
|
||||
#define STAGE_POWERSINK 4
|
||||
#define STAGE_PIPENET 5
|
||||
|
||||
/proc/add_machine(var/obj/machinery/M)
|
||||
if (NULL_OR_GC(M))
|
||||
return
|
||||
|
||||
var/type = M.get_process_type()
|
||||
if (type)
|
||||
machines += M
|
||||
|
||||
if (type & M_PROCESSES)
|
||||
ticking_machines += M
|
||||
|
||||
if (type & M_USES_POWER)
|
||||
power_using_machines += M
|
||||
|
||||
/proc/remove_machine(var/obj/machinery/M)
|
||||
machines -= M
|
||||
power_using_machines -= M
|
||||
ticking_machines -= M
|
||||
|
||||
/datum/controller/process/machinery
|
||||
var/tmp/list/processing_machinery = list()
|
||||
var/tmp/list/processing_powernets = list()
|
||||
var/tmp/list/processing_powersinks = list()
|
||||
var/tmp/list/processing_pipenets = list()
|
||||
var/tmp/list/processing_machinery = list()
|
||||
var/tmp/list/processing_power_users = list()
|
||||
var/tmp/list/processing_powernets = list()
|
||||
var/tmp/list/processing_powersinks = list()
|
||||
var/tmp/list/processing_pipenets = list()
|
||||
var/stage = STAGE_NONE
|
||||
|
||||
/datum/controller/process/machinery/setup()
|
||||
@@ -21,20 +44,37 @@
|
||||
/datum/controller/process/machinery/doWork()
|
||||
// If we're starting a new tick, setup.
|
||||
if (stage == STAGE_NONE)
|
||||
processing_machinery = machines.Copy()
|
||||
stage = STAGE_MACHINERY
|
||||
processing_machinery = ticking_machines.Copy()
|
||||
stage = STAGE_MACHINERY_PROCESS
|
||||
|
||||
// Process machinery.
|
||||
while (processing_machinery.len)
|
||||
var/obj/machinery/M = processing_machinery[processing_machinery.len]
|
||||
processing_machinery.len--
|
||||
|
||||
if (!M || M.gcDestroyed)
|
||||
machines -= M
|
||||
if (NULL_OR_GC(M))
|
||||
remove_machine(M)
|
||||
continue
|
||||
|
||||
if (M.process() == PROCESS_KILL)
|
||||
machines -= M
|
||||
switch (M.process())
|
||||
if (PROCESS_KILL)
|
||||
remove_machine(M)
|
||||
|
||||
if (M_NO_PROCESS)
|
||||
ticking_machines -= M
|
||||
|
||||
F_SCHECK
|
||||
|
||||
if (stage == STAGE_MACHINERY_PROCESS)
|
||||
processing_power_users = power_using_machines.Copy()
|
||||
stage = STAGE_MACHINERY_POWER
|
||||
|
||||
while (processing_power_users.len)
|
||||
var/obj/machinery/M = processing_power_users[processing_power_users.len]
|
||||
processing_power_users.len--
|
||||
|
||||
if (NULL_OR_GC(M))
|
||||
remove_machine(M)
|
||||
continue
|
||||
|
||||
if (M.use_power)
|
||||
@@ -42,7 +82,7 @@
|
||||
|
||||
F_SCHECK
|
||||
|
||||
if (stage == STAGE_MACHINERY)
|
||||
if (stage == STAGE_MACHINERY_POWER)
|
||||
processing_powernets = powernets.Copy()
|
||||
stage = STAGE_POWERNET
|
||||
|
||||
@@ -50,7 +90,7 @@
|
||||
var/datum/powernet/PN = processing_powernets[processing_powernets.len]
|
||||
processing_powernets.len--
|
||||
|
||||
if (!PN || PN.gcDestroyed)
|
||||
if (NULL_OR_GC(PN))
|
||||
powernets -= PN
|
||||
continue
|
||||
|
||||
@@ -65,7 +105,7 @@
|
||||
var/obj/item/I = processing_powersinks[processing_powersinks.len]
|
||||
processing_powersinks.len--
|
||||
|
||||
if (!I || !I.pwr_drain())
|
||||
if (NULL_OR_GC(I) || !I.pwr_drain())
|
||||
processing_power_items -= I
|
||||
|
||||
F_SCHECK
|
||||
@@ -78,7 +118,8 @@
|
||||
var/datum/pipe_network/PN = processing_pipenets[processing_pipenets.len]
|
||||
processing_pipenets.len--
|
||||
|
||||
if (!PN || PN.gcDestroyed)
|
||||
if (NULL_OR_GC(PN))
|
||||
pipe_networks -= PN
|
||||
continue
|
||||
|
||||
PN.process()
|
||||
@@ -93,13 +134,16 @@
|
||||
|
||||
/datum/controller/process/machinery/statProcess()
|
||||
..()
|
||||
stat(null, "[machines.len] machines, [processing_machinery.len] queued")
|
||||
stat(null, "[machines.len] total machines")
|
||||
stat(null, "[ticking_machines.len] ticking machines, [processing_machinery.len] queued")
|
||||
stat(null, "[power_using_machines.len] power-using machines, [processing_power_users.len] queued")
|
||||
stat(null, "[powernets.len] powernets, [processing_powernets.len] queued")
|
||||
stat(null, "[processing_power_items.len] power items, [processing_powersinks.len] queued")
|
||||
stat(null, "[pipe_networks.len] pipenets, [processing_pipenets.len] queued")
|
||||
|
||||
#undef STAGE_NONE
|
||||
#undef STAGE_MACHINERY
|
||||
#undef STAGE_MACHINERY_PROCESS
|
||||
#undef STAGE_MACHINERY_POWER
|
||||
#undef STAGE_POWERNET
|
||||
#undef STAGE_POWERSINK
|
||||
#undef STAGE_PIPENET
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
/datum/controller/process/scheduler/setup()
|
||||
name = "scheduler"
|
||||
schedule_interval = 3 SECONDS
|
||||
schedule_interval = 2 SECONDS
|
||||
scheduled_tasks = list()
|
||||
scheduler = src
|
||||
|
||||
|
||||
Reference in New Issue
Block a user