mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-22 20:48:56 +01:00
Merge pull request #13345 from neersighted/sstimer_lovin
Fix up SStimer, make Crew Console use SStimer
This commit is contained in:
@@ -1,61 +0,0 @@
|
||||
var/datum/subsystem/procqueue/procqueue
|
||||
|
||||
/datum/subsystem/procqueue
|
||||
var/list/queue = list()
|
||||
|
||||
/datum/subsystem/procqueue/New()
|
||||
NEW_SS_GLOBAL(procqueue)
|
||||
|
||||
/datum/subsystem/procqueue/fire()
|
||||
if (queue.len)
|
||||
var/list/L = list()
|
||||
|
||||
for (var/datum/procqueue_item/item in queue)
|
||||
if (!item.runafter || item.runafter-- <= 0)
|
||||
if (!(item.id in L))
|
||||
if (item.args) call(item.ref, item.procname)(arglist(item.args))
|
||||
else call(item.ref, item.procname)()
|
||||
|
||||
L.Add(item.id)
|
||||
|
||||
queue.Remove(item)
|
||||
|
||||
/datum/subsystem/procqueue/proc/queue(ref, procname, ...)
|
||||
var/list/L = args.Copy()
|
||||
|
||||
L.Insert(1, 0)
|
||||
|
||||
src.schedule(arglist(L))
|
||||
|
||||
/datum/subsystem/procqueue/proc/schedule(time, ref, procname, ...)
|
||||
var/datum/procqueue_item/item = new/datum/procqueue_item
|
||||
item.ref = ref
|
||||
item.procname = procname
|
||||
|
||||
if (args.len > 3)
|
||||
item.args = args.Copy(4)
|
||||
|
||||
if (time > 0) item.runafter = time / 10
|
||||
|
||||
item.id = "[item.ref]_[item.procname]"
|
||||
|
||||
if (item.args)
|
||||
item.id += "("
|
||||
var/first = 1
|
||||
for (var/a in item.args)
|
||||
if (!first) item.id += ","
|
||||
item.id += "[a]"
|
||||
first = 0
|
||||
item.id += ")"
|
||||
|
||||
for (var/datum/procqueue_item/candidate in queue)
|
||||
if (candidate.id == item.id)
|
||||
return
|
||||
|
||||
src.queue.Insert(1, item)
|
||||
|
||||
/datum/procqueue_item/var/id
|
||||
/datum/procqueue_item/var/runafter
|
||||
/datum/procqueue_item/var/ref
|
||||
/datum/procqueue_item/var/procname
|
||||
/datum/procqueue_item/var/list/args
|
||||
@@ -21,12 +21,11 @@ var/datum/subsystem/timer/SStimer
|
||||
can_fire = 0 //nothing to do, lets stop firing.
|
||||
return
|
||||
for (var/datum/timedevent/event in processing)
|
||||
// hacky i know, but its the only way to ensure this works with clients
|
||||
if (!event.thingToCall || qdeleted(event.thingToCall))
|
||||
qdel(event)
|
||||
if (event.timeToRun <= world.time)
|
||||
spawn(-1)
|
||||
call(event.thingToCall,event.procToCall)(arglist(event.argList))
|
||||
call(event.thingToCall, event.procToCall)(arglist(event.argList))
|
||||
qdel(event)
|
||||
|
||||
/datum/timedevent
|
||||
@@ -45,7 +44,7 @@ var/datum/subsystem/timer/SStimer
|
||||
SStimer.processing -= src
|
||||
return ..()
|
||||
|
||||
/proc/addtimer(thingToCall, procToCall, wait, argList = list())
|
||||
/proc/addtimer(thingToCall, procToCall, wait, ...)
|
||||
if (!SStimer) //can't run timers before the mc has been created
|
||||
return
|
||||
if (!thingToCall || !procToCall || wait <= 0)
|
||||
@@ -58,7 +57,8 @@ var/datum/subsystem/timer/SStimer
|
||||
event.thingToCall = thingToCall
|
||||
event.procToCall = procToCall
|
||||
event.timeToRun = world.time + wait
|
||||
event.argList = argList
|
||||
if (args.len > 3)
|
||||
event.argList = args.Copy(4)
|
||||
|
||||
SStimer.processing += event
|
||||
|
||||
|
||||
@@ -255,7 +255,7 @@ var/global/datum/crewmonitor/crewmonitor = new
|
||||
return ..()
|
||||
|
||||
/datum/crewmonitor/proc/queueUpdate(z)
|
||||
procqueue.schedule(50, crewmonitor, "update", z)
|
||||
addtimer(crewmonitor, "update", 5, z)
|
||||
|
||||
/datum/crewmonitor/proc/generateMiniMaps()
|
||||
for(var/z = 1 to world.maxz)
|
||||
|
||||
Reference in New Issue
Block a user