mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2025-12-24 09:14:17 +00:00
- Integrates Volundr's btime library and associated process scheduler changes. - btime is implemented separately from the process scheduler, as precise time measurement is also useful elsewhere. - `TimeOfHour` is no longer internally throttled; throttling is instead done by `SCHECK`. - If btime's `gettime` cannot be called at world startup, an error will be output and the world will stop. - Retains the change to schedule processes according to game time, rather than real time. - Removes the (now unused) update queue files. - Removes the process scheduler testing files. - These are standalone tests for the process scheduler, completely unrelated to its use in the full codebase. We never used them. - Moves the process scheduler defines into __DEFINES. - Makes the lighting process run once before the round starts. - Renames `scheck` to `sleepCheck`, to ensure any code that tries to use `scheck` will fail to compile. - Adds `SCHECK` and `SCHECK_EVERY` macros that skip calling `sleepCheck` entirely until a specified number of `SCHECK`s (50 by default) have been called. - Makes most processes iterate using their `last_object` variable, allowing hang recovery to show the type that caused the hang. - Makes processes output an error when they filter out a type they refuse to process. - Rolls the recently-added alarm subsystem into the alarm process. - Removes the now unused subsystems code.
75 lines
1.9 KiB
Plaintext
75 lines
1.9 KiB
Plaintext
/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/statProcess()
|
|
..()
|
|
stat(null, "[machines.len] machines")
|
|
stat(null, "[powernets.len] powernets")
|
|
|
|
/datum/controller/process/machinery/doWork()
|
|
process_sort()
|
|
process_power()
|
|
process_power_drain()
|
|
process_machines()
|
|
|
|
/datum/controller/process/machinery/proc/process_sort()
|
|
if(machinery_sort_required)
|
|
machinery_sort_required = 0
|
|
machines = dd_sortedObjectList(machines)
|
|
|
|
/datum/controller/process/machinery/proc/process_machines()
|
|
for(last_object in machines)
|
|
var/obj/machinery/M = last_object
|
|
if(istype(M) && isnull(M.gcDestroyed))
|
|
#ifdef PROFILE_MACHINES
|
|
var/time_start = world.timeofday
|
|
#endif
|
|
|
|
try
|
|
if(M.process() == PROCESS_KILL)
|
|
machines.Remove(M)
|
|
continue
|
|
|
|
if(M.use_power)
|
|
M.auto_use_power()
|
|
catch(var/exception/e)
|
|
catchException(e, M)
|
|
|
|
#ifdef PROFILE_MACHINES
|
|
var/time_end = world.timeofday
|
|
|
|
if(!(M.type in machine_profiling))
|
|
machine_profiling[M.type] = 0
|
|
|
|
machine_profiling[M.type] += (time_end - time_start)
|
|
#endif
|
|
else
|
|
catchBadType(M)
|
|
machines -= M
|
|
|
|
SCHECK_EVERY(100)
|
|
|
|
/datum/controller/process/machinery/proc/process_power()
|
|
for(last_object in powernets)
|
|
var/datum/powernet/powerNetwork = last_object
|
|
if(istype(powerNetwork) && isnull(powerNetwork.gcDestroyed))
|
|
try
|
|
powerNetwork.reset()
|
|
catch(var/exception/e)
|
|
catchException(e, powerNetwork)
|
|
SCHECK
|
|
continue
|
|
|
|
powernets.Remove(powerNetwork)
|
|
|
|
/datum/controller/process/machinery/proc/process_power_drain()
|
|
// Currently only used by powersinks. These items get priority processed before machinery
|
|
for(var/obj/item/I in processing_power_items)
|
|
if(!I.pwr_drain()) // 0 = Process Kill, remove from processing list.
|
|
processing_power_items.Remove(I)
|
|
SCHECK
|