From a9b042dc09e390a327b07b0eb923604169cfda0d Mon Sep 17 00:00:00 2001 From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> Date: Thu, 17 Feb 2022 11:33:36 +0000 Subject: [PATCH] Automatic handling of majorly-colliding CIDs (#17414) --- .../configuration/sections/admin_configuration.dm | 8 ++++++++ code/modules/admin/db_ban/functions.dm | 6 ++++++ config/example/config.toml | 4 ++++ 3 files changed, 18 insertions(+) diff --git a/code/controllers/configuration/sections/admin_configuration.dm b/code/controllers/configuration/sections/admin_configuration.dm index 42bcbff4bc1..9050bd79a5d 100644 --- a/code/controllers/configuration/sections/admin_configuration.dm +++ b/code/controllers/configuration/sections/admin_configuration.dm @@ -13,6 +13,8 @@ var/list/ckey_rank_map = list() /// Assoc list of admin ranks and their colours. key: rank | value: rank colour var/list/rank_colour_map = list() + /// Assoc list of CIDs which shouldnt be banned due to mass collisions + var/list/common_cid_map = list() /datum/configuration_section/admin_configuration/load_data(list/data) // Use the load wrappers here. That way the default isnt made 'null' if you comment out the config line @@ -38,6 +40,12 @@ for(var/list/kvset in data["admin_rank_colour_map"]) rank_colour_map[kvset["name"]] = kvset["colour"] + // Load common CIDs + if(islist(data["common_cid_map"])) + common_cid_map.Cut() + for(var/list/kvset in data["common_cid_map"]) + common_cid_map[kvset["cid"]] = kvset["reason"] + // For the person who asks "Why not put admin datum generation in this step?", well I will tell you why // Admins can be reloaded at runtime when DB edits are made and such, and I dont want an entire config reload to be part of this // Separation makes sense. That and in prod we use the DB anyways. diff --git a/code/modules/admin/db_ban/functions.dm b/code/modules/admin/db_ban/functions.dm index 44b27afb2e6..b6d113b67a2 100644 --- a/code/modules/admin/db_ban/functions.dm +++ b/code/modules/admin/db_ban/functions.dm @@ -112,6 +112,12 @@ to_chat(usr, "You cannot apply this ban type on yourself.") return + // Check validity of the CID. Some have a lot of collisions due to bad industry practices (thanks walmart) + if(computerid && (computerid in GLOB.configuration.admin.common_cid_map)) + to_chat(usr, "You attempted to apply a ban that includes the CID [computerid]. This CID has been ignored for the following reason: [GLOB.configuration.admin.common_cid_map[computerid]]") + // Cancel it out. DO NOT USE NULL HERE. IT MAKES THE DB CRY. USE AN EMPTY STRING. + computerid = "" + var/who for(var/client/C in GLOB.clients) if(!who) diff --git a/config/example/config.toml b/config/example/config.toml index 99c1dca9cd8..8f912e703b2 100644 --- a/config/example/config.toml +++ b/config/example/config.toml @@ -91,6 +91,10 @@ admin_rank_colour_map = [ {name = "PR Reviewer", colour = "#c27c0e"}, {name = "Mentor", colour = "#f1c40f"}, ] +# Map of common CIDs that should not be banned, plus their reasons +common_cid_map = [ + {cid = "3923664137", reason = "Mass-Match related to Walmart branded prebuilt PCs"} +] ################################################################