[MIRROR] Makes the game start faster by optimizing round-start manifest injections [MDB IGNORE] (#15866)

* Makes the game start faster by optimizing round-start manifest injections

* Fixin' dem conflicts yo

Co-authored-by: GoldenAlpharex <58045821+GoldenAlpharex@users.noreply.github.com>
This commit is contained in:
SkyratBot
2022-08-27 02:38:14 +02:00
committed by GitHub
parent c0a866dc01
commit 97778f3d14
6 changed files with 120 additions and 74 deletions

View File

@@ -1007,7 +1007,8 @@ GLOBAL_LIST_EMPTY(friendly_animal_types)
return J return J
return 0 return 0
//For creating consistent icons for human looking simple animals /// # If you already have a human and need to get its flat icon, call `get_flat_existing_human_icon()` instead.
/// For creating consistent icons for human looking simple animals.
/proc/get_flat_human_icon(icon_id, datum/job/job, datum/preferences/prefs, dummy_key, showDirs = GLOB.cardinals, outfit_override = null) /proc/get_flat_human_icon(icon_id, datum/job/job, datum/preferences/prefs, dummy_key, showDirs = GLOB.cardinals, outfit_override = null)
var/static/list/humanoid_icon_cache = list() var/static/list/humanoid_icon_cache = list()
if(icon_id && humanoid_icon_cache[icon_id]) if(icon_id && humanoid_icon_cache[icon_id])
@@ -1037,7 +1038,8 @@ GLOBAL_LIST_EMPTY(friendly_animal_types)
* A simpler version of get_flat_human_icon() that uses an existing human as a base to create the 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 * 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 * 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. * generated once and handle the caching yourself if you need to access that icon multiple times, or
* refactor this proc to feature caching of icons.
* *
* Arguments: * Arguments:
* * existing_human - The human we want to get a flat icon out of. * * existing_human - The human we want to get a flat icon out of.

View File

@@ -19,16 +19,61 @@ GLOBAL_DATUM_INIT(data_core, /datum/datacore, new)
var/list/fields = list() var/list/fields = list()
/datum/data/record/Destroy() /datum/data/record/Destroy()
if(src in GLOB.data_core.medical) GLOB.data_core.medical -= src
GLOB.data_core.medical -= src GLOB.data_core.security -= src
if(src in GLOB.data_core.security) GLOB.data_core.general -= src
GLOB.data_core.security -= src GLOB.data_core.locked -= src
if(src in GLOB.data_core.general)
GLOB.data_core.general -= src
if(src in GLOB.data_core.locked)
GLOB.data_core.locked -= src
. = ..() . = ..()
/// A helper proc to get the front photo of a character from the record.
/// Handles calling `get_photo()`, read its documentation for more information.
/datum/data/record/proc/get_front_photo()
return get_photo("photo_front", SOUTH)
/// A helper proc to get the side photo of a character from the record.
/// Handles calling `get_photo()`, read its documentation for more information.
/datum/data/record/proc/get_side_photo()
return get_photo("photo_side", WEST)
/**
* You shouldn't be calling this directly, use `get_front_photo()` or `get_side_photo()`
* instead.
*
* This is the proc that handles either fetching (if it was already generated before) or
* generating (if it wasn't) the specified photo from the specified record. This is only
* intended to be used by records that used to try to access `fields["photo_front"]` or
* `fields["photo_side"]`, and will return an empty icon if there isn't any of the necessary
* fields.
*
* Arguments:
* * field_name - The name of the key in the `fields` list, of the record itself.
* * orientation - The direction in which you want the character appearance to be rotated
* in the outputed photo.
*
* Returns an empty `/icon` if there was no `character_appearance` entry in the `fields` list,
* returns the generated/cached photo otherwise.
*/
/datum/data/record/proc/get_photo(field_name, orientation)
if(fields[field_name])
return fields[field_name]
if(!fields["character_appearance"])
return new /icon()
var/mutable_appearance/character_appearance = fields["character_appearance"]
character_appearance.setDir(orientation)
var/icon/picture_image = getFlatIcon(character_appearance)
var/datum/picture/picture = new
picture.picture_name = "[fields["name"]]"
picture.picture_desc = "This is [fields["name"]]."
picture.picture_image = picture_image
var/obj/item/photo/photo = new(null, picture)
fields[field_name] = photo
return photo
/datum/data/crime /datum/data/crime
name = "crime" name = "crime"
var/crimeName = "" var/crimeName = ""
@@ -229,17 +274,9 @@ GLOBAL_DATUM_INIT(data_core, /datum/datacore, new)
var/static/record_id_num = 1001 var/static/record_id_num = 1001
var/id = num2hex(record_id_num++,6) var/id = num2hex(record_id_num++,6)
var/image = get_id_photo(H, show_directions) // We need to compile the overlays now, otherwise we're basically copying an empty icon.
var/datum/picture/pf = new COMPILE_OVERLAYS(H)
var/datum/picture/ps = new var/mutable_appearance/character_appearance = new(H.appearance)
pf.picture_name = "[H]"
ps.picture_name = "[H]"
pf.picture_desc = "This is [H]."
ps.picture_desc = "This is [H]."
pf.picture_image = icon(image, dir = SOUTH)
ps.picture_image = icon(image, dir = WEST)
var/obj/item/photo/photo_front = new(null, pf)
var/obj/item/photo/photo_side = new(null, ps)
//These records should ~really~ be merged or something //These records should ~really~ be merged or something
//General Record //General Record
@@ -261,8 +298,7 @@ GLOBAL_DATUM_INIT(data_core, /datum/datacore, new)
G.fields["gender"] = "Female" G.fields["gender"] = "Female"
else else
G.fields["gender"] = "Other" G.fields["gender"] = "Other"
G.fields["photo_front"] = photo_front G.fields["character_appearance"] = character_appearance
G.fields["photo_side"] = photo_side
// SKYRAT ADDITION START - RP RECORDS // SKYRAT ADDITION START - RP RECORDS
G.fields["past_records"] = human_client?.prefs?.read_preference(/datum/preference/text/general) || "" 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["background_records"] = human_client?.prefs?.read_preference(/datum/preference/text/background) || ""
@@ -322,14 +358,11 @@ GLOBAL_DATUM_INIT(data_core, /datum/datacore, new)
L.fields["identity"] = H.dna.unique_identity L.fields["identity"] = H.dna.unique_identity
L.fields["species"] = H.dna.species.type L.fields["species"] = H.dna.species.type
L.fields["features"] = H.dna.features L.fields["features"] = H.dna.features
L.fields["image"] = image L.fields["character_appearance"] = character_appearance
L.fields["mindref"] = H.mind L.fields["mindref"] = H.mind
locked += L locked += L
return return
/datum/datacore/proc/get_id_photo(mob/living/carbon/human/human, show_directions = list(SOUTH))
return get_flat_existing_human_icon(human, show_directions)
//Todo: Add citations to the prinout - you get them from sec record's "citation" field, same as "crim" (which is frankly a terrible fucking field name) //Todo: Add citations to the prinout - you get them from sec record's "citation" field, same as "crim" (which is frankly a terrible fucking field name)
///Standardized printed records. SPRs. Like SATs but for bad guys who probably didn't actually finish school. Input the records and out comes a paper. ///Standardized printed records. SPRs. Like SATs but for bad guys who probably didn't actually finish school. Input the records and out comes a paper.
/proc/print_security_record(datum/data/record/general_data, datum/data/record/security, atom/location) /proc/print_security_record(datum/data/record/general_data, datum/data/record/security, atom/location)

View File

@@ -98,15 +98,17 @@
dat += "<table><tr><td><b><font size='4'>Medical Record</font></b></td></tr>" dat += "<table><tr><td><b><font size='4'>Medical Record</font></b></td></tr>"
if(active1 in GLOB.data_core.general) if(active1 in GLOB.data_core.general)
if(istype(active1.fields["photo_front"], /obj/item/photo)) var/front_photo = active1.get_front_photo()
var/obj/item/photo/P1 = active1.fields["photo_front"] if(istype(front_photo, /obj/item/photo))
user << browse_rsc(P1.picture.picture_image, "photo_front") var/obj/item/photo/photo_front = front_photo
if(istype(active1.fields["photo_side"], /obj/item/photo)) user << browse_rsc(photo_front.picture.picture_image, "photo_front")
var/obj/item/photo/P2 = active1.fields["photo_side"] var/side_photo = active1.get_side_photo()
user << browse_rsc(P2.picture.picture_image, "photo_side") if(istype(side_photo, /obj/item/photo))
var/obj/item/photo/photo_side = side_photo
user << browse_rsc(photo_side.picture.picture_image, "photo_side")
dat += "<tr><td>Name:</td><td>[active1.fields["name"]]</td>" dat += "<tr><td>Name:</td><td>[active1.fields["name"]]</td>"
dat += "<td><a href='?src=[REF(src)];field=show_photo_front'><img src=photo_front height=80 width=80 border=4></a></td>" dat += "<td><a href='?src=[REF(src)];field=show_photo_front'><img src=photo_front height=96 width=96 border=4 style=\"-ms-interpolation-mode:nearest-neighbor\"></a></td>"
dat += "<td><a href='?src=[REF(src)];field=show_photo_side'><img src=photo_side height=80 width=80 border=4></a></td></tr>" dat += "<td><a href='?src=[REF(src)];field=show_photo_side'><img src=photo_side height=96 width=96 border=4 style=\"-ms-interpolation-mode:nearest-neighbor\"></a></td></tr>"
dat += "<tr><td>ID:</td><td>[active1.fields["id"]]</td></tr>" dat += "<tr><td>ID:</td><td>[active1.fields["id"]]</td></tr>"
dat += "<tr><td>Gender:</td><td><A href='?src=[REF(src)];field=gender'>&nbsp;[active1.fields["gender"]]&nbsp;</A></td></tr>" dat += "<tr><td>Gender:</td><td><A href='?src=[REF(src)];field=gender'>&nbsp;[active1.fields["gender"]]&nbsp;</A></td></tr>"
dat += "<tr><td>Age:</td><td><A href='?src=[REF(src)];field=age'>&nbsp;[active1.fields["age"]]&nbsp;</A></td></tr>" dat += "<tr><td>Age:</td><td><A href='?src=[REF(src)];field=age'>&nbsp;[active1.fields["age"]]&nbsp;</A></td></tr>"
@@ -389,16 +391,16 @@
active2.fields["b_dna"] = t1 active2.fields["b_dna"] = t1
if("show_photo_front") if("show_photo_front")
if(active1) if(active1)
if(active1.fields["photo_front"]) var/front_photo = active1.get_front_photo()
if(istype(active1.fields["photo_front"], /obj/item/photo)) if(istype(front_photo, /obj/item/photo))
var/obj/item/photo/P = active1.fields["photo_front"] var/obj/item/photo/photo = front_photo
P.show(usr) photo.show(usr)
if("show_photo_side") if("show_photo_side")
if(active1) if(active1)
if(active1.fields["photo_side"]) var/side_photo = active1.get_side_photo()
if(istype(active1.fields["photo_side"], /obj/item/photo)) if(istype(side_photo, /obj/item/photo))
var/obj/item/photo/P = active1.fields["photo_side"] var/obj/item/photo/photo = side_photo
P.show(usr) photo.show(usr)
else else
else if(href_list["p_stat"]) else if(href_list["p_stat"])

View File

@@ -338,12 +338,14 @@
if(3) if(3)
dat += "<font size='4'><b>Security Record</b></font><br>" dat += "<font size='4'><b>Security Record</b></font><br>"
if(istype(active1, /datum/data/record) && GLOB.data_core.general.Find(active1)) if(istype(active1, /datum/data/record) && GLOB.data_core.general.Find(active1))
if(istype(active1.fields["photo_front"], /obj/item/photo)) var/front_photo = active1.get_front_photo()
var/obj/item/photo/P1 = active1.fields["photo_front"] if(istype(front_photo, /obj/item/photo))
user << browse_rsc(P1.picture.picture_image, "photo_front") var/obj/item/photo/photo_front = front_photo
if(istype(active1.fields["photo_side"], /obj/item/photo)) user << browse_rsc(photo_front.picture.picture_image, "photo_front")
var/obj/item/photo/P2 = active1.fields["photo_side"] var/side_photo = active1.get_side_photo()
user << browse_rsc(P2.picture.picture_image, "photo_side") if(istype(side_photo, /obj/item/photo))
var/obj/item/photo/photo_side = side_photo
user << browse_rsc(photo_side.picture.picture_image, "photo_side")
dat += {"<table><tr><td><table> dat += {"<table><tr><td><table>
<tr><td>Name:</td><td><A href='?src=[REF(src)];choice=Edit Field;field=name'>&nbsp;[active1.fields["name"]]&nbsp;</A></td></tr> <tr><td>Name:</td><td><A href='?src=[REF(src)];choice=Edit Field;field=name'>&nbsp;[active1.fields["name"]]&nbsp;</A></td></tr>
<tr><td>ID:</td><td><A href='?src=[REF(src)];choice=Edit Field;field=id'>&nbsp;[active1.fields["id"]]&nbsp;</A></td></tr> <tr><td>ID:</td><td><A href='?src=[REF(src)];choice=Edit Field;field=id'>&nbsp;[active1.fields["id"]]&nbsp;</A></td></tr>
@@ -357,10 +359,10 @@
<tr><td>Mental Status:</td><td>&nbsp;[active1.fields["m_stat"]]&nbsp;</td></tr> <tr><td>Mental Status:</td><td>&nbsp;[active1.fields["m_stat"]]&nbsp;</td></tr>
<tr><td>General Records:</td><td><A href='?src=[REF(src)];choice=View Past General'>View&nbsp;</A></td></tr> <tr><td>General Records:</td><td><A href='?src=[REF(src)];choice=View Past General'>View&nbsp;</A></td></tr>
</table></td> </table></td>
<td><table><td align = center><a href='?src=[REF(src)];choice=Edit Field;field=show_photo_front'><img src=photo_front height=80 width=80 border=4></a><br> <td><table><td align = center><a href='?src=[REF(src)];choice=Edit Field;field=show_photo_front'><img src=photo_front height=96 width=96 border=4 style="-ms-interpolation-mode:nearest-neighbor"></a><br>
<a href='?src=[REF(src)];choice=Edit Field;field=print_photo_front'>Print photo</a><br> <a href='?src=[REF(src)];choice=Edit Field;field=print_photo_front'>Print photo</a><br>
<a href='?src=[REF(src)];choice=Edit Field;field=upd_photo_front'>Update front photo</a></td> <a href='?src=[REF(src)];choice=Edit Field;field=upd_photo_front'>Update front photo</a></td>
<td align = center><a href='?src=[REF(src)];choice=Edit Field;field=show_photo_side'><img src=photo_side height=80 width=80 border=4></a><br> <td align = center><a href='?src=[REF(src)];choice=Edit Field;field=show_photo_side'><img src=photo_side height=96 width=96 border=4 style="-ms-interpolation-mode:nearest-neighbor"></a><br>
<a href='?src=[REF(src)];choice=Edit Field;field=print_photo_side'>Print photo</a><br> <a href='?src=[REF(src)];choice=Edit Field;field=print_photo_side'>Print photo</a><br>
<a href='?src=[REF(src)];choice=Edit Field;field=upd_photo_side'>Update side photo</a></td></table> <a href='?src=[REF(src)];choice=Edit Field;field=upd_photo_side'>Update side photo</a></td></table>
</td></tr></table></td></tr></table>"} // SKYRAT EDIT - TEXT AMENDED, "GENERAL RECORDS" - RP RECORDS </td></tr></table></td></tr></table>"} // SKYRAT EDIT - TEXT AMENDED, "GENERAL RECORDS" - RP RECORDS
@@ -593,7 +595,7 @@ What a mess.*/
printing = 1 printing = 1
sleep(30) sleep(30)
if((istype(active1, /datum/data/record) && GLOB.data_core.general.Find(active1)))//make sure the record still exists. if((istype(active1, /datum/data/record) && GLOB.data_core.general.Find(active1)))//make sure the record still exists.
var/obj/item/photo/photo = active1.fields["photo_front"] var/obj/item/photo/photo = active1.get_front_photo()
new /obj/item/poster/wanted(loc, photo.picture.picture_image, wanted_name, info, headerText) new /obj/item/poster/wanted(loc, photo.picture.picture_image, wanted_name, info, headerText)
printing = 0 printing = 0
if("Print Missing") if("Print Missing")
@@ -610,7 +612,7 @@ What a mess.*/
printing = 1 printing = 1
sleep(30) sleep(30)
if((istype(active1, /datum/data/record) && GLOB.data_core.general.Find(active1)))//make sure the record still exists. if((istype(active1, /datum/data/record) && GLOB.data_core.general.Find(active1)))//make sure the record still exists.
var/obj/item/photo/photo = active1.fields["photo_front"] var/obj/item/photo/photo = active1.get_front_photo()
new /obj/item/poster/wanted/missing(loc, photo.picture.picture_image, missing_name, info, headerText) new /obj/item/poster/wanted/missing(loc, photo.picture.picture_image, missing_name, info, headerText)
printing = 0 printing = 0
@@ -773,10 +775,11 @@ What a mess.*/
return return
active1.fields["species"] = t1 active1.fields["species"] = t1
if("show_photo_front") if("show_photo_front")
if(active1.fields["photo_front"]) if(active1)
if(istype(active1.fields["photo_front"], /obj/item/photo)) var/front_photo = active1.get_front_photo()
var/obj/item/photo/P = active1.fields["photo_front"] if(istype(front_photo, /obj/item/photo))
P.show(usr) var/obj/item/photo/photo = front_photo
photo.show(usr)
if("upd_photo_front") if("upd_photo_front")
var/obj/item/photo/photo = get_photo(usr) var/obj/item/photo/photo = get_photo(usr)
if(photo) if(photo)
@@ -790,15 +793,17 @@ What a mess.*/
I.Crop(dw/2, dh/2, w - dw/2, h - dh/2) I.Crop(dw/2, dh/2, w - dw/2, h - dh/2)
active1.fields["photo_front"] = photo active1.fields["photo_front"] = photo
if("print_photo_front") if("print_photo_front")
if(active1.fields["photo_front"]) if(active1)
if(istype(active1.fields["photo_front"], /obj/item/photo)) var/front_photo = active1.get_front_photo()
var/obj/item/photo/P = active1.fields["photo_front"] if(istype(front_photo, /obj/item/photo))
print_photo(P.picture.picture_image, active1.fields["name"]) var/obj/item/photo/photo_front = front_photo
print_photo(photo_front.picture.picture_image, active1.fields["name"])
if("show_photo_side") if("show_photo_side")
if(active1.fields["photo_side"]) if(active1)
if(istype(active1.fields["photo_side"], /obj/item/photo)) var/side_photo = active1.get_side_photo()
var/obj/item/photo/P = active1.fields["photo_side"] if(istype(side_photo, /obj/item/photo))
P.show(usr) var/obj/item/photo/photo = side_photo
photo.show(usr)
if("upd_photo_side") if("upd_photo_side")
var/obj/item/photo/photo = get_photo(usr) var/obj/item/photo/photo = get_photo(usr)
if(photo) if(photo)
@@ -812,10 +817,11 @@ What a mess.*/
I.Crop(dw/2, dh/2, w - dw/2, h - dh/2) I.Crop(dw/2, dh/2, w - dw/2, h - dh/2)
active1.fields["photo_side"] = photo active1.fields["photo_side"] = photo
if("print_photo_side") if("print_photo_side")
if(active1.fields["photo_side"]) if(active1)
if(istype(active1.fields["photo_side"], /obj/item/photo)) var/side_photo = active1.get_side_photo()
var/obj/item/photo/P = active1.fields["photo_side"] if(istype(side_photo, /obj/item/photo))
print_photo(P.picture.picture_image, active1.fields["name"]) var/obj/item/photo/photo_side = side_photo
print_photo(photo_side.picture.picture_image, active1.fields["name"])
if("crim_add") if("crim_add")
if(istype(active1, /datum/data/record)) if(istype(active1, /datum/data/record))
var/t1 = tgui_input_text(usr, "Input crime names", "Security Records") var/t1 = tgui_input_text(usr, "Input crime names", "Security Records")

View File

@@ -144,9 +144,9 @@
return return
var/obj/item/photo/photo_from_record = null var/obj/item/photo/photo_from_record = null
if(href_list["photo_front"]) if(href_list["photo_front"])
photo_from_record = general_record.fields["photo_front"] // SKYRAT EDIT CHANGE photo_from_record = general_record.get_front_photo() // SKYRAT EDIT - Examine Records - ORIGINAL: photo_from_record = target_record.get_front_photo()
else if(href_list["photo_side"]) else if(href_list["photo_side"])
photo_from_record = general_record.fields["photo_side"] // SKYRAT EDIT CHANGE photo_from_record = general_record.get_side_photo() // SKYRAT EDIT - Examine Records - ORIGINAL: photo_from_record = target_record.get_side_photo()
if(photo_from_record) if(photo_from_record)
photo_from_record.show(human_user) photo_from_record.show(human_user)
return return

View File

@@ -661,7 +661,7 @@
var/list/personnel_list = list() var/list/personnel_list = list()
for(var/datum/data/record/record_datum in GLOB.data_core.locked)//Look in data core locked. for(var/datum/data/record/record_datum in GLOB.data_core.locked)//Look in data core locked.
personnel_list["[record_datum.fields["name"]]: [record_datum.fields["rank"]]"] = record_datum.fields["image"]//Pull names, rank, and image. personnel_list["[record_datum.fields["name"]]: [record_datum.fields["rank"]]"] = record_datum.fields["character_appearance"]//Pull names, rank, and image.
if(!length(personnel_list)) if(!length(personnel_list))
tgui_alert(usr,"No suitable records found. Aborting.") tgui_alert(usr,"No suitable records found. Aborting.")
@@ -671,10 +671,13 @@
return return
if(isnull(personnel_list[input])) if(isnull(personnel_list[input]))
return return
var/icon/character_icon = personnel_list[input] var/mutable_appearance/character_icon = personnel_list[input]
if(character_icon) if(character_icon)
qdel(holo_icon)//Clear old icon so we're not storing it in memory. qdel(holo_icon)//Clear old icon so we're not storing it in memory.
holo_icon = getHologramIcon(icon(character_icon)) character_icon.setDir(SOUTH)
var/icon/icon_for_holo = getFlatIcon(character_icon)
holo_icon = getHologramIcon(icon(icon_for_holo))
if("My Character") if("My Character")
switch(tgui_alert(usr,"WARNING: Your AI hologram will take the appearance of your currently selected character ([usr.client.prefs?.read_preference(/datum/preference/name/real_name)]). Are you sure you want to proceed?", "Customize", list("Yes","No"))) switch(tgui_alert(usr,"WARNING: Your AI hologram will take the appearance of your currently selected character ([usr.client.prefs?.read_preference(/datum/preference/name/real_name)]). Are you sure you want to proceed?", "Customize", list("Yes","No")))