Skip to content

Commit

Permalink
1729
Browse files Browse the repository at this point in the history
  • Loading branch information
Very-Soft committed Dec 21, 2024
1 parent 351f2a0 commit f15ad7c
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 32 deletions.
2 changes: 1 addition & 1 deletion code/modules/client/preference_setup/vore/08_nif.dm
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@
*/

/datum/category_item/player_setup_item/vore/nif/content(var/mob/user)
. += "<b>NIF:</b> [ispath(pref.client.etching.nif_type) ? "Present" : "None"]"
. += "<b>NIF:</b> [ispath(text2path("[pref.client.etching.nif_type]")) ? "Present" : "None"]" //RS EDIT
3 changes: 2 additions & 1 deletion code/modules/client/preferences_savefile.dm
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@

clear_character_previews() // VOREStation Edit

client.load_etching() //RS ADD - Let's reload our character persist data
client.load_etching(src) //RS ADD - Let's reload our character persist data

return 1

/datum/preferences/proc/save_character()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@

/mob/living/Login()
. = ..()
if(etching)
log_debug("<span class = 'danger'>Etching started: Registered to [ckey]</span>")
etching.load()
if(!etching)
return
if(etching.save_path) //We already got loaded
return
log_debug("<span class = 'danger'>Etching started: Registered to [ckey]</span>")
etching.load(client.prefs)

/mob/living/Destroy()
if(etching && istype(etching, /datum/etching))
Expand Down Expand Up @@ -88,17 +91,13 @@
/client
var/datum/etching/etching

/client/New()
. = ..()
load_etching()

/client/proc/load_etching()
/client/proc/load_etching(var/datum/preferences/P)
if(etching)
var/datum/etching/oldetch = etching
etching = null
qdel(oldetch)
etching = new /datum/etching(src)
etching.load()
etching.load(P)

/datum/etching
var/mob/living/ourmob //Reference to the mob we are working with
Expand All @@ -109,7 +108,7 @@
var/save_path //The file path for the save/load function
var/list/xp = list() //A list of different experience values

var/savable = TRUE //Will never save while false
var/savable = FALSE //Will never save while false
var/needs_saving = FALSE //For if changes have occured, it will try to save if it can
var/save_cooldown = 0

Expand Down Expand Up @@ -143,19 +142,23 @@
else
save_cooldown --

/datum/etching/proc/get_save_path()
/datum/etching/proc/get_save_path(var/datum/preferences/P)
if(isliving(ourmob))
if(event_character)
save_path = "data/player_saves/[copytext(ourmob.ckey, 1, 2)]/[ourmob.ckey]/magic/[ourmob.real_name]-EVENT-etching.json"
else
save_path = "data/player_saves/[copytext(ourmob.ckey, 1, 2)]/[ourmob.ckey]/magic/[ourmob.real_name]-etching.json"
savable = TRUE
else if(isclient(ourclient))
save_path = "data/player_saves/[copytext(ourclient.ckey, 1, 2)]/[ourclient.ckey]/magic/[ourclient.prefs.real_name]-etching.json"
save_path = "data/player_saves/[copytext(ourclient.ckey, 1, 2)]/[ourclient.ckey]/magic/[P.real_name]-etching.json"


/datum/etching/proc/load()
/datum/etching/proc/load(var/datum/preferences/P)
if(ourmob)
if(IsGuestKey(ourmob.key))
return
if(save_path)
return
if(ourmob && !ourmob.ckey)
log_debug("<span class = 'danger'>Etching load failed: Aborting etching load for [ourmob.real_name], no ckey</span>")
savable = FALSE
Expand All @@ -166,15 +169,15 @@
savable = FALSE
return

get_save_path()
get_save_path(P)

if(!save_path)
log_debug("<span class = 'danger'>Etching load failed: No save_path</span>")
savable = FALSE
return
if(!fexists(save_path))
log_debug("Etching load failed: No file '[save_path]' exists. Beginning setup.")
setup()
setup(P)
return

var/content
Expand Down Expand Up @@ -207,9 +210,9 @@

item_load(load)
if(ourmob)
log_debug("<span class = 'rose'>Etching load complete for [ourmob.real_name].</span>")
log_debug("<span class = 'rose'>Mob etching load complete for [ourmob.real_name].</span>")
if(ourclient)
log_debug("<span class = 'rose'>Etching load complete for [ourclient.prefs.real_name].</span>")
log_debug("<span class = 'rose'>Client etching load complete for [ourclient.prefs.real_name].</span>")

/datum/etching/proc/save(delet = FALSE)
if(ourmob)
Expand Down Expand Up @@ -261,7 +264,7 @@
ourmob = null
qdel(src)

/datum/etching/proc/setup()
/datum/etching/proc/setup(var/datum/preferences/P)
needs_saving = TRUE

/datum/etching/proc/update_etching(mode,value)
Expand Down Expand Up @@ -366,7 +369,7 @@
to_chat(usr, "Loading [L]'s event etching.")
else
to_chat(usr, "Loading [L]'s etching.")
L.etching.load()
L.etching.load(L.client.prefs)
log_and_message_admins(" has loaded [L]'s etching.")

/* //Just for fun. UwU
Expand Down
26 changes: 15 additions & 11 deletions code/modules/mob/living/Character Persist/item_storage.dm
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ var/global/list/permanent_unlockables = list(
to_save["nif_type"] = H.nif.type
to_save["nif_durability"] = H.nif.durability
to_save["nif_savedata"] = H.nif.save_data
else if(ourclient) //For nif conversion
to_save["nif_type"] = nif_type
to_save["nif_durability"] = nif_durability
to_save["nif_savedata"] = nif_savedata

return to_save

Expand Down Expand Up @@ -185,27 +189,27 @@ var/global/list/permanent_unlockables = list(
return
H.etching.update_nif(H)

/datum/etching/setup()
/datum/etching/setup(var/datum/preferences/P)
. = ..()
if(ourmob)
if(!nif_type && ourmob.client.prefs.nif_path)
convert_nif(ourmob.client)
convert_nif(ourmob.client, P)
load_nif()
if(ourclient)
if(!nif_type && ourclient.prefs.nif_path)
convert_nif(ourclient)
if(!nif_type && P.nif_path)
convert_nif(ourclient,P)

/datum/etching/proc/convert_nif(var/client/thissun)
/datum/etching/proc/convert_nif(var/client/thissun,var/datum/preferences/P)
if(event_character)
return
var/orig = savable
savable = TRUE
log_debug("ETCHING: Converting legacy NIF data: [thissun.prefs.nif_path] - [thissun.prefs.nif_durability] - [thissun.prefs.nif_savedata]")
nif_type = thissun.prefs.nif_path
nif_durability = thissun.prefs.nif_durability
nif_savedata = thissun.prefs.nif_savedata
log_debug("ETCHING: Converting legacy NIF data: [P.nif_path] - [P.nif_durability] - [P.nif_savedata]")
nif_type = P.nif_path
nif_durability = P.nif_durability
nif_savedata = P.nif_savedata
needs_saving = TRUE
thissun.prefs.nif_path = null
log_debug("ETCHING: Legacy NIF data conversion complete.")
log_debug("ETCHING: Legacy NIF data conversion complete - [nif_type] - [nif_durability] - [nif_savedata]")
save()
savable = orig

Expand Down

0 comments on commit f15ad7c

Please sign in to comment.