mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-19 22:23:11 +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>
60 lines
2.1 KiB
Plaintext
60 lines
2.1 KiB
Plaintext
/datum/component/art
|
|
var/impressiveness = 0
|
|
|
|
/datum/component/art/Initialize(impress)
|
|
impressiveness = impress
|
|
if(isobj(parent))
|
|
RegisterSignal(parent, COMSIG_PARENT_EXAMINE, .proc/on_obj_examine)
|
|
else
|
|
RegisterSignal(parent, COMSIG_PARENT_EXAMINE, .proc/on_other_examine)
|
|
if(isstructure(parent))
|
|
RegisterSignal(parent, COMSIG_ATOM_ATTACK_HAND, .proc/on_attack_hand)
|
|
if(isitem(parent))
|
|
RegisterSignal(parent, COMSIG_ITEM_ATTACK_SELF, .proc/apply_moodlet)
|
|
|
|
/datum/component/art/proc/apply_moodlet(mob/M, impress)
|
|
SIGNAL_HANDLER
|
|
|
|
M.visible_message("<span class='notice'>[M] stops and looks intently at [parent].</span>", \
|
|
"<span class='notice'>You stop to take in [parent].</span>")
|
|
switch(impress)
|
|
if (0 to BAD_ART)
|
|
SEND_SIGNAL(M, COMSIG_ADD_MOOD_EVENT, "artbad", /datum/mood_event/artbad)
|
|
if (BAD_ART to GOOD_ART)
|
|
SEND_SIGNAL(M, COMSIG_ADD_MOOD_EVENT, "artok", /datum/mood_event/artok)
|
|
if (GOOD_ART to GREAT_ART)
|
|
SEND_SIGNAL(M, COMSIG_ADD_MOOD_EVENT, "artgood", /datum/mood_event/artgood)
|
|
if(GREAT_ART to INFINITY)
|
|
SEND_SIGNAL(M, COMSIG_ADD_MOOD_EVENT, "artgreat", /datum/mood_event/artgreat)
|
|
|
|
|
|
/datum/component/art/proc/on_other_examine(datum/source, mob/M)
|
|
SIGNAL_HANDLER
|
|
|
|
apply_moodlet(M, impressiveness)
|
|
|
|
/datum/component/art/proc/on_obj_examine(datum/source, mob/M)
|
|
SIGNAL_HANDLER
|
|
|
|
var/obj/O = parent
|
|
apply_moodlet(M, impressiveness *(O.obj_integrity/O.max_integrity))
|
|
|
|
/datum/component/art/proc/on_attack_hand(datum/source, mob/M)
|
|
SIGNAL_HANDLER_DOES_SLEEP
|
|
|
|
to_chat(M, "<span class='notice'>You start examining [parent]...</span>")
|
|
if(!do_after(M, 20, target = parent))
|
|
return
|
|
on_obj_examine(source, M)
|
|
|
|
/datum/component/art/rev
|
|
|
|
/datum/component/art/rev/apply_moodlet(mob/M, impress)
|
|
M.visible_message("<span class='notice'>[M] stops to inspect [parent].</span>", \
|
|
"<span class='notice'>You take in [parent], inspecting the fine craftsmanship of the proletariat.</span>")
|
|
|
|
if(M.mind && M.mind.has_antag_datum(/datum/antagonist/rev))
|
|
SEND_SIGNAL(M, COMSIG_ADD_MOOD_EVENT, "artgreat", /datum/mood_event/artgreat)
|
|
else
|
|
SEND_SIGNAL(M, COMSIG_ADD_MOOD_EVENT, "artbad", /datum/mood_event/artbad)
|