mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-25 04:57:12 +01:00
Merge pull request #5222 from Crazylemon64/json_serialization2
Lets you convert people to text and back again
This commit is contained in:
@@ -105,13 +105,13 @@
|
||||
var/photo
|
||||
var/dat
|
||||
var/stamped = 0
|
||||
|
||||
|
||||
var/obj/item/weapon/card/id/guest/guest_pass = null // Guest pass attached to the ID
|
||||
|
||||
/obj/item/weapon/card/id/New()
|
||||
..()
|
||||
spawn(30)
|
||||
if(ishuman(loc))
|
||||
if(ishuman(loc) && blood_type == "\[UNSET\]")
|
||||
var/mob/living/carbon/human/H = loc
|
||||
SetOwnerInfo(H)
|
||||
|
||||
@@ -242,10 +242,10 @@
|
||||
set name = "Remove Guest Pass"
|
||||
set category = "Object"
|
||||
set src in range(0)
|
||||
|
||||
|
||||
if(usr.stat || !usr.canmove || usr.restrained())
|
||||
return
|
||||
|
||||
|
||||
if(guest_pass)
|
||||
to_chat(usr, "<span class='notice'>You remove the guest pass from this ID.</span>")
|
||||
guest_pass.forceMove(get_turf(src))
|
||||
@@ -253,6 +253,37 @@
|
||||
else
|
||||
to_chat(usr, "<span class='warning'>There is no guest pass attached to this ID</span>")
|
||||
|
||||
/obj/item/weapon/card/id/serialize()
|
||||
var/list/data = ..()
|
||||
|
||||
data["sex"] = sex
|
||||
data["age"] = age
|
||||
data["btype"] = blood_type
|
||||
data["dna_hash"] = dna_hash
|
||||
data["fprint_hash"] = fingerprint_hash
|
||||
data["access"] = access
|
||||
data["job"] = assignment
|
||||
data["account"] = associated_account_number
|
||||
data["owner"] = registered_name
|
||||
data["mining"] = mining_points
|
||||
return data
|
||||
|
||||
/obj/item/weapon/card/id/deserialize(list/data)
|
||||
sex = data["sex"]
|
||||
age = data["age"]
|
||||
blood_type = data["btype"]
|
||||
dna_hash = data["dna_hash"]
|
||||
fingerprint_hash = data["fprint_hash"]
|
||||
access = data["access"] // No need for a copy, the list isn't getting touched
|
||||
assignment = data["job"]
|
||||
associated_account_number = data["account"]
|
||||
registered_name = data["owner"]
|
||||
mining_points = data["mining"]
|
||||
// We'd need to use icon serialization(b64) to save the photo, and I don't feel like i
|
||||
UpdateName()
|
||||
RebuildHTML()
|
||||
..()
|
||||
|
||||
/obj/item/weapon/card/id/silver
|
||||
name = "identification card"
|
||||
desc = "A silver card which shows honour and dedication."
|
||||
@@ -767,4 +798,4 @@
|
||||
if("TDgreen")
|
||||
return "Thunderdome Green"
|
||||
else
|
||||
return capitalize(skin)
|
||||
return capitalize(skin)
|
||||
|
||||
@@ -37,7 +37,9 @@
|
||||
src.add_fingerprint(usr)
|
||||
return
|
||||
|
||||
|
||||
/obj/item/weapon/storage/belt/deserialize(list/data)
|
||||
..()
|
||||
update_icon()
|
||||
|
||||
/obj/item/weapon/storage/belt/utility
|
||||
name = "tool-belt" //Carn: utility belt is nicer, but it bamboozles the text parsing.
|
||||
|
||||
@@ -547,3 +547,34 @@
|
||||
|
||||
return depth
|
||||
|
||||
/obj/item/weapon/storage/serialize()
|
||||
var data = ..()
|
||||
var/list/content_list = list()
|
||||
data["content"] = content_list
|
||||
data["slots"] = storage_slots
|
||||
data["max_w_class"] = max_w_class
|
||||
data["max_c_w_class"] = max_combined_w_class
|
||||
for(var/thing in contents)
|
||||
var/atom/movable/AM = thing
|
||||
// This code does not watch out for infinite loops
|
||||
// But then again a tesseract would destroy the server anyways
|
||||
// Also I wish I could just insert a list instead of it reading it the wrong way
|
||||
content_list.len++
|
||||
content_list[content_list.len] = AM.serialize()
|
||||
return data
|
||||
|
||||
/obj/item/weapon/storage/deserialize(list/data)
|
||||
if(isnum(data["slots"]))
|
||||
storage_slots = data["slots"]
|
||||
if(isnum(data["max_w_class"]))
|
||||
max_w_class = data["max_w_class"]
|
||||
if(isnum(data["max_c_w_class"]))
|
||||
max_combined_w_class = data["max_c_w_class"]
|
||||
for(var/thing in contents)
|
||||
qdel(thing) // out with the old
|
||||
for(var/thing in data["content"])
|
||||
if(islist(thing))
|
||||
list_to_object(thing, src)
|
||||
else
|
||||
log_debug("Non-list thing: [thing]. We are a [name]")
|
||||
..()
|
||||
|
||||
Reference in New Issue
Block a user