Merge pull request #31494 from MrStonedOne/tick_contention_tug_of_war

In which the stoner one gets stoned and tries to address tick contention... again
This commit is contained in:
Jordan Brown
2017-10-10 13:28:38 -05:00
committed by CitadelStationBot
parent f8d0646b09
commit 7b30be0058
21 changed files with 72 additions and 54 deletions
+3 -3
View File
@@ -321,7 +321,7 @@ Proc for attack log creation, because really why not
var/starttime = world.time
. = 1
while (world.time < endtime)
stoplag()
stoplag(1)
if (progress)
progbar.update(world.time - starttime)
if(QDELETED(user) || QDELETED(target))
@@ -382,7 +382,7 @@ Proc for attack log creation, because really why not
var/starttime = world.time
. = 1
while (world.time < endtime)
stoplag()
stoplag(1)
if (progress)
progbar.update(world.time - starttime)
@@ -437,7 +437,7 @@ Proc for attack log creation, because really why not
. = 1
mainloop:
while(world.time < endtime)
sleep(1)
stoplag(1)
if(progress)
progbar.update(world.time - starttime)
if(QDELETED(user) || !targets)
+11 -8
View File
@@ -504,10 +504,10 @@ Turf and target are separate in case you want to teleport some distance from a t
/atom/proc/GetAllContents(list/output=list())
. = output
output += src
for(var/i in 1 to contents.len)
var/atom/thing = contents[i]
thing.GetAllContents(output)
output += src
for(var/i in 1 to contents.len)
var/atom/thing = contents[i]
thing.GetAllContents(output)
//Step-towards method of determining whether one atom can see another. Similar to viewers()
/proc/can_see(atom/source, atom/target, length=5) // I couldnt be arsed to do actual raycasting :I This is horribly inaccurate.
@@ -1225,16 +1225,19 @@ proc/pick_closest_path(value, list/matches = get_fancy_list_of_atom_types())
//Increases delay as the server gets more overloaded,
//as sleeps aren't cheap and sleeping only to wake up and sleep again is wasteful
#define DELTA_CALC max(((max(TICK_USAGE, world.cpu) / 100) * max(Master.sleep_delta,1)), 1)
#define DELTA_CALC max(((max(TICK_USAGE, world.cpu) / 100) * max(Master.sleep_delta-1,1)), 1)
/proc/stoplag()
//returns the number of ticks slept
/proc/stoplag(initial_delay)
if (!Master || !(Master.current_runlevel & RUNLEVELS_DEFAULT))
sleep(world.tick_lag)
return 1
if (!initial_delay)
initial_delay = world.tick_lag
. = 0
var/i = 1
var/i = DS2TICKS(initial_delay)
do
. += round(i*DELTA_CALC)
. += Ceiling(i*DELTA_CALC)
sleep(i*world.tick_lag*DELTA_CALC)
i *= 2
while (TICK_USAGE > min(TICK_LIMIT_TO_RUN, Master.current_ticklimit))