From 823e949b27a666996e6f9c54f51d50c5cdbe334d Mon Sep 17 00:00:00 2001 From: CitadelStationBot Date: Mon, 17 Apr 2017 09:45:42 -0500 Subject: [PATCH] Makes radio keys table more compact and easy to change --- code/modules/mob/living/say.dm | 137 ++++++++++-------- .../mob/living/simple_animal/parrot.dm | 6 +- 2 files changed, 78 insertions(+), 65 deletions(-) diff --git a/code/modules/mob/living/say.dm b/code/modules/mob/living/say.dm index b12b6516c2..f0e39189af 100644 --- a/code/modules/mob/living/say.dm +++ b/code/modules/mob/living/say.dm @@ -1,62 +1,73 @@ +GLOBAL_LIST_INIT(department_radio_prefixes, list(":", ".")) + GLOBAL_LIST_INIT(department_radio_keys, list( - ":r" = "right hand", ".r" = "right hand", - ":l" = "left hand", ".l" = "left hand", - ":i" = "intercom", ".i" = "intercom", - ":h" = "department", ".h" = "department", - ":c" = "Command", ".c" = "Command", - ":n" = "Science", ".n" = "Science", - ":m" = "Medical", ".m" = "Medical", - ":e" = "Engineering", ".e" = "Engineering", - ":s" = "Security", ".s" = "Security", - ":b" = "binary", ".b" = "binary", - ":a" = "alientalk", ".a" = "alientalk", - ":t" = "Syndicate", ".t" = "Syndicate", - ":u" = "Supply", ".u" = "Supply", - ":v" = "Service", ".v" = "Service", - ":o" = "AI Private", ".o" = "AI Private", - ":g" = "changeling", ".g" = "changeling", - ":y" = "Centcom", ".y" = "Centcom", - ":x" = "cords", ".x" = "cords", - ":p" = "admin", ".p" = "admin", - ":d" = "deadmin", ".d" = "deadmin", - - ":R" = "right hand", ".R" = "right hand", - ":L" = "left hand", ".L" = "left hand", - ":I" = "intercom", ".I" = "intercom", - ":H" = "department", ".H" = "department", - ":C" = "Command", ".C" = "Command", - ":N" = "Science", ".N" = "Science", - ":M" = "Medical", ".M" = "Medical", - ":E" = "Engineering", ".E" = "Engineering", - ":S" = "Security", ".S" = "Security", - ":B" = "binary", ".B" = "binary", - ":A" = "alientalk", ".A" = "alientalk", - ":T" = "Syndicate", ".T" = "Syndicate", - ":U" = "Supply", ".U" = "Supply", - ":V" = "Service", ".V" = "Service", - ":O" = "AI Private", ".O" = "AI Private", - ":G" = "changeling", ".G" = "changeling", - ":Y" = "Centcom", ".Y" = "Centcom", - ":X" = "cords", ".X" = "cords", - ":P" = "admin", ".P" = "admin", - ":D" = "deadmin", ".D" = "deadmin", - - //kinda localization -- rastaf0 - //same keys as above, but on russian keyboard layout. This file uses cp1251 as encoding. - ":ê" = "right hand", ".ê" = "right hand", - ":ä" = "left hand", ".ä" = "left hand", - ":ø" = "intercom", ".ø" = "intercom", - ":ð" = "department", ".ð" = "department", - ":ñ" = "Command", ".ñ" = "Command", - ":ò" = "Science", ".ò" = "Science", - ":ü" = "Medical", ".ü" = "Medical", - ":ó" = "Engineering", ".ó" = "Engineering", - ":û" = "Security", ".û" = "Security", - ":è" = "binary", ".è" = "binary", - ":ô" = "alientalk", ".ô" = "alientalk", - ":Ã¥" = "Syndicate", ".Ã¥" = "Syndicate", - ":é" = "Supply", ".é" = "Supply", - ":ï" = "changeling", ".ï" = "changeling")) + // Location + "r" = "right hand", + "l" = "left hand", + "i" = "intercom", + + // Department + "h" = "department", + "c" = "Command", + "n" = "Science", + "m" = "Medical", + "e" = "Engineering", + "s" = "Security", + "u" = "Supply", + "v" = "Service", + + // Faction + "t" = "Syndicate", + "y" = "Centcom", + + // Species + "b" = "binary", + "g" = "changeling", + "a" = "alientalk", + + // Admin + "p" = "admin", + "d" = "deadmin", + + // Misc + "o" = "AI Private", // AI Upload channel + "x" = "cords", // vocal cords, used by Voice of God + + + //kinda localization -- rastaf0 + //same keys as above, but on russian keyboard layout. This file uses cp1251 as encoding. + // Location + "ê" = "right hand", + "ä" = "left hand", + "ø" = "intercom", + + // Department + "ð" = "department", + "ñ" = "Command", + "ò" = "Science", + "ü" = "Medical", + "ó" = "Engineering", + "û" = "Security", + "ã" = "Supply", + "ì" = "Service", + + // Faction + "å" = "Syndicate", + "í" = "Centcom", + + // Species + "è" = "binary", + "ï" = "changeling", + "ô" = "alientalk", + + // Admin + "ç" = "admin", + "â" = "deadmin", + + // Misc + "ù" = "AI Private", + "÷" = "cords" +)) /mob/living/say(message, bubble_type,var/list/spans = list(), sanitize = TRUE, datum/language/language = null) var/static/list/crit_allowed_modes = list(MODE_WHISPER = TRUE, MODE_CHANGELING = TRUE, MODE_ALIEN = TRUE) @@ -279,12 +290,14 @@ GLOBAL_LIST_INIT(department_radio_keys, list( return 1 /mob/living/proc/get_message_mode(message) - if(copytext(message, 1, 2) == ";") + var/key = copytext(message, 1, 2) + if(key == ";") return MODE_HEADSET - else if(copytext(message, 1, 2) == "#") + else if(key == "#") return MODE_WHISPER - else if(length(message) > 2) - return GLOB.department_radio_keys[copytext(message, 1, 3)] + else if(length(message) > 2 && (key in GLOB.department_radio_prefixes)) + var/key_symbol = lowertext(copytext(message, 2, 3)) + return GLOB.department_radio_keys[key_symbol] /mob/living/proc/get_message_language(message) var/static/list/langlist diff --git a/code/modules/mob/living/simple_animal/parrot.dm b/code/modules/mob/living/simple_animal/parrot.dm index df096f2306..e5dc99ea27 100644 --- a/code/modules/mob/living/simple_animal/parrot.dm +++ b/code/modules/mob/living/simple_animal/parrot.dm @@ -425,7 +425,7 @@ if(prob(50)) useradio = 1 - if(copytext(possible_phrase,1,3) in GLOB.department_radio_keys) + if((copytext(possible_phrase,1,2) in GLOB.department_radio_prefixes) && (copytext(possible_phrase,2,3) in GLOB.department_radio_keys)) possible_phrase = "[useradio?pick(available_channels):""][copytext(possible_phrase,3)]" //crop out the channel prefix else possible_phrase = "[useradio?pick(available_channels):""][possible_phrase]" @@ -434,8 +434,8 @@ else //If we have no headset or channels to use, dont try to use any! for(var/possible_phrase in speak) - if(copytext(possible_phrase,1,3) in GLOB.department_radio_keys) - possible_phrase = "[copytext(possible_phrase,3,length(possible_phrase)+1)]" //crop out the channel prefix + if((copytext(possible_phrase,1,2) in GLOB.department_radio_prefixes) && (copytext(possible_phrase,2,3) in GLOB.department_radio_keys)) + possible_phrase = copytext(possible_phrase,3) //crop out the channel prefix newspeak.Add(possible_phrase) speak = newspeak