mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-09 16:33:50 +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>
47 lines
1.7 KiB
Plaintext
47 lines
1.7 KiB
Plaintext
/datum/component/magnetic_catch/Initialize()
|
|
if(!isatom(parent))
|
|
return COMPONENT_INCOMPATIBLE
|
|
RegisterSignal(parent, COMSIG_PARENT_EXAMINE, .proc/examine)
|
|
if(ismovable(parent))
|
|
RegisterSignal(parent, COMSIG_MOVABLE_CROSSED, .proc/crossed_react)
|
|
RegisterSignal(parent, COMSIG_MOVABLE_UNCROSSED, .proc/uncrossed_react)
|
|
for(var/i in get_turf(parent))
|
|
if(i == parent)
|
|
continue
|
|
RegisterSignal(i, COMSIG_MOVABLE_PRE_THROW, .proc/throw_react)
|
|
else
|
|
RegisterSignal(parent, COMSIG_ATOM_ENTERED, .proc/entered_react)
|
|
RegisterSignal(parent, COMSIG_ATOM_EXITED, .proc/exited_react)
|
|
for(var/i in parent)
|
|
RegisterSignal(i, COMSIG_MOVABLE_PRE_THROW, .proc/throw_react)
|
|
|
|
/datum/component/magnetic_catch/proc/examine(datum/source, mob/user, list/examine_list)
|
|
SIGNAL_HANDLER
|
|
|
|
examine_list += "It has been installed with inertia dampening to prevent coffee spills."
|
|
|
|
/datum/component/magnetic_catch/proc/crossed_react(datum/source, atom/movable/thing)
|
|
SIGNAL_HANDLER
|
|
|
|
RegisterSignal(thing, COMSIG_MOVABLE_PRE_THROW, .proc/throw_react, TRUE)
|
|
|
|
/datum/component/magnetic_catch/proc/uncrossed_react(datum/source, atom/movable/thing)
|
|
SIGNAL_HANDLER
|
|
|
|
UnregisterSignal(thing, COMSIG_MOVABLE_PRE_THROW)
|
|
|
|
/datum/component/magnetic_catch/proc/entered_react(datum/source, atom/movable/thing, atom/oldloc)
|
|
SIGNAL_HANDLER
|
|
|
|
RegisterSignal(thing, COMSIG_MOVABLE_PRE_THROW, .proc/throw_react, TRUE)
|
|
|
|
/datum/component/magnetic_catch/proc/exited_react(datum/source, atom/movable/thing, atom/newloc)
|
|
SIGNAL_HANDLER
|
|
|
|
UnregisterSignal(thing, COMSIG_MOVABLE_PRE_THROW)
|
|
|
|
/datum/component/magnetic_catch/proc/throw_react(datum/source, list/arguments)
|
|
SIGNAL_HANDLER
|
|
|
|
return COMPONENT_CANCEL_THROW
|