Skip to content

Commit

Permalink
TGS Test Merge (#8217)
Browse files Browse the repository at this point in the history
  • Loading branch information
cm13-github committed Jan 25, 2025
2 parents a010d97 + bd5796b commit 37d65db
Show file tree
Hide file tree
Showing 15 changed files with 509 additions and 431 deletions.
3 changes: 3 additions & 0 deletions code/__DEFINES/data_core.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#define FLAG_DATA_CORE_MEDICAL_UPDATED (1>>0)
#define FLAG_DATA_CORE_SECURITY_UPDATED (1>>1)
#define FLAG_DATA_CORE_GENERAL_UPDATED (1>>2)
1 change: 1 addition & 0 deletions code/__DEFINES/subsystems.dm
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@
#define SS_PRIORITY_HUMAN 148
#define SS_PRIORITY_STAMINA 126
#define SS_PRIORITY_COMPONENT 125
#define SS_PRIORITY_DATA_CORE 121
#define SS_PRIORITY_NANOUI 120
#define SS_PRIORITY_TGUI 120
#define SS_PRIORITY_HIVE_STATUS 112
Expand Down
31 changes: 31 additions & 0 deletions code/controllers/subsystem/data_core.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
SUBSYSTEM_DEF(data_core)
name = "Data Core"
priority = SS_PRIORITY_DATA_CORE
flags = SS_NO_INIT
wait = 10 SECONDS

var/list/datum/tgui_havers = list()
var/list/datum/currentrun = list()

/datum/controller/subsystem/data_core/stat_entry(msg)
msg = "P:[length(tgui_havers)]"
return ..()

/datum/controller/subsystem/data_core/fire(resumed = FALSE)
if (!resumed)
if(GLOB.data_core.update_flags == NONE)
return
GLOB.data_core.update_flags = NONE
currentrun = tgui_havers.Copy()

while (length(currentrun))
var/datum/tgui_haver = currentrun[length(currentrun)]
currentrun.len--

if (!tgui_haver || QDELETED(tgui_haver))
continue

tgui_haver.update_static_data_for_all_viewers()

if (MC_TICK_CHECK)
return
135 changes: 132 additions & 3 deletions code/datums/datacore.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ GLOBAL_DATUM_INIT(data_core, /datum/datacore, new)
var/locked[] = list()
var/leveled_riflemen = 0
var/leveled_riflemen_max = 7
var/update_flags = NONE

/datum/datacore/proc/manifest(nosleep = 0)
spawn()
Expand All @@ -21,11 +22,11 @@ GLOBAL_DATUM_INIT(data_core, /datum/datacore, new)
if(H.job in jobs_to_check)
manifest_inject(H)

/datum/datacore/proc/manifest_modify(name, ref, assignment, rank, p_stat)
/datum/datacore/proc/manifest_modify(name, ref, assignment, rank, p_stat, squad_name)
var/datum/data/record/foundrecord

var/use_name = isnull(ref)
for(var/datum/data/record/record_entry in GLOB.data_core.general)
for(var/datum/data/record/record_entry in general)
if(use_name)
if(record_entry.fields["name"] == name)
foundrecord = record_entry
Expand All @@ -42,12 +43,139 @@ GLOBAL_DATUM_INIT(data_core, /datum/datacore, new)
foundrecord.fields["real_rank"] = rank
if(p_stat)
foundrecord.fields["p_stat"] = p_stat
if(squad_name)
foundrecord.fields["squad"] = squad_name
if(!use_name)
if(name)
foundrecord.fields["name"] = name
update_flags |= FLAG_DATA_CORE_GENERAL_UPDATED
return TRUE
return FALSE

/datum/datacore/proc/manifest_delete_all_medical()
msg_admin_niche("[key_name_admin(usr)] deleted all medical records.")
QDEL_LIST(medical)
update_flags |= FLAG_DATA_CORE_MEDICAL_UPDATED

/datum/datacore/proc/manifest_medical_emp_act(severity)
for(var/datum/data/record/R as anything in medical)
if(prob(10/severity))
switch(rand(1,6))
if(1)
msg_admin_niche("The medical record name of [R.fields["name"]] was scrambled!")
R.fields["name"] = "[pick(pick(GLOB.first_names_male), pick(GLOB.first_names_female))] [pick(GLOB.last_names)]"
if(2)
R.fields["sex"] = pick("Male", "Female")
msg_admin_niche("The medical record sex of [R.fields["name"]] was scrambled!")
if(3)
R.fields["age"] = rand(5, 85)
msg_admin_niche("The medical record age of [R.fields["name"]] was scrambled!")
if(4)
R.fields["b_type"] = pick("A-", "B-", "AB-", "O-", "A+", "B+", "AB+", "O+")
msg_admin_niche("The medical record blood type of [R.fields["name"]] was scrambled!")
if(5)
R.fields["p_stat"] = pick("*SSD*", "Active", "Physically Unfit", "Disabled")
msg_admin_niche("The medical record physical state of [R.fields["name"]] was scrambled!")
if(6)
R.fields["m_stat"] = pick("*Insane*", "*Unstable*", "*Watch*", "Stable")
msg_admin_niche("The medical record mental state of [R.fields["name"]] was scrambled!")
continue

else if(prob(1))
msg_admin_niche("The medical record of [R.fields["name"]] was lost!")
medical -= R
qdel(R)
continue
update_flags |= FLAG_DATA_CORE_MEDICAL_UPDATED

/datum/datacore/proc/manifest_delete_all_security()
msg_admin_niche("[key_name_admin(usr)] deleted all security records.")
QDEL_LIST(security)

update_flags |= FLAG_DATA_CORE_SECURITY_UPDATED

/datum/datacore/proc/manifest_security_emp_act(severity)
for(var/datum/data/record/R in security)
if(prob(10/severity))
switch(rand(1,6))
if(1)
msg_admin_niche("The employment record name of [R.fields["name"]] was scrambled!")
R.fields["name"] = "[pick(pick(GLOB.first_names_male), pick(GLOB.first_names_female))] [pick(GLOB.last_names)]"
if(2)
R.fields["sex"] = pick("Male", "Female")
msg_admin_niche("The employment record sex of [R.fields["name"]] was scrambled!")
if(3)
R.fields["age"] = rand(5, 85)
msg_admin_niche("The employment record age of [R.fields["name"]] was scrambled!")
if(4)
R.fields["criminal"] = pick("None", "*Arrest*", "Incarcerated", "Released")
msg_admin_niche("The employment record criminal status of [R.fields["name"]] was scrambled!")
if(5)
R.fields["p_stat"] = pick("*Unconscious*", "Active", "Physically Unfit")
msg_admin_niche("The employment record physical state of [R.fields["name"]] was scrambled!")
if(6)
R.fields["m_stat"] = pick("*Insane*", "*Unstable*", "*Watch*", "Stable")
msg_admin_niche("The employment record mental state of [R.fields["name"]] was scrambled!")
continue

else if(prob(1))
msg_admin_niche("The employment record of [R.fields["name"]] was lost!")
security -= R
qdel(R)
continue
update_flags |= FLAG_DATA_CORE_SECURITY_UPDATED

/datum/datacore/proc/manifest_delete_medical_record(datum/data/record/target)
if(!istype(target, /datum/data/record))
return
for(var/datum/data/record/R as anything in medical)
if ((R.fields["name"] == target.fields["name"] || R.fields["id"] == target.fields["id"]))
medical -= R
qdel(R)
msg_admin_niche("[key_name_admin(usr)] deleted all employment records for [target.fields["name"]] ([target.fields["id"]]).")
QDEL_NULL(target)
update_flags |= FLAG_DATA_CORE_MEDICAL_UPDATED

// Used for ensuring injected records flag for updates
/datum/datacore/proc/manifest_inject_medical_record(datum/data/record/record)
medical += record
update_flags |= FLAG_DATA_CORE_MEDICAL_UPDATED

/datum/datacore/proc/manifest_inject_general_record(datum/data/record/record)
general += record
update_flags |= FLAG_DATA_CORE_GENERAL_UPDATED

/datum/datacore/proc/manifest_inject_security_record(datum/data/record/record)
security += record
update_flags |= FLAG_DATA_CORE_SECURITY_UPDATED

// Currently do nothing except flag, could do something in future
/datum/datacore/proc/manifest_updated_medical_record(datum/data/record/record)
update_flags |= FLAG_DATA_CORE_MEDICAL_UPDATED

/datum/datacore/proc/manifest_updated_general_record(datum/data/record/record)
update_flags |= FLAG_DATA_CORE_GENERAL_UPDATED

/datum/datacore/proc/manifest_updated_security_record(datum/data/record/record)
update_flags |= FLAG_DATA_CORE_SECURITY_UPDATED

/datum/datacore/proc/manifest_delete(mob/living/carbon/human/target)
//Delete them from datacore.
var/target_ref = WEAKREF(target)
for(var/datum/data/record/R as anything in medical)
if((R.fields["ref"] == target_ref))
medical -= R
qdel(R)
for(var/datum/data/record/T in security)
if((T.fields["ref"] == target_ref))
security -= T
qdel(T)
for(var/datum/data/record/G in general)
if((G.fields["ref"] == target_ref))
general -= G
qdel(G)
update_flags |= FLAG_DATA_CORE_MEDICAL_UPDATED|FLAG_DATA_CORE_SECURITY_UPDATED|FLAG_DATA_CORE_GENERAL_UPDATED

/datum/datacore/proc/manifest_inject(mob/living/carbon/human/target)
var/assignment
if(target.job)
Expand Down Expand Up @@ -110,7 +238,7 @@ GLOBAL_DATUM_INIT(data_core, /datum/datacore, new)
record_medical.fields["notes"] = target.med_record
else
record_medical.fields["notes"] = "No notes found."
medical += record_medical
manifest_inject_medical_record(record_medical)

//Security Record
var/datum/data/record/record_security = new()
Expand Down Expand Up @@ -148,6 +276,7 @@ GLOBAL_DATUM_INIT(data_core, /datum/datacore, new)
else
record_locked.fields["exploit_record"] = "No additional information acquired."
locked += record_locked
update_flags |= FLAG_DATA_CORE_MEDICAL_UPDATED|FLAG_DATA_CORE_SECURITY_UPDATED|FLAG_DATA_CORE_GENERAL_UPDATED


/proc/get_id_photo(mob/living/carbon/human/H)
Expand Down
6 changes: 3 additions & 3 deletions code/defines/procs/records.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
general_record.fields["faction"] = "Unknown"
general_record.fields["mob_faction"] = "Unknown"
general_record.fields["religion"] = "Unknown"
GLOB.data_core.general += general_record
GLOB.data_core.manifest_inject_general_record(general_record)
return general_record

/proc/CreateSecurityRecord(name as text, id as text)
Expand All @@ -24,7 +24,7 @@
security_record.fields["id"] = id
security_record.name = text("Security Record #[id]")
security_record.fields["incidents"] = "None"
GLOB.data_core.security += security_record
GLOB.data_core.manifest_inject_security_record(security_record)
return security_record

/proc/create_medical_record(mob/living/carbon/human/person)
Expand All @@ -46,5 +46,5 @@
medical_record.fields["autodoc_data"] = list()
medical_record.fields["autodoc_manual"] = list()
medical_record.fields["ref"] = WEAKREF(person)
GLOB.data_core.medical += medical_record
GLOB.data_core.manifest_inject_medical_record(medical_record)
return medical_record
5 changes: 1 addition & 4 deletions code/game/jobs/role_authority.dm
Original file line number Diff line number Diff line change
Expand Up @@ -649,10 +649,7 @@ I hope it's easier to tell what the heck this proc is even doing, unlike previou
new_squad.update_free_mar()

var/marine_ref = WEAKREF(transfer_marine)
for(var/datum/data/record/t in GLOB.data_core.general) //we update the crew manifest
if(t.fields["ref"] == marine_ref)
t.fields["squad"] = new_squad.name
break
GLOB.data_core.manifest_modify(ref=marine_ref, squad_name=new_squad.name)

transfer_marine.hud_set_squad()

Expand Down
Loading

0 comments on commit 37d65db

Please sign in to comment.