Skip to content

Commit

Permalink
Fixes persistence not spawning instances.
Browse files Browse the repository at this point in the history
  • Loading branch information
MistakeNot4892 committed Jan 8, 2025
1 parent 1a3a0b3 commit fc76d92
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
23 changes: 13 additions & 10 deletions code/modules/persistence/persistence_datum.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
Expand Down
20 changes: 14 additions & 6 deletions code/modules/persistence/persistence_datum_book.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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))
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit fc76d92

Please sign in to comment.