From efe3bc31623424aa9dcf4041b9e01fa4daef58bb Mon Sep 17 00:00:00 2001 From: kevinz000 Date: Fri, 15 Sep 2017 12:14:28 -0700 Subject: [PATCH] (Hopefully) Lessens preferences and manifest injection lag (#30596) * first step to fixing a potential problem is identifying it * woops * kk * mso is already doing this kek * yeah lets do that too. * replicated code * wups * wups * better * gibe the merge b0ss * cyberboss * Update dummy.dm --- code/__DEFINES/misc.dm | 4 ++ code/__HELPERS/icons.dm | 8 ++-- code/controllers/subsystem/ticker.dm | 4 +- code/datums/datacore.dm | 3 +- .../mob/dead/new_player/preferences_setup.dm | 4 +- code/modules/mob/living/carbon/human/dummy.dm | 43 +++++++++++++++++++ code/modules/mob/living/carbon/human/human.dm | 9 ---- tgstation.dme | 1 + 8 files changed, 57 insertions(+), 19 deletions(-) create mode 100644 code/modules/mob/living/carbon/human/dummy.dm diff --git a/code/__DEFINES/misc.dm b/code/__DEFINES/misc.dm index a6afae4504b..f7980becfa6 100644 --- a/code/__DEFINES/misc.dm +++ b/code/__DEFINES/misc.dm @@ -450,3 +450,7 @@ GLOBAL_LIST_INIT(ghost_others_options, list(GHOST_OTHERS_SIMPLE, GHOST_OTHERS_DE #define SECURITY_SAFE 1 #define SECURITY_ULTRASAFE 2 #define SECURITY_TRUSTED 3 + +//Dummy mob reserve slots +#define DUMMY_HUMAN_SLOT_PREFERENCES "dummy_preference_preview" +#define DUMMY_HUMAN_SLOT_MANIFEST "dummy_manifest_generation" diff --git a/code/__HELPERS/icons.dm b/code/__HELPERS/icons.dm index 9b16644b4ca..91bf127ab83 100644 --- a/code/__HELPERS/icons.dm +++ b/code/__HELPERS/icons.dm @@ -926,10 +926,10 @@ GLOBAL_LIST_EMPTY(friendly_animal_types) return 0 //For creating consistent icons for human looking simple animals -/proc/get_flat_human_icon(icon_id, datum/job/J, datum/preferences/prefs) +/proc/get_flat_human_icon(icon_id, datum/job/J, datum/preferences/prefs, dummy_key) var/static/list/humanoid_icon_cache = list() if(!icon_id || !humanoid_icon_cache[icon_id]) - var/mob/living/carbon/human/dummy/body = new() + var/mob/living/carbon/human/dummy/body = generate_or_wait_for_human_dummy(dummy_key) if(prefs) prefs.copy_to(body) @@ -956,14 +956,12 @@ GLOBAL_LIST_EMPTY(friendly_animal_types) partial = getFlatIcon(body) out_icon.Insert(partial,dir=EAST) - qdel(body) - humanoid_icon_cache[icon_id] = out_icon + dummy_key? unset_busy_human_dummy(dummy_key) : qdel(body) return out_icon else return humanoid_icon_cache[icon_id] - //Hook, override to run code on- wait this is images //Images have dir without being an atom, so they get their own definition. //Lame. diff --git a/code/controllers/subsystem/ticker.dm b/code/controllers/subsystem/ticker.dm index cad47636861..2a8b9b82375 100755 --- a/code/controllers/subsystem/ticker.dm +++ b/code/controllers/subsystem/ticker.dm @@ -236,10 +236,10 @@ SUBSYSTEM_DEF(ticker) PostSetup() - return 1 + return TRUE /datum/controller/subsystem/ticker/proc/PostSetup() - set waitfor = 0 + set waitfor = FALSE mode.post_setup() GLOB.start_state = new /datum/station_state() GLOB.start_state.count(1) diff --git a/code/datums/datacore.dm b/code/datums/datacore.dm index 0685b5f0bee..e6cd7d325e6 100644 --- a/code/datums/datacore.dm +++ b/code/datums/datacore.dm @@ -196,6 +196,7 @@ /datum/datacore/proc/manifest_inject(mob/living/carbon/human/H, client/C) + set waitfor = FALSE if(H.mind && (H.mind.assigned_role != H.mind.special_role)) var/assignment if(H.mind.assigned_role) @@ -284,4 +285,4 @@ C = H.client if(C) P = C.prefs - return get_flat_human_icon(null, J, P) + return get_flat_human_icon(null, J, P, DUMMY_HUMAN_SLOT_MANIFEST) diff --git a/code/modules/mob/dead/new_player/preferences_setup.dm b/code/modules/mob/dead/new_player/preferences_setup.dm index d067aee4b1a..9b7d32456f8 100644 --- a/code/modules/mob/dead/new_player/preferences_setup.dm +++ b/code/modules/mob/dead/new_player/preferences_setup.dm @@ -34,7 +34,7 @@ return // Set up the dummy for its photoshoot - var/mob/living/carbon/human/dummy/mannequin = new() + var/mob/living/carbon/human/dummy/mannequin = generate_or_wait_for_human_dummy(DUMMY_HUMAN_SLOT_PREFERENCES) copy_to(mannequin) // Determine what job is marked as 'High' priority, and dress them up as such. @@ -82,4 +82,4 @@ CHECK_TICK preview_icon.Scale(preview_icon.Width() * 2, preview_icon.Height() * 2) // Scaling here to prevent blurring in the browser. CHECK_TICK - qdel(mannequin) + unset_busy_human_dummy(DUMMY_HUMAN_SLOT_PREFERENCES) diff --git a/code/modules/mob/living/carbon/human/dummy.dm b/code/modules/mob/living/carbon/human/dummy.dm new file mode 100644 index 00000000000..0492a0b5e63 --- /dev/null +++ b/code/modules/mob/living/carbon/human/dummy.dm @@ -0,0 +1,43 @@ + +/mob/living/carbon/human/dummy + real_name = "Test Dummy" + status_flags = GODMODE|CANPUSH + var/in_use = FALSE + +INITIALIZE_IMMEDIATE(/mob/living/carbon/human/dummy) + +/mob/living/carbon/human/dummy/Destroy() + in_use = FALSE + return ..() + +/mob/living/carbon/human/dummy/Life() + return + +/mob/living/carbon/human/dummy/proc/wipe_state() + QDEL_LIST(contents) + cut_overlays(TRUE) + +//Inefficient pooling/caching way. +GLOBAL_LIST_EMPTY(human_dummy_list) + +/proc/generate_or_wait_for_human_dummy(slotkey) + if(!slotkey) + return new /mob/living/carbon/human/dummy + var/mob/living/carbon/human/dummy/D = GLOB.human_dummy_list[slotkey] + if(istype(D)) + UNTIL(!D.in_use) + else + pass() + if(QDELETED(D)) + D = new + GLOB.human_dummy_list[slotkey] = D + D.in_use = TRUE + return D + +/proc/unset_busy_human_dummy(slotnumber) + if(!slotnumber) + return + var/mob/living/carbon/human/dummy/D = GLOB.human_dummy_list[slotnumber] + if(istype(D)) + D.wipe_state() + D.in_use = FALSE diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index 484e2b469bf..fd4959b0ba2 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -5,15 +5,6 @@ icon = 'icons/mob/human.dmi' icon_state = "caucasian_m" -/mob/living/carbon/human/dummy - real_name = "Test Dummy" - status_flags = GODMODE|CANPUSH - -INITIALIZE_IMMEDIATE(/mob/living/carbon/human/dummy) - -/mob/living/carbon/human/dummy/Life() - return - /mob/living/carbon/human/Initialize() verbs += /mob/living/proc/mob_sleep verbs += /mob/living/proc/lay_down diff --git a/tgstation.dme b/tgstation.dme index f722bf7ced0..071db6c3400 100755 --- a/tgstation.dme +++ b/tgstation.dme @@ -1579,6 +1579,7 @@ #include "code\modules\mob\living\carbon\alien\special\facehugger.dm" #include "code\modules\mob\living\carbon\human\damage_procs.dm" #include "code\modules\mob\living\carbon\human\death.dm" +#include "code\modules\mob\living\carbon\human\dummy.dm" #include "code\modules\mob\living\carbon\human\emote.dm" #include "code\modules\mob\living\carbon\human\examine.dm" #include "code\modules\mob\living\carbon\human\human.dm"