Skip to content

Commit

Permalink
[MIRROR] makes verb callbacks not execute if the original client disc…
Browse files Browse the repository at this point in the history
…onnected [MDB IGNORE] (#25287)

* 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
:cl:
code: verb callbacks will no longer execute if the original client
disconnected
/:cl:

---------

Co-authored-by: san7890 <the@ san7890.com>

* makes verb callbacks not execute if the original client disconnected

---------

Co-authored-by: Kylerace <[email protected]>
Co-authored-by: san7890 <the@ san7890.com>
  • Loading branch information
3 people authored and FFMirrorBot committed Nov 28, 2023
1 parent 87a3362 commit 0e88280
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
8 changes: 5 additions & 3 deletions code/controllers/subsystem/verb_manager.dm
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,15 @@ SUBSYSTEM_DEF(verb_manager)
incoming_callback.user = WEAKREF(incoming_callback.object)
var/datum/callback/new_us = CALLBACK(arglist(list(GLOBAL_PROC, GLOBAL_PROC_REF(_queue_verb)) + args.Copy()))
return world.push_usr(incoming_callback.object, new_us)
#endif

//debatable whether this is needed, this is just to try and ensure that you dont use this to queue stuff that isnt from player input.
if(QDELETED(usr))
#else

if(QDELETED(usr) || isnull(usr.client))
stack_trace("_queue_verb() returned false because it wasnt called from player input!")
return FALSE

#endif

if(!istype(subsystem_to_use))
stack_trace("_queue_verb() returned false because it was given an invalid subsystem to queue for!")
return FALSE
Expand Down
21 changes: 21 additions & 0 deletions code/datums/verb_callbacks.dm
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
///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


0 comments on commit 0e88280

Please sign in to comment.