diff --git a/btime.dll b/btime.dll deleted file mode 100644 index 36dcbe3af75..00000000000 Binary files a/btime.dll and /dev/null differ diff --git a/code/__DEFINES/btime.dm b/code/__DEFINES/btime.dm deleted file mode 100644 index 33d5def1deb..00000000000 --- a/code/__DEFINES/btime.dm +++ /dev/null @@ -1,18 +0,0 @@ -// Comment this out if the external btime library is unavailable -#define PRECISE_TIMER_AVAILABLE - -#ifdef PRECISE_TIMER_AVAILABLE -var/global/__btime__libName = "btime.[world.system_type==MS_WINDOWS?"dll":"so"]" -#define TimeOfHour (__extern__timeofhour) -#define __extern__timeofhour text2num(call(__btime__libName, "gettime")()) -/hook/startup/proc/checkbtime() - try - // This will always return 1 unless the btime library cannot be accessed - if(TimeOfHour || 1) return 1 - catch(var/exception/e) - log_to_dd("PRECISE_TIMER_AVAILABLE is defined in btime.dm, but calling the btime library failed: [e]") - log_to_dd("This is a fatal error. The world will now shut down.") - del(world) -#else -#define TimeOfHour (world.timeofday % 36000) -#endif diff --git a/code/__DEFINES/process_scheduler.dm b/code/__DEFINES/process_scheduler.dm index af859e314ff..d9c8f106efc 100644 --- a/code/__DEFINES/process_scheduler.dm +++ b/code/__DEFINES/process_scheduler.dm @@ -16,4 +16,4 @@ // SCHECK macros // This references src directly to work around a weird bug with try/catch #define SCHECK_EVERY(this_many_calls) if(++src.calls_since_last_scheck >= this_many_calls) sleepCheck() -#define SCHECK SCHECK_EVERY(50) +#define SCHECK sleepCheck() diff --git a/code/__HELPERS/time.dm b/code/__HELPERS/time.dm index 1bdd85841a5..4973de14b81 100644 --- a/code/__HELPERS/time.dm +++ b/code/__HELPERS/time.dm @@ -3,6 +3,25 @@ #define MINUTES *600 #define HOURS *36000 +#define TimeOfGame (get_game_time()) +#define TimeOfTick (world.tick_usage*0.01*world.tick_lag) + +/proc/get_game_time() + var/global/time_offset = 0 + var/global/last_time = 0 + var/global/last_usage = 0 + + var/wtime = world.time + var/wusage = world.tick_usage * 0.01 + + if(last_time < wtime && last_usage > 1) + time_offset += last_usage - 1 + + last_time = wtime + last_usage = wusage + + return wtime + (time_offset + wusage) * world.tick_lag + //Returns the world time in english /proc/worldtime2text(time = world.time) return "[round(time / 36000)+12]:[(time / 600 % 60) < 10 ? add_zero(time / 600 % 60, 1) : time / 600 % 60]" @@ -33,15 +52,14 @@ proc/isDay(var/month, var/day) * Returns "watch handle" (really just a timestamp :V) */ /proc/start_watch() - return world.timeofday + return TimeOfGame /** * Returns number of seconds elapsed. * @param wh number The "Watch Handle" from start_watch(). (timestamp) */ /proc/stop_watch(wh) - return round(0.1*(world.timeofday-wh),0.1) + return round(0.1 * (TimeOfGame - wh), 0.1) /proc/month2number(month) - return month_names.Find(month) - \ No newline at end of file + return month_names.Find(month) \ No newline at end of file diff --git a/code/controllers/ProcessScheduler/core/_stubs.dm b/code/controllers/ProcessScheduler/core/_stubs.dm deleted file mode 100644 index 94f4cc1fc4b..00000000000 --- a/code/controllers/ProcessScheduler/core/_stubs.dm +++ /dev/null @@ -1,27 +0,0 @@ -/** - * _stubs.dm - * - * This file contains constructs that the process scheduler expects to exist - * in a standard ss13 fork. - */ -/* -/** - * message_admins - * - * sends a message to admins - */ -/proc/message_admins(msg) - world << msg -*/ -/** - * logTheThing - * - * In goonstation, this proc writes a message to either the world log or diary. - * - * Blame Keelin. - */ -/proc/logTheThing(type, source, target, text, diaryType) - if(diaryType) - world << "Diary: \[[diaryType]:[type]] [text]" - else - world << "Log: \[[type]] [text]" diff --git a/code/controllers/ProcessScheduler/core/process.dm b/code/controllers/ProcessScheduler/core/process.dm index b7767c367fd..27ba2479ae5 100644 --- a/code/controllers/ProcessScheduler/core/process.dm +++ b/code/controllers/ProcessScheduler/core/process.dm @@ -69,10 +69,10 @@ * recordkeeping vars */ - // Records the time (1/10s timeofday) at which the process last finished sleeping + // Records the time (1/10s timeoftick) at which the process last finished sleeping var/tmp/last_slept = 0 - // Records the time (1/10s timeofday) at which the process last began running + // Records the time (1/10s timeofgame) at which the process last began running var/tmp/run_start = 0 // Records the number of times this process has been killed and restarted @@ -106,12 +106,8 @@ last_object = null /datum/controller/process/proc/started() - var/timeofhour = TimeOfHour - // Initialize last_slept so we can know when to sleep - last_slept = timeofhour - // Initialize run_start so we can detect hung processes. - run_start = timeofhour + run_start = TimeOfGame // Initialize defer count cpu_defer_count = 0 @@ -163,18 +159,13 @@ setStatus(PROCESS_STATUS_HUNG) /datum/controller/process/proc/handleHung() - var/timeofhour = TimeOfHour var/datum/lastObj = last_object var/lastObjType = "null" if(istype(lastObj)) lastObjType = lastObj.type - // If timeofhour has rolled over, then we need to adjust. - if (timeofhour < run_start) - run_start -= 36000 - var/msg = "[name] process hung at tick #[ticks]. Process was unresponsive for [(timeofhour - run_start) / 10] seconds and was restarted. Last task: [last_task]. Last Object Type: [lastObjType]" - logTheThing("debug", null, null, msg) - logTheThing("diary", null, null, msg, "debug") + var/msg = "[name] process hung at tick #[ticks]. Process was unresponsive for [(TimeOfGame - run_start) / 10] seconds and was restarted. Last task: [last_task]. Last Object Type: [lastObjType]" + log_debug(msg) message_admins(msg) main.restartProcess(src.name) @@ -182,8 +173,8 @@ /datum/controller/process/proc/kill() if (!killed) var/msg = "[name] process was killed at tick #[ticks]." - logTheThing("debug", null, null, msg) - logTheThing("diary", null, null, msg, "debug") + log_debug(msg) + message_admins(msg) //finished() // Allow inheritors to clean up if needed @@ -208,17 +199,12 @@ if (main.getCurrentTickElapsedTime() > main.timeAllowance) sleep(world.tick_lag) cpu_defer_count++ - last_slept = TimeOfHour + last_slept = 0 else - var/timeofhour = TimeOfHour - // If timeofhour has rolled over, then we need to adjust. - if (timeofhour < last_slept) - last_slept -= 36000 - - if (timeofhour > last_slept + sleep_interval) + if (TimeOfTick > last_slept + sleep_interval) // If we haven't slept in sleep_interval deciseconds, sleep to allow other work to proceed. sleep(0) - last_slept = TimeOfHour + last_slept = TimeOfTick /datum/controller/process/proc/update() // Clear delta @@ -239,10 +225,7 @@ /datum/controller/process/proc/getElapsedTime() - var/timeofhour = TimeOfHour - if (timeofhour < run_start) - return timeofhour - (run_start - 36000) - return timeofhour - run_start + return TimeOfGame - run_start /datum/controller/process/proc/tickDetail() return diff --git a/code/controllers/ProcessScheduler/core/processScheduler.dm b/code/controllers/ProcessScheduler/core/processScheduler.dm index eccb44c49c5..1c6a0c91a28 100644 --- a/code/controllers/ProcessScheduler/core/processScheduler.dm +++ b/code/controllers/ProcessScheduler/core/processScheduler.dm @@ -43,8 +43,6 @@ var/global/datum/controller/processScheduler/processScheduler var/tmp/currentTick = 0 - var/tmp/currentTickStart = 0 - var/tmp/timeAllowance = 0 var/tmp/cpuAverage = 0 @@ -247,7 +245,7 @@ var/global/datum/controller/processScheduler/processScheduler /datum/controller/processScheduler/proc/recordStart(var/datum/controller/process/process, var/time = null) if (isnull(time)) - time = TimeOfHour + time = TimeOfGame last_queued[process] = world.time last_start[process] = time else @@ -256,11 +254,7 @@ var/global/datum/controller/processScheduler/processScheduler /datum/controller/processScheduler/proc/recordEnd(var/datum/controller/process/process, var/time = null) if (isnull(time)) - time = TimeOfHour - - // If world.timeofday has rolled over, then we need to adjust. - if (time < last_start[process]) - last_start[process] -= 36000 + time = TimeOfGame var/lastRunTime = time - last_start[process] @@ -349,13 +343,12 @@ var/global/datum/controller/processScheduler/processScheduler updateCurrentTickData() return 0 else - return TimeOfHour - currentTickStart + return TimeOfTick /datum/controller/processScheduler/proc/updateCurrentTickData() if (world.time > currentTick) // New tick! currentTick = world.time - currentTickStart = TimeOfHour updateTimeAllowance() cpuAverage = (world.cpu + cpuAverage + cpuAverage) / 3 diff --git a/code/game/objects/explosion.dm b/code/game/objects/explosion.dm index 068e3144e73..caaf79a9981 100644 --- a/code/game/objects/explosion.dm +++ b/code/game/objects/explosion.dm @@ -31,7 +31,7 @@ flame_range = min (MAX_EX_FLAME_RANGE, flame_range) spawn(0) - var/start = TimeOfHour + var/watch = start_watch() if(!epicenter) return var/max_range = max(devastation_range, heavy_impact_range, light_impact_range, flame_range) @@ -157,8 +157,7 @@ var/turf/throw_at = get_ranged_target_turf(I, throw_dir, throw_range) I.throw_at(throw_at, throw_range, 2, no_spin = 1) //Throw it at 2 speed, this is purely visual anyway; don't spin the thrown items, it's very costly. */ - var/timeofhour = TimeOfHour - var/took = round((start <= timeofhour) ? ((timeofhour-start)/10) : ((timeofhour-(start-36000))/10), 0.01) + var/took = stop_watch(watch) //You need to press the DebugGame verb to see these now....they were getting annoying and we've collected a fair bit of data. Just -test- changes to explosion code using this please so we can compare if(Debug2) log_to_dd("## DEBUG: Explosion([x0],[y0],[z0])(d[devastation_range],h[heavy_impact_range],l[light_impact_range]): Took [took] seconds.") diff --git a/paradise.dme b/paradise.dme index af0eb57e422..b796d5cd55d 100644 --- a/paradise.dme +++ b/paradise.dme @@ -17,7 +17,6 @@ #include "code\__DEFINES\_readme.dm" #include "code\__DEFINES\admin.dm" #include "code\__DEFINES\atmospherics.dm" -#include "code\__DEFINES\btime.dm" #include "code\__DEFINES\clothing.dm" #include "code\__DEFINES\combat.dm" #include "code\__DEFINES\flags.dm" @@ -173,7 +172,6 @@ #include "code\controllers\Processes\vote.dm" #include "code\controllers\Processes\shuttles\emergency.dm" #include "code\controllers\Processes\shuttles\supply.dm" -#include "code\controllers\ProcessScheduler\core\_stubs.dm" #include "code\controllers\ProcessScheduler\core\process.dm" #include "code\controllers\ProcessScheduler\core\processScheduler.dm" #include "code\datums\ai_law_sets.dm"