From 021fd9a416243c1027b0260053046b5fba983bc6 Mon Sep 17 00:00:00 2001
From: S34N <12197162+S34NW@users.noreply.github.com>
Date: Sat, 3 Sep 2022 21:14:44 +0100
Subject: [PATCH] adds implants and hair gradients to serialisation (#18934)
removes organ DNA from serialisation
---
.../items/weapons/implants/implant_mindshield.dm | 10 ++++++----
code/modules/mob/living/carbon/human/human.dm | 13 +++++++++++++
code/modules/surgery/organs/organ.dm | 13 ++-----------
code/modules/surgery/organs/subtypes/standard.dm | 3 +++
4 files changed, 24 insertions(+), 15 deletions(-)
diff --git a/code/game/objects/items/weapons/implants/implant_mindshield.dm b/code/game/objects/items/weapons/implants/implant_mindshield.dm
index 30f7d9acaa9..77da96784fc 100644
--- a/code/game/objects/items/weapons/implants/implant_mindshield.dm
+++ b/code/game/objects/items/weapons/implants/implant_mindshield.dm
@@ -7,15 +7,17 @@
implant_state = "implant-nanotrasen"
/obj/item/implant/mindshield/implant(mob/target)
- if(..())
+ if(!..())
+ return FALSE
+ if(target.mind)
if(target.mind in SSticker.mode.revolutionaries)
SSticker.mode.remove_revolutionary(target.mind)
if(target.mind in SSticker.mode.cult)
to_chat(target, "You feel the corporate tendrils of Nanotrasen try to invade your mind!")
- else
- to_chat(target, "Your mind feels hardened - more resistant to brainwashing.")
return TRUE
- return FALSE
+
+ to_chat(target, "Your mind feels hardened - more resistant to brainwashing.")
+ return TRUE
/obj/item/implant/mindshield/removed(mob/target, silent = 0)
if(..())
diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm
index e56d64ca3e3..a1c0fd12b94 100644
--- a/code/modules/mob/living/carbon/human/human.dm
+++ b/code/modules/mob/living/carbon/human/human.dm
@@ -1821,9 +1821,11 @@ Eyes need to have significantly high darksight to shine unless the mob has the X
var/list/limbs_list = list()
var/list/organs_list = list()
var/list/equip_list = list()
+ var/list/implant_list = list()
data["limbs"] = limbs_list
data["iorgans"] = organs_list
data["equip"] = equip_list
+ data["implant_list"] = implant_list
data["dna"] = dna.serialize()
data["age"] = age
@@ -1854,12 +1856,16 @@ Eyes need to have significantly high darksight to shine unless the mob has the X
if(thing != null)
equip_list[i] = thing.serialize()
+ for(var/obj/item/implant/implant in src)
+ implant_list[implant] = implant.serialize()
+
return data
/mob/living/carbon/human/deserialize(list/data)
var/list/limbs_list = data["limbs"]
var/list/organs_list = data["iorgans"]
var/list/equip_list = data["equip"]
+ var/list/implant_list = data["implant_list"]
var/turf/T = get_turf(src)
if(!islist(data["limbs"]))
throw EXCEPTION("Expected a limbs list, but found none")
@@ -1891,6 +1897,13 @@ Eyes need to have significantly high darksight to shine unless the mob has the X
// As above, "New" code handles insertion, DNA sync
list_to_object(organs_list[organ], src)
+ for(var/thing in implant_list)
+ var/implant_data = implant_list[thing]
+ var/path = text2path(implant_data["type"])
+ var/obj/item/implant/implant = new path(T)
+ if(!implant.implant(src, src))
+ qdel(implant)
+
UpdateAppearance()
// De-serialize equipment
diff --git a/code/modules/surgery/organs/organ.dm b/code/modules/surgery/organs/organ.dm
index ffd3c7f4ae4..be260c51fa9 100644
--- a/code/modules/surgery/organs/organ.dm
+++ b/code/modules/surgery/organs/organ.dm
@@ -291,13 +291,8 @@ I use this so that this can be made better once the organ overhaul rolls out --
/obj/item/organ/serialize()
var/data = ..()
- if(status != 0)
+ if(status)
data["status"] = status
-
- // Save the DNA datum if: The owner doesn't exist, or the dna doesn't match the owner
- // Don't save when the organ has no initialized DNA. Happens when you spawn it in as admin
- if(dna.unique_enzymes && !(owner && dna.unique_enzymes == owner.dna.unique_enzymes))
- data["dna"] = dna.serialize()
return data
/obj/item/organ/deserialize(data)
@@ -305,8 +300,4 @@ I use this so that this can be made better once the organ overhaul rolls out --
if(data["status"] & ORGAN_ROBOT)
robotize()
status = data["status"]
- if(islist(data["dna"]))
- // The only thing the official proc does is
- //instantiate the list and call this proc
- dna.deserialize(data["dna"])
- ..()
+ ..()
diff --git a/code/modules/surgery/organs/subtypes/standard.dm b/code/modules/surgery/organs/subtypes/standard.dm
index 6a3bd62c3a1..57f5b10d6a8 100644
--- a/code/modules/surgery/organs/subtypes/standard.dm
+++ b/code/modules/surgery/organs/subtypes/standard.dm
@@ -233,6 +233,9 @@
if(!length(contents))
. += "There is nothing left inside!"
+/obj/item/organ/external/head/vars_to_save()
+ return list("color", "name", "h_grad_style", "h_grad_offset_x", "h_grad_offset_y", "h_grad_colour", "h_grad_alpha")
+
/obj/item/organ/external/head/remove()
if(owner)
if(!istype(dna))