cleanup _HELPERS/_lists.dm and all the necessary files (#61827)

Bring _HELPERS/_lists.dm to latest standards by:
-Adding proper documentation and fixing existing one
-Giving vars proper names
-Procs now use snake case as per standard (many files that use those procs will be affected)
This commit is contained in:
Ghilker
2021-10-12 15:48:51 +02:00
committed by GitHub
parent 56d21164d0
commit 95c8e00af7
207 changed files with 551 additions and 522 deletions
+1 -1
View File
@@ -22,7 +22,7 @@
else
logs_missing += "[subject] (empty)"
var/list/combined = sortList(logs_present) + sortList(logs_missing)
var/list/combined = sort_list(logs_present) + sort_list(logs_missing)
var/selected = input("Investigate what?", "Investigate") as null|anything in combined
+4 -4
View File
@@ -606,7 +606,7 @@ GLOBAL_PROTECT(admin_verbs_hideable)
if(!SStrading_card_game.loaded)
message_admins("The card subsystem is not currently loaded")
return
var/pack = input("Which pack should we test?", "You fucked it didn't you") as null|anything in sortList(SStrading_card_game.card_packs)
var/pack = input("Which pack should we test?", "You fucked it didn't you") as null|anything in sort_list(SStrading_card_game.card_packs)
var/batchCount = input("How many times should we open it?", "Don't worry, I understand") as null|num
var/batchSize = input("How many cards per batch?", "I hope you remember to check the validation") as null|num
var/guar = input("Should we use the pack's guaranteed rarity? If so, how many?", "We've all been there. Man you should have seen the old system") as null|num
@@ -626,7 +626,7 @@ GLOBAL_PROTECT(admin_verbs_hideable)
var/type_length = length_char("/obj/effect/proc_holder/spell") + 2
for(var/spell in GLOB.spells)
spell_list[copytext_char("[spell]", type_length)] = spell
var/spell_desc = input("Choose the spell to give to that guy", "ABRAKADABRA") as null|anything in sortList(spell_list)
var/spell_desc = input("Choose the spell to give to that guy", "ABRAKADABRA") as null|anything in sort_list(spell_list)
if(!spell_desc)
return
@@ -663,7 +663,7 @@ GLOBAL_PROTECT(admin_verbs_hideable)
if(!length(target_spell_list))
return
var/obj/effect/proc_holder/spell/removed_spell = input("Choose the spell to remove", "NO ABRAKADABRA") as null|anything in sortList(target_spell_list)
var/obj/effect/proc_holder/spell/removed_spell = input("Choose the spell to remove", "NO ABRAKADABRA") as null|anything in sort_list(target_spell_list)
if(removed_spell)
removal_target.mind.RemoveSpell(removed_spell)
log_admin("[key_name(usr)] removed the spell [removed_spell] from [key_name(removal_target)].")
@@ -677,7 +677,7 @@ GLOBAL_PROTECT(admin_verbs_hideable)
if(!istype(T))
to_chat(src, span_notice("You can only give a disease to a mob of type /mob/living."), confidential = TRUE)
return
var/datum/disease/D = input("Choose the disease to give to that guy", "ACHOO") as null|anything in sortList(SSdisease.diseases, /proc/cmp_typepaths_asc)
var/datum/disease/D = input("Choose the disease to give to that guy", "ACHOO") as null|anything in sort_list(SSdisease.diseases, /proc/cmp_typepaths_asc)
if(!D)
return
T.ForceContractDisease(new D, FALSE, TRUE)
+1 -1
View File
@@ -19,7 +19,7 @@
/obj/item, /obj/item/clothing, /obj/item/stack, /obj/item,
/obj/item/reagent_containers, /obj/item/gun)
var/path = input("Select the path of the object you wish to create.", "Path", /obj) in sortList(create_object_forms, /proc/cmp_typepaths_asc)
var/path = input("Select the path of the object you wish to create.", "Path", /obj) in sort_list(create_object_forms, /proc/cmp_typepaths_asc)
var/html_form = create_object_forms[path]
if (!html_form)
@@ -14,7 +14,7 @@
var/random_appearance
/datum/smite/custom_imaginary_friend/configure(client/user)
friend_candidate_client = tgui_input_list(user, "Pick the player to put in control.", "New Imaginary Friend", sortList(GLOB.clients))
friend_candidate_client = tgui_input_list(user, "Pick the player to put in control.", "New Imaginary Friend", sort_list(GLOB.clients))
if(QDELETED(friend_candidate_client))
to_chat(user, span_notice("Selected player no longer has a client, aborting."))
+1 -1
View File
@@ -403,7 +403,7 @@
if (SSstickyban.dbcacheexpire)
return SSstickyban.dbcache.Copy()
return sortList(world.GetConfig("ban"))
return sort_list(world.GetConfig("ban"))
/proc/get_stickyban_from_ckey(ckey)
+2 -2
View File
@@ -111,7 +111,7 @@
for(var/mob/M in GLOB.mob_list)
if(M.mind)
minds |= M.mind
var/datum/mind/value = input("Select new member:", "New team member", null) as null|anything in sortNames(minds)
var/datum/mind/value = input("Select new member:", "New team member", null) as null|anything in sort_names(minds)
if (!value)
return
@@ -169,7 +169,7 @@
//This is here if you want admin created teams to tell each other apart easily.
/datum/team/custom/proc/admin_force_hud(mob/user)
var/list/possible_icons = icon_states('icons/mob/hud.dmi')
var/new_hud_state = input(user,"Choose hud icon state","Custom HUD","traitor") as null|anything in sortList(possible_icons)
var/new_hud_state = input(user,"Choose hud icon state","Custom HUD","traitor") as null|anything in sort_list(possible_icons)
if(!new_hud_state)
return
//suppose could ask for color too
+2 -2
View File
@@ -476,7 +476,7 @@
for (var/rule in subtypesof(/datum/dynamic_ruleset/roundstart))
var/datum/dynamic_ruleset/roundstart/newrule = new rule()
roundstart_rules[newrule.name] = newrule
var/added_rule = input(usr,"What ruleset do you want to force? This will bypass threat level and population restrictions.", "Rigging Roundstart", null) as null|anything in sortList(roundstart_rules)
var/added_rule = input(usr,"What ruleset do you want to force? This will bypass threat level and population restrictions.", "Rigging Roundstart", null) as null|anything in sort_list(roundstart_rules)
if (added_rule)
GLOB.dynamic_forced_roundstart_ruleset += roundstart_rules[added_rule]
log_admin("[key_name(usr)] set [added_rule] to be a forced roundstart ruleset.")
@@ -1432,7 +1432,7 @@
var/list/available_channels = list()
for(var/datum/newscaster/feed_channel/F in GLOB.news_network.network_channels)
available_channels += F.channel_name
src.admincaster_feed_channel.channel_name = adminscrub(input(usr, "Choose receiving Feed Channel.", "Network Channel Handler") in sortList(available_channels) )
src.admincaster_feed_channel.channel_name = adminscrub(input(usr, "Choose receiving Feed Channel.", "Network Channel Handler") in sort_list(available_channels) )
src.access_news_network()
else if(href_list["ac_set_new_message"])
@@ -335,7 +335,7 @@ GLOBAL_LIST_INIT_TYPED(sdql_spells, /obj/effect/proc_holder/spell, list())
var/path = saved_vars[special_list_vars[params["list"]]]
var/datum/sample = new path
var/list/choosable_vars = map_var_list(sample.vars-list_vars[params["list"]], sample)
var/chosen_var = tgui_input_list(user, "Select variable to add.", "Add SDQL Spell", sortList(choosable_vars))
var/chosen_var = tgui_input_list(user, "Select variable to add.", "Add SDQL Spell", sort_list(choosable_vars))
if(chosen_var)
if(islist(sample.vars[choosable_vars[chosen_var]]))
list_vars[params["list"]][choosable_vars[chosen_var]] = list("type" = "list", "value" = null, "flags" = LIST_VAR_FLAGS_TYPED|LIST_VAR_FLAGS_NAMED)
@@ -425,7 +425,7 @@ GLOBAL_LIST_INIT_TYPED(sdql_spells, /obj/effect/proc_holder/spell, list())
//Change all references in the list vars, either to null (for saving) or to their string representation (for display)
/datum/give_sdql_spell/proc/json_sanitize_list_vars(list/list_vars, mode = SANITIZE_NULLIFY)
var/list/temp_list_vars = deepCopyList(list_vars)
var/list/temp_list_vars = deep_copy_list(list_vars)
for(var/V in temp_list_vars)
var/list/L = temp_list_vars[V]
for(var/W in L)
+3 -3
View File
@@ -65,7 +65,7 @@
var/list/msg = list()
msg += "<html><head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8'><title>Playtime Report</title></head><body>Playtime:<BR><UL>"
var/list/clients_list_copy = GLOB.clients.Copy()
sortList(clients_list_copy)
sort_list(clients_list_copy)
for(var/client/C in clients_list_copy)
msg += "<LI> - [key_name_admin(C)]: <A href='?_src_=holder;[HrefToken()];getplaytimewindow=[REF(C.mob)]'>" + C.get_exp_living() + "</a></LI>"
msg += "</UL></BODY></HTML>"
@@ -140,7 +140,7 @@
var/name = GLOB.trait_name_map[trait] || trait
available_traits[name] = trait
var/chosen_trait = input("Select trait to modify", "Trait") as null|anything in sortList(available_traits)
var/chosen_trait = input("Select trait to modify", "Trait") as null|anything in sort_list(available_traits)
if(!chosen_trait)
return
chosen_trait = available_traits[chosen_trait]
@@ -159,7 +159,7 @@
if("All")
source = null
if("Specific")
source = input("Source to be removed","Trait Remove/Add") as null|anything in sortList(D.status_traits[chosen_trait])
source = input("Source to be removed","Trait Remove/Add") as null|anything in sort_list(D.status_traits[chosen_trait])
if(!source)
return
REMOVE_TRAIT(D,chosen_trait,source)
+1 -1
View File
@@ -491,7 +491,7 @@
if(!holder)
return
var/weather_type = input("Choose a weather", "Weather") as null|anything in sortList(subtypesof(/datum/weather), /proc/cmp_typepaths_asc)
var/weather_type = input("Choose a weather", "Weather") as null|anything in sort_list(subtypesof(/datum/weather), /proc/cmp_typepaths_asc)
if(!weather_type)
return
+2 -2
View File
@@ -84,7 +84,7 @@
var/list/keys = list()
for(var/mob/M in GLOB.player_list)
keys += M.client
var/client/selection = input("Please, select a player!", "Admin Jumping", null, null) as null|anything in sortKey(keys)
var/client/selection = input("Please, select a player!", "Admin Jumping", null, null) as null|anything in sort_key(keys)
if(!selection)
to_chat(src, "No keys found.", confidential = TRUE)
return
@@ -137,7 +137,7 @@
var/list/keys = list()
for(var/mob/M in GLOB.player_list)
keys += M.client
var/client/selection = input("Please, select a player!", "Admin Jumping", null, null) as null|anything in sortKey(keys)
var/client/selection = input("Please, select a player!", "Admin Jumping", null, null) as null|anything in sort_key(keys)
if(!selection)
return
var/mob/M = selection.mob
+1 -1
View File
@@ -36,7 +36,7 @@
targets["[client.mob.real_name](as [client.mob.name]) - [client]"] = client
else
targets["(No Mob) - [client]"] = client
var/target = input(src,"To whom shall we send a message?","Admin PM",null) as null|anything in sortList(targets)
var/target = input(src,"To whom shall we send a message?","Admin PM",null) as null|anything in sort_list(targets)
cmd_admin_pm(targets[target],null)
SSblackbox.record_feedback("tally", "admin_verb", 1, "Admin PM") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
+1 -1
View File
@@ -7,7 +7,7 @@
return
if (!istype(borgo, /mob/living/silicon/robot))
borgo = input("Select a borg", "Select a borg", null, null) as null|anything in sortNames(GLOB.silicon_mobs)
borgo = input("Select a borg", "Select a borg", null, null) as null|anything in sort_names(GLOB.silicon_mobs)
if (!istype(borgo, /mob/living/silicon/robot))
to_chat(usr, span_warning("Borg is required for borgpanel"), confidential = TRUE)
+1 -1
View File
@@ -6,6 +6,6 @@
if(!SSticker)
return
var/datum/cinematic/choice = input(src,"Cinematic","Choose",null) as null|anything in sortList(subtypesof(/datum/cinematic), /proc/cmp_typepaths_asc)
var/datum/cinematic/choice = input(src,"Cinematic","Choose",null) as null|anything in sort_list(subtypesof(/datum/cinematic), /proc/cmp_typepaths_asc)
if(choice)
Cinematic(initial(choice.id),world,null)
+9 -9
View File
@@ -96,7 +96,7 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that
for(var/mob/C in GLOB.mob_list)
if(C.key)
available.Add(C)
var/mob/choice = tgui_input_list(usr, "Choose a player to play the pAI", "Spawn pAI", sortNames(available))
var/mob/choice = tgui_input_list(usr, "Choose a player to play the pAI", "Spawn pAI", sort_names(available))
if(!choice)
return
if(!isobserver(choice))
@@ -162,7 +162,7 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that
if(matches.len==0)
return
var/hsbitem = input(usr, "Choose an object to delete.", "Delete:") as null|anything in sortList(matches)
var/hsbitem = input(usr, "Choose an object to delete.", "Delete:") as null|anything in sort_list(matches)
if(hsbitem)
hsbitem = matches[hsbitem]
var/counter = 0
@@ -259,7 +259,7 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that
if(M.ckey)
if(tgui_alert(usr,"This mob is being controlled by [M.key]. Are you sure you wish to give someone else control of it? [M.key] will be made a ghost.",,list("Yes","No")) != "Yes")
return
var/client/newkey = input(src, "Pick the player to put in control.", "New player") as null|anything in sortList(GLOB.clients)
var/client/newkey = input(src, "Pick the player to put in control.", "New player") as null|anything in sort_list(GLOB.clients)
var/mob/oldmob = newkey.mob
var/delmob = FALSE
if((isobserver(oldmob) || tgui_alert(usr,"Do you want to delete [newkey]'s old mob?","Delete?",list("Yes","No")) != "No"))
@@ -505,7 +505,7 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that
var/datum/outfit/O = path //not much to initalize here but whatever
outfits[initial(O.name)] = path
var/dresscode = input("Select outfit", "Robust quick dress shop") as null|anything in baseoutfits + sortList(outfits)
var/dresscode = input("Select outfit", "Robust quick dress shop") as null|anything in baseoutfits + sort_list(outfits)
if (isnull(dresscode))
return
@@ -519,7 +519,7 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that
var/datum/outfit/O = path
job_outfits[initial(O.name)] = path
dresscode = input("Select job equipment", "Robust quick dress shop") as null|anything in sortList(job_outfits)
dresscode = input("Select job equipment", "Robust quick dress shop") as null|anything in sort_list(job_outfits)
dresscode = job_outfits[dresscode]
if(isnull(dresscode))
return
@@ -531,7 +531,7 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that
var/datum/outfit/O = path
plasmaman_outfits[initial(O.name)] = path
dresscode = input("Select plasmeme equipment", "Robust quick dress shop") as null|anything in sortList(plasmaman_outfits)
dresscode = input("Select plasmeme equipment", "Robust quick dress shop") as null|anything in sort_list(plasmaman_outfits)
dresscode = plasmaman_outfits[dresscode]
if(isnull(dresscode))
return
@@ -540,7 +540,7 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that
var/list/custom_names = list()
for(var/datum/outfit/D in GLOB.custom_outfits)
custom_names[D.name] = D
var/selected_name = input("Select outfit", "Robust quick dress shop") as null|anything in sortList(custom_names)
var/selected_name = input("Select outfit", "Robust quick dress shop") as null|anything in sort_list(custom_names)
dresscode = custom_names[selected_name]
if(isnull(dresscode))
return
@@ -700,7 +700,7 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that
names[name] = ruin_landmark
var/ruinname = input("Select ruin", "Jump to Ruin") as null|anything in sortList(names)
var/ruinname = input("Select ruin", "Jump to Ruin") as null|anything in sort_list(names)
var/obj/effect/landmark/ruin/landmark = names[ruinname]
@@ -737,7 +737,7 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that
for(var/name in SSmapping.ice_ruins_underground_templates)
names[name] = list(SSmapping.ice_ruins_underground_templates[name], ZTRAIT_ICE_RUINS_UNDERGROUND, list(/area/icemoon/underground/unexplored))
var/ruinname = input("Select ruin", "Spawn Ruin") as null|anything in sortList(names)
var/ruinname = input("Select ruin", "Spawn Ruin") as null|anything in sort_list(names)
var/data = names[ruinname]
if (!data)
return
+1 -1
View File
@@ -157,7 +157,7 @@
var/mob/dead/observer/potential_leader = i
candidate_living_exps[potential_leader] = potential_leader.client?.get_exp_living(TRUE)
candidate_living_exps = sortList(candidate_living_exps, cmp=/proc/cmp_numeric_dsc)
candidate_living_exps = sort_list(candidate_living_exps, cmp=/proc/cmp_numeric_dsc)
if(candidate_living_exps.len > ERT_EXPERIENCED_LEADER_CHOOSE_TOP)
candidate_living_exps = candidate_living_exps.Cut(ERT_EXPERIENCED_LEADER_CHOOSE_TOP+1) // pick from the top ERT_EXPERIENCED_LEADER_CHOOSE_TOP contenders in playtime
earmarked_leader = pick(candidate_living_exps)
+2 -2
View File
@@ -9,12 +9,12 @@
victim_hiddenprints = list()
var/list/hiddenprints = flatten_list(victim_hiddenprints)
removeNullsFromList(hiddenprints)
remove_nulls_from_list(hiddenprints)
if(!length(hiddenprints))
hiddenprints = list("Nobody has touched this yet!")
hiddenprints = sortList(hiddenprints, /proc/cmp_hiddenprint_lasttime_dsc)
hiddenprints = sort_list(hiddenprints, /proc/cmp_hiddenprint_lasttime_dsc)
for(var/record in hiddenprints)
interface += "<li>[record]</li><br>"
@@ -4,7 +4,7 @@
var/datum/map_template/template
var/map = input(src, "Choose a Map Template to place at your CURRENT LOCATION","Place Map Template") as null|anything in sortList(SSmapping.map_templates)
var/map = input(src, "Choose a Map Template to place at your CURRENT LOCATION","Place Map Template") as null|anything in sort_list(SSmapping.map_templates)
if(!map)
return
template = SSmapping.map_templates[map]
+1 -1
View File
@@ -32,7 +32,7 @@
mapname += "\]"
maprotatechoices[mapname] = VM
var/chosenmap = tgui_input_list(usr, "Choose a map to change to", "Change Map", sortList(maprotatechoices)|"Custom")
var/chosenmap = tgui_input_list(usr, "Choose a map to change to", "Change Map", sort_list(maprotatechoices)|"Custom")
if (!chosenmap)
return
+1 -1
View File
@@ -57,7 +57,7 @@
return
if(!M)
M = input(usr, "Choose a mob to play the sound to. Only they will hear it.", "Play Mob Sound") as null|anything in sortNames(GLOB.player_list)
M = input(usr, "Choose a mob to play the sound to. Only they will hear it.", "Play Mob Sound") as null|anything in sort_names(GLOB.player_list)
if(!M || QDELETED(M))
return
log_admin("[key_name(src)] played a direct mob sound [S] to [M].")
+1 -1
View File
@@ -222,7 +222,7 @@ GLOBAL_DATUM(everyone_a_traitor, /datum/everyone_is_a_traitor_controller)
var/datum/round_event_control/disease_outbreak/DC = locate(/datum/round_event_control/disease_outbreak) in SSevents.control
E = DC.runEvent()
if("Choose")
var/virus = input("Choose the virus to spread", "BIOHAZARD") as null|anything in sortList(typesof(/datum/disease), /proc/cmp_typepaths_asc)
var/virus = input("Choose the virus to spread", "BIOHAZARD") as null|anything in sort_list(typesof(/datum/disease), /proc/cmp_typepaths_asc)
var/datum/round_event_control/disease_outbreak/DC = locate(/datum/round_event_control/disease_outbreak) in SSevents.control
var/datum/round_event/disease_outbreak/DO = DC.runEvent()
DO.virus_type = virus
@@ -29,7 +29,7 @@
for (var/V in O.vars)
names += V
names = sortList(names)
names = sort_list(names)
variable = input("Which var?", "Var") as null|anything in names
else
@@ -142,7 +142,7 @@ GLOBAL_PROTECT(VVpixelmovement)
if(variable == "(CLEAR NULLS)")
L = L.Copy()
listclearnulls(L)
list_clear_nulls(L)
if (!O.vv_edit_var(objectvar, L))
to_chat(src, "Your edit was rejected by the object.", confidential = TRUE)
return
@@ -152,7 +152,7 @@ GLOBAL_PROTECT(VVpixelmovement)
return
if(variable == "(CLEAR DUPES)")
L = uniqueList(L)
L = unique_list(L)
if (!O.vv_edit_var(objectvar, L))
to_chat(src, "Your edit was rejected by the object.", confidential = TRUE)
return
@@ -306,7 +306,7 @@ GLOBAL_PROTECT(VVpixelmovement)
for (var/V in O.vars)
names += V
names = sortList(names)
names = sort_list(names)
variable = input("Which var?","Var") as null|anything in names
if(!variable)
@@ -54,11 +54,11 @@
if(!check_rights(NONE))
return
var/list/names = list()
var/list/componentsubtypes = sortList(subtypesof(/datum/component), /proc/cmp_typepaths_asc)
var/list/componentsubtypes = sort_list(subtypesof(/datum/component), /proc/cmp_typepaths_asc)
names += "---Components---"
names += componentsubtypes
names += "---Elements---"
names += sortList(subtypesof(/datum/element), /proc/cmp_typepaths_asc)
names += sort_list(subtypesof(/datum/element), /proc/cmp_typepaths_asc)
var/result = tgui_input_list(usr, "Choose a component/element to add", "Add Component", names)
if(!usr || !result || result == "---Components---" || result == "---Elements---")
return
@@ -93,10 +93,10 @@
var/list/names = list()
names += "---Components---"
if(length(components))
names += sortList(components, /proc/cmp_typepaths_asc)
names += sort_list(components, /proc/cmp_typepaths_asc)
names += "---Elements---"
// We have to list every element here because there is no way to know what element is on this object without doing some sort of hack.
names += sortList(subtypesof(/datum/element), /proc/cmp_typepaths_asc)
names += sort_list(subtypesof(/datum/element), /proc/cmp_typepaths_asc)
var/path = tgui_input_list(usr, "Choose a component/element to remove. All elements listed here may not be on the datum.", "Remove element", names)
if(!usr || !path || path == "---Components---" || path == "---Elements---")
return
@@ -19,12 +19,12 @@
if(href_list[VV_HK_LIST_ADD])
mod_list_add(target, null, "list", "contents")
if(href_list[VV_HK_LIST_ERASE_DUPES])
uniqueList_inplace(target)
unique_list_in_place(target)
log_world("### ListVarEdit by [src]: /list contents: CLEAR DUPES")
log_admin("[key_name(src)] modified list's contents: CLEAR DUPES")
message_admins("[key_name_admin(src)] modified list's contents: CLEAR DUPES")
if(href_list[VV_HK_LIST_ERASE_NULLS])
listclearnulls(target)
list_clear_nulls(target)
log_world("### ListVarEdit by [src]: /list contents: CLEAR NULLS")
log_admin("[key_name(src)] modified list's contents: CLEAR NULLS")
message_admins("[key_name_admin(src)] modified list's contents: CLEAR NULLS")
@@ -87,7 +87,7 @@
value = L[key]
variable_html += debug_variable(i, value, 0, L)
else
names = sortList(names)
names = sort_list(names)
for(var/V in names)
if(D.can_vv_get(V))
variable_html += D.vv_get_var(V)