From c70e69004c904a1e1f4ce0eb528f28ff464b9903 Mon Sep 17 00:00:00 2001 From: Fox-McCloud Date: Wed, 30 Nov 2016 17:50:16 -0500 Subject: [PATCH] Timer Controller Update --- code/__DEFINES/process_scheduler.dm | 3 +++ code/controllers/Processes/timer.dm | 24 ++++++++++++++++-------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/code/__DEFINES/process_scheduler.dm b/code/__DEFINES/process_scheduler.dm index f1e30c23ed3..5cdb99fc4bd 100644 --- a/code/__DEFINES/process_scheduler.dm +++ b/code/__DEFINES/process_scheduler.dm @@ -16,3 +16,6 @@ // Sleep check macro #define SCHECK if(world.tick_usage >= next_sleep_usage) defer() + +//Timing Controller +#define GLOBAL_PROC "some_magic_bullshit" \ No newline at end of file diff --git a/code/controllers/Processes/timer.dm b/code/controllers/Processes/timer.dm index 2e60f8752b8..4add16aae31 100644 --- a/code/controllers/Processes/timer.dm +++ b/code/controllers/Processes/timer.dm @@ -6,7 +6,7 @@ var/global/datum/controller/process/timer/timer_master /datum/controller/process/timer/setup() name = "timer" - schedule_interval = 5 //every 0.5 seconds + schedule_interval = 1 //every 0.1 seconds--2 server ticks timer_master = src log_startup_progress("Timer process starting up.") @@ -30,7 +30,10 @@ var/global/datum/controller/process/timer/timer_master /datum/controller/process/timer/proc/runevent(datum/timedevent/event) set waitfor = 0 if(event.thingToCall) - call(event.thingToCall, event.procToCall)(arglist(event.argList)) + if(event.thingToCall == GLOBAL_PROC && istext(event.procToCall)) + call("/proc/[event.procToCall]")(arglist(event.argList)) + else + call(event.thingToCall, event.procToCall)(arglist(event.argList)) /datum/timedevent var/thingToCall @@ -42,8 +45,7 @@ var/global/datum/controller/process/timer/timer_master var/static/nextid = 1 /datum/timedevent/New() - id = nextid - nextid++ + id = nextid++ /datum/timedevent/Destroy() timer_master.processing_timers -= src @@ -53,7 +55,7 @@ var/global/datum/controller/process/timer/timer_master /proc/addtimer(thingToCall, procToCall, wait, unique = FALSE, ...) if(!timer_master) //can't run timers before the mc has been created return - if(!thingToCall || !procToCall || wait <= 0) + if(!thingToCall || !procToCall) return if(timer_master.disabled) timer_master.disabled = 0 @@ -71,11 +73,17 @@ var/global/datum/controller/process/timer/timer_master // Check for dupes if unique = 1. if(unique) - if(event.hash in timer_master.hashes) - return + var/datum/timedevent/hash_event = timer_master.hashes[event.hash] + if(hash_event) + return hash_event.id + timer_master.hashes[event.hash] = event + if(wait <= 0) + timer_master.runevent(event) + timer_master.hashes -= event.hash + return // If we are unique (or we're not checking that), add the timer and return the id. timer_master.processing_timers += event - timer_master.hashes += event.hash + return event.id /proc/deltimer(id)