From 83396d41dfe6ce0fd4f8fb74c96628bd01e0012f Mon Sep 17 00:00:00 2001 From: Tastyfish Date: Mon, 29 Feb 2016 15:48:49 -0500 Subject: [PATCH] Removes btime dependency, makes sleep check happen on Every SCHECK --- btime.dll | Bin 6656 -> 0 bytes code/__DEFINES/btime.dm | 18 -------- code/__DEFINES/process_scheduler.dm | 2 +- code/__HELPERS/time.dm | 26 ++++++++++-- .../ProcessScheduler/core/_stubs.dm | 27 ------------ .../ProcessScheduler/core/process.dm | 39 +++++------------- .../ProcessScheduler/core/processScheduler.dm | 13 ++---- code/game/objects/explosion.dm | 5 +-- paradise.dme | 2 - 9 files changed, 39 insertions(+), 93 deletions(-) delete mode 100644 btime.dll delete mode 100644 code/__DEFINES/btime.dm delete mode 100644 code/controllers/ProcessScheduler/core/_stubs.dm diff --git a/btime.dll b/btime.dll deleted file mode 100644 index 36dcbe3af7561942191dde97718a2844dc2a23ef..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6656 zcmeHLdvH|M89$qBU;`VnY8Jv6WC=-!K?(aLS(4!9u_cTI7dB5IESudMcEdj6-Fq>y z;=ruwxL#9fb*y$e4j3J5r)8j0iPDjUfB`2=BXu%y1e>d;= zt$(zRXY!rL_dehG&UfyndgC6FN(hkyM3ImljI>##{+qiP$a5CHK8GAmKf9<$w)X6z z8jm-mX=8)iSf^j(as~oHPSeb2SU#Zf1~irT+co~6n<>c1n3b1Mz2NQ2+ZqopEl)!E zvRBJDVO_rLaAMq5UMsD4OKaQd*UC3a{CAgkNchh325CH$7>`Kf2CvIQbtZRUvl6ma zmPTgHj@Bk|!z5+VY}qVA@JEz!Y;G1t6+k1cRnk0#kTfEb5Xq5j#S%eVx{;6+VgV6C zRPOp1U)u5sX#rN5OGpVNTL?KES4CGhnvD=6@Ow3ch^6@DHI$0b;~DVmK42o{E?hNCaGw z;)}e>EM*0+h*Xb^9-+~i;L^g^Quu;>e}LWMHoS9$WIp;7cz}sL`GqI~ zNkg(Lf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)%q}pCru|cQR#wo^Bhacw_bU9os zM})K%mSG5)pWg zCw%UbJNN(`+fFut8`}s5BqNJc9TN6Tsw06}1aI42OdIF$I0J5^n$h73`u)KG`G{Dh zZPHWaze%>+zH|)E?ExxUKC-;lMVA{7!E7F-#j7oldO?`rDi=bDfDq7qtK{y}>{tIOHX{o#DQooVq4dnFySXWkOI& z-Y1pbkh9sx)Oc9N>0aw?W}R$D1&%O8_NT7r8Med5uq{E>?+mz@iXcz-N1meDQR8)O zmk zX)ezOR)+8f`kkR=ey@uShJr2JGSsJ)&XB)ghb~uxo9b<0LR=l5Q`CmiTwQ@ScU8tL zji!WS`4G1T)$!ldW{Ar{GQ_xe*2{HBdNgPyEb{;lD~#L5dUxOoZ(~B&iPOo}c8Jm< zwU*hz_%uG+m*zS{YXUoh+Zi@j!+XnI^kpy2ZE^ZSOzx_Z<=1uJEPP%6G>$J>FIj$* zuO-W`ZyMqy%aie3WuvvAa?QHc4GoFOf3v1_C=2H{Q#)5%uXSh{?RITQ`;c~*woAKT z`-b+k_N?}tHm1F-RqGb(v^tY+lg_QQ_= 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"