mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-29 19:11:51 +00:00
* Adds SIGNAL_HANDLER and SIGNAL_HANDLER_DOES_SLEEP to prevent signal callbacks from blocking (#52761) Adds SIGNAL_HANDLER, a macro that sets SHOULD_NOT_SLEEP(TRUE). This should ideally be required on all new signal callbacks. Adds BLOCKING_SIGNAL_HANDLER, a macro that does nothing except symbolize "this is an older signal that didn't necessitate a code rewrite". It should not be allowed for new work. This comes from discussion around #52735, which yields by calling input, and (though it sets the return type beforehand) will not properly return the flag to prevent attack from slapping. To fix 60% of the yielding cases, WrapAdminProcCall no longer waits for another admin's proc call to finish. I'm not an admin, so I don't know how many behinds this has saved, but if this is problematic for admins I can just make it so that it lets you do it anyway. I'm not sure what the point of this babysitting was anyway. Requested by @optimumtact. Changelog cl admin: Calling a proc while another admin is calling one will no longer wait for the first to finish. You will simply just have to call it again. /cl * Adds SIGNAL_HANDLER and SIGNAL_HANDLER_DOES_SLEEP to prevent signal callbacks from blocking Co-authored-by: Jared-Fogle <35135081+Jared-Fogle@users.noreply.github.com>
56 lines
1.9 KiB
Plaintext
56 lines
1.9 KiB
Plaintext
/datum/element/digitalcamo
|
|
element_flags = ELEMENT_DETACH
|
|
var/list/attached_mobs = list()
|
|
|
|
/datum/element/digitalcamo/New()
|
|
. = ..()
|
|
START_PROCESSING(SSdcs, src)
|
|
|
|
/datum/element/digitalcamo/Attach(datum/target)
|
|
. = ..()
|
|
if(!isliving(target) || (target in attached_mobs))
|
|
return ELEMENT_INCOMPATIBLE
|
|
RegisterSignal(target, COMSIG_PARENT_EXAMINE, .proc/on_examine)
|
|
RegisterSignal(target, COMSIG_LIVING_CAN_TRACK, .proc/can_track)
|
|
var/image/img = image(loc = target)
|
|
img.override = TRUE
|
|
attached_mobs[target] = img
|
|
HideFromAIHuds(target)
|
|
|
|
/datum/element/digitalcamo/Detach(datum/target)
|
|
. = ..()
|
|
UnregisterSignal(target, list(COMSIG_PARENT_EXAMINE, COMSIG_LIVING_CAN_TRACK))
|
|
for(var/mob/living/silicon/ai/AI in GLOB.player_list)
|
|
AI.client.images -= attached_mobs[target]
|
|
attached_mobs -= target
|
|
UnhideFromAIHuds(target)
|
|
|
|
/datum/element/digitalcamo/proc/HideFromAIHuds(mob/living/target)
|
|
for(var/mob/living/silicon/ai/AI in GLOB.ai_list)
|
|
var/datum/atom_hud/M = GLOB.huds[AI.med_hud]
|
|
M.hide_single_atomhud_from(AI,target)
|
|
var/datum/atom_hud/S = GLOB.huds[AI.sec_hud]
|
|
S.hide_single_atomhud_from(AI,target)
|
|
|
|
/datum/element/digitalcamo/proc/UnhideFromAIHuds(mob/living/target)
|
|
for(var/mob/living/silicon/ai/AI in GLOB.ai_list)
|
|
var/datum/atom_hud/M = GLOB.huds[AI.med_hud]
|
|
M.unhide_single_atomhud_from(AI,target)
|
|
var/datum/atom_hud/S = GLOB.huds[AI.sec_hud]
|
|
S.unhide_single_atomhud_from(AI,target)
|
|
|
|
/datum/element/digitalcamo/proc/on_examine(datum/source, mob/M)
|
|
SIGNAL_HANDLER
|
|
|
|
to_chat(M, "<span class = 'warning'>[source.p_their()] skin seems to be shifting and morphing like is moving around below it.</span>")
|
|
|
|
/datum/element/digitalcamo/proc/can_track(datum/source)
|
|
SIGNAL_HANDLER
|
|
|
|
return COMPONENT_CANT_TRACK
|
|
|
|
/datum/element/digitalcamo/process()
|
|
for(var/mob/living/silicon/ai/AI in GLOB.player_list)
|
|
for(var/mob in attached_mobs)
|
|
AI.client.images |= attached_mobs[mob]
|