atom/proc
Process_Environmentals() // main procedure to handle atmos
//set background = 1
spawn while(src)
if(block_air_calc || temp == DEFAULT_TEMP) // if block air calc is flagged, then do not simulate heat transfer
sleep(20)
continue
else
var/CONTROL=0 // this redundant block air calc check is contributing slightly to increased cpu usage
for(var/obj/A in src.loc)
if(A.block_air_calc)CONTROL=1
else continue
if(!CONTROL)
if(temp < DEFAULT_TEMP)
temp = DEFAULT_TEMP
else
temp-=0.10 // bleed off temp slowly, if no heat source is present, heat will dissipate over time
Thermal_Leak_Detect()
Heat_Transfer()
else
sleep(20)
continue
sleep(20)
Problem description:
Well my question is, when calling a loop like so spawn while(src), is there a way to include the delay in the same line, so that within the loop if a situation occurs where continue is called, i don't need to also call sleep() before hand?
Recently during some testing i noticed that with a large number of objects present in the world that have to calculate heat transfer, via the snippet above, there was high cpu usage. Right now im running the heat transfer calculations all the time just to test efficiency, once its all said and done the loop will only run while a player or players offline mob is in range, may also adjust delay and heat bleed off rate in favor of cpu usage.
this is a project i've been working on for roughly 6 years, finally pushed it to a alpha playable state and im really hoping to rent a server next month and host some public testing, just need to nail any possible high cpu situations that i haven't run into while solo testing with just a small test map.
Even the for() should be breaking when CONTROL=1 happens, not continuing when it doesn't happen.
The first if() can just be inverted.
If you just let the code naturally fall out of the conditions, it'll reach the final sleep(20) and repeat as normal anyways.
Otherwise, you could just have the sleep(20) at the top, I guess.