Split and clarify global lists of processing vs non-processing machinery. (#5307)

* Renaming local var 'machines' to avoid confusion with the global var of same name.

* Delete the unused process scheduler machinery.dm file.  Long since replaced with SSmachines

* Split and clarify global lists of processing vs non-processing machinery.

- Renamed the list of processing machinery from "machines" to "processing_machines"
- Added new global list "machines" to be a list of all machines.
- Since nearly every reference to machines actually wanted to iterate over all machines anyway, this works out great.
This commit is contained in:
Leshana
2018-05-28 15:56:49 -04:00
committed by Atermonera
parent 1a42238ac3
commit 30f10be83e
6 changed files with 14 additions and 78 deletions

View File

@@ -128,8 +128,8 @@ if(DATUM.is_processing) {\
}
// Note - I would prefer these be defined machines.dm, but some are used prior in file order. ~Leshana
#define START_MACHINE_PROCESSING(Datum) START_PROCESSING_IN_LIST(Datum, global.machines)
#define STOP_MACHINE_PROCESSING(Datum) STOP_PROCESSING_IN_LIST(Datum, global.machines)
#define START_MACHINE_PROCESSING(Datum) START_PROCESSING_IN_LIST(Datum, global.processing_machines)
#define STOP_MACHINE_PROCESSING(Datum) STOP_PROCESSING_IN_LIST(Datum, global.processing_machines)
#define START_PROCESSING_PIPENET(Datum) START_PROCESSING_IN_LIST(Datum, global.pipe_networks)
#define STOP_PROCESSING_PIPENET(Datum) STOP_PROCESSING_IN_LIST(Datum, global.pipe_networks)

View File

@@ -1,67 +0,0 @@
/var/global/machinery_sort_required = 0
/datum/controller/process/machinery/setup()
name = "machinery"
schedule_interval = 20 // every 2 seconds
start_delay = 12
/datum/controller/process/machinery/doWork()
internal_sort()
internal_process_pipenets()
internal_process_machinery()
internal_process_power()
internal_process_power_drain()
/datum/controller/process/machinery/proc/internal_sort()
if(machinery_sort_required)
machinery_sort_required = 0
machines = dd_sortedObjectList(machines)
/datum/controller/process/machinery/proc/internal_process_machinery()
for(last_object in machines)
var/obj/machinery/M = last_object
if(M && !QDELETED(M))
if(M.process() == PROCESS_KILL)
//M.inMachineList = 0 We don't use this debugging function
machines.Remove(M)
continue
if(M && M.use_power)
M.auto_use_power()
SCHECK
/datum/controller/process/machinery/proc/internal_process_power()
for(last_object in powernets)
var/datum/powernet/powerNetwork = last_object
if(istype(powerNetwork) && !QDELETED(powerNetwork))
powerNetwork.reset()
SCHECK
continue
powernets.Remove(powerNetwork)
/datum/controller/process/machinery/proc/internal_process_power_drain()
// Currently only used by powersinks. These items get priority processed before machinery
for(last_object in processing_power_items)
var/obj/item/I = last_object
if(!I.pwr_drain()) // 0 = Process Kill, remove from processing list.
processing_power_items.Remove(I)
SCHECK
/datum/controller/process/machinery/proc/internal_process_pipenets()
for(last_object in pipe_networks)
var/datum/pipe_network/pipeNetwork = last_object
if(istype(pipeNetwork) && !QDELETED(pipeNetwork))
pipeNetwork.process()
SCHECK
continue
pipe_networks.Remove(pipeNetwork)
/datum/controller/process/machinery/statProcess()
..()
stat(null, "[machines.len] machines")
stat(null, "[powernets.len] powernets")
stat(null, "[pipe_networks.len] pipenets")
stat(null, "[processing_power_items.len] power item\s")

View File

@@ -90,10 +90,10 @@ SUBSYSTEM_DEF(machines)
msg += "PO:[round(cost_power_objects,1)]"
msg += "} "
msg += "PI:[global.pipe_networks.len]|"
msg += "MC:[global.machines.len]|"
msg += "MC:[global.processing_machines.len]|"
msg += "PN:[global.powernets.len]|"
msg += "PO:[global.processing_power_items.len]|"
msg += "MC/MS:[round((cost ? global.machines.len/cost_machinery : 0),0.1)]"
msg += "MC/MS:[round((cost ? global.processing_machines.len/cost_machinery : 0),0.1)]"
..(jointext(msg, null))
/datum/controller/subsystem/machines/proc/process_pipenets(resumed = 0)
@@ -115,7 +115,7 @@ SUBSYSTEM_DEF(machines)
/datum/controller/subsystem/machines/proc/process_machinery(resumed = 0)
if (!resumed)
src.current_run = global.machines.Copy()
src.current_run = global.processing_machines.Copy()
var/list/current_run = src.current_run
while(current_run.len)
@@ -125,7 +125,7 @@ SUBSYSTEM_DEF(machines)
if(M.use_power)
M.auto_use_power()
else
global.machines.Remove(M)
global.processing_machines.Remove(M)
if(!QDELETED(M))
M.is_processing = null
if(MC_TICK_CHECK)

View File

@@ -172,16 +172,16 @@
return list()
if(typekey == null)
typekey = /obj/machinery
var/list/machines = list()
var/list/nearby_machines = list()
for(var/obj/O in T)
if(istype(O,typekey))
machines += O
nearby_machines += O
for(var/d in cardinal)
var/turf/T2 = get_step(T,d)
for(var/obj/O in T2)
if(istype(O,typekey))
machines += O
return machines
nearby_machines += O
return nearby_machines
/obj/item/part/computer/networking/prox/verify_machine(var/obj/previous)
if(!previous)

View File

@@ -124,10 +124,12 @@ Class Procs:
/obj/machinery/initialize()
. = ..()
global.machines += src
START_MACHINE_PROCESSING(src)
/obj/machinery/Destroy()
STOP_MACHINE_PROCESSING(src)
global.machines -= src
if(component_parts)
for(var/atom/A in component_parts)
if(A.loc == src) // If the components are inside the machine, delete them.

View File

@@ -6,7 +6,8 @@
// Items that ask to be called every cycle.
var/global/datum/datacore/data_core = null
var/global/list/all_areas = list()
var/global/list/machines = list() // TODO - Move into SSmachines
var/global/list/machines = list() // ALL Machines, wether processing or not.
var/global/list/processing_machines = list() // TODO - Move into SSmachines
var/global/list/processing_objects = list()
var/global/list/processing_power_items = list() // TODO - Move into SSmachines
var/global/list/active_diseases = list()