Fix remote renaming with gene modder

Also improve comments, the null check thing could confuse people
Is sanitization even supposed to break nulls???
This commit is contained in:
theo-3
2021-08-13 11:17:42 +03:00
parent d0e8dfd69a
commit abeb522e58
2 changed files with 12 additions and 4 deletions
+1 -1
View File
@@ -879,7 +879,7 @@
adjustWeeds(-10) //Has a side effect of cleaning up those nasty weeds
update_icon()
else if(istype(O, /obj/item/pen) && myseed)
myseed.variant_prompt(user, src) // adj parameter makes Adjacent use the tray instead of the seed (which would always fail)
myseed.variant_prompt(user, src)
else
return ..()
+11 -3
View File
@@ -334,11 +334,19 @@
// adj parameter changes what Adjacent is called from, such as the gene modder or a tray
/obj/item/seeds/proc/variant_prompt(mob/user, obj/item/adj = src)
/obj/item/seeds/proc/variant_prompt(mob/user, obj/item/container = null)
var/V = input(user, "Choose variant name:", "Plant Variant Naming", variant) as text|null
if(!adj.Adjacent(user) || isnull(V))
if(isnull(V)) // Did the user cancel?
return
variant = copytext(sanitize(html_encode(trim(V))), 1, 64)
if(container)
if(loc != container) // Was the seed removed from the container?
return
if(!container.Adjacent(user)) // No remote renaming
return
else
if(!Adjacent(user)) // No remote renaming
return
variant = copytext(sanitize(html_encode(trim(V))), 1, 64) // Sanitization must happen after null check because it converts nulls to empty strings
if(variant == "")
variant = null
to_chat(user, "<span class='notice'>You [variant ? "change" : "remove"] the [plantname]'s variant designation.</span>")