From 45c61f599abc4126da482af8b0e7618870832837 Mon Sep 17 00:00:00 2001 From: Purpose Date: Mon, 15 Oct 2018 22:45:52 +0100 Subject: [PATCH 1/2] arrays start at 0 damnit --- code/controllers/subsystem/timer.dm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/controllers/subsystem/timer.dm b/code/controllers/subsystem/timer.dm index e2539ebdf06..20ab9d47e0c 100644 --- a/code/controllers/subsystem/timer.dm +++ b/code/controllers/subsystem/timer.dm @@ -122,7 +122,7 @@ SUBSYSTEM_DEF(timer) if(!resumed) timer = null - while(practical_offset <= BUCKET_LEN && head_offset + (practical_offset*world.tick_lag) <= world.time) + while(practical_offset <= BUCKET_LEN && head_offset + ((practical_offset-1)*world.tick_lag) <= world.time) var/datum/timedevent/head = bucket_list[practical_offset] if(!timer || !head || timer == head) head = bucket_list[practical_offset] @@ -170,7 +170,7 @@ SUBSYSTEM_DEF(timer) qdel(timer) continue - if(timer.timeToRun < head_offset + TICKS2DS(practical_offset)) + if(timer.timeToRun < head_offset + TICKS2DS(practical_offset-1)) bucket_resolution = null //force bucket recreation CRASH("[i] Invalid timer state: Timer in long run queue that would require a backtrack to transfer to short run queue. [get_timer_debug_string(timer)] world.time: [world.time], head_offset: [head_offset], practical_offset: [practical_offset]") if(timer.callBack && !timer.spent) @@ -521,4 +521,4 @@ SUBSYSTEM_DEF(timer) #undef BUCKET_LEN #undef BUCKET_POS #undef TIMER_MAX -#undef TIMER_ID_MAX \ No newline at end of file +#undef TIMER_ID_MAX From 75fdf0095d3f2d9e189f3cf9d476eb18ac77cd26 Mon Sep 17 00:00:00 2001 From: Purpose Date: Thu, 18 Oct 2018 20:54:22 +0100 Subject: [PATCH 2/2] more --- code/controllers/subsystem/timer.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/controllers/subsystem/timer.dm b/code/controllers/subsystem/timer.dm index 20ab9d47e0c..2a25c3d05a9 100644 --- a/code/controllers/subsystem/timer.dm +++ b/code/controllers/subsystem/timer.dm @@ -1,5 +1,5 @@ #define BUCKET_LEN (world.fps*1*60) //how many ticks should we keep in the bucket. (1 minutes worth) -#define BUCKET_POS(timer) ((round((timer.timeToRun - SStimer.head_offset) / world.tick_lag) % BUCKET_LEN)||BUCKET_LEN) +#define BUCKET_POS(timer) (((round((timer.timeToRun - SStimer.head_offset) / world.tick_lag)+1) % BUCKET_LEN)||BUCKET_LEN) #define TIMER_MAX (world.time + TICKS2DS(min(BUCKET_LEN-(SStimer.practical_offset-DS2TICKS(world.time - SStimer.head_offset))-1, BUCKET_LEN-1))) #define TIMER_ID_MAX (2**24) //max float with integer precision