Ported LemonInTheDark's scheduler offset optimization.

This commit is contained in:
Spookerton
2023-02-05 10:28:34 -05:00
committed by VirgoBot
parent 909c382e4e
commit 6cb1df8f60
+12 -1
View File
@@ -257,7 +257,7 @@ GLOBAL_REAL(Master, /datum/controller/master) = new
SS.state = SS_IDLE
if (SS.flags & SS_TICKER)
tickersubsystems += SS
timer += world.tick_lag * rand(1, 5)
timer += world.tick_lag * rand(0,1)
SS.next_fire = timer
continue
@@ -332,13 +332,24 @@ GLOBAL_REAL(Master, /datum/controller/master) = new
var/checking_runlevel = current_runlevel
if(cached_runlevel != checking_runlevel)
//resechedule subsystems
var/list/old_subsystems = current_runlevel_subsystems
cached_runlevel = checking_runlevel
current_runlevel_subsystems = runlevel_sorted_subsystems[cached_runlevel]
<<<<<<< HEAD
var/stagger = world.time
for(var/datum/controller/subsystem/SS as anything in current_runlevel_subsystems)
if(SS.next_fire <= world.time)
stagger += world.tick_lag * rand(1, 5)
SS.next_fire = stagger
=======
//now we'll go through all the subsystems we want to offset and give them a next_fire
for(var/datum/controller/subsystem/SS as anything in current_runlevel_subsystems)
//we only want to offset it if it's new and also behind
if(SS.next_fire > world.time || (SS in old_subsystems))
continue
SS.next_fire = world.time + world.tick_lag * rand(0, DS2TICKS(min(SS.wait, 2 SECONDS)))
>>>>>>> 13c028088ea... Merge pull request #8925 from MistakeNot4892/tgopt
subsystems_to_check = current_runlevel_subsystems
else