Sorted client time timers

This commit is contained in:
Cyberboss
2017-02-21 09:33:00 -05:00
parent 8d87c435fc
commit ec8c42bbff
+27 -15
View File
@@ -40,20 +40,18 @@ var/datum/subsystem/timer/SStimer
..("B:[bucket_count] P:[length(processing)] H:[length(hashes)] C:[length(clienttime_timers)]")
/datum/subsystem/timer/fire(resumed = FALSE)
if (length(clienttime_timers))
for (var/thing in clienttime_timers)
var/datum/timedevent/ctime_timer = thing
if (ctime_timer.spent)
qdel(ctime_timer)
continue
if (ctime_timer.timeToRun <= REALTIMEOFDAY)
var/datum/callback/callBack = ctime_timer.callBack
ctime_timer.spent = TRUE
callBack.InvokeAsync()
qdel(ctime_timer)
if (MC_TICK_CHECK)
return
while(length(clienttime_timers))
var/datum/timedevent/ctime_timer = clienttime_timers[clienttime_timers.len]
if (ctime_timer.timeToRun <= REALTIMEOFDAY)
--clienttime_timers.len
var/datum/callback/callBack = ctime_timer.callBack
ctime_timer.spent = TRUE
callBack.InvokeAsync()
qdel(ctime_timer)
else
break //None of the rest are ready to run
if (MC_TICK_CHECK)
return
var/static/list/spent = list()
var/static/datum/timedevent/timer
@@ -211,7 +209,21 @@ var/datum/subsystem/timer/SStimer
LAZYADD(callBack.object.active_timers, src)
if (flags & TIMER_CLIENT_TIME)
SStimer.clienttime_timers += src
//sorted insert
var/list/ctts = SStimer.clienttime_timers
var/cttl = length(ctts)
if(cttl)
var/datum/timedevent/Last = ctts[cttl]
if(Last.timeToRun >= timeToRun)
ctts += src
else if(cttl > 1)
for(var/I in cttl to 1)
var/datum/timedevent/E = ctts[I]
if(E.timeToRun <= timeToRun)
ctts.Insert(src, I)
break
else
ctts += src
return
//get the list of buckets