From abeb522e583b61b69631065cf6cda2943bded89e Mon Sep 17 00:00:00 2001 From: theo-3 <85434590+theo-3@users.noreply.github.com> Date: Fri, 13 Aug 2021 11:17:42 +0300 Subject: [PATCH] Fix remote renaming with gene modder Also improve comments, the null check thing could confuse people Is sanitization even supposed to break nulls??? --- code/modules/hydroponics/hydroponics.dm | 2 +- code/modules/hydroponics/seeds.dm | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/code/modules/hydroponics/hydroponics.dm b/code/modules/hydroponics/hydroponics.dm index 72117d41187..81a4f83e6a6 100644 --- a/code/modules/hydroponics/hydroponics.dm +++ b/code/modules/hydroponics/hydroponics.dm @@ -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 ..() diff --git a/code/modules/hydroponics/seeds.dm b/code/modules/hydroponics/seeds.dm index 7e245e10154..0b8eee55145 100644 --- a/code/modules/hydroponics/seeds.dm +++ b/code/modules/hydroponics/seeds.dm @@ -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, "You [variant ? "change" : "remove"] the [plantname]'s variant designation.")