[MIRROR] Improves Records code to use existing humans instead of dummies to create security record mugshots [MDB IGNORE] (#15242)

* Improves Records code to use existing humans instead of dummies to create security record mugshots (#68706)

* Adds get_flat_existing_human_icon()

* Improves on manifest_inject() by using get_flat_existing_human_icon() instead of get_flat_human_icon()

* Improves Records code to use existing humans instead of dummies to create security record mugshots

* I don't like having to do that, but you gotta do what you gotta do

Co-authored-by: GoldenAlpharex <58045821+GoldenAlpharex@users.noreply.github.com>
Co-authored-by: GoldenAlpharex <jerego1234@hotmail.com>
This commit is contained in:
SkyratBot
2022-07-31 03:44:06 +02:00
committed by GitHub
parent 3a6afad423
commit 04bc0df465
2 changed files with 40 additions and 33 deletions

View File

@@ -1033,6 +1033,35 @@ GLOBAL_LIST_EMPTY(friendly_animal_types)
return out_icon
/**
* A simpler version of get_flat_human_icon() that uses an existing human as a base to create the icon.
* Does not feature caching yet, since I could not think of a good way to cache them without having a possibility
* of using the cached version when we don't want to, so only use this proc if you just need this flat icon
* generated once.
*
* Arguments:
* * existing_human - The human we want to get a flat icon out of.
* * directions_to_output - The directions of the resulting flat icon, defaults to all cardinal directions.
*/
/proc/get_flat_existing_human_icon(mob/living/carbon/human/existing_human, directions_to_output = GLOB.cardinals)
RETURN_TYPE(/icon)
if(!existing_human || !istype(existing_human))
CRASH("Attempted to call get_flat_existing_human_icon on a [existing_human ? existing_human.type : "null"].")
// We need to force the dir of the human so we can take those pictures, we'll set it back afterwards.
var/initial_human_dir = existing_human.dir
existing_human.dir = SOUTH
var/icon/out_icon = icon('icons/effects/effects.dmi', "nothing")
COMPILE_OVERLAYS(existing_human)
for(var/direction in directions_to_output)
var/icon/partial = getFlatIcon(existing_human, defdir = direction)
out_icon.Insert(partial, dir = direction)
existing_human.dir = initial_human_dir
return out_icon
//Hook, override to run code on- wait this is images
//Images have dir without being an atom, so they get their own definition.
//Lame.

View File

@@ -1,6 +1,3 @@
///Dummy mob reserve slot for manifest
#define DUMMY_HUMAN_SLOT_MANIFEST "dummy_manifest_generation"
GLOBAL_DATUM_INIT(data_core, /datum/datacore, new)
//TODO: someone please get rid of this shit
@@ -136,7 +133,7 @@ GLOBAL_DATUM_INIT(data_core, /datum/datacore, new)
if(N.new_character)
log_manifest(N.ckey,N.new_character.mind,N.new_character)
if(ishuman(N.new_character))
manifest_inject(N.new_character, N.client)
manifest_inject(N.new_character, N.client) // SKYRAT EDIT - Alt-titles - ORIGINAL: manifest_inject(N.new_character)
CHECK_TICK
/datum/datacore/proc/manifest_modify(name, assignment, trim)
@@ -220,21 +217,19 @@ GLOBAL_DATUM_INIT(data_core, /datum/datacore, new)
return dat
/datum/datacore/proc/manifest_inject(mob/living/carbon/human/H, client/C)
/datum/datacore/proc/manifest_inject(mob/living/carbon/human/H, client/human_client) // SKYRAT EDIT - Alt-titles - ORIGINAL: /datum/datacore/proc/manifest_inject(mob/living/carbon/human/H)
set waitfor = FALSE
var/static/list/show_directions = list(SOUTH, WEST)
if(H.mind?.assigned_role.job_flags & JOB_CREW_MANIFEST)
var/assignment = H.mind.assigned_role.title
// SKYRAT EDIT ADDITION BEGIN - ALTERNATIVE_JOB_TITLES
// The alt job title, if user picked one, or the default
var/chosen_assignment = C?.prefs.alt_job_titles[assignment] || assignment
var/chosen_assignment = human_client?.prefs.alt_job_titles[assignment] || assignment
// SKYRAT EDIT ADDITION END - ALTERNATIVE_JOB_TITLES
var/static/record_id_num = 1001
var/id = num2hex(record_id_num++,6)
if(!C)
C = H.client
var/image = get_id_photo(H, C, show_directions)
var/image = get_id_photo(H, show_directions)
var/datum/picture/pf = new
var/datum/picture/ps = new
pf.picture_name = "[H]"
@@ -269,9 +264,9 @@ GLOBAL_DATUM_INIT(data_core, /datum/datacore, new)
G.fields["photo_front"] = photo_front
G.fields["photo_side"] = photo_side
// SKYRAT ADDITION START - RP RECORDS
G.fields["past_records"] = C?.prefs?.read_preference(/datum/preference/text/general) || ""
G.fields["background_records"] = C?.prefs?.read_preference(/datum/preference/text/background) || ""
G.fields["exploitable_records"] = C?.prefs?.read_preference(/datum/preference/text/exploitable) || ""
G.fields["past_records"] = human_client?.prefs?.read_preference(/datum/preference/text/general) || ""
G.fields["background_records"] = human_client?.prefs?.read_preference(/datum/preference/text/background) || ""
G.fields["exploitable_records"] = human_client?.prefs?.read_preference(/datum/preference/text/exploitable) || ""
// SKYRAT ADDITION END
general += G
@@ -290,10 +285,7 @@ GLOBAL_DATUM_INIT(data_core, /datum/datacore, new)
M.fields["notes"] = H.get_quirk_string(!medical, CAT_QUIRK_NOTES)
M.fields["notes_d"] = H.get_quirk_string(medical, CAT_QUIRK_NOTES)
// SKYRAT EDIT ADD - RP RECORDS
if(C && C.prefs && C.prefs.read_preference(/datum/preference/text/medical))
M.fields["past_records"] = C.prefs.read_preference(/datum/preference/text/medical)
else
M.fields["past_records"] = ""
M.fields["past_records"] = human_client?.prefs?.read_preference(/datum/preference/text/medical) || ""
// SKYRAT EDIT END
medical += M
@@ -306,10 +298,7 @@ GLOBAL_DATUM_INIT(data_core, /datum/datacore, new)
S.fields["crim"] = list()
S.fields["notes"] = "No notes."
// SKYRAT EDIT ADD - RP RECORDS
if(C && C.prefs && C.prefs.read_preference(/datum/preference/text/security))
S.fields["past_records"] = C.prefs.read_preference(/datum/preference/text/security)
else
S.fields["past_records"] = ""
S.fields["past_records"] = human_client?.prefs?.read_preference(/datum/preference/text/security) || ""
// SKYRAT EDIT END
security += S
@@ -338,16 +327,5 @@ GLOBAL_DATUM_INIT(data_core, /datum/datacore, new)
locked += L
return
/datum/datacore/proc/get_id_photo(mob/living/carbon/human/human, client/client, show_directions = list(SOUTH))
var/datum/job/humans_job = human.mind.assigned_role
var/datum/preferences/humans_prefs
if(!client)
client = human.client
if(client)
humans_prefs = client.prefs
if (human.dna.species.roundstart_changed)
return get_flat_human_icon(null, humans_job, null, DUMMY_HUMAN_SLOT_MANIFEST, show_directions)
else
return get_flat_human_icon(null, humans_job, humans_prefs, DUMMY_HUMAN_SLOT_MANIFEST, show_directions)
#undef DUMMY_HUMAN_SLOT_MANIFEST
/datum/datacore/proc/get_id_photo(mob/living/carbon/human/human, show_directions = list(SOUTH))
return get_flat_existing_human_icon(human, show_directions)