From 5cbd17b6f90a4e04e05c50d198bbafc4739bbf0e Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Sat, 3 Jul 2021 23:23:16 +0200 Subject: [PATCH] [MIRROR] Fix blanket cure_blind calls removing quirk and blindfold traits (#6673) * Fix blanket cure_blind calls removing quirk and blindfold traits (#59943) Makes it so when proc/cure_blind(source) is called with no source is does not cure blindness from the quirk, blindfolds, or other eye coverings. * Fix blanket cure_blind calls removing quirk and blindfold traits Co-authored-by: Wayland-Smithy <64715958+Wayland-Smithy@users.noreply.github.com> --- code/__DEFINES/traits.dm | 24 ++++++++++++++++++++++++ code/modules/mob/living/status_procs.dm | 5 ++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/code/__DEFINES/traits.dm b/code/__DEFINES/traits.dm index 3b2cc98097d..126b0b144ee 100644 --- a/code/__DEFINES/traits.dm +++ b/code/__DEFINES/traits.dm @@ -44,6 +44,30 @@ }; \ } \ } while (0) +#define REMOVE_TRAIT_NOT_FROM(target, trait, sources) \ + do { \ + var/list/_traits_list = target.status_traits; \ + var/list/_sources_list; \ + if (sources && !islist(sources)) { \ + _sources_list = list(sources); \ + } else { \ + _sources_list = sources\ + }; \ + if (_traits_list && _traits_list[trait]) { \ + for (var/_trait_source in _traits_list[trait]) { \ + if (!(_trait_source in _sources_list)) { \ + _traits_list[trait] -= _trait_source \ + } \ + };\ + if (!length(_traits_list[trait])) { \ + _traits_list -= trait; \ + SEND_SIGNAL(target, SIGNAL_REMOVETRAIT(trait), trait); \ + }; \ + if (!length(_traits_list)) { \ + target.status_traits = null \ + }; \ + } \ + } while (0) #define REMOVE_TRAITS_NOT_IN(target, sources) \ do { \ var/list/_L = target.status_traits; \ diff --git a/code/modules/mob/living/status_procs.dm b/code/modules/mob/living/status_procs.dm index 6e38ececef1..7cca1bc5d2c 100644 --- a/code/modules/mob/living/status_procs.dm +++ b/code/modules/mob/living/status_procs.dm @@ -450,7 +450,10 @@ /////////////////////////////////// TRAIT PROCS //////////////////////////////////// /mob/living/proc/cure_blind(source) - REMOVE_TRAIT(src, TRAIT_BLIND, source) + if(source) + REMOVE_TRAIT(src, TRAIT_BLIND, source) + else + REMOVE_TRAIT_NOT_FROM(src, TRAIT_BLIND, list(QUIRK_TRAIT, EYES_COVERED, BLINDFOLD_TRAIT)) if(!HAS_TRAIT(src, TRAIT_BLIND)) update_blindness()