[MIRROR] Fixes chem and addiction scans, null checks for addiction_list (#1826)

* Fixes chem and addiction scans, null checks for addiction_list (#55105)

So #54797 changed addiction_list to instantiate as a null instead of a list. Turns out a few things relied on the list existing!
Things like health analyser/medical kiosk chem and addiction scans broke, and smokers would no longer get addicted!
Made a few places check if addiction_list is null before continuing.

(Lemon's note, refactored some code to make it cleaner/removed some unneeded loop typechecks)

* Fixes chem and addiction scans, null checks for addiction_list

Co-authored-by: prodirus <44090982+prodirus@users.noreply.github.com>
This commit is contained in:
SkyratBot
2020-11-25 13:56:15 +01:00
committed by GitHub
co-authored by prodirus
parent 8cddcf1887
commit 384d439381
4 changed files with 23 additions and 19 deletions
+7 -5
View File
@@ -428,8 +428,9 @@ GENE SCANNER
var/render_list = list()
if(M.reagents.reagent_list.len)
render_list += "<span class='notice ml-1'>Subject contains the following reagents in their blood:</span>\n"
for(var/datum/reagent/R in M.reagents.reagent_list)
render_list += "<span class='notice ml-2'>[round(R.volume, 0.001)] units of [R.name][R.overdosed ? "</span> - <span class='boldannounce'>OVERDOSING</span>" : ".</span>"]\n"
for(var/r in M.reagents.reagent_list)
var/datum/reagent/reagent = r
render_list += "<span class='notice ml-2'>[round(reagent.volume, 0.001)] units of [reagent.name][reagent.overdosed ? "</span> - <span class='boldannounce'>OVERDOSING</span>" : ".</span>"]\n"
else
render_list += "<span class='notice ml-1'>Subject contains no reagents in their blood.</span>\n"
var/obj/item/organ/stomach/belly = M.getorganslot(ORGAN_SLOT_STOMACH)
@@ -447,10 +448,11 @@ GENE SCANNER
else
render_list += "<span class='notice ml-1'>Subject contains no reagents in their stomach.</span>\n"
if(M.reagents.addiction_list.len)
if(LAZYLEN(M.reagents.addiction_list))
render_list += "<span class='boldannounce ml-1'>Subject is addicted to the following reagents:</span>\n"
for(var/datum/reagent/R in M.reagents.addiction_list)
render_list += "<span class='alert ml-2'>[R.name]</span>\n"
for(var/a in M.reagents.addiction_list)
var/datum/reagent/addiction = a
render_list += "<span class='alert ml-2'>[addiction.name]</span>\n"
else
render_list += "<span class='notice ml-1'>Subject is not addicted to any reagents.</span>\n"