Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIRROR] makes verb callbacks not execute if the original client disconnected #861

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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


Loading