Skip to content

Commit

Permalink
Merge pull request #710 from Very-Soft/transcore
Browse files Browse the repository at this point in the history
Transcore tweaks
  • Loading branch information
Very-Soft authored Jan 5, 2025
2 parents 07d1d40 + 155494d commit d34c728
Show file tree
Hide file tree
Showing 15 changed files with 288 additions and 45 deletions.
1 change: 1 addition & 0 deletions code/__defines/dcs/signals_rs.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#define COMSIG_BACKUP_IMPLANT "backup_implant"
15 changes: 13 additions & 2 deletions code/controllers/subsystems/transcore_vr.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
SUBSYSTEM_DEF(transcore)
name = "Transcore"
priority = 20
wait = 3 MINUTES
wait = 10 SECONDS //RS edit - reduced from 3 minutes, because not firing at all means the MC panel will never update
flags = SS_BACKGROUND
runlevels = RUNLEVEL_GAME
init_order = INIT_ORDER_TRANSCORE
Expand All @@ -27,6 +27,8 @@ SUBSYSTEM_DEF(transcore)

var/list/current_run = list()

var/cooldown = 18 //RS ADD - A countdown used with wait. While cooldown is 0, fire will signal, otherwise it only counts down

/datum/controller/subsystem/transcore/Initialize()
default_db = new()
databases["default"] = default_db
Expand All @@ -39,10 +41,19 @@ SUBSYSTEM_DEF(transcore)
return ..()

/datum/controller/subsystem/transcore/fire(resumed = 0)
var/timer = TICK_USAGE
cooldown -- //RS ADD - countdown to send the signal

if(cooldown == 0)
SEND_SIGNAL(src, COMSIG_BACKUP_IMPLANT) //Rather than doing a bunch of for or whiles, just signal every implant to update itself.
cooldown = 18

//RS EDIT START
/* var/timer = TICK_USAGE
INTERNAL_PROCESS_STEP(SSTRANSCORE_IMPLANTS,TRUE,process_implants,cost_implants,SSTRANSCORE_BACKUPS)
INTERNAL_PROCESS_STEP(SSTRANSCORE_BACKUPS,FALSE,process_backups,cost_backups,SSTRANSCORE_IMPLANTS)
*/
//RS EDIT END

/datum/controller/subsystem/transcore/proc/process_implants(resumed = 0)
if (!resumed)
Expand Down
12 changes: 11 additions & 1 deletion code/modules/client/preference_setup/vore/08_nif.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@
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 All @@ -36,7 +38,9 @@
if(!islist(pref.nif_savedata))
pref.nif_savedata = list()

/* RS REMOVAL - gets handled elsewhere
/datum/category_item/player_setup_item/vore/nif/copy_to_mob(var/mob/living/carbon/human/character)
//If you had a NIF...
if((character.type == /mob/living/carbon/human) && ispath(pref.nif_path) && pref.nif_durability)
new pref.nif_path(character,pref.nif_durability,pref.nif_savedata)
Expand All @@ -55,6 +59,12 @@
if(!S) WARNING ("Couldn't load NIF save savefile? [pref.real_name]")
S.cd = "/character[pref.default_slot]"
save_character(S)
*/

/datum/category_item/player_setup_item/vore/nif/content(var/mob/user)
. += "<b>NIF:</b> [ispath(pref.nif_path) ? "Present" : "None"]"

if(!pref.client.etching)
log_debug("[user] etching data to populate")
return

. += "<b>NIF:</b> [ispath(text2path("[pref.client.etching.nif_type]")) ? "Present" : "None"]" //RS EDIT
3 changes: 3 additions & 0 deletions code/modules/client/preferences_savefile.dm
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@
player_setup.save_character(S)

clear_character_previews() // VOREStation Edit

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

return 1

/datum/preferences/proc/save_character()
Expand Down
25 changes: 23 additions & 2 deletions code/modules/client/stored_item.dm
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,18 @@
busy_bank = FALSE
icon_state = "item_bank"
return
var/ourtype = user.etching.item_storage[our_item] //RS EDIT
var/obj/N = new ourtype(get_turf(src)) //RS EDIT
var/ourtype = user.etching.item_storage[our_item] //RS EDIT START
var/backup
if(!ispath(ourtype))
backup = ourtype
ourtype = text2path(ourtype)

if(!ourtype)
user.etching.item_storage -= our_item
log_and_message_admins("<span class = 'danger'>[user]/[user.ckey] attempted to retrieve an invalid item: [our_item] - [backup]</span>")

return
var/obj/N = new ourtype(get_turf(src)) //RS EDIT END
log_admin("[key_name_admin(user)] retrieved [N] from the item bank.")
visible_message("<span class='notice'>\The [src] dispenses the [N] to \the [user].</span>")
user.put_in_hands(N)
Expand Down Expand Up @@ -165,6 +175,17 @@
icon_state = "item_bank"
return
var/ourtype = user.etching.unlockables[our_item]
//RS EDIT START
var/backup
if(!ispath(ourtype))
backup = ourtype
ourtype = text2path(ourtype)

if(!ourtype)
user.etching.unlockables -= our_item
log_and_message_admins("<span class = 'danger'>[user]/[user.ckey] attempted to retrieve an invalid unlockable item: [our_item] - [backup]</span>")
return
//RS EDIT END
var/obj/N = new ourtype(get_turf(src))
log_admin("[key_name_admin(user)] retrieved [N] from the item bank.")
visible_message("<span class='notice'>\The [src] dispenses the [N] to \the [user].</span>")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//RS FILE

/mob/living
/mob
var/datum/etching/etching
var/admin_magic = FALSE

Expand All @@ -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 @@ -85,16 +88,27 @@
log_debug("Saving: [old_path] failed to delete on rename function")
return

/client
var/datum/etching/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(P)

/datum/etching
var/mob/living/ourmob //Reference to the mob we are working with
var/client/ourclient //Reference to the client, which may not represent the mob
var/event_character = FALSE //If true, saves to an alternative path and allows editing

var/shutting_down = FALSE //If true it won't try to save again
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 All @@ -103,50 +117,67 @@
log_debug("<span class = 'danger'>Etching: No target, delete self</span>")
qdel(src)
return
if(!isliving(L))
log_debug("<span class = 'danger'>Etching: Target [L] is not living, delete self</span>")
qdel(src)
return
ourmob = L
save_cooldown = rand(200,350) //Make the number be random so that there's less chance it tries to autosave everyone at the same time.
return ..()
if(isliving(L))
ourmob = L
save_cooldown = rand(5,10) //Make the number be random so that there's less chance it tries to autosave everyone at the same time.
return ..()
if(isclient(L))
ourclient = L
savable = FALSE
return ..()

log_debug("<span class = 'danger'>Etching: Target [L] is invalid, delete self</span>")
qdel(src)

/datum/etching/Destroy()
. = ..()
ourmob = null
ourclient = null

/datum/etching/proc/process_etching()
if(savable)
if(save_cooldown <= 0)
save()
save_cooldown = rand(200,350) //Make the number be random so that there's less chance it tries to autosave everyone at the same time.
save_cooldown = rand(5,10) //Make the number be random so that there's less chance it tries to autosave everyone at the same time.
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/[P.real_name]-etching.json"

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"

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

get_save_path()
if(ourclient && !ourclient.ckey)
log_debug("<span class = 'danger'>Etching load failed: Aborting etching load for [ourclient.prefs.real_name], no ckey</span>")
savable = FALSE
return

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 @@ -178,11 +209,15 @@
xp = load["xp"]

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

/datum/etching/proc/save(delet = FALSE)
if(IsGuestKey(ourmob.key))
return
if(ourmob)
if(IsGuestKey(ourmob.key))
return

if((!savable && !event_character) || !needs_saving)
return
Expand All @@ -192,7 +227,7 @@
if(delet) //Our mob got deleted, so we're saving and quitting.
shutting_down = TRUE

if(!save_path || !ishuman(ourmob) || istype(ourmob, /mob/living/carbon/human/dummy))
if(!save_path)
if(shutting_down)
ourmob = null
qdel(src)
Expand Down Expand Up @@ -229,8 +264,8 @@
ourmob = null
qdel(src)

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

/datum/etching/proc/update_etching(mode,value)
needs_saving = TRUE
Expand Down Expand Up @@ -334,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
Loading

0 comments on commit d34c728

Please sign in to comment.