From 12bc3aa0ff4908d5f0a584bd812ae40533402cdd Mon Sep 17 00:00:00 2001 From: GinjaNinja32 Date: Sun, 31 Jul 2016 14:48:35 +0100 Subject: [PATCH 1/2] Rewrite english_list to be a little nicer on lists of objects, and also faster --- code/_helpers/lists.dm | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/code/_helpers/lists.dm b/code/_helpers/lists.dm index d4e6710b35..30df4693db 100644 --- a/code/_helpers/lists.dm +++ b/code/_helpers/lists.dm @@ -11,24 +11,11 @@ //Returns a list in plain english as a string /proc/english_list(var/list/input, nothing_text = "nothing", and_text = " and ", comma_text = ", ", final_comma_text = "" ) - var/total = input.len - if (!total) - return "[nothing_text]" - else if (total == 1) - return "[input[1]]" - else if (total == 2) - return "[input[1]][and_text][input[2]]" - else - var/output = "" - var/index = 1 - while (index < total) - if (index == total - 1) - comma_text = final_comma_text - - output += "[input[index]][comma_text]" - index++ - - return "[output][and_text][input[index]]" + switch(input.len) + if(0) return nothing_text + if(1) return "[input[1]]" + if(2) return "[input[1]][and_text][input[2]]" + else return "[jointext(input, comma_text, 1, -1)][final_comma_text][and_text][input[input.len]]" //Returns list element or null. Should prevent "index out of bounds" error. proc/listgetindex(var/list/list,index) From e395e7374d434fd433a93a8f75c43082bc27d27d Mon Sep 17 00:00:00 2001 From: Yoshax Date: Mon, 15 Aug 2016 17:33:36 +0100 Subject: [PATCH 2/2] replace pointless english_list call with jointext --- code/modules/client/preference_setup/general/02_language.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/client/preference_setup/general/02_language.dm b/code/modules/client/preference_setup/general/02_language.dm index 5d4a73c64a..d42449ab84 100644 --- a/code/modules/client/preference_setup/general/02_language.dm +++ b/code/modules/client/preference_setup/general/02_language.dm @@ -34,7 +34,7 @@ . += "- [pref.species] cannot choose secondary languages.
" . += "Language Keys
" - . += " [english_list(pref.language_prefixes, and_text = " ", comma_text = " ")] Change Reset
" + . += " [jointext(pref.language_prefixes, " ")] Change Reset
" /datum/category_item/player_setup_item/general/language/OnTopic(var/href,var/list/href_list, var/mob/user) if(href_list["remove_language"])