diff --git a/code/controllers/subsystem/timer.dm b/code/controllers/subsystem/timer.dm index 4bbc44c218a..3e7285a79bf 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 @@ -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