mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-18 21:15:21 +00:00
A pretty heavy refactor for pAIs that just spilled into a rework. Attempts to fully document and organize backend code. Fixes a large number of bugs left untouched for a decade. Breaks down the frontend into subcomponents. Rebalances their software modules. (should) fix pAI faces get removed if you activate them during alert #68242
57 lines
1.4 KiB
Plaintext
57 lines
1.4 KiB
Plaintext
/**
|
|
* name
|
|
* key
|
|
* description
|
|
* role
|
|
* comments
|
|
* ready = TRUE
|
|
*/
|
|
|
|
/datum/pai_candidate/proc/savefile_path(mob/user)
|
|
return "data/player_saves/[user.ckey[1]]/[user.ckey]/pai.sav"
|
|
|
|
/datum/pai_candidate/proc/savefile_save(mob/user)
|
|
if(is_guest_key(user.key))
|
|
to_chat(usr, span_warning("You cannot save pAI information as a guest."))
|
|
return FALSE
|
|
var/savefile/F = new /savefile(src.savefile_path(user))
|
|
WRITE_FILE(F["name"], name)
|
|
WRITE_FILE(F["description"], description)
|
|
WRITE_FILE(F["comments"], comments)
|
|
WRITE_FILE(F["version"], 1)
|
|
to_chat(usr, span_boldnotice("You have saved pAI information locally."))
|
|
return TRUE
|
|
|
|
// loads the savefile corresponding to the mob's ckey
|
|
// if silent=true, report incompatible savefiles
|
|
// returns TRUE if loaded (or file was incompatible)
|
|
// returns FALSE if savefile did not exist
|
|
|
|
/datum/pai_candidate/proc/savefile_load(mob/user, silent = TRUE)
|
|
if (is_guest_key(user.key))
|
|
return FALSE
|
|
|
|
var/path = savefile_path(user)
|
|
|
|
if (!fexists(path))
|
|
return FALSE
|
|
|
|
var/savefile/F = new /savefile(path)
|
|
|
|
if(!F)
|
|
return //Not everyone has a pai savefile.
|
|
|
|
var/version = null
|
|
F["version"] >> version
|
|
|
|
if (isnull(version) || version != 1)
|
|
fdel(path)
|
|
if (!silent)
|
|
tgui_alert(user, "Your savefile was incompatible with this version and was deleted.")
|
|
return FALSE
|
|
|
|
F["name"] >> src.name
|
|
F["description"] >> src.description
|
|
F["comments"] >> src.comments
|
|
return TRUE
|