From 3b4bda996a431bb787e7675241f7e11f7847684c Mon Sep 17 00:00:00 2001 From: AffectedArc07 Date: Sat, 6 Jun 2020 19:59:04 +0100 Subject: [PATCH] Re-adds NTTC filtering --- code/game/machinery/tcomms/_base.dm | 2 ++ code/game/machinery/tcomms/core.dm | 37 +++++++++++++++++++++++- code/game/machinery/tcomms/nttc.dm | 7 +++++ nano/templates/tcomms_core.tmpl | 44 +++++++++++++++++++++++++++++ 4 files changed, 89 insertions(+), 1 deletion(-) diff --git a/code/game/machinery/tcomms/_base.dm b/code/game/machinery/tcomms/_base.dm index a857afcef89..7fc2ddae23b 100644 --- a/code/game/machinery/tcomms/_base.dm +++ b/code/game/machinery/tcomms/_base.dm @@ -171,6 +171,8 @@ GLOBAL_LIST_EMPTY(tcomms_machines) var/vname /// List of all channels this can be sent or recieved on var/list/zlevels = list() + /// Should this signal be re-broadcasted (Can be modified by NTTC, defaults to TRUE) + var/pass = TRUE /** * Destructor for the TCM datum. diff --git a/code/game/machinery/tcomms/core.dm b/code/game/machinery/tcomms/core.dm index 9e638913f9d..3fdae14746f 100644 --- a/code/game/machinery/tcomms/core.dm +++ b/code/game/machinery/tcomms/core.dm @@ -1,5 +1,6 @@ #define UI_TAB_CONFIG "CONFIG" #define UI_TAB_LINKS "LINKS" +#define UI_TAB_FILTER "FILTER" /** * # Telecommunications Core @@ -81,6 +82,11 @@ // Now we can run NTTC tcm = nttc.modify_message(tcm) + // If the signal shouldnt be broadcast, dont broadcast it + if(!tcm.pass) + // We still return TRUE here because the signal was handled, even though we didnt broadcast + return TRUE + // Now we generate the list of where that signal should go to tcm.zlevels = reachable_zlevels tcm.zlevels |= tcm.source_level @@ -168,6 +174,9 @@ data["entries"] += list(list("addr" = "\ref[R]", "net_id" = R.network_id, "sector" = R.loc.z, "status" = status, "status_color" = status_color)) // End the shit + if(ui_tab == UI_TAB_FILTER) + data["filtered_users"] = nttc.filtering + return data /obj/machinery/tcomms/core/Topic(href, href_list) @@ -177,7 +186,7 @@ if(href_list["tab"]) // Make sure its a valid tab - if(href_list["tab"] in list(UI_TAB_CONFIG, UI_TAB_LINKS)) + if(href_list["tab"] in list(UI_TAB_CONFIG, UI_TAB_LINKS, UI_TAB_FILTER)) ui_tab = href_list["tab"] // Check if they did a href, but only for that current tab @@ -257,9 +266,35 @@ to_chat(usr, "Successfully changed password from [link_password] to [new_password].") link_password = new_password + if(ui_tab == UI_TAB_FILTER) + if(href_list["add_filter"]) + // This is a stripped input because I did NOT come this far for this system to be abused by HTML injection + var/name_to_add = stripped_input(usr, "Enter a name to add to the filtering list", "Name Entry") + if(name_to_add == "") + return + if(name_to_add in nttc.filtering) + to_chat(usr, "ERROR: User already in filtering list.") + else + nttc.filtering |= name_to_add + log_action(usr, "has added [name_to_add] to the NTTC filter list on core with ID [network_id]", TRUE) + to_chat(usr, "Successfully added [name_to_add] to the NTTC filtering list.") + + + if(href_list["remove_filter"]) + var/name_to_remove = href_list["remove_filter"] + if(!(name_to_remove in nttc.filtering)) + to_chat(usr, "ERROR: Name does not exist in filter list. Please file an issue report.") + else + var/confirm = alert(usr, "Are you sure you want to remove [name_to_remove] from the filtering list?", "Confirm Removal", "Yes", "No") + if(confirm == "Yes") + nttc.filtering -= name_to_remove + log_action(usr, "has removed [name_to_remove] from the NTTC filter list on core with ID [network_id]", TRUE) + to_chat(usr, "Successfully removed [name_to_remove] from the NTTC filtering list.") + // Hack to speed update the nanoUI SSnanoui.update_uis(src) #undef UI_TAB_CONFIG #undef UI_TAB_LINKS +#undef UI_TAB_FILTER diff --git a/code/game/machinery/tcomms/nttc.dm b/code/game/machinery/tcomms/nttc.dm index 6ee158c6cc0..14e932dcf7f 100644 --- a/code/game/machinery/tcomms/nttc.dm +++ b/code/game/machinery/tcomms/nttc.dm @@ -153,6 +153,10 @@ var/list/job_card_styles = list( JOB_STYLE_1, JOB_STYLE_2, JOB_STYLE_3, JOB_STYLE_4 ) + + // List of people who will get blocked out of comms + var/list/filtering = list() + // Used to determine what languages are allowable for conversion. Generated during runtime. var/list/valid_languages = list("--DISABLE--") @@ -220,6 +224,9 @@ // Primary signal modification. This is where all of the variables behavior are actually implemented. /datum/nttc_configuration/proc/modify_message(datum/tcomms_message/tcm) + // Check if they should be blacklisted right off the bat. We can save CPU if the message wont even be processed + if(tcm.sender_name in filtering) + tcm.pass = FALSE // All job and coloring shit if(toggle_job_color || toggle_name_color) var/job = tcm.sender_job diff --git a/nano/templates/tcomms_core.tmpl b/nano/templates/tcomms_core.tmpl index 028f087aec8..bc083e657a7 100644 --- a/nano/templates/tcomms_core.tmpl +++ b/nano/templates/tcomms_core.tmpl @@ -1,5 +1,6 @@ {{:helper.link('Device Configuration', 'wrench', {'tab' : "CONFIG"}, data.tab == "CONFIG" ? 'selected' : '')}} {{:helper.link('Device Links', 'link', {'tab' : "LINKS"}, data.tab == "LINKS" ? 'selected' : '')}} +{{:helper.link('User Filtering', 'user-times', {'tab' : "FILTER"}, data.tab == "FILTER" ? 'selected' : '')}} {{if data.tab == "CONFIG"}}

Core Configuration

@@ -136,4 +137,47 @@ {{/for}} +{{else data.tab == "FILTER"}} + +

Filtering List

+
+
+ {{:helper.link('Add User', 'plus', {'add_filter': 1})}} +
+
+
+ + + + + + + + + + + + + {{for data.filtered_users}} + + + + + {{/for}} + +
NameRemove
{{:value}}{{:helper.link('Remove', 'times', {'remove_filter' : value}, null, 'infoButton')}}
{{/if}}