mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-04 05:51:54 +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>
63 lines
2.1 KiB
Plaintext
63 lines
2.1 KiB
Plaintext
|
|
#define PUNISHMENT_MURDER "murder"
|
|
#define PUNISHMENT_GIB "gib"
|
|
#define PUNISHMENT_TELEPORT "teleport"
|
|
|
|
//very similar to stationloving, but more made for mobs and not objects. used on derelict drones currently
|
|
|
|
|
|
/*
|
|
This component is similar to stationloving in that it is meant to keep something on the z-level
|
|
The difference is that stationloving is for objects and stationstuck is for mobs.
|
|
It has a punishment variable that is what happens to the parent when they leave the z-level. See punish() documentation
|
|
*/
|
|
/datum/component/stationstuck
|
|
dupe_mode = COMPONENT_DUPE_UNIQUE_PASSARGS
|
|
var/punishment = PUNISHMENT_GIB //see defines above
|
|
var/stuck_zlevel
|
|
var/message = ""
|
|
|
|
/datum/component/stationstuck/Initialize(_punishment = PUNISHMENT_GIB, _message = "")
|
|
if(!isliving(parent))
|
|
return COMPONENT_INCOMPATIBLE
|
|
var/mob/living/L = parent
|
|
RegisterSignal(L, list(COMSIG_MOVABLE_Z_CHANGED), .proc/punish)
|
|
punishment = _punishment
|
|
message = _message
|
|
stuck_zlevel = L.z
|
|
|
|
/datum/component/stationstuck/InheritComponent(datum/component/stationstuck/newc, original, _punishment, _message)
|
|
if(newc)
|
|
punishment = newc.punishment
|
|
message = newc.message
|
|
else
|
|
punishment = _punishment
|
|
message = _message
|
|
|
|
/**
|
|
* Called when parent leaves the zlevel this is set to (aka whichever zlevel it was on when it was added)
|
|
* Sends a message, then does an effect depending on what the punishment was.
|
|
*
|
|
* Punishments:
|
|
* * PUNISHMENT_MURDER: kills parent
|
|
* * PUNISHMENT_GIB: gibs parent
|
|
* * PUNISHMENT_TELEPORT: finds a safe turf if possible, or a completely random one if not.
|
|
*/
|
|
/datum/component/stationstuck/proc/punish()
|
|
SIGNAL_HANDLER
|
|
|
|
var/mob/living/L = parent
|
|
if(message)
|
|
var/span = punishment == PUNISHMENT_TELEPORT ? "danger" : "userdanger"
|
|
to_chat(L, "<span class='[span]'>[message]</span>")
|
|
switch(punishment)
|
|
if(PUNISHMENT_MURDER)
|
|
L.death()
|
|
if(PUNISHMENT_GIB)
|
|
L.gib()
|
|
if(PUNISHMENT_TELEPORT)
|
|
var/targetturf = find_safe_turf(stuck_zlevel)
|
|
if(!targetturf)
|
|
targetturf = locate(world.maxx/2,world.maxy/2,stuck_zlevel)
|
|
L.forceMove(targetturf)
|