diff --git a/code/modules/persistence/persistence_datum.dm b/code/modules/persistence/persistence_datum.dm index 0c9e0aedca6b..3ca013a7c4cb 100644 --- a/code/modules/persistence/persistence_datum.dm +++ b/code/modules/persistence/persistence_datum.dm @@ -30,14 +30,16 @@ return TRUE /decl/persistence_handler/proc/CheckTokenSanity(var/list/tokens) - return ( \ - islist(tokens) && \ - !isnull(tokens["x"]) && \ - !isnull(tokens["y"]) && \ - !isnull(tokens["z"]) && \ - !isnull(tokens["age"]) && \ - tokens["age"] <= entries_expire_at \ - ) + if(!islist(tokens)) + return FALSE + if(isnull(tokens["x"]) || isnull(tokens["y"]) || isnull(tokens["z"])) + return FALSE + if(!isnull(entries_expire_at)) + if(isnull(tokens["age"])) + return FALSE + if(tokens["age"] > entries_expire_at) + return FALSE + return TRUE /decl/persistence_handler/proc/CreateEntryInstance(var/turf/creating, var/list/tokens) return @@ -63,8 +65,9 @@ else return - if(GetValidTurf(locate(tokens["x"], tokens["y"], tokens["z"]), tokens)) - return CreateEntryInstance(., tokens) + . = GetValidTurf(locate(tokens["x"], tokens["y"], tokens["z"]), tokens) + if(.) + . = CreateEntryInstance(., tokens) /decl/persistence_handler/proc/IsValidEntry(var/atom/entry) if(!istype(entry)) diff --git a/code/modules/persistence/persistence_datum_book.dm b/code/modules/persistence/persistence_datum_book.dm index 479a9c8cb454..cf33c5df07d4 100644 --- a/code/modules/persistence/persistence_datum_book.dm +++ b/code/modules/persistence/persistence_datum_book.dm @@ -5,7 +5,14 @@ ignore_invalid_loc = TRUE /decl/persistence_handler/book/CreateEntryInstance(var/turf/creating, var/list/tokens) - var/obj/item/book/book = new(creating) + + var/book_type = tokens["book_type"] + if(book_type) + book_type = text2path(book_type) + if(!ispath(book_type)) + book_type = /obj/item/book + + var/obj/item/book/book = new book_type(creating) book.dat = tokens["message"] book.title = tokens["title"] book.author = tokens["writer"] @@ -29,11 +36,12 @@ . = ..() var/obj/item/book/book = entry - .["author"] = book.last_modified_ckey || "" - .["message"] = book.dat || "dat" - .["title"] = book.title || "Untitled" - .["writer"] = book.author || "unknown" + .["author"] = book.last_modified_ckey || "" + .["message"] = book.dat || "dat" + .["title"] = book.title || "Untitled" + .["writer"] = book.author || "unknown" .["icon_state"] = book.icon_state || "book" + .["book_type"] = "[book.type]" var/turf/T = get_turf(entry) if(!T || !isStationLevel(T.z)) @@ -62,7 +70,7 @@ else T = get_random_spawn_turf(SPAWN_FLAG_PERSISTENCE_CAN_SPAWN) - . = ..(T, tokens) + . = ..() /decl/persistence_handler/book/GetEntryAge(var/atom/entry) . = -1