From dccbf7e5a6d6fd657e567b807c5b1a73f492fdd2 Mon Sep 17 00:00:00 2001
From: Zonespace <41448081+Zonespace27@users.noreply.github.com>
Date: Mon, 21 Nov 2022 20:44:55 -0800
Subject: [PATCH] Unit tests radio, saymode, and language prefix keys (#71328)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
## About The Pull Request
This PR unit tests radio/saymode prefixes together, and language
prefixes on their own, for any possible overlaps and duplicates
Moved mafia saymode key to :1 and holopad key to :2, we're running out
of radio keys and i'm too afraid to move to 2-letter
## Why It's Good For The Game
1. Unit tests are good
2. https://github.com/tgstation/tgstation/pull/71326 this is bad
🆑
spellcheck: Mafia changeling say prefix is now :1, and holopad say is
now :2
/🆑
Co-authored-by: Zephyr <12817816+ZephyrTFA@users.noreply.github.com>
---
code/datums/saymode.dm | 4 ++--
code/game/machinery/hologram.dm | 2 +-
code/modules/mob/living/silicon/ai/ai.dm | 2 +-
code/modules/unit_tests/_unit_tests.dm | 1 +
code/modules/unit_tests/key_prefixes.dm | 26 ++++++++++++++++++++++++
5 files changed, 31 insertions(+), 4 deletions(-)
create mode 100644 code/modules/unit_tests/key_prefixes.dm
diff --git a/code/datums/saymode.dm b/code/datums/saymode.dm
index b3855fe8070..99098b6eafb 100644
--- a/code/datums/saymode.dm
+++ b/code/datums/saymode.dm
@@ -87,7 +87,7 @@
/datum/saymode/holopad
- key = "h"
+ key = "2"
mode = MODE_HOLOPAD
/datum/saymode/holopad/handle_message(mob/living/user, message, datum/language/language)
@@ -98,7 +98,7 @@
return TRUE
/datum/saymode/mafia
- key = "j"
+ key = "1"
mode = MODE_MAFIA
/datum/saymode/mafia/handle_message(mob/living/user, message, datum/language/language)
diff --git a/code/game/machinery/hologram.dm b/code/game/machinery/hologram.dm
index 4b03984a19c..32516e903e4 100644
--- a/code/game/machinery/hologram.dm
+++ b/code/game/machinery/hologram.dm
@@ -209,7 +209,7 @@ Possible to do for anyone motivated enough:
/obj/machinery/holopad/examine(mob/user)
. = ..()
if(isAI(user))
- . += span_notice("The status display reads: Current projection range: [holo_range] units. Use :h to speak through the projection. Right-click to project or cancel a projection. Alt-click to hangup all active and incomming calls. Ctrl-click to end projection without jumping to your last location.")
+ . += span_notice("The status display reads: Current projection range: [holo_range] units. Use :2 to speak through the projection. Right-click to project or cancel a projection. Alt-click to hangup all active and incomming calls. Ctrl-click to end projection without jumping to your last location.")
else if(in_range(user, src) || isobserver(user))
. += span_notice("The status display reads: Current projection range: [holo_range] units.")
diff --git a/code/modules/mob/living/silicon/ai/ai.dm b/code/modules/mob/living/silicon/ai/ai.dm
index 46251fd5f30..7cf63235926 100644
--- a/code/modules/mob/living/silicon/ai/ai.dm
+++ b/code/modules/mob/living/silicon/ai/ai.dm
@@ -146,7 +146,7 @@
to_chat(src, "While observing through a camera, you can use most (networked) devices which you can see, such as computers, APCs, intercoms, doors, etc.")
to_chat(src, "To use something, simply click on it.")
to_chat(src, "For department channels, use the following say commands:")
- to_chat(src, ":o - AI Private, :c - Command, :s - Security, :e - Engineering, :u - Supply, :v - Service, :m - Medical, :n - Science, :h - Holopad.")
+ to_chat(src, ":o - AI Private, :c - Command, :s - Security, :e - Engineering, :u - Supply, :v - Service, :m - Medical, :n - Science, :2 - Holopad.")
show_laws()
to_chat(src, "These laws may be changed by other players, or by you being the traitor.")
diff --git a/code/modules/unit_tests/_unit_tests.dm b/code/modules/unit_tests/_unit_tests.dm
index c06ad61827f..8de44cce602 100644
--- a/code/modules/unit_tests/_unit_tests.dm
+++ b/code/modules/unit_tests/_unit_tests.dm
@@ -120,6 +120,7 @@
#include "inhands.dm"
#include "json_savefile_importing.dm"
#include "keybinding_init.dm"
+#include "key_prefixes.dm"
#include "knockoff_component.dm"
#include "limbsanity.dm"
#include "load_map_security.dm"
diff --git a/code/modules/unit_tests/key_prefixes.dm b/code/modules/unit_tests/key_prefixes.dm
new file mode 100644
index 00000000000..290bcb36628
--- /dev/null
+++ b/code/modules/unit_tests/key_prefixes.dm
@@ -0,0 +1,26 @@
+/// A unit test to ensure radio and language prefix keys don't overlap
+/datum/unit_test/key_prefixes
+
+/datum/unit_test/key_prefixes/Run()
+ // Languages first
+ // Assoc list of key:lang type
+ var/list/language_keys = list()
+ for(var/datum/language/language_type as anything in subtypesof(/datum/language))
+ if(initial(language_type.key) in language_keys)
+ TEST_FAIL("[language_type] language has the same prefix key ([initial(language_type.key)]) as [language_keys[initial(language_type.key)]]")
+ language_keys[initial(language_type.key)] = language_type
+
+ // Now radioes
+
+ // Assoc list of key:name (or type in the cases of saymodes)
+ var/list/radio_keys = list()
+
+ for(var/radio_key in GLOB.department_radio_keys)
+ if(radio_key in radio_keys)
+ TEST_FAIL("[GLOB.department_radio_keys[radio_key]] radio channel has the same prefix key ([radio_key]) as [GLOB.department_radio_keys[radio_keys.Find(radio_key)]]")
+ radio_keys[radio_key] = GLOB.department_radio_keys[radio_key]
+
+ for(var/datum/saymode/say_type as anything in subtypesof(/datum/saymode))
+ if(initial(say_type.key) in radio_keys)
+ TEST_FAIL("[say_type] saymode has the same prefix key ([initial(say_type.key)]) as [radio_keys[initial(say_type.key)]]")
+ radio_keys[initial(say_type.key)] = say_type