From aa44dfee3989ccb2315dfe7d7b318d8a65e824f1 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Tue, 24 Oct 2023 20:40:58 +0200 Subject: [PATCH] [MIRROR] Precalculates special list var names and avoids incorrect vv targets [MDB IGNORE] (#24553) * Precalculates special list var names and avoids incorrect vv targets (#79154) ## About The Pull Request This adds a global list to precalculate lists that need to be handled special by vv instead of manually updating such a list. @ LemonInTheDark brought up a potential issue with handling all lists in the way special lists are handled, that modifying a list in vv can in some cases result in the wrong list being opened for editing. This makes only special lists have the issue instead of blindly accessing all lists the same way. * Precalculates special list var names and avoids incorrect vv targets --------- Co-authored-by: Emmett Gaines --- code/_globalvars/admin.dm | 16 ++++++++++++++++ .../admin/view_variables/debug_variables.dm | 11 ++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/code/_globalvars/admin.dm b/code/_globalvars/admin.dm index f614061366c..22c6f2de9e5 100644 --- a/code/_globalvars/admin.dm +++ b/code/_globalvars/admin.dm @@ -12,3 +12,19 @@ GLOBAL_VAR(stickbanadminexemptiontimerid) //stores the timerid of the callback t GLOBAL_LIST_INIT_TYPED(smites, /datum/smite, init_smites()) GLOBAL_VAR_INIT(admin_notice, "") // Admin notice that all clients see when joining the server + +// A list of all the special byond lists that need to be handled different by vv +GLOBAL_LIST_INIT(vv_special_lists, init_special_list_names()) + +/proc/init_special_list_names() + var/list/output = list() + var/obj/sacrifice = new + for(var/varname in sacrifice.vars) + var/value = sacrifice.vars[varname] + if(!islist(value)) + if(!isdatum(value) && hascall(value, "Cut")) + output[varname] = TRUE + continue + if(isnull(locate(REF(value)))) + output[varname] = TRUE + return output diff --git a/code/modules/admin/view_variables/debug_variables.dm b/code/modules/admin/view_variables/debug_variables.dm index ea119597ffa..01cc3953901 100644 --- a/code/modules/admin/view_variables/debug_variables.dm +++ b/code/modules/admin/view_variables/debug_variables.dm @@ -64,10 +64,15 @@ var/datum/datum_value = value return datum_value.debug_variable_value(name, level, owner, sanitize, display_flags) - if(islist(value) || hascall(value, "Cut")) // Some special lists arent detectable as a list through istype, so we check if it has a list proc instead + if(islist(value) || GLOB.vv_special_lists[name]) // Some special lists arent detectable as a list through istype var/list/list_value = value var/list/items = list() + // This is becuse some lists either dont count as lists or a locate on their ref will return null + var/link_vars = "Vars=[REF(value)]" + if(GLOB.vv_special_lists[name]) + link_vars = "Vars=[REF(owner)];special_varname=[name]" + if (!(display_flags & VV_ALWAYS_CONTRACT_LIST) && list_value.len > 0 && list_value.len <= (IS_NORMAL_LIST(list_value) ? VV_NORMAL_LIST_NO_EXPAND_THRESHOLD : VV_SPECIAL_LIST_NO_EXPAND_THRESHOLD)) for (var/i in 1 to list_value.len) var/key = list_value[i] @@ -80,9 +85,9 @@ items += debug_variable(key, val, level + 1, sanitize = sanitize) - return "/list ([list_value.len])" + return "/list ([list_value.len])" else - return "/list ([list_value.len])" + return "/list ([list_value.len])" if(name in GLOB.bitfields) var/list/flags = list()