Skip to content

Commit

Permalink
Merge pull request #732 from Very-Soft/transcore
Browse files Browse the repository at this point in the history
Smol revision
  • Loading branch information
Very-Soft authored Jan 9, 2025
2 parents fca8755 + d61b37d commit c22b7b0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
2 changes: 0 additions & 2 deletions code/modules/client/preference_setup/vore/08_nif.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@
S["nif_durability"] >> pref.nif_durability
S["nif_savedata"] >> pref.nif_savedata

/* //RS REMOVE
/datum/category_item/player_setup_item/vore/nif/save_character(var/savefile/S)
S["nif_path"] << pref.nif_path
S["nif_durability"] << pref.nif_durability
S["nif_savedata"] << pref.nif_savedata
*/

/datum/category_item/player_setup_item/vore/nif/sanitize_character()
if(pref.nif_path && !ispath(pref.nif_path)) //We have at least a text string that should be a path.
Expand Down
38 changes: 25 additions & 13 deletions code/modules/mob/living/Character Persist/item_storage.dm
Original file line number Diff line number Diff line change
Expand Up @@ -192,37 +192,49 @@ var/global/list/permanent_unlockables = list(
/datum/etching/setup(var/datum/preferences/P)
. = ..()
if(ourmob)
if(!nif_type && ourmob.client.prefs.nif_path)
if(ourmob.client.prefs.nif_path)
convert_nif(ourmob.client, P)
load_nif()
load_nif() //We're spawning in!!!
if(ourclient)
if(!nif_type && P.nif_path)
if(P.nif_path) //Clean dat shit up
convert_nif(ourclient,P)

/datum/etching/proc/convert_nif(var/client/thissun,var/datum/preferences/P)
if(event_character)
return
var/orig = savable
if(!P.nif_path) //Let's double check
return //What are you trying to convert?!
var/orig = savable //TBH it is basically impossible that this will ever be relevant but one of you will find a way so let's store this in case somehow you are converting the nif data of an unsavable character
savable = TRUE
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
log_debug("ETCHING: Legacy NIF data conversion complete - [nif_type] - [nif_durability] - [nif_savedata]")
save()
savable = orig
save() //Save the etching data so we don't lose anything
savable = orig //Return our savable status to what it was

P.nif_path = null //Clear the old data, so we don't try to convert it again later
P.nif_durability = null
P.nif_savedata = null

P.save_character() //Save our character. This SHOULD ONLY HAPPEN when someone is opening character setup, loading a character, or spawning in. If you make it happen at any other times, I don't know what will happen, and it's possible it will mess up the person's save file so don't fuck up.

/datum/etching/proc/load_nif()
if(!nif_type || !ourmob)
if(!ourmob) //The product of this proc is the creation of a nif, so if we don't have a mob, then let's not
return
if(ourmob.client.prefs.nif_path) //Hey we have old style nif data saved that wasn't caught, let's convert it
convert_nif(ourmob.client,ourmob.client.prefs)
if(!nif_type) //No nif type, no nif mister!!!
return
var/backup
if(!ispath(nif_type))
backup = nif_type
nif_type = text2path(nif_type)
if(!nif_type)
if(!ispath(nif_type)) //Let's double check and make sure the nif we have is a valid type, in case of type paths changing or whatever. You can put conversion stuff in here.
backup = nif_type //Let's hold on to this in case it isn't a type.
nif_type = text2path(nif_type) //Convert the string to a path!
if(!nif_type) //Was it a valid path?
log_debug("ETCHING: Attempted to load nif, but had invalid type: [backup], aborting")
nif_type = backup
nif_type = backup //It wasn't, so let's put the data back here, and abort. Someone will need to convert the old type to a new type!
return

new nif_type(ourmob,nif_durability,nif_savedata)
new nif_type(ourmob,nif_durability,nif_savedata) //Nice nif bud you go, look how handsome you are with that twinkle in your eye wow

0 comments on commit c22b7b0

Please sign in to comment.