diff --git a/code/__DEFINES/admin.dm b/code/__DEFINES/admin.dm index 55d836c34f4..7b6626411a1 100644 --- a/code/__DEFINES/admin.dm +++ b/code/__DEFINES/admin.dm @@ -144,6 +144,8 @@ GLOBAL_VAR_INIT(ghost_role_flags, (~0)) /// for asay pings, this is the index in the return list for [/proc/check_admin_pings] that contains the message modified with underlines for the spotted names #define ADMINSAY_PING_UNDERLINE_NAME_INDEX "!underlined_names" +/// for asay datum refs, this is the index in the return list for [/proc/check_memory_refs] that contains the message modified with underlines for the linked datums +#define ADMINSAY_LINK_DATUM_REF "!datum_ref" /// When passed in as the duration for ban_panel, will make the ban default to permanent #define BAN_PANEL_PERMANENT "permanent" diff --git a/code/__DEFINES/vv.dm b/code/__DEFINES/vv.dm index 0334870cf1a..5f9322eb00c 100644 --- a/code/__DEFINES/vv.dm +++ b/code/__DEFINES/vv.dm @@ -28,6 +28,7 @@ #define VV_WEAKREF "Weak Reference Datum" #define VV_MSG_MARKED "
Marked Object" +#define VV_MSG_TAGGED(num) "
Tagged Datum #[num]" #define VV_MSG_EDITED "
Var Edited" #define VV_MSG_DELETED "
Deleted" diff --git a/code/_globalvars/regexes.dm b/code/_globalvars/regexes.dm index 7e571576213..1902fed0d20 100644 --- a/code/_globalvars/regexes.dm +++ b/code/_globalvars/regexes.dm @@ -6,6 +6,7 @@ GLOBAL_DATUM_INIT(is_email, /regex, regex("\[a-z0-9_-]+@\[a-z0-9_-]+.\[a-z0-9_-] GLOBAL_DATUM_INIT(is_alphanumeric, /regex, regex("\[a-z0-9]+", "i")) GLOBAL_DATUM_INIT(is_punctuation, /regex, regex("\[.!?]+", "i")) GLOBAL_DATUM_INIT(is_color, /regex, regex("^#\[0-9a-fA-F]{6}$")) +GLOBAL_DATUM_INIT(is_memref, /regex, regex("0x\[0-9a-fA-F\]{7,8}")) //finds text strings recognized as links on discord. Mainly used to stop embedding. GLOBAL_DATUM_INIT(has_discord_embeddable_links, /regex, regex("(https?://\[^\\s|<\]{2,})")) diff --git a/code/modules/admin/verbs/adminhelp.dm b/code/modules/admin/verbs/adminhelp.dm index 831dec49793..36349f1a9ed 100644 --- a/code/modules/admin/verbs/adminhelp.dm +++ b/code/modules/admin/verbs/adminhelp.dm @@ -967,3 +967,36 @@ GLOBAL_DATUM_INIT(admin_help_ui_handler, /datum/admin_help_ui_handler, new) if(length(admins_to_ping)) admins_to_ping[ADMINSAY_PING_UNDERLINE_NAME_INDEX] = jointext(msglist, " ") // without tuples, we must make do! return admins_to_ping + +/** + * Checks a given message to see if any of the words contain a memory ref for a datum. Said ref should not have brackets around it + * + * Returns nothing if no refs are found, otherwise returns an associative list with ckey -> client + * Also modifies msg to underline and linkify the [ref] so other admins can click on the address to open the VV entry for said datum + * + * Arguments: + * * msg - the message being scanned + */ +/proc/check_memory_refs(msg) + if(!findtext(msg, GLOB.is_memref)) + return + + //explode the input msg into a list + var/list/msglist = splittext(msg, " ") + var/list/datums_to_ref = list() + + var/i = 0 + for(var/word in msglist) + i++ + if(!length(word)) + continue + var/word_with_brackets = "\[[word]\]" // the actual memory address lookups need the bracket wraps + var/datum/check_datum = locate(word_with_brackets) + if(!istype(check_datum)) + continue + msglist[i] = "[word_with_brackets]" + datums_to_ref[word] = word + + if(length(datums_to_ref)) + datums_to_ref[ADMINSAY_LINK_DATUM_REF] = jointext(msglist, " ") // without tuples, we must make do! + return datums_to_ref diff --git a/code/modules/admin/verbs/adminsay.dm b/code/modules/admin/verbs/adminsay.dm index eed7a7c1101..f39358b2f34 100644 --- a/code/modules/admin/verbs/adminsay.dm +++ b/code/modules/admin/verbs/adminsay.dm @@ -21,6 +21,12 @@ window_flash(iter_admin_client) SEND_SOUND(iter_admin_client.mob, sound('sound/misc/asay_ping.ogg')) + + var/list/linked_datums = check_memory_refs(msg) + if(length(linked_datums) && linked_datums[ADMINSAY_LINK_DATUM_REF]) + msg = linked_datums[ADMINSAY_LINK_DATUM_REF] + linked_datums -= ADMINSAY_LINK_DATUM_REF + mob.log_talk(msg, LOG_ASAY) msg = keywords_lookup(msg) var/asay_color = prefs.read_preference(/datum/preference/color/asay_color) diff --git a/code/modules/admin/view_variables/view_variables.dm b/code/modules/admin/view_variables/view_variables.dm index 8e056d97b26..459316f18aa 100644 --- a/code/modules/admin/view_variables/view_variables.dm +++ b/code/modules/admin/view_variables/view_variables.dm @@ -42,9 +42,15 @@ sprite_text = no_icon? "\[NO ICON\]" : "" var/list/header = islist(D)? list("/list") : D.vv_get_header() + var/ref_line = copytext(refid, 2, -1) // get rid of the brackets + var/marked_line if(holder && holder.marked_datum && holder.marked_datum == D) marked_line = VV_MSG_MARKED + var/tagged_line + if(holder && LAZYFIND(holder.tagged_datums, D)) + var/tag_index = LAZYFIND(holder.tagged_datums, D) + tagged_line = VV_MSG_TAGGED(tag_index) var/varedited_line if(!islist && (D.datum_flags & DF_VAR_EDITED)) varedited_line = VV_MSG_EDITED @@ -211,7 +217,9 @@
[formatted_type] +
[ref_line] [marked_line] + [tagged_line] [varedited_line] [deleted_line]