for(var/turf/T in range(10,src))
// list.Find(item, start, end)proc/list_find(list/list, item, start = 1, end = list.len + 1) for(var/index in start to end - 1) if(list[index] == item) return index return 0
// item in listproc/list_in(list/list, item) for(var/check in list) if(check == item) return TRUE return FALSE
Here's my source:
while(Duration > 0) Duration -= 5 sleep(10)
This is what's causing the lag over time. Every turf in the aoe is running this loop. Every second, every turf in the aoe does something and then sleeps for another second. It might not seem like much, but multiplied by the number of turfs you have, it is apparently enough to cause lag that "lasts for the remainder of the server's runtime" (but in theory should only last as long as the while() lasts).
If you do the math, the actual sleep duration is 10 * Duration / 5.
In other words, you sleep by 10 for every time you can remove 5 from Duration, so you can just sleep once by that amount.
One large optimization you can make is to only sleep once. The thing to notice is that the duration of the sleep doesn't differ between the turfs, so you don't need each turf to sleep separately (each call to sleep has its own overhead, so it's best to minimize the calls). There's actually a lot of work being done in Transform per turf that all of the turfs are repeating exactly.
Assuming there aren't any overrides of Transform() that drastically change what's being done.
mob var status_bleeding = 0 proc gameTick() if(status_bleeding) takeDamage(5) Bleed(time) status_bleeding = 1 sleep(time) status_bleeding = 0
Bleed(time) ++status_bleeding sleep(time) --status_bleeding
mob var/tmp status_bleed_time proc gameTick() if(world.time<status_bleed_time) takeDamage(5) Bleed(time) status_bleed_time = max(status_bleed_time,world.time + time) Write(savefile/F) ..() F["status_bleed_time"] << (status_bleed_time-world.time) Read(savefile/F) ..() F["status_bleed_time"] >> status_bleed_time status_bleed_time += world.time
turf var/tmp transform_status = 0 transform_appearance = 0
if(!(turf.transform_status++)) turf.transform_appearance = turf.appearance
if(!(--turf.transform_status)) turf.appearance = turf.transform_appearance turf.transform_appearance = null