mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-13 11:43:31 +00:00
VS: Fix a destroy by creating a subsystem
This commit is contained in:
@@ -1,3 +1,6 @@
|
|||||||
|
#define SSTRANSCORE_IMPLANTS 1
|
||||||
|
#define SSTRANSCORE_BACKUPS 2
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//// Mind/body data storage system
|
//// Mind/body data storage system
|
||||||
//// for the resleeving tech
|
//// for the resleeving tech
|
||||||
@@ -6,39 +9,102 @@
|
|||||||
SUBSYSTEM_DEF(transcore)
|
SUBSYSTEM_DEF(transcore)
|
||||||
name = "Transcore"
|
name = "Transcore"
|
||||||
priority = 20
|
priority = 20
|
||||||
wait = 1 MINUTE
|
wait = 3 MINUTES
|
||||||
flags = SS_BACKGROUND|SS_NO_TICK_CHECK|SS_NO_INIT
|
flags = SS_BACKGROUND|SS_NO_INIT
|
||||||
runlevels = RUNLEVEL_GAME
|
runlevels = RUNLEVEL_GAME
|
||||||
|
|
||||||
// THINGS
|
// THINGS
|
||||||
var/overdue_time = 15 MINUTES
|
var/overdue_time = 15 MINUTES
|
||||||
var/core_dumped = FALSE // Core has been dumped! Also set can_fire = 0 when you set this.
|
var/core_dumped = FALSE // Core has been dumped! Also set can_fire = 0 when you set this.
|
||||||
|
|
||||||
|
var/current_step = SSTRANSCORE_IMPLANTS
|
||||||
|
|
||||||
|
var/cost_backups = 0
|
||||||
|
var/cost_implants = 0
|
||||||
|
|
||||||
var/datum/transhuman/mind_record/list/backed_up = list() // All known mind records, indexed by MR.mindname/mind.name
|
var/datum/transhuman/mind_record/list/backed_up = list() // All known mind records, indexed by MR.mindname/mind.name
|
||||||
var/datum/transhuman/mind_record/list/has_left = list() // Why do we even have this?
|
var/datum/transhuman/mind_record/list/has_left = list() // Why do we even have this?
|
||||||
var/datum/transhuman/body_record/list/body_scans = list() // All known body records, indexed by BR.mydna.name
|
var/datum/transhuman/body_record/list/body_scans = list() // All known body records, indexed by BR.mydna.name
|
||||||
|
var/obj/item/weapon/implant/backup/list/implants = list() // All OPERATING implants that are being ticked
|
||||||
|
|
||||||
/datum/controller/subsystem/transcore/fire()
|
var/list/current_run = list()
|
||||||
for(var/N in backed_up)
|
|
||||||
var/datum/transhuman/mind_record/curr_MR = backed_up[N]
|
/datum/controller/subsystem/transcore/fire(resumed = 0)
|
||||||
if(!curr_MR)
|
var/timer = TICK_USAGE
|
||||||
log_debug("Tried to process [N] in transcore w/o a record!")
|
|
||||||
|
INTERNAL_PROCESS_STEP(SSTRANSCORE_IMPLANTS,TRUE,process_implants,cost_implants,SSTRANSCORE_BACKUPS)
|
||||||
|
INTERNAL_PROCESS_STEP(SSTRANSCORE_BACKUPS,FALSE,process_backups,cost_backups,SSTRANSCORE_IMPLANTS)
|
||||||
|
|
||||||
|
/datum/controller/subsystem/transcore/proc/process_implants(resumed = 0)
|
||||||
|
if (!resumed)
|
||||||
|
src.current_run = implants.Copy()
|
||||||
|
|
||||||
|
var/list/current_run = src.current_run
|
||||||
|
while(current_run.len)
|
||||||
|
var/obj/item/weapon/implant/backup/imp = current_run[current_run.len]
|
||||||
|
current_run.len--
|
||||||
|
|
||||||
|
//Remove if not in a human anymore.
|
||||||
|
if(!imp || !ishuman(imp.loc))
|
||||||
|
implants -= imp
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
//We're in a human, at least.
|
||||||
|
var/mob/living/carbon/human/H = imp.loc
|
||||||
|
BITSET(H.hud_updateflag, BACKUP_HUD)
|
||||||
|
|
||||||
|
if(H == imp.imp_in && H.mind && H.stat < DEAD)
|
||||||
|
SStranscore.m_backup(H.mind,H.nif)
|
||||||
|
persist_nif_data(H)
|
||||||
|
|
||||||
|
if(MC_TICK_CHECK)
|
||||||
|
return
|
||||||
|
|
||||||
|
/datum/controller/subsystem/transcore/proc/process_backups(resumed = 0)
|
||||||
|
if (!resumed)
|
||||||
|
src.current_run = backed_up.Copy()
|
||||||
|
|
||||||
|
var/list/current_run = src.current_run
|
||||||
|
while(current_run.len)
|
||||||
|
var/name = current_run[current_run.len]
|
||||||
|
var/datum/transhuman/mind_record/curr_MR = current_run[name]
|
||||||
|
current_run -= name
|
||||||
|
|
||||||
|
//Invalid record
|
||||||
|
if(!curr_MR)
|
||||||
|
log_debug("Tried to process [name] in transcore w/o a record!")
|
||||||
|
backed_up -= name
|
||||||
|
continue
|
||||||
|
|
||||||
|
//Onetimes do not get processing or notifications
|
||||||
if(curr_MR.one_time)
|
if(curr_MR.one_time)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
//Timing check
|
||||||
var/since_backup = world.time - curr_MR.last_update
|
var/since_backup = world.time - curr_MR.last_update
|
||||||
if(since_backup < overdue_time)
|
if(since_backup < overdue_time)
|
||||||
curr_MR.dead_state = MR_NORMAL
|
curr_MR.dead_state = MR_NORMAL
|
||||||
else
|
else
|
||||||
if(curr_MR.dead_state != MR_DEAD) //First time switching to dead
|
if(curr_MR.dead_state != MR_DEAD) //First time switching to dead
|
||||||
notify(N)
|
notify(name)
|
||||||
curr_MR.dead_state = MR_DEAD
|
curr_MR.dead_state = MR_DEAD
|
||||||
|
|
||||||
/datum/controller/subsystem/transcore/stat_entry(msg)
|
if(MC_TICK_CHECK)
|
||||||
|
return
|
||||||
|
|
||||||
|
/datum/controller/subsystem/transcore/stat_entry()
|
||||||
|
var/msg = list()
|
||||||
if(core_dumped)
|
if(core_dumped)
|
||||||
msg += "CORE DUMPED | "
|
msg += "CORE DUMPED | "
|
||||||
msg += "MR: [backed_up.len] | BR: [body_scans.len]"
|
msg += "$:{"
|
||||||
..(msg)
|
msg += "IM:[round(cost_implants,1)]|"
|
||||||
|
msg += "BK:[round(cost_backups,1)]"
|
||||||
|
msg += "} "
|
||||||
|
msg += "#:{"
|
||||||
|
msg += "IM:[implants.len]|"
|
||||||
|
msg += "BK:[backed_up.len]"
|
||||||
|
msg += "} "
|
||||||
|
..(jointext(msg, null))
|
||||||
|
|
||||||
/datum/controller/subsystem/transcore/Recover()
|
/datum/controller/subsystem/transcore/Recover()
|
||||||
if (istype(SStranscore.body_scans))
|
if (istype(SStranscore.body_scans))
|
||||||
@@ -131,3 +197,6 @@ SUBSYSTEM_DEF(transcore)
|
|||||||
core_dumped = TRUE
|
core_dumped = TRUE
|
||||||
can_fire = FALSE
|
can_fire = FALSE
|
||||||
return disk.stored.len
|
return disk.stored.len
|
||||||
|
|
||||||
|
#undef SSTRANSCORE_BACKUPS
|
||||||
|
#undef SSTRANSCORE_IMPLANTS
|
||||||
@@ -9,8 +9,6 @@
|
|||||||
desc = "A mindstate backup implant that occasionally stores a copy of one's mind on a central server for backup purposes."
|
desc = "A mindstate backup implant that occasionally stores a copy of one's mind on a central server for backup purposes."
|
||||||
icon = 'icons/vore/custom_items_vr.dmi'
|
icon = 'icons/vore/custom_items_vr.dmi'
|
||||||
icon_state = "backup_implant"
|
icon_state = "backup_implant"
|
||||||
var/last_attempt
|
|
||||||
var/attempt_delay = 5 MINUTES
|
|
||||||
|
|
||||||
/obj/item/weapon/implant/backup/get_data()
|
/obj/item/weapon/implant/backup/get_data()
|
||||||
var/dat = {"
|
var/dat = {"
|
||||||
@@ -25,6 +23,10 @@
|
|||||||
<b>Integrity:</b> Generally very survivable. Susceptible to being destroyed by acid."}
|
<b>Integrity:</b> Generally very survivable. Susceptible to being destroyed by acid."}
|
||||||
return dat
|
return dat
|
||||||
|
|
||||||
|
/obj/item/weapon/implant/backup/Destroy()
|
||||||
|
SStranscore.implants -= src
|
||||||
|
return ..()
|
||||||
|
|
||||||
/obj/item/weapon/implant/backup/implanted(var/mob/living/carbon/human/H)
|
/obj/item/weapon/implant/backup/implanted(var/mob/living/carbon/human/H)
|
||||||
..()
|
..()
|
||||||
if(istype(H))
|
if(istype(H))
|
||||||
@@ -32,29 +34,10 @@
|
|||||||
if(other_imp && other_imp.imp_in == H)
|
if(other_imp && other_imp.imp_in == H)
|
||||||
qdel(other_imp) //implant fight
|
qdel(other_imp) //implant fight
|
||||||
|
|
||||||
if(H.mind && H.stat < DEAD) //One right now, on implanting.
|
SStranscore.implants |= src
|
||||||
SStranscore.m_backup(H.mind)
|
|
||||||
last_attempt = world.time
|
|
||||||
|
|
||||||
backup()
|
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
/obj/item/weapon/implant/backup/proc/backup()
|
|
||||||
last_attempt = world.time
|
|
||||||
var/mob/living/carbon/human/H = loc
|
|
||||||
|
|
||||||
//We're in a human, at least.
|
|
||||||
if(istype(H))
|
|
||||||
BITSET(H.hud_updateflag, BACKUP_HUD)
|
|
||||||
//Okay we've got a mind at least
|
|
||||||
if(H == imp_in && H.mind && H.stat < DEAD)
|
|
||||||
SStranscore.m_backup(H.mind,H.nif)
|
|
||||||
persist_nif_data(H)
|
|
||||||
|
|
||||||
spawn(attempt_delay)
|
|
||||||
backup()
|
|
||||||
|
|
||||||
//New, modern implanter instead of old style implanter.
|
//New, modern implanter instead of old style implanter.
|
||||||
/obj/item/weapon/backup_implanter
|
/obj/item/weapon/backup_implanter
|
||||||
name = "backup implanter"
|
name = "backup implanter"
|
||||||
|
|||||||
Reference in New Issue
Block a user