From 951a580759c9efa259f9039cd28b4d2a9ceb8e65 Mon Sep 17 00:00:00 2001 From: KomradeSpectre Date: Fri, 23 Feb 2018 10:07:25 -0500 Subject: [PATCH 1/2] Fixes a dumbo runtime error in the analyzer's barometer function. OOF. (#35902) * Fixes a dumbo runtime error in the Barometer function. OOF. * Moves butchertime stuff into a proc. --- code/game/objects/items/devices/scanners.dm | 35 ++++++++++----------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/code/game/objects/items/devices/scanners.dm b/code/game/objects/items/devices/scanners.dm index f5c14db8a8..39ab21d72b 100644 --- a/code/game/objects/items/devices/scanners.dm +++ b/code/game/objects/items/devices/scanners.dm @@ -431,6 +431,11 @@ GAS ANALYZER playsound(src, 'sound/effects/pop.ogg', 100) var/area/user_area = T.loc var/datum/weather/ongoing_weather = null + + if(!user_area.outdoors) + to_chat(user, "[src]'s barometer function won't work indoors!") + return + for(var/V in SSweather.processing) var/datum/weather/W = V if(W.barometer_predictable && (T.z in W.impacted_z_levels) && W.area_type == user_area.type && !(W.stage == END_STAGE)) @@ -439,30 +444,27 @@ GAS ANALYZER if(ongoing_weather) if((ongoing_weather.stage == MAIN_STAGE) || (ongoing_weather.stage == WIND_DOWN_STAGE)) - to_chat(user, "[src] can't trace anything while the storm is [ongoing_weather.stage == MAIN_STAGE ? "already here!" : "winding down."]") + to_chat(user, "[src]'s barometer function can't trace anything while the storm is [ongoing_weather.stage == MAIN_STAGE ? "already here!" : "winding down."]") return - var/time = butchertime((ongoing_weather.next_hit_time - world.time)/10) - to_chat(user, "The next [ongoing_weather] will hit in [round(time)] seconds.") + to_chat(user, "The next [ongoing_weather] will hit in [butchertime(ongoing_weather.next_hit_time - world.time)].") if(ongoing_weather.aesthetic) - to_chat(user, "[src] says that the next storm will breeze on by.") - else if(user_area.outdoors) + to_chat(user, "[src]'s barometer function says that the next storm will breeze on by.") + else var/next_hit = SSweather.next_hit_by_zlevel["[T.z]"] var/fixed = next_hit ? next_hit - world.time : -1 if(fixed < 0) - to_chat(user, "[src] was unable to trace any weather patterns.") + to_chat(user, "[src]'s barometer function was unable to trace any weather patterns.") else - fixed = butchertime(round(fixed / 10)) - to_chat(user, "A storm will land in approximately [fixed] seconds.") - else - to_chat(user, "[src]'s barometer function won't work indoors!") + to_chat(user, "[src]'s barometer function says a storm will land in approximately [butchertime(fixed)].") cooldown = TRUE - addtimer(src, /obj/item/device/analyzer/proc/ping, cooldown_time) + addtimer(CALLBACK(src,/obj/item/device/analyzer/proc/ping), cooldown_time) + /obj/item/device/analyzer/proc/ping() if(isliving(loc)) var/mob/living/L = loc - to_chat(L, "[src] is ready!") + to_chat(L, "[src]'s barometer function is ready!") playsound(src, 'sound/machines/click.ogg', 100) cooldown = FALSE @@ -470,15 +472,12 @@ GAS ANALYZER if(!amount) return if(accuracy) - var/time = amount var/inaccurate = round(accuracy*(1/3)) if(prob(50)) - time -= inaccurate + amount -= inaccurate if(prob(50)) - time += inaccurate - return time - else - return amount + amount += inaccurate + return DisplayTimeText(max(1,amount)) /obj/item/device/slime_scanner name = "slime scanner"