Files
2b8c889578 reworks pathfinding (#5907)
- adds astar with visualizer
- adds jps with visualizer
- transitions everything to subsystem calls
- subsystem now limits the number of calls that can go on at once for
performance reasons

"uh oh, silicons is fucking with integral game code while half asleep
again"

---------

Co-authored-by: silicons <no@you.cat>
2023-08-30 19:28:20 -07:00

39 lines
1.1 KiB
Plaintext

/*
This is pretty much just an optimization for wait=0 timers. They're relatively common, but generally don't actually need the more
complex features of SStimer. SSdpc can handle these timers instead (and it's a lot simpler than SStimer is), but it can't handle
complex timers with flags. This doesn't need to be explicitly used, eligible timers are automatically converted.
*/
SUBSYSTEM_DEF(dpc)
name = "Delayed Procedure Call"
wait = 1
runlevels = RUNLEVELS_ALL
priority = FIRE_PRIORITY_DPC
subsystem_flags = SS_TICKER | SS_NO_INIT
var/list/queued_calls = list()
var/list/avg = 0
/datum/controller/subsystem/dpc/stat_entry()
return ..() + " Q: [queued_calls.len], AQ: ~[round(avg)]"
/datum/controller/subsystem/dpc/fire(resumed = FALSE)
var/list/qc = queued_calls
if (!resumed)
avg = MC_AVERAGE_FAST(avg, qc.len)
var/q_idex = 1
while (q_idex <= qc.len)
var/datum/callback/CB = qc[q_idex]
q_idex += 1
if (!isdatum(CB.object) || !CB.object.gc_destroyed)
CB.InvokeAsync()
if (MC_TICK_CHECK)
break
if (q_idex > 1)
queued_calls.Cut(1, q_idex)