From 68892b7fb01916b34b10b8d9363af7742f8378b6 Mon Sep 17 00:00:00 2001 From: VMSolidus Date: Sat, 11 Apr 2026 10:24:34 -0400 Subject: [PATCH] Implanted HUD Flicker Fix (#22191) closes #22079 closes #21945 This bug was also my fault, and it happened when I decoupled organ processing from the life() tick to prevent organs being processed twice. Since Huds were generated during the Life() tick, but implants were adding the Hud during Process(), a flicker occured whenever they fired out of sync, with the Life() tick erasing the hud and Process() adding it back. To significantly cut down on the time complexity of having to iterate and fire every HUD producing implant and component during Life(), I've instead reworked it into a Signal that permits the HUD implants to inject hud elements into the Life() codepath dynamically. Here is the fix in action now. https://github.com/user-attachments/assets/18ccc80d-cb5f-4fd7-9ad5-28c91acf6ca5 --- .../signals/signals_mob/signals_mob_main.dm | 3 ++ .../mob/living/carbon/human/human_helpers.dm | 2 + .../subtypes/augment/augments/eye_sensors.dm | 48 ++++++++++++++----- .../augment/augments/phalanx_facial_plate.dm | 5 +- .../hellfirejag-implant-hud-fix.yml | 5 ++ 5 files changed, 48 insertions(+), 15 deletions(-) create mode 100644 html/changelogs/hellfirejag-implant-hud-fix.yml diff --git a/code/__DEFINES/dcs/signals/signals_mob/signals_mob_main.dm b/code/__DEFINES/dcs/signals/signals_mob/signals_mob_main.dm index e0820a84864..06154fbdc1e 100644 --- a/code/__DEFINES/dcs/signals/signals_mob/signals_mob_main.dm +++ b/code/__DEFINES/dcs/signals/signals_mob/signals_mob_main.dm @@ -54,3 +54,6 @@ /// For when the players intent changes #define COMSIG_INTENT_CHANGE "intent_change" + +/// Signal raised at the end of a mob's vision update to check if signals wish to supplement their own huds. +#define COMSIG_MOB_UPDATE_VISION "mob_update_vision" diff --git a/code/modules/mob/living/carbon/human/human_helpers.dm b/code/modules/mob/living/carbon/human/human_helpers.dm index 3eec815aa7d..1fb5d15d7d4 100644 --- a/code/modules/mob/living/carbon/human/human_helpers.dm +++ b/code/modules/mob/living/carbon/human/human_helpers.dm @@ -72,6 +72,8 @@ if(istype(back,/obj/item/rig)) process_rig(back) + SEND_SIGNAL(src, COMSIG_MOB_UPDATE_VISION) + /mob/living/carbon/human/proc/process_glasses(var/obj/item/clothing/glasses/G) if(G && G.active) equipment_darkness_modifier += G.darkness_view diff --git a/code/modules/organs/subtypes/augment/augments/eye_sensors.dm b/code/modules/organs/subtypes/augment/augments/eye_sensors.dm index 0172784d552..67350216137 100644 --- a/code/modules/organs/subtypes/augment/augments/eye_sensors.dm +++ b/code/modules/organs/subtypes/augment/augments/eye_sensors.dm @@ -15,17 +15,38 @@ var/selected_hud = "disabled" -/obj/item/organ/internal/augment/eye_sensors/attack_self(var/mob/user) +/obj/item/organ/internal/augment/eye_sensors/Initialize() + . = ..() + if(!owner) + return + + RegisterSignal(owner, COMSIG_MOB_UPDATE_VISION, PROC_REF(handle_vision_update)) + +/obj/item/organ/internal/augment/eye_sensors/replaced(mob/living/carbon/human/target) + . = ..() + if(!owner) + return + + RegisterSignal(owner, COMSIG_MOB_UPDATE_VISION, PROC_REF(handle_vision_update)) + +/obj/item/organ/internal/augment/eye_sensors/removed() + if(!owner) + return ..() + + UnregisterSignal(owner, COMSIG_MOB_UPDATE_VISION) + return ..() + +/obj/item/organ/internal/augment/eye_sensors/attack_self(mob/user) . = ..() if(!.) return FALSE -/obj/item/organ/internal/augment/eye_sensors/process() - ..() + // Update HUD immediately on toggle + handle_vision_update() - if(!owner) - return +/obj/item/organ/internal/augment/eye_sensors/proc/handle_vision_update(mob/living/carbon/human/H) + SIGNAL_HANDLER /obj/item/organ/internal/augment/eye_sensors/emp_act(severity) . = ..() @@ -36,14 +57,14 @@ E.take_damage(5) -/obj/item/organ/internal/augment/eye_sensors/proc/check_hud(var/hud) +/obj/item/organ/internal/augment/eye_sensors/proc/check_hud(hud) return (hud == active_hud) /obj/item/organ/internal/augment/eye_sensors/security name = "integrated security HUD sensors" action_button_name = "Toggle Security Sensors" -/obj/item/organ/internal/augment/eye_sensors/security/attack_self(var/mob/user) +/obj/item/organ/internal/augment/eye_sensors/security/attack_self(mob/user) . = ..() if(selected_hud == "disabled") @@ -53,11 +74,11 @@ selected_hud = "disabled" to_chat(user, SPAN_NOTICE("You deactivate \the [src].")) -/obj/item/organ/internal/augment/eye_sensors/security/process() - ..() +/obj/item/organ/internal/augment/eye_sensors/security/handle_vision_update(mob/living/carbon/human/H) + if(!owner) + return switch(selected_hud) - if(SEC_HUDTYPE) req_access = list(ACCESS_SECURITY) if(allowed(owner)) @@ -72,7 +93,7 @@ name = "integrated medical HUD sensors" action_button_name = "Toggle Medical Sensors" -/obj/item/organ/internal/augment/eye_sensors/medical/attack_self(var/mob/user) +/obj/item/organ/internal/augment/eye_sensors/medical/attack_self(mob/user) . = ..() if(selected_hud == "disabled") @@ -82,8 +103,9 @@ selected_hud = "disabled" to_chat(user, SPAN_NOTICE("You deactivate \the [src].")) -/obj/item/organ/internal/augment/eye_sensors/medical/process() - ..() +/obj/item/organ/internal/augment/eye_sensors/medical/handle_vision_update(mob/living/carbon/human/H) + if(!owner) + return switch(selected_hud) diff --git a/code/modules/organs/subtypes/augment/augments/phalanx_facial_plate.dm b/code/modules/organs/subtypes/augment/augments/phalanx_facial_plate.dm index 729f1705979..55001d62d00 100644 --- a/code/modules/organs/subtypes/augment/augments/phalanx_facial_plate.dm +++ b/code/modules/organs/subtypes/augment/augments/phalanx_facial_plate.dm @@ -29,8 +29,9 @@ to_chat(user, "You deactivate \the [src].") return -/obj/item/organ/internal/augment/eye_sensors/phalanx/process() - ..() +/obj/item/organ/internal/augment/eye_sensors/phalanx/handle_vision_update(mob/living/carbon/human/H) + if(!owner) + return switch(selected_hud) if(SEC_HUDTYPE) diff --git a/html/changelogs/hellfirejag-implant-hud-fix.yml b/html/changelogs/hellfirejag-implant-hud-fix.yml new file mode 100644 index 00000000000..8947aea5c79 --- /dev/null +++ b/html/changelogs/hellfirejag-implant-hud-fix.yml @@ -0,0 +1,5 @@ +author: Hellfirejag +delete-after: True +changes: + - bugfix: "Fixed implanted medical and security huds flickering." + - rscadd: "Components and Implants can now add hud elements via signals."