From 3ab2a08d865a8a425d1b1193cd65b37b3d05c370 Mon Sep 17 00:00:00 2001 From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> Date: Sun, 4 Feb 2024 21:17:50 +0000 Subject: [PATCH] [TM prolly] Some init optimisationss (#23800) * [TM prolly] Some init optimisationss * Do this as well * Sod it some runtime optimisations as well --- code/controllers/subsystem/SSair.dm | 1 + .../subsystem/non_firing/SSmapping.dm | 2 ++ code/datums/datacore.dm | 14 ++++++++--- code/game/dna/dna2.dm | 8 ++++-- code/game/jobs/job_exp.dm | 5 ++-- .../items/devices/painter/floor_painter.dm | 25 +++++++++++++++---- code/modules/client/preference/character.dm | 7 +++--- .../mob/living/carbon/human/appearance.dm | 8 +++--- .../mob/living/carbon/human/human_mob.dm | 7 +++--- 9 files changed, 54 insertions(+), 23 deletions(-) diff --git a/code/controllers/subsystem/SSair.dm b/code/controllers/subsystem/SSair.dm index 0a97e76490e..0d4f7b8858f 100644 --- a/code/controllers/subsystem/SSair.dm +++ b/code/controllers/subsystem/SSair.dm @@ -361,6 +361,7 @@ SUBSYSTEM_DEF(air) for(var/obj/machinery/atmospherics/A in machines_to_init) A.atmos_init() count++ + CHECK_TICK return count //this can't be done with setup_atmos_machinery() because diff --git a/code/controllers/subsystem/non_firing/SSmapping.dm b/code/controllers/subsystem/non_firing/SSmapping.dm index 887b0495cc6..27193044dee 100644 --- a/code/controllers/subsystem/non_firing/SSmapping.dm +++ b/code/controllers/subsystem/non_firing/SSmapping.dm @@ -126,6 +126,8 @@ SUBSYSTEM_DEF(mapping) var/num_extra_space = rand(GLOB.configuration.ruins.extra_levels_min, GLOB.configuration.ruins.extra_levels_max) for(var/i in 1 to num_extra_space) GLOB.space_manager.add_new_zlevel("Ruin Area #[i]", linkage = CROSSLINKED, traits = list(REACHABLE_BY_CREW, SPAWN_RUINS, REACHABLE_SPACE_ONLY)) + CHECK_TICK + log_startup_progress("Loaded random space levels in [stop_watch(load_zlevels_timer)]s.") // Now spawn ruins, random budget between 20 and 30 for all zlevels combined. diff --git a/code/datums/datacore.dm b/code/datums/datacore.dm index f55638d1eb7..e74385de46c 100644 --- a/code/datums/datacore.dm +++ b/code/datums/datacore.dm @@ -166,9 +166,17 @@ GLOBAL_VAR_INIT(record_id_num, 1001) G.fields["m_stat"] = "Stable" G.fields["sex"] = capitalize(H.gender) G.fields["species"] = H.dna.species.name - G.fields["photo"] = get_id_photo(H) - G.fields["photo-south"] = "data:image/png;base64,[icon2base64(icon(G.fields["photo"], dir = SOUTH))]" - G.fields["photo-west"] = "data:image/png;base64,[icon2base64(icon(G.fields["photo"], dir = WEST))]" + // Do some ID card checking stuff here to save on resources + var/card_photo + if(istype(H.wear_id, /obj/item/card/id)) + var/obj/item/card/id/IDC = H.wear_id + card_photo = IDC.photo + else + card_photo = get_id_photo(H) + + G.fields["photo"] = card_photo + G.fields["photo-south"] = "data:image/png;base64,[icon2base64(icon(card_photo, dir = SOUTH))]" + G.fields["photo-west"] = "data:image/png;base64,[icon2base64(icon(card_photo, dir = WEST))]" if(H.gen_record && !jobban_isbanned(H, ROLEBAN_RECORDS)) G.fields["notes"] = H.gen_record else diff --git a/code/game/dna/dna2.dm b/code/game/dna/dna2.dm index cd779459274..090aa51320f 100644 --- a/code/game/dna/dna2.dm +++ b/code/game/dna/dna2.dm @@ -370,17 +370,21 @@ GLOBAL_LIST_EMPTY(bad_blocks) return num2hex(value, 3) /datum/dna/proc/UpdateUI() + var/list/ui_text_list = list() uni_identity = "" for(var/block in UI) - uni_identity += EncodeDNABlock(block) + ui_text_list += EncodeDNABlock(block) + uni_identity = ui_text_list.Join("") //testing("New UI: [uni_identity]") dirtyUI = 0 /datum/dna/proc/UpdateSE() //var/oldse=struc_enzymes + var/list/se_text_list = list() struc_enzymes = "" for(var/block in SE) - struc_enzymes += EncodeDNABlock(block) + se_text_list += EncodeDNABlock(block) + struc_enzymes = se_text_list.Join("") //testing("Old SE: [oldse]") //testing("New SE: [struc_enzymes]") dirtySE = 0 diff --git a/code/game/jobs/job_exp.dm b/code/game/jobs/job_exp.dm index cf9a76969f5..0a5c39f7475 100644 --- a/code/game/jobs/job_exp.dm +++ b/code/game/jobs/job_exp.dm @@ -51,7 +51,8 @@ GLOBAL_LIST_INIT(role_playtime_requirements, list( set name = "Check Player Playtime" if(!check_rights(R_ADMIN|R_MOD|R_MENTOR)) return - var/msg = "Playtime Report" + var/list/msg = list() + msg += "Playtime Report" var/datum/job/theirjob var/jtext msg += "" @@ -80,7 +81,7 @@ GLOBAL_LIST_INIT(role_playtime_requirements, list( msg += "" msg += "
PlayerJobCrew
" - src << browse(msg, "window=Player_playtime_check") + src << browse(msg.Join(""), "window=Player_playtime_check") /datum/admins/proc/cmd_mentor_show_exp_panel(client/C) diff --git a/code/game/objects/items/devices/painter/floor_painter.dm b/code/game/objects/items/devices/painter/floor_painter.dm index eac55a9ea04..d8681d8153f 100644 --- a/code/game/objects/items/devices/painter/floor_painter.dm +++ b/code/game/objects/items/devices/painter/floor_painter.dm @@ -21,6 +21,23 @@ "darkred", "darkredcorners", "darkredfull", "darkblue", "darkbluecorners", "darkbluefull", "darkgreen", "darkgreencorners", "darkgreenfull", "darkyellow", "darkyellowcorners", "darkyellowfull", "darkbrown", "darkbrowncorners", "darkbrownfull") + // This is a double-list. First entry is the type key, second is the direction, with the final value being the b64 of the icon + var/static/list/lookup_cache = list() + +/datum/painter/floor/New(obj/item/painter/parent_painter) + . = ..() + if(!length(lookup_cache)) + for(var/style in allowed_states) + if(!(style in lookup_cache)) + lookup_cache += style + lookup_cache[style] = list() + + for(var/dir in GLOB.alldirs) + var/icon/floor_icon = icon('icons/turf/floors.dmi', style, dir) + // These indexes have to be strings otherwise it treats it as a list index not a map lookup index + lookup_cache[style] += "[dir]" + lookup_cache[style]["[dir]"] = icon2base64(floor_icon) + /datum/painter/floor/paint_atom(atom/target, mob/user) if(!istype(target, /turf/simulated/floor/plasteel)) to_chat(user, "[holder] can only be used on station flooring.") @@ -62,8 +79,7 @@ data["directionsPreview"] = list() for(var/dir in GLOB.alldirs) - var/icon/floor_icon = icon('icons/turf/floors.dmi', floor_state, dir) - data["directionsPreview"][dir2text(dir)] = icon2base64(floor_icon) + data["directionsPreview"][dir2text(dir)] = lookup_cache[floor_state]["[dir]"] return data @@ -72,8 +88,7 @@ var/list/data = list() data["allStylesPreview"] = list() for(var/style in allowed_states) - var/icon/floor_icon = icon('icons/turf/floors.dmi', style, SOUTH) - data["allStylesPreview"][style] = icon2base64(floor_icon) + data["allStylesPreview"][style] = lookup_cache[style]["[SOUTH]"] return data @@ -100,4 +115,4 @@ if(dir != 0) floor_dir = dir - SStgui.update_uis(src) + return TRUE diff --git a/code/modules/client/preference/character.dm b/code/modules/client/preference/character.dm index 3c2ec538781..2aebc2d715b 100644 --- a/code/modules/client/preference/character.dm +++ b/code/modules/client/preference/character.dm @@ -1784,7 +1784,7 @@ /datum/character_save/proc/copy_to(mob/living/carbon/human/character) var/datum/species/S = GLOB.all_species[species] - character.set_species(S.type) // Yell at me if this causes everything to melt + character.set_species(S.type, delay_icon_update = TRUE) // Yell at me if this causes everything to melt if(be_random_name) real_name = random_name(gender, species) @@ -1885,7 +1885,7 @@ message_admins("[key_name_admin(character)] has spawned with their gender as plural or neuter. Please notify coders.") character.change_gender(MALE) - character.change_eye_color(e_colour) + character.change_eye_color(e_colour, skip_icons = TRUE) character.original_eye_color = e_colour if(disabilities & DISABILITY_FLAG_FAT) @@ -1945,12 +1945,11 @@ character.dna.ready_dna(character, flatten_SE = FALSE) character.sync_organ_dna(assimilate = TRUE) - character.UpdateAppearance() // Do the initial caching of the player's body icons. character.force_update_limbs() character.update_eyes() - character.regenerate_icons() + character.UpdateAppearance() //Check if the user has ANY job selected. /datum/character_save/proc/check_any_job() diff --git a/code/modules/mob/living/carbon/human/appearance.dm b/code/modules/mob/living/carbon/human/appearance.dm index 33896b03324..9f9ad50fe92 100644 --- a/code/modules/mob/living/carbon/human/appearance.dm +++ b/code/modules/mob/living/carbon/human/appearance.dm @@ -214,7 +214,7 @@ H.ha_style = "None" update_head_accessory() -/mob/living/carbon/human/proc/change_eye_color(colour = "#000000", update_dna = TRUE) +/mob/living/carbon/human/proc/change_eye_color(colour = "#000000", update_dna = TRUE, skip_icons = FALSE) // Update the main DNA datum, then sync the change across the organs var/obj/item/organ/internal/eyes/eyes_organ = get_int_organ(/obj/item/organ/internal/eyes) if(eyes_organ) @@ -227,9 +227,11 @@ if(update_dna) update_dna() + sync_organ_dna(assimilate = FALSE) - update_eyes() - update_body() + if(!skip_icons) + update_eyes() + update_body() return TRUE /mob/living/carbon/human/proc/get_eye_color() diff --git a/code/modules/mob/living/carbon/human/human_mob.dm b/code/modules/mob/living/carbon/human/human_mob.dm index 6e33d88a31a..17d619c694c 100644 --- a/code/modules/mob/living/carbon/human/human_mob.dm +++ b/code/modules/mob/living/carbon/human/human_mob.dm @@ -1450,10 +1450,9 @@ if(!delay_icon_update) UpdateAppearance() - - overlays.Cut() - update_mutantrace() - regenerate_icons() + overlays.Cut() + update_mutantrace() + regenerate_icons() if(dna.species) return TRUE