From f3b0edf03ee8f72d47af8051de6ff62ee8ee14f2 Mon Sep 17 00:00:00 2001 From: Lohikar Date: Sun, 26 Mar 2017 04:37:35 -0500 Subject: [PATCH] Fix smoke (#1996) changes: Smoke no longer leaves mysterious patches of darkness. Smoke now uses client-side animations instead of while loops. Fixes #1985. --- code/game/objects/effects/chem/chemsmoke.dm | 19 ------------------- code/game/objects/effects/effect_system.dm | 15 +++++++++++++-- code/modules/lighting/lighting_turf.dm | 6 ++++++ html/changelogs/lohikar-PR-1996.yml | 4 ++++ 4 files changed, 23 insertions(+), 21 deletions(-) create mode 100644 html/changelogs/lohikar-PR-1996.yml diff --git a/code/game/objects/effects/chem/chemsmoke.dm b/code/game/objects/effects/chem/chemsmoke.dm index d95d9966b29..e0d547d1eee 100644 --- a/code/game/objects/effects/chem/chemsmoke.dm +++ b/code/game/objects/effects/chem/chemsmoke.dm @@ -24,20 +24,11 @@ pixel_x = -32 + rand(-8, 8) pixel_y = -32 + rand(-8, 8) - //switching opacity on after the smoke has spawned, and then turning it off before it is deleted results in cleaner - //lighting and view range updates (Is this still true with the new lighting system?) - set_opacity(1) - //float over to our destination, if we have one destination = dest_turf if(destination) walk_to(src, destination) -/obj/effect/effect/smoke/chem/Destroy() - set_opacity(0) - fadeOut() - ..() - /obj/effect/effect/smoke/chem/Move() var/list/oldlocs = view(1, src) . = ..() @@ -61,16 +52,6 @@ if(!istype(AM, /obj/effect/effect/smoke/chem)) reagents.splash(AM, splash_amount, copy = 1) -// Fades out the smoke smoothly using it's alpha variable. -/obj/effect/effect/smoke/chem/proc/fadeOut(var/frames = 16) - if(!alpha) return //already transparent - - frames = max(frames, 1) //We will just assume that by 0 frames, the coder meant "during one frame". - var/alpha_step = round(alpha / frames) - while(alpha > 0) - alpha = max(0, alpha - alpha_step) - sleep(world.tick_lag) - ///////////////////////////////////////////// // Chem Smoke Effect System ///////////////////////////////////////////// diff --git a/code/game/objects/effects/effect_system.dm b/code/game/objects/effects/effect_system.dm index 1ee8015889c..e5cea9767bd 100644 --- a/code/game/objects/effects/effect_system.dm +++ b/code/game/objects/effects/effect_system.dm @@ -113,7 +113,18 @@ steam.start() -- spawns the effect if (duration) time_to_live = duration spawn (time_to_live) - qdel(src) + kill() + +/obj/effect/effect/smoke/proc/kill() + set waitfor = FALSE + animate(src, alpha = 0, time = 2 SECONDS, easing = QUAD_EASING) + set_opacity(FALSE) + + var/turf/T = get_turf(src) + if (T) + T.force_update_lights() // I hate it, but nothing else seems to work. + + QDEL_IN(src, 2 SECONDS) /obj/effect/effect/smoke/Crossed(mob/living/carbon/M as mob ) ..() @@ -271,8 +282,8 @@ steam.start() -- spawns the effect sleep(10) step(smoke,direction) spawn(smoke.time_to_live*0.75+rand(10,30)) - if (smoke) qdel(smoke) src.total_smoke-- + qdel(smoke) /datum/effect/effect/system/smoke_spread/bad diff --git a/code/modules/lighting/lighting_turf.dm b/code/modules/lighting/lighting_turf.dm index 4935e8d2ea2..2ae145242d3 100644 --- a/code/modules/lighting/lighting_turf.dm +++ b/code/modules/lighting/lighting_turf.dm @@ -21,6 +21,12 @@ for (var/datum/light_source/L in affecting_lights) L.vis_update() +// Forces a lighting update. Reconsider lights is preferred when possible. +/turf/proc/force_update_lights() + L_PROF(src, "turf_forceupdate") + for (var/datum/light_source/L in affecting_lights) + L.force_update() + /turf/proc/lighting_clear_overlay() if (lighting_overlay) returnToPool(lighting_overlay) diff --git a/html/changelogs/lohikar-PR-1996.yml b/html/changelogs/lohikar-PR-1996.yml new file mode 100644 index 00000000000..569a9edcafd --- /dev/null +++ b/html/changelogs/lohikar-PR-1996.yml @@ -0,0 +1,4 @@ +author: Lohikar +delete-after: True +changes: + - bugfix: "Smoke no longer causes unexplainable patches of darkness. Thanks oldcode."