mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-09 07:46:20 +00:00
* makes verb callbacks not execute if the original client disconnected (#79964) ## About The Pull Request currently verb callbacks still execute if the usr at the time of their creation got deleted or had their client disconnected before they got invoked. this can cause issues if the verb being deferred assumes usr exists, now the callback will return instead of calling its proc if its invoked after usr is deleted or disconnected. ## Why It's Good For The Game less runtimes ## Changelog 🆑 code: verb callbacks will no longer execute if the original client disconnected /🆑 --------- Co-authored-by: san7890 <the@ san7890.com> * makes verb callbacks not execute if the original client disconnected --------- Co-authored-by: Kylerace <kylerlumpkin1@gmail.com> Co-authored-by: san7890 <the@ san7890.com>
30 lines
855 B
Plaintext
30 lines
855 B
Plaintext
///like normal callbacks but they also record their creation time for measurement purposes
|
|
///they also require the same usr/user that made the callback to both still exist and to still have a client in order to execute
|
|
/datum/callback/verb_callback
|
|
///the tick this callback datum was created in. used for testing latency
|
|
var/creation_time = 0
|
|
|
|
/datum/callback/verb_callback/New(thingtocall, proctocall, ...)
|
|
creation_time = DS2TICKS(world.time)
|
|
. = ..()
|
|
|
|
#ifndef UNIT_TESTS
|
|
/datum/callback/verb_callback/Invoke(...)
|
|
var/mob/our_user = user?.resolve()
|
|
if(QDELETED(our_user) || isnull(our_user.client))
|
|
return
|
|
var/mob/temp = usr
|
|
. = ..()
|
|
usr = temp
|
|
|
|
/datum/callback/verb_callback/InvokeAsync(...)
|
|
var/mob/our_user = user?.resolve()
|
|
if(QDELETED(our_user) || isnull(our_user.client))
|
|
return
|
|
var/mob/temp = usr
|
|
. = ..()
|
|
usr = temp
|
|
#endif
|
|
|
|
|