From 9c9aa48b26e230fb535bf790729c93e86d95e3c4 Mon Sep 17 00:00:00 2001 From: Evildragon Date: Mon, 16 Sep 2024 20:22:59 +0900 Subject: [PATCH 01/11] vv filters and list refresh --- code/__DEFINES/is_helpers.dm | 2 +- code/__DEFINES/ref.dm | 9 ++++++ code/_globalvars/lists/admin.dm | 4 ++- .../admin/view_variables/debug_variables.dm | 32 +++++++++++++------ code/modules/admin/view_variables/topic.dm | 18 ++++++++--- .../admin/view_variables/view_variables.dm | 13 ++++++-- 6 files changed, 60 insertions(+), 18 deletions(-) diff --git a/code/__DEFINES/is_helpers.dm b/code/__DEFINES/is_helpers.dm index 2dd680c073300..65641cfc3dbf5 100644 --- a/code/__DEFINES/is_helpers.dm +++ b/code/__DEFINES/is_helpers.dm @@ -18,7 +18,7 @@ GLOBAL_VAR_INIT(magic_appearance_detecting_image, new /image) // appearances are // The filters list has the same ref type id as a filter, but isnt one and also isnt a list, so we have to check if the thing has Cut() instead GLOBAL_VAR_INIT(refid_filter, TYPEID(filter(type="angular_blur"))) -#define isfilter(thing) (!hascall(thing, "Cut") && TYPEID(thing) == GLOB.refid_filter) +#define isfilter(thing) (hascall(thing, "Cut") && TYPEID(thing) == GLOB.refid_filter) // simple check whether or not a player is a guest using their key #define IS_GUEST_KEY(key) (findtextEx(key, "Guest-", 1, 7)) diff --git a/code/__DEFINES/ref.dm b/code/__DEFINES/ref.dm index f5f7d59052227..5ad82fa246268 100644 --- a/code/__DEFINES/ref.dm +++ b/code/__DEFINES/ref.dm @@ -23,3 +23,12 @@ return "\[[url_encode(thing.tag)]\]" return CACHED_REF(thing) return "\ref[input]" + +// Note: +// some hardcoded byond references (like filters) are not possible to get back through locate(). +// If you try so, you'll get ref[0x0]. This macros are made for it. +#define REF_TEXT_0X0 ("\[0x0\]") +/// Checks if you can take back a reference through locate(). If locate() returns [0x0], it's not locatable +#define IS_REF_LOCATABLE(thing) (thing && (istext(thing) ? REF(locate(thing)) : REF(locate(REF(thing)))) != REF_TEXT_0X0) +/// Checks if locate() returns [0x0] +#define IS_REF_0X0(thing) (thing && ((istext(thing) ? thing : REF(thing)) == REF_TEXT_0X0)) diff --git a/code/_globalvars/lists/admin.dm b/code/_globalvars/lists/admin.dm index aa7075fd54dda..599da9b8b81f4 100644 --- a/code/_globalvars/lists/admin.dm +++ b/code/_globalvars/lists/admin.dm @@ -10,7 +10,9 @@ GLOBAL_LIST_INIT_TYPED(smite_list, /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()) +GLOBAL_LIST_INIT(vv_special_lists, list( + "images", "screen" // manually adding /client special lists +) + init_special_list_names()) /proc/init_special_list_names() var/list/output = list() diff --git a/code/modules/admin/view_variables/debug_variables.dm b/code/modules/admin/view_variables/debug_variables.dm index 6643b8f698069..c7a39f3fa381c 100644 --- a/code/modules/admin/view_variables/debug_variables.dm +++ b/code/modules/admin/view_variables/debug_variables.dm @@ -57,9 +57,9 @@ var/image/image = value return "[image.type] ([get_appearance_vv_summary_name(image)]) [REF(value)]" - if(isfilter(value)) - var/datum/filter_value = value - return "/filter ([filter_value.type] [REF(filter_value)])" + var/isfilter = isfilter(value) + if(isfilter && !isdatum(owner) && !isappearance(owner)) // each filter in atom.filters + return "/filter ([value:type])" if(isfile(value)) return "'[value]'" @@ -68,17 +68,29 @@ var/datum/datum_value = value return datum_value.debug_variable_value(name, level, owner, sanitize, display_flags) + // list debug if(islist(value) || (name in GLOB.vv_special_lists)) // 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)]" + // Saves a list name format + var/is_special_list if(name in GLOB.vv_special_lists) - link_vars = "Vars=[REF(owner)];special_varname=[name]" + is_special_list = "special_" + var/special_list_name_holder = isfilter ? ":filters" : null + + // This is becuse some lists either dont count as lists or a locate on their ref will return null + var/link_vars = is_special_list ? "Vars=[REF(owner)];special_varname=[name]" : "Vars=[REF(value)]" + + // checks if a list is safe to open. atom/filters does very weird thing + var/is_unsafe_list = isfilter ? TRUE : FALSE + // do not make a href hyperlink to open a list if it's not safe. filters aren't recommended to open + var/a_open = is_unsafe_list ? null : "" + var/a_close = is_unsafe_list ? null : "" - 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) + // Checks if it's too big to open, so it's gonna be folded, or not. If is_unsafe_list, it's always unfolded. + if (!(display_flags & VV_ALWAYS_CONTRACT_LIST) && length(list_value) > 0 && length(list_value) <= (IS_NORMAL_LIST(list_value) ? VV_NORMAL_LIST_NO_EXPAND_THRESHOLD : VV_SPECIAL_LIST_NO_EXPAND_THRESHOLD) || is_unsafe_list) + for (var/i in 1 to length(list_value)) var/key = list_value[i] var/val if (IS_NORMAL_LIST(list_value) && !isnum(key)) @@ -89,9 +101,9 @@ items += debug_variable(key, val, level + 1, sanitize = sanitize) - return "/list ([list_value.len])" + return "[a_open]/[is_special_list]list[special_list_name_holder] ([length(list_value)])[a_close]" else - return "/list ([list_value.len])" + return "[a_open]/[is_special_list]list[special_list_name_holder] ([length(list_value)])[a_close]" if(name in GLOB.bitfields) var/list/flags = list() diff --git a/code/modules/admin/view_variables/topic.dm b/code/modules/admin/view_variables/topic.dm index f753221828cea..965f2a1ada4a7 100644 --- a/code/modules/admin/view_variables/topic.dm +++ b/code/modules/admin/view_variables/topic.dm @@ -126,7 +126,17 @@ //Finally, refresh if something modified the list. if(href_list["datumrefresh"]) - var/datum/DAT = locate(href_list["datumrefresh"]) - if(istype(DAT, /datum) || istype(DAT, /client)) - debug_variables(DAT) - + var/datum/datum_ref = locate(href_list["datumrefresh"]) // note: this can't track 'list ref' + if(datum_ref) + debug_variables(datum_ref) + return + + // For list, or some special byond list + var/real_ref = locate(href_list["datumrefresh"]) + if(real_ref && !IS_REF_0X0(real_ref)) // some reference is not possible to recover + GLOB.vv_ghost.tag = real_ref + debug_variables(GLOB.vv_ghost) // the proc blames if it doesn't take an actual datum. We send a fake datum, by letting datum.tag hold the real reference. + GLOB.vv_ghost.tag = null + return + +GLOBAL_DATUM(vv_ghost, /datum) // Fake datum for vv debug_variables() proc. Am I real? diff --git a/code/modules/admin/view_variables/view_variables.dm b/code/modules/admin/view_variables/view_variables.dm index a330c337b7fa1..1d61e8b5275e3 100644 --- a/code/modules/admin/view_variables/view_variables.dm +++ b/code/modules/admin/view_variables/view_variables.dm @@ -14,6 +14,10 @@ if(!thing) return + if(thing == GLOB.vv_ghost && GLOB.vv_ghost.tag) + thing = GLOB.vv_ghost.tag + GLOB.vv_ghost = null + var/datum/asset/asset_cache_datum = get_asset_datum(/datum/asset/simple/vv) asset_cache_datum.send(usr) @@ -133,6 +137,8 @@ if(thing.can_vv_get(varname)) variable_html += thing.vv_get_var(varname) + var/ref_locatable = IS_REF_LOCATABLE(refid) + var/html = {" @@ -261,8 +267,11 @@
- Refresh + [\ + ref_locatable \ + ? "Refresh" \ + : "Not-refreshable" \ + ]
"} + vv_spectre.reset() src << browse(html, "window=variables[refid];size=475x650") /client/proc/vv_update_display(datum/thing, span, content) diff --git a/code/modules/admin/view_variables/vv_ghost.dm b/code/modules/admin/view_variables/vv_ghost.dm new file mode 100644 index 0000000000000..1248122aacb63 --- /dev/null +++ b/code/modules/admin/view_variables/vv_ghost.dm @@ -0,0 +1,82 @@ +GLOBAL_DATUM_INIT(vv_ghost, /datum/vv_ghost, new) // Fake datum for vv debug_variables() proc. Am I real? + +/* < What the hell is this vv_ghost? > + Our view-variables client proc doesn't like to investigate + a non-standard special list like client/images, because these are not a datum. + vv_ghost works like a fake datum for those special lists. + +*/ + +/datum/vv_ghost + /// Reference ID of a thing. + var/special_owner + /// which var of the reference you're s eeing + var/special_varname + /// an actual ref from above (= owner:vars[special_varname]) + var/special_ref + /// a list ref that isn't special + var/list_ref + + var/ready_to_del + +/datum/vv_ghost/New() + var/static/creation_count = 2 // to prevent something bullshit + + if(creation_count) + creation_count-- + ..() + return + + else + stack_trace("vv_ghost is not meant to be created more than 2 in the current logic. One for GLOB, one for vv internal") + ready_to_del = TRUE + qdel(src) + +/datum/vv_ghost/Destroy(force = FALSE) + if(ready_to_del || force) + reset() + return ..() + + stack_trace("Something breaks view-variables debugging tool... Check something.") + return QDEL_HINT_LETMELIVE + +/datum/vv_ghost/proc/mark_special(owner, varname) + if(special_owner) + CRASH("vv_ghost has special_owner already: [special_owner]. It can be async issue.") + if(special_varname) + CRASH("vv_ghost has special_varname already: [special_varname]. It can be async issue.") + special_owner = owner + special_varname = varname + +/datum/vv_ghost/proc/mark_list_ref(actual_list) + if(list_ref) + CRASH("vv_ghost has list_ref already: [list_ref]. It can be async issue.") + list_ref = actual_list + +/// a proc that delivers values to vv_spectre (internal static one). +/// vv_spectre exists to prevent async error, just in case +/datum/vv_ghost/proc/deliver_special() + if(GLOB.vv_ghost == src) + CRASH("This proc isn't meant be called from GLOB one.") + + special_owner = GLOB.vv_ghost.special_owner // = [0x123456] + special_varname = GLOB.vv_ghost.special_varname // = "vis_contents" + GLOB.vv_ghost.special_owner = null + GLOB.vv_ghost.special_varname = null + + special_ref = locate(special_owner) // = Clown [0x123456] + special_ref = special_ref:vars[special_varname] // = Clown.vis_contents + return special_ref + +/// a proc that delivers values to vv_spectre (internal static one). +/// vv_spectre exists to prevent async error, just in case +/datum/vv_ghost/proc/deliver_list_ref() + if(GLOB.vv_ghost == src) + CRASH("This proc isn't meant be called from GLOB one.") + + var/return_target = GLOB.vv_ghost.list_ref + GLOB.vv_ghost.list_ref = null + return return_target + +/datum/vv_ghost/proc/reset() + special_owner = special_varname = special_ref = list_ref = null From b7b96adee26c1d09327fd0a4b5388f34727c1600 Mon Sep 17 00:00:00 2001 From: Evildragon Date: Wed, 18 Sep 2024 21:42:02 +0900 Subject: [PATCH 03/11] Fixes some possible bug cases --- code/modules/admin/view_variables/debug_variables.dm | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/code/modules/admin/view_variables/debug_variables.dm b/code/modules/admin/view_variables/debug_variables.dm index 8c6da9ca02e93..2a2d9382ca764 100644 --- a/code/modules/admin/view_variables/debug_variables.dm +++ b/code/modules/admin/view_variables/debug_variables.dm @@ -2,12 +2,11 @@ /// Get displayed variable in VV variable list /proc/debug_variable(name, value, level, datum/owner, sanitize = TRUE, display_flags = NONE) //if D is a list, name will be index, and value will be assoc value. // variables to store values - var/read_only = CHECK_BITFIELD(display_flags, VV_READ_ONLY) var/index var/list/owner_list var/datum/vv_ghost/vv_spectre - // checks if a thing is /list or /vv_ghost to deliver a special list + // checks if a thing is /list, or /vv_ghost to deliver a special list, and then reassign name/value if(owner) if(istype(owner, /datum/vv_ghost)) vv_spectre = owner @@ -20,7 +19,7 @@ value = owner_list[name] // Builds text for single letter actions - if(read_only) + if(CHECK_BITFIELD(display_flags, VV_READ_ONLY)) . = "
  • (READ ONLY) " else if(vv_spectre) . = "
  • ([VV_HREF_SPECIAL(vv_spectre.special_owner, VV_HK_LIST_EDIT, "E", index, vv_spectre.special_varname)]) ([VV_HREF_SPECIAL(vv_spectre.special_owner, VV_HK_LIST_CHANGE, "C", index, vv_spectre.special_varname)]) ([VV_HREF_SPECIAL(vv_spectre.special_owner, VV_HK_LIST_REMOVE, "-", index, vv_spectre.special_varname)]) " @@ -85,7 +84,7 @@ return datum_value.debug_variable_value(name, level, owner, sanitize, display_flags) // list debug - var/special_list_level = istext(name) ? GLOB.vv_special_lists[name] : null + var/special_list_level = (istext(name) && isdatum(owner)) ? GLOB.vv_special_lists[name] : null if(islist(value) || special_list_level) // Some special lists arent detectable as a list through istype var/list/list_value = value var/list/items = list() @@ -99,7 +98,6 @@ else list_name = "special_list" - // checks if a list is safe to open. Some special list does very weird thing var/is_unsafe_list = (special_list_level == VV_LIST_PROTECTED) || isappearance(owner) // This is becuse some lists either dont count as lists or a locate on their ref will return null From f1fcdc1feeb1f06586514ad3695aae8ae93b98d4 Mon Sep 17 00:00:00 2001 From: EvilDragonfiend <87972842+EvilDragonfiend@users.noreply.github.com> Date: Wed, 18 Sep 2024 23:06:50 +0900 Subject: [PATCH 04/11] Removes outdated comment --- code/__DEFINES/vv.dm | 1 - 1 file changed, 1 deletion(-) diff --git a/code/__DEFINES/vv.dm b/code/__DEFINES/vv.dm index 987d8e2fd84e9..30e89032b5dea 100644 --- a/code/__DEFINES/vv.dm +++ b/code/__DEFINES/vv.dm @@ -191,7 +191,6 @@ /// A list of all the special byond lists that need to be handled different by vv. /// manually adding var name is recommanded. -/// * TRUE = read_only / FALSE = can edit GLOBAL_LIST_INIT(vv_special_lists, list( // /datum "vars" = VV_LIST_READ_ONLY, // This is meant to be read-only From 616b38811969e36026f702d7cbee703e55e6fdf6 Mon Sep 17 00:00:00 2001 From: Evildragon Date: Thu, 19 Sep 2024 02:13:11 +0900 Subject: [PATCH 05/11] Cleans up code, fixes an error --- code/__DEFINES/ref.dm | 9 --------- code/__DEFINES/vv.dm | 5 ++++- code/modules/admin/view_variables/topic.dm | 4 ++-- code/modules/admin/view_variables/view_variables.dm | 1 - 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/code/__DEFINES/ref.dm b/code/__DEFINES/ref.dm index 287e3a1b7f8e8..f5f7d59052227 100644 --- a/code/__DEFINES/ref.dm +++ b/code/__DEFINES/ref.dm @@ -23,12 +23,3 @@ return "\[[url_encode(thing.tag)]\]" return CACHED_REF(thing) return "\ref[input]" - -// Note: -// some hardcoded byond references (like filters) are not possible to get back through locate(). -// If you try so, you'll get ref[0x0]. This macros are made for it. -#define REF_TEXT_0X0 ("\[0x0\]") -/// Checks if you can take back a reference through locate(). If locate() returns [0x0], it's not locatable. -#define IS_REF_LOCATABLE(thing) (thing && ((istext(thing) ? REF(locate(thing)) : REF(locate(REF(thing)))) != REF_TEXT_0X0)) // currently unusued -/// Checks if the current ref id is [0x0], without using locate(). -#define IS_REF_0X0(thing) (thing && ((istext(thing) ? thing : REF(thing)) == REF_TEXT_0X0)) diff --git a/code/__DEFINES/vv.dm b/code/__DEFINES/vv.dm index 987d8e2fd84e9..d3c8212c5e8bb 100644 --- a/code/__DEFINES/vv.dm +++ b/code/__DEFINES/vv.dm @@ -47,7 +47,7 @@ #define VV_HREF_TARGETREF_1V(targetref, href_key, text, varname) "[text]" //! Non-standard helper for special list vv. this doesn't use VV_HK_TARGET and REF because special list doesn't work in a sane sense. #define VV_HREF_SPECIAL(special_owner, href_action, text, list_index, special_varname) "[text]" -#define VV_HREF_SPECIAL_MENU(special_owner, href_action, special_varname) "?_src_=vars;[HrefToken()];[href_action]=TRUE;special_owner=[special_owner];special_varname=[special_varname]" +#define VV_HREF_SPECIAL_MENU(special_owner, href_action, special_varname) "?_src_=vars;[HrefToken()];[href_action]=TRUE;[VV_HK_DO_LIST_EDIT]=TRUE;special_owner=[special_owner];special_varname=[special_varname]" #define GET_VV_TARGET locate(href_list[VV_HK_TARGET]) #define GET_VV_VAR_TARGET href_list[VV_HK_VARNAME] @@ -74,6 +74,9 @@ #define VV_HK_LIST_SHUFFLE "listshuffle" #define VV_HK_LIST_SET_LENGTH "listlen" +// I exist alone here just for special list edit. God, why. +#define VV_HK_DO_LIST_EDIT "do_vv_list_edit" + // vv_do_basic() keys #define VV_HK_BASIC_EDIT "datumedit" #define VV_HK_BASIC_CHANGE "datumchange" diff --git a/code/modules/admin/view_variables/topic.dm b/code/modules/admin/view_variables/topic.dm index 47717eb6f60a9..f33c4117a236d 100644 --- a/code/modules/admin/view_variables/topic.dm +++ b/code/modules/admin/view_variables/topic.dm @@ -10,9 +10,9 @@ // for non-standard special list if(href_list["special_owner"]) var/special_owner = locate(href_list["special_owner"]) - if(IS_REF_0X0(special_owner) || !isdatum(special_owner)) + if(!isdatum(special_owner)) return - if(GET_VV_VAR_TARGET) + if(GET_VV_VAR_TARGET || href_list[VV_HK_DO_LIST_EDIT]) // if href_list["targetvar"] exists, we do vv_edit to list. if not, it's just viewing. vv_do_list(special_owner:vars[href_list["special_varname"]], href_list) GLOB.vv_ghost.mark_special(href_list["special_owner"], href_list["special_varname"]) vv_refresh_target = GLOB.vv_ghost diff --git a/code/modules/admin/view_variables/view_variables.dm b/code/modules/admin/view_variables/view_variables.dm index 5c36651b76283..3f2c252377fa6 100644 --- a/code/modules/admin/view_variables/view_variables.dm +++ b/code/modules/admin/view_variables/view_variables.dm @@ -117,7 +117,6 @@ "---", "Add Item" = VV_HREF_SPECIAL_MENU(vv_spectre.special_owner, VV_HK_LIST_ADD, vv_spectre.special_varname), "Remove Nulls" = VV_HREF_SPECIAL_MENU(vv_spectre.special_owner, VV_HK_LIST_ERASE_NULLS, vv_spectre.special_varname), - "Remove Dupes" = VV_HREF_SPECIAL_MENU(vv_spectre.special_owner, VV_HK_LIST_ERASE_DUPES, vv_spectre.special_varname), "Show VV To Player" = VV_HREF_SPECIAL_MENU(vv_spectre.special_owner, VV_HK_EXPOSE, vv_spectre.special_varname), "---" ) From d42081530ee1945f018bc1ae7f4288d59be1e522 Mon Sep 17 00:00:00 2001 From: EvilDragonfiend <87972842+EvilDragonfiend@users.noreply.github.com> Date: Thu, 19 Sep 2024 11:04:14 +0900 Subject: [PATCH 06/11] Update vv_ghost.dm (more documentation) --- code/modules/admin/view_variables/vv_ghost.dm | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/code/modules/admin/view_variables/vv_ghost.dm b/code/modules/admin/view_variables/vv_ghost.dm index 1248122aacb63..a96da987b5f69 100644 --- a/code/modules/admin/view_variables/vv_ghost.dm +++ b/code/modules/admin/view_variables/vv_ghost.dm @@ -1,10 +1,25 @@ GLOBAL_DATUM_INIT(vv_ghost, /datum/vv_ghost, new) // Fake datum for vv debug_variables() proc. Am I real? -/* < What the hell is this vv_ghost? > - Our view-variables client proc doesn't like to investigate - a non-standard special list like client/images, because these are not a datum. - vv_ghost works like a fake datum for those special lists. - +/* + < What the hell is this vv_ghost? > + Our view-variables client proc doesn't like to investigate. + This means `debug_variables(list_reference)` won't work, because it only wants /datum. + vv_ghost exists to trick the proc, by storing values to bypass /datum restriction of the proc. + but also, it exists to deliever some special list that isn't possible to get through locate(). + + < Can you just do `locate([0x0_list_ref_id])`? > + Only an ordinary /list is possible to be located through locate() + First, vv takes values from 'href' texts. + Of course, we can get ref_id of a special list, + BUT `locate(ref_id_of_special_list)` returns null. (only ordinary /list works this) + This is why we need to store 'special_owner', and 'special_varname' + We locate(special_owner), then access their special list from their var list. + => special_onwer:vars[special_varname] + + < Summary > + Two usages exist: + 1. Store a list_ref into this datum, to deliver the list into the vv debugging system. + 2. Store a datum's ref_id with target varname, to deliver the special list into the vv debugging system. */ /datum/vv_ghost @@ -13,10 +28,12 @@ GLOBAL_DATUM_INIT(vv_ghost, /datum/vv_ghost, new) // Fake datum for vv debug_var /// which var of the reference you're s eeing var/special_varname /// an actual ref from above (= owner:vars[special_varname]) - var/special_ref + var/special_ref // this exists to remember the actual special list reference for a while. + /// a list ref that isn't special var/list_ref + /// a failsafe variable var/ready_to_del /datum/vv_ghost/New() From b748a5e5ba171a2e31b74b4b4941a86ce0352e92 Mon Sep 17 00:00:00 2001 From: EvilDragonfiend <87972842+EvilDragonfiend@users.noreply.github.com> Date: Wed, 25 Sep 2024 15:31:01 +0900 Subject: [PATCH 07/11] adds comments to fix the weird error --- code/modules/admin/view_variables/vv_ghost.dm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/code/modules/admin/view_variables/vv_ghost.dm b/code/modules/admin/view_variables/vv_ghost.dm index a96da987b5f69..b716a204957ee 100644 --- a/code/modules/admin/view_variables/vv_ghost.dm +++ b/code/modules/admin/view_variables/vv_ghost.dm @@ -23,6 +23,7 @@ GLOBAL_DATUM_INIT(vv_ghost, /datum/vv_ghost, new) // Fake datum for vv debug_var */ /datum/vv_ghost + // variables for vv special list /// Reference ID of a thing. var/special_owner /// which var of the reference you're s eeing @@ -30,9 +31,12 @@ GLOBAL_DATUM_INIT(vv_ghost, /datum/vv_ghost, new) // Fake datum for vv debug_var /// an actual ref from above (= owner:vars[special_varname]) var/special_ref // this exists to remember the actual special list reference for a while. + + // variable for ordinary lists /// a list ref that isn't special var/list_ref + // variable for internal use only /// a failsafe variable var/ready_to_del From f06a1436cc71eff0b896947bea861c0236d4a097 Mon Sep 17 00:00:00 2001 From: EvilDragonfiend <87972842+EvilDragonfiend@users.noreply.github.com> Date: Wed, 25 Sep 2024 15:33:06 +0900 Subject: [PATCH 08/11] I have no idea why this throws that error --- code/modules/admin/view_variables/vv_ghost.dm | 35 ++++--------------- 1 file changed, 6 insertions(+), 29 deletions(-) diff --git a/code/modules/admin/view_variables/vv_ghost.dm b/code/modules/admin/view_variables/vv_ghost.dm index b716a204957ee..dd62d1cf51b05 100644 --- a/code/modules/admin/view_variables/vv_ghost.dm +++ b/code/modules/admin/view_variables/vv_ghost.dm @@ -1,43 +1,20 @@ GLOBAL_DATUM_INIT(vv_ghost, /datum/vv_ghost, new) // Fake datum for vv debug_variables() proc. Am I real? -/* - < What the hell is this vv_ghost? > - Our view-variables client proc doesn't like to investigate. - This means `debug_variables(list_reference)` won't work, because it only wants /datum. - vv_ghost exists to trick the proc, by storing values to bypass /datum restriction of the proc. - but also, it exists to deliever some special list that isn't possible to get through locate(). - - < Can you just do `locate([0x0_list_ref_id])`? > - Only an ordinary /list is possible to be located through locate() - First, vv takes values from 'href' texts. - Of course, we can get ref_id of a special list, - BUT `locate(ref_id_of_special_list)` returns null. (only ordinary /list works this) - This is why we need to store 'special_owner', and 'special_varname' - We locate(special_owner), then access their special list from their var list. - => special_onwer:vars[special_varname] - - < Summary > - Two usages exist: - 1. Store a list_ref into this datum, to deliver the list into the vv debugging system. - 2. Store a datum's ref_id with target varname, to deliver the special list into the vv debugging system. +/* < What the hell is this vv_ghost? > + Our view-variables client proc doesn't like to investigate + a non-standard special list like client/images, because these are not a datum. + vv_ghost works like a fake datum for those special lists. */ /datum/vv_ghost - // variables for vv special list - /// Reference ID of a thing. - var/special_owner + @@ -13,10 +28,12 @@ GLOBAL_DATUM_INIT(vv_ghost, /datum/vv_ghost, new) // Fake datum for vv debug_var /// which var of the reference you're s eeing var/special_varname /// an actual ref from above (= owner:vars[special_varname]) - var/special_ref // this exists to remember the actual special list reference for a while. - - - // variable for ordinary lists + var/special_ref /// a list ref that isn't special var/list_ref - // variable for internal use only - /// a failsafe variable var/ready_to_del /datum/vv_ghost/New() From aff5a2ac50aa8a2fb0ff0ee96e009bb0f2e0bf7b Mon Sep 17 00:00:00 2001 From: EvilDragonfiend <87972842+EvilDragonfiend@users.noreply.github.com> Date: Wed, 25 Sep 2024 15:34:20 +0900 Subject: [PATCH 09/11] wrong line --- code/modules/admin/view_variables/vv_ghost.dm | 1 - 1 file changed, 1 deletion(-) diff --git a/code/modules/admin/view_variables/vv_ghost.dm b/code/modules/admin/view_variables/vv_ghost.dm index dd62d1cf51b05..a771bd1d2efcb 100644 --- a/code/modules/admin/view_variables/vv_ghost.dm +++ b/code/modules/admin/view_variables/vv_ghost.dm @@ -7,7 +7,6 @@ GLOBAL_DATUM_INIT(vv_ghost, /datum/vv_ghost, new) // Fake datum for vv debug_var */ /datum/vv_ghost - @@ -13,10 +28,12 @@ GLOBAL_DATUM_INIT(vv_ghost, /datum/vv_ghost, new) // Fake datum for vv debug_var /// which var of the reference you're s eeing var/special_varname /// an actual ref from above (= owner:vars[special_varname]) From 1f965f4dc31d6465628844f9297047dc266fe677 Mon Sep 17 00:00:00 2001 From: Evildragon Date: Fri, 27 Sep 2024 20:27:11 +0900 Subject: [PATCH 10/11] trying to fix weird lint error --- code/modules/admin/view_variables/vv_ghost.dm | 33 ++++++++++++++++--- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/code/modules/admin/view_variables/vv_ghost.dm b/code/modules/admin/view_variables/vv_ghost.dm index a771bd1d2efcb..1ed23f68e1205 100644 --- a/code/modules/admin/view_variables/vv_ghost.dm +++ b/code/modules/admin/view_variables/vv_ghost.dm @@ -1,19 +1,42 @@ GLOBAL_DATUM_INIT(vv_ghost, /datum/vv_ghost, new) // Fake datum for vv debug_variables() proc. Am I real? -/* < What the hell is this vv_ghost? > - Our view-variables client proc doesn't like to investigate - a non-standard special list like client/images, because these are not a datum. - vv_ghost works like a fake datum for those special lists. +/* + < What the hell is this vv_ghost? > + Our view-variables client proc doesn't like to investigate. + This means `debug_variables(list_reference)` won't work, because it only wants /datum. + vv_ghost exists to trick the proc, by storing values to bypass /datum restriction of the proc. + but also, it exists to deliever some special list that isn't possible to get through locate(). + < Can you just do `locate([0x0_list_ref_id])`? > + Only an ordinary /list is possible to be located through locate() + First, vv takes values from 'href' texts. + Of course, we can get ref_id of a special list, + BUT `locate(ref_id_of_special_list)` returns null. (only ordinary /list works this) + This is why we need to store 'special_owner', and 'special_varname' + We locate(special_owner), then access their special list from their var list. + => special_onwer:vars[special_varname] + < Summary > + Two usages exist: + 1. Store a list_ref into this datum, to deliver the list into the vv debugging system. + 2. Store a datum's ref_id with target varname, to deliver the special list into the vv debugging system. */ /datum/vv_ghost + // --- variables for vv special list --- + /// Reference ID of a thing. + var/special_owner /// which var of the reference you're s eeing var/special_varname /// an actual ref from above (= owner:vars[special_varname]) - var/special_ref + var/special_ref // this exists to remember the actual special list reference for a while. + + + // --- variable for ordinary lists --- /// a list ref that isn't special var/list_ref + + // --- variable for internal use only --- + /// a failsafe variable var/ready_to_del /datum/vv_ghost/New() From 38d4bca86b2e3bc96d8319dfcbcddaebed0dd0c1 Mon Sep 17 00:00:00 2001 From: Evildragon Date: Fri, 27 Sep 2024 21:07:06 +0900 Subject: [PATCH 11/11] some fix --- code/modules/admin/view_variables/debug_variables.dm | 2 +- code/modules/admin/view_variables/view_variables.dm | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/code/modules/admin/view_variables/debug_variables.dm b/code/modules/admin/view_variables/debug_variables.dm index 2a2d9382ca764..e6c3d60252e30 100644 --- a/code/modules/admin/view_variables/debug_variables.dm +++ b/code/modules/admin/view_variables/debug_variables.dm @@ -12,7 +12,7 @@ vv_spectre = owner if(islist(owner) || vv_spectre) index = name - owner_list = vv_spectre.special_ref || owner + owner_list = vv_spectre?.special_ref || owner if (value) name = owner_list[name] //name is really the index until this line else diff --git a/code/modules/admin/view_variables/view_variables.dm b/code/modules/admin/view_variables/view_variables.dm index 3f2c252377fa6..4a1972a5a78ae 100644 --- a/code/modules/admin/view_variables/view_variables.dm +++ b/code/modules/admin/view_variables/view_variables.dm @@ -22,12 +22,12 @@ var/special_list_level /// protected level of special list var/is_vv_readonly /// checks if the special list is not vv editable, as read-only if(thing == GLOB.vv_ghost) - if(GLOB.vv_ghost.list_ref) - thing = vv_spectre.deliver_list_ref() - else if(GLOB.vv_ghost.special_owner) + if(GLOB.vv_ghost.special_owner) thing = vv_spectre.deliver_special() special_list_level = GLOB.vv_special_lists[vv_spectre.special_varname] is_vv_readonly = (special_list_level && (special_list_level != VV_LIST_EDITABLE)) ? VV_READ_ONLY : null + else if(GLOB.vv_ghost.list_ref) + thing = vv_spectre.deliver_list_ref() else return // vv_ghost is not meant to be vv'ed