From c8a01f0b29c4af5e78ec79f656cc9930838c855f Mon Sep 17 00:00:00 2001 From: n3ophyt3 Date: Fri, 22 Jul 2011 05:37:13 +0000 Subject: [PATCH] Bombs are now less laggy. To go into details: Was some talk going on in the IRC about how bombs were far less laggy in ye olde days, and having a copy of oldcode, I decided to compare the code side by side a bit. With no particularly obvious difference between the two, we assumed atmos was the culprit, it being the laggy cesspool of mystery that it is. CPU profiling a test wherein atmos processing was turned off on tiles being exploded, we discovered that it was in fact the lighting code causing the lag. So exploded walls no longer call sd_SetOpacity. This will likely cause some lighting quirks until we come up with a proper fix, but bombs are much quicker now. http://pastebin.com/raw.php?i=jDAHH9x7 The CPU profile where the culprit was discovered. I kept the start and end times as close to the explosion as possible. Compare /proc/explosion's Total CPU (cpu usage of the proc and all procs called by it (and all procs called by THOSE, etc etc)) to /atom/proc/sd_SetOpacity's self CPU, which is the CPU use only the proc itself used. Notice how it accounts for over half of explosion's total CPU usage? So did I. git-svn-id: http://tgstation13.googlecode.com/svn/trunk@1904 316c924e-a436-60f5-8080-3fe189b3f50e --- code/game/turf.dm | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/code/game/turf.dm b/code/game/turf.dm index 78ef3dfa0d..002e1faa77 100644 --- a/code/game/turf.dm +++ b/code/game/turf.dm @@ -106,7 +106,7 @@ if(O.level == 1) O.hide(0) -/turf/proc/ReplaceWithFloor() +/turf/proc/ReplaceWithFloor(explode=0) var/prior_icon = icon_old var/old_dir = dir @@ -115,8 +115,11 @@ W.dir = old_dir if(prior_icon) W.icon_state = prior_icon else W.icon_state = "floor" - W.opacity = 1 - W.sd_SetOpacity(0) + + if (!explode) + W.opacity = 1 + W.sd_SetOpacity(0) + //This is probably gonna make lighting go a bit wonky in bombed areas, but sd_SetOpacity was the primary reason bombs have been so laggy. --NEO W.levelupdate() return W @@ -230,7 +233,7 @@ /turf/simulated/wall/New() ..() -/turf/simulated/wall/proc/dismantle_wall(devastated=0) +/turf/simulated/wall/proc/dismantle_wall(devastated=0, explode=0) if(istype(src,/turf/simulated/wall/r_wall)) if(!devastated) playsound(src.loc, 'Welder.ogg', 100, 1) @@ -251,7 +254,7 @@ new /obj/item/stack/sheet/metal( src ) new /obj/item/stack/sheet/metal( src ) - ReplaceWithFloor() + ReplaceWithFloor(explode) /turf/simulated/wall/examine() set src in oview(1) @@ -269,9 +272,9 @@ return if(2.0) if (prob(50)) - dismantle_wall() + dismantle_wall(0,1) else - dismantle_wall(devastated=1) + dismantle_wall(1,1) if(3.0) var/proba if (istype(src, /turf/simulated/wall/r_wall)) @@ -279,7 +282,7 @@ else proba = 40 if (prob(proba)) - dismantle_wall() + dismantle_wall(0,1) else return