Fixes subsystem issues and other timer bugfixes (#13061)

* Debug code to figure out why timer fire isn't yielding

* please man

* thing 2

* BALLS

* BALLS 2

* correction

* remove debug shitcode

Co-authored-by: Matt Atlas <liermattia@gmail.com>
This commit is contained in:
Matt Atlas
2022-02-05 06:07:06 +01:00
committed by GitHub
parent e314a6ec9b
commit d596fd831e
4 changed files with 13 additions and 5 deletions

View File

@@ -65,12 +65,13 @@
#define SS_PRIORITY_AIRFLOW 10 // Handles object movement due to ZAS airflow.
#define SS_PRIORITY_PING 10
#define SS_PRIORITY_ZCOPY 10 // Z-mimic icon generation/updates.
#define SS_PRIORITY_ARRIVALS 10 // Centcomm arrivals shuttle auto-launch. Usually asleep.
// SS_BACKGROUND
#define SS_PRIORITY_PROCESSING 50 // Generic datum processor. Replaces objects processor.
//#define SS_PRIORITY_DEFAULT 50 // This is defined somewhere else.
#define SS_PRIORITY_PSYCHICS 30
#define SS_PRIORITY_ARRIVALS 30 // Centcomm arrivals shuttle auto-launch. Usually asleep.
#define SS_PRIORITY_EVAC 30 // Processes the evac controller.
#define SS_PRIORITY_EXPLOSIVES 20 // Explosion processor. Doesn't have much effect on explosion tick-checking.
#define SS_PRIORITY_DISPOSALS 20 // Disposal holder movement.

View File

@@ -2,7 +2,7 @@
/datum/controller/subsystem/arrivals
name = "Arrivals"
flags = SS_NO_INIT | SS_BACKGROUND | SS_NO_TICK_CHECK
flags = SS_NO_INIT | SS_BACKGROUND
priority = SS_PRIORITY_ARRIVALS
var/datum/shuttle/autodock/ferry/arrival/shuttle

View File

@@ -4,7 +4,7 @@ var/datum/controller/subsystem/evac/SSevac
name = "Evacuation"
priority = SS_PRIORITY_EVAC
//Initializes at default time
flags = SS_NO_TICK_CHECK|SS_BACKGROUND
flags = SS_BACKGROUND
wait = 2 SECONDS
/datum/controller/subsystem/evac/Initialize()

View File

@@ -3,7 +3,7 @@
/// Helper for getting the correct bucket for a given timer
#define BUCKET_POS(timer) (((round((timer.timeToRun - SStimer.head_offset) / world.tick_lag)+1) % BUCKET_LEN)||BUCKET_LEN)
/// Gets the maximum time at which timers will be invoked from buckets, used for deferring to secondary queue
#define TIMER_MAX (world.time + TICKS2DS(min(BUCKET_LEN-(SStimer.practical_offset-DS2TICKS(world.time - SStimer.head_offset))-1, BUCKET_LEN-1)))
#define TIMER_MAX (SStimer.head_offset + TICKS2DS(BUCKET_LEN + SStimer.practical_offset - 1))
/// Max float with integer precision
#define TIMER_ID_MAX (2**24)
@@ -261,6 +261,12 @@ var/datum/controller/subsystem/timer/SStimer
// Add all timed events from the secondary queue as well
alltimers += second_queue
for (var/datum/timedevent/t as anything in alltimers)
t.bucket_joined = FALSE
t.bucket_pos = -1
t.prev = null
t.next = null
// If there are no timers being tracked by the subsystem,
// there is no need to do any further rebuilding
if (!length(alltimers))
@@ -304,6 +310,7 @@ var/datum/controller/subsystem/timer/SStimer
new_bucket_count++
var/bucket_pos = BUCKET_POS(timer)
timer.bucket_pos = bucket_pos
timer.bucket_joined = TRUE
var/datum/timedevent/bucket_head = bucket_list[bucket_pos]
if (!bucket_head)
@@ -452,7 +459,7 @@ var/datum/controller/subsystem/timer/SStimer
if(buckethead == src)
bucket_list[bucket_pos] = next
SStimer.bucket_count--
else if(timeToRun < TIMER_MAX)
else if(bucket_joined)
SStimer.bucket_count--
else
var/l = length(second_queue)