[TM-ONLY][DNM] Attempts to remove all instances where a list is accessed with a '?' (#5932)

* I hate TGUI even if its better than what we had before

* this is why linters exist

* you need to be a Head or the Warden to get items

* does this please you linter?

* foundation

* basic interactions

* yea I can spell okay?

* linters please leave me alone

* begone debug code

* if you are dead, no interacting

* linters leave me alone

* linters are stealing my soul

* forgot to do this

* sound framework, probably wont work though

* max length, and interaction cooldowns

* message can now be a list and minor code improve

* I am a slave and linters are my master

* fix improper static reference

* add json loading/saving functionality

* default for message is now a list

* jsonize def interactions; implement requirements

* bad

* bug fix; CtrlShiftClick to interact

* minor qol fix

* fix CtrlShiftClick and remove debug code

* haha docker has security measures

* this was painful

* why are you in this branch

* begone

* bruh

* begone

Co-authored-by: Matthew <matthew@tfaluc.com>
Co-authored-by: Matthew J <GoldenKeyboard@users.noreply.github.com>
This commit is contained in:
Matthew J
2021-05-25 11:26:39 -04:00
committed by GitHub
parent e698438b7c
commit aac40d2ed3
42 changed files with 61 additions and 57 deletions

View File

@@ -29,7 +29,7 @@
return value
if(default)
return default
if(List?.len)
if(List && List.len)
return pick(List)

View File

@@ -99,9 +99,9 @@ have ways of interacting with a specific atom and control it. They posses a blac
walk(pawn, 0) //stop moving
return //this should remove them from processing in the future through event-based stuff.
if(!current_behaviors?.len)
if(!current_behaviors && current_behaviors.len)
SelectBehaviors(delta_time)
if(!current_behaviors?.len)
if(!(current_behaviors && current_behaviors.len))
PerformIdleBehavior(delta_time) //Do some stupid shit while we have nothing to do
return

View File

@@ -159,7 +159,8 @@
LAZYSET(language_icons, language, language_icon)
LAZYADD(prefixes, "\icon[language_icon]")
text = "[prefixes?.Join("&nbsp;")][text]"
if(prefixes)
text = "[prefixes.Join("&nbsp;")][text]"
// We dim italicized text to make it more distinguishable from regular text
var/tgt_color = extra_classes.Find("italics") ? target.chat_color_darkened : target.chat_color

View File

@@ -210,7 +210,7 @@
/datum/disease/advance/proc/Refresh(new_name = FALSE)
GenerateProperties()
AssignProperties()
if(processing && symptoms?.len)
if(processing && symptoms && symptoms.len)
for(var/datum/symptom/S in symptoms)
S.Start(src)
S.on_stage_change(src)
@@ -238,7 +238,7 @@
// Assign the properties that are in the list.
/datum/disease/advance/proc/AssignProperties()
if(properties?.len)
if(properties && properties.len)
if(properties["stealth"] >= 2)
visibility_flags |= HIDDEN_SCANNER
else
@@ -308,7 +308,7 @@
// Will generate a random cure, the more resistance the symptoms have, the harder the cure.
/datum/disease/advance/proc/GenerateCure()
if(properties?.len)
if(properties && properties.len)
var/res = clamp(properties["resistance"] - (symptoms.len / 2), 1, advance_cures.len)
if(res == oldres)
return

View File

@@ -118,7 +118,7 @@
var/atom/picked_mob = pickweight(mob_spawn_list)
if(picked_mob == SPAWN_MEGAFAUNA) //
if((A.area_flags & MEGAFAUNA_SPAWN_ALLOWED) && megafauna_spawn_list?.len) //this is danger. it's boss time.
if((A.area_flags & MEGAFAUNA_SPAWN_ALLOWED) && megafauna_spawn_list && megafauna_spawn_list.len) //this is danger. it's boss time.
picked_mob = pickweight(megafauna_spawn_list)
else //this is not danger, don't spawn a boss, spawn something else
picked_mob = pickweight(mob_spawn_list - SPAWN_MEGAFAUNA) //What if we used 100% of the brain...and did something (slightly) less shit than a while loop?

View File

@@ -131,7 +131,7 @@
/// Checks for revhead loss conditions and other antag datums.
/datum/dynamic_ruleset/latejoin/provocateur/proc/check_eligible(datum/mind/M)
var/turf/T = get_turf(M.current)
if(!considered_afk(M) && considered_alive(M) && is_station_level(T.z) && !M.antag_datums?.len && !HAS_TRAIT(M, TRAIT_MINDSHIELD))
if(!considered_afk(M) && considered_alive(M) && is_station_level(T.z) && !(M.antag_datums && M.antag_datums.len) && !HAS_TRAIT(M, TRAIT_MINDSHIELD))
return TRUE
return FALSE

View File

@@ -201,7 +201,7 @@
living_players -= player
else if(is_centcom_level(player.z))
living_players -= player // We don't autotator people in CentCom
else if(player.mind && (player.mind.special_role || player.mind.antag_datums?.len > 0))
else if(player.mind && (player.mind.special_role || ( player.mind.antag_datums && player.mind.antag_datums.len ) > 0))
living_players -= player // We don't autotator people with roles already
/datum/dynamic_ruleset/midround/autotraitor/ready(forced = FALSE)
@@ -250,7 +250,7 @@
candidates -= player
else if(is_centcom_level(player.z))
candidates -= player
else if(player.mind && (player.mind.special_role || player.mind.antag_datums?.len > 0))
else if(player.mind && (player.mind.special_role || ( player.mind.antag_datums && player.mind.antag_datums.len ) > 0))
candidates -= player
else if(HAS_TRAIT(player, TRAIT_MINDSHIELD))
candidates -= player
@@ -319,7 +319,7 @@
candidates -= player
continue
if(player.mind && (player.mind.special_role || player.mind.antag_datums?.len > 0))
if(player.mind && (player.mind.special_role || ( player.mind.antag_datums && player.mind.antag_datums.len ) > 0))
candidates -= player
/datum/dynamic_ruleset/midround/malf/execute()

View File

@@ -478,7 +478,7 @@
/// Checks for revhead loss conditions and other antag datums.
/datum/dynamic_ruleset/roundstart/revs/proc/check_eligible(datum/mind/M)
var/turf/T = get_turf(M.current)
if(!considered_afk(M) && considered_alive(M) && is_station_level(T.z) && !M.antag_datums?.len && !HAS_TRAIT(M, TRAIT_MINDSHIELD))
if(!considered_afk(M) && considered_alive(M) && is_station_level(T.z) && !(M.antag_datums && M.antag_datums.len) && !HAS_TRAIT(M, TRAIT_MINDSHIELD))
return TRUE
return FALSE

View File

@@ -8,7 +8,7 @@
/obj/effect/spawner/bundle/Initialize(mapload)
..()
if(items?.len)
if(items && items.len)
for(var/path in items)
new path(loc)
return INITIALIZE_HINT_QDEL

View File

@@ -9,7 +9,7 @@
/obj/effect/spawner/lootdrop/Initialize(mapload)
..()
if(loot?.len)
if(loot && loot.len)
var/loot_spawned = 0
while((lootcount-loot_spawned) && loot.len)
var/lootspawn = pickweight(loot)

View File

@@ -10,7 +10,7 @@ again.
/obj/effect/spawner/structure/Initialize()
. = ..()
if(spawn_list?.len)
if(spawn_list && spawn_list.len)
for(var/I in spawn_list)
new I(get_turf(src))
return INITIALIZE_HINT_QDEL

View File

@@ -1104,7 +1104,7 @@ GLOBAL_DATUM_INIT(fire_overlay, /mutable_appearance, mutable_appearance('icons/e
return
source_item?.reagents?.add_reagent(/datum/reagent/blood, 2)
else if(custom_materials?.len) //if we've got materials, lets see whats in it
else if(custom_materials && custom_materials.len) //if we've got materials, lets see whats in it
/// How many mats have we found? You can only be affected by two material datums by default
var/found_mats = 0
/// How much of each material is in it? Used to determine if the glass should break

View File

@@ -48,7 +48,7 @@
/obj/structure/flora/tree/pine/Initialize()
. = ..()
if(islist(icon_states?.len))
if(islist(icon_states))
icon_state = pick(icon_states)
/obj/structure/flora/tree/pine/xmas

View File

@@ -117,7 +117,7 @@
var/list/varsvars = vv_parse_text(O, new_value)
var/pre_processing = new_value
var/unique
if (varsvars?.len)
if (varsvars && varsvars.len)
unique = tgui_alert(usr, "Process vars unique to each instance, or same for all?", "Variable Association", list("Unique", "Same"))
if(unique == "Unique")
unique = TRUE

View File

@@ -23,7 +23,7 @@ GLOBAL_PROTECT(VVpixelmovement)
var/list/subtypes = subtypesof(type)
if (!subtypes || !subtypes.len)
return FALSE
if (subtypes?.len)
if (subtypes && subtypes.len)
switch(tgui_alert(usr,"Strict object type detection?", "Type detection", list("Strictly this type","This type and subtypes", "Cancel")))
if("Strictly this type")
return FALSE

View File

@@ -77,7 +77,7 @@
while(possible_expansions.len)
for(var/obj/machinery/atmospherics/borderline in possible_expansions)
var/list/result = borderline.pipeline_expansion(src)
if(!result?.len)
if(!(result && result.len))
possible_expansions -= borderline
continue
for(var/obj/machinery/atmospherics/considered_device in result)

View File

@@ -19,7 +19,7 @@
if(accessible_markets.len)
viewing_market = accessible_markets[1]
var/list/categories = SSblackmarket.markets[viewing_market].categories
if(categories?.len)
if(categories && categories.len)
viewing_category = categories[1]
/obj/item/blackmarket_uplink/attackby(obj/item/I, mob/user, params)
@@ -121,7 +121,7 @@
viewing_market = market
var/list/categories = SSblackmarket.markets[viewing_market].categories
if(categories?.len)
if(categories && categories.len)
viewing_category = categories[1]
else
viewing_category = null

View File

@@ -201,7 +201,7 @@
continue
LAZYADD(empty_turfs, T)
CHECK_TICK
if(empty_turfs?.len)
if(empty_turfs && empty_turfs.len)
LZ = pick(empty_turfs)
if (SO.pack.get_cost() <= points_to_check && LZ)//we need to call the cost check again because of the CHECK_TICK call
TIMER_COOLDOWN_START(src, COOLDOWN_EXPRESSPOD_CONSOLE, 5 SECONDS)
@@ -220,7 +220,7 @@
continue
LAZYADD(empty_turfs, T)
CHECK_TICK
if(empty_turfs?.len)
if(empty_turfs && empty_turfs.len)
TIMER_COOLDOWN_START(src, COOLDOWN_EXPRESSPOD_CONSOLE, 10 SECONDS)
D.adjust_money(-(SO.pack.get_cost() * (0.72*MAX_EMAG_ROCKETS)))

View File

@@ -16,7 +16,7 @@
errors |= MANIFEST_ERROR_ITEM
/obj/item/paper/fluff/jobs/cargo/manifest/proc/is_approved()
return stamped?.len && !is_denied()
return (stamped && stamped.len) && !is_denied()
/obj/item/paper/fluff/jobs/cargo/manifest/proc/is_denied()
return stamped && ("stamp-deny" in stamped)

View File

@@ -1143,7 +1143,7 @@ GLOBAL_LIST_EMPTY(preferences_datums)
continue
ban_details = i
break //we only want to get the most recent ban's details
if(ban_details?.len)
if(ban_details && ban_details.len)
var/expires = "This is a permanent ban."
if(ban_details["expiration_time"])
expires = " The ban is for [DisplayTimeText(text2num(ban_details["duration"]) MINUTES)] and expires on [ban_details["expiration_time"]] (server time)."

View File

@@ -304,7 +304,7 @@
how_cool_are_your_threads += "[src]'s storage opens when clicked.\n"
else
how_cool_are_your_threads += "[src]'s storage opens when dragged to yourself.\n"
if (pockets.can_hold?.len) // If pocket type can hold anything, vs only specific items
if (pockets.can_hold && pockets.can_hold.len) // If pocket type can hold anything, vs only specific items
how_cool_are_your_threads += "[src] can store [pockets.max_items] <a href='?src=[REF(src)];show_valid_pocket_items=1'>item\s</a>.\n"
else
how_cool_are_your_threads += "[src] can store [pockets.max_items] item\s that are [weightclass2text(pockets.max_w_class)] or smaller.\n"

View File

@@ -467,7 +467,7 @@
growth_queue += SV
vines += SV
SV.master = src
if(muts?.len)
if(muts && muts.len)
for(var/datum/spacevine_mutation/M in muts)
M.add_mutation_to_vinepiece(SV)
if(parent)

View File

@@ -103,7 +103,7 @@
/obj/item/food/grown/on_grind()
. = ..()
var/nutriment = reagents.get_reagent_amount(/datum/reagent/consumable/nutriment)
if(grind_results?.len)
if(grind_results && grind_results.len)
for(var/i in 1 to grind_results.len)
grind_results[grind_results[i]] = nutriment
reagents.del_reagent(/datum/reagent/consumable/nutriment)
@@ -111,7 +111,7 @@
/obj/item/food/grown/on_juice()
var/nutriment = reagents.get_reagent_amount(/datum/reagent/consumable/nutriment)
if(juice_results?.len)
if(juice_results && juice_results.len)
for(var/i in 1 to juice_results.len)
juice_results[juice_results[i]] = nutriment
reagents.del_reagent(/datum/reagent/consumable/nutriment)

View File

@@ -218,7 +218,7 @@
if(scanned_object.reagents) //we have reagents contents
returned_message += get_analyzer_text_chem_contents(scanned_object)
else if (our_seed.reagents_add?.len) //we have a seed with reagent genes
else if (our_seed.reagents_add && our_seed.reagents_add.len) //we have a seed with reagent genes
returned_message += get_analyzer_text_chem_genes(our_seed)
else
returned_message += "*---------*\nNo reagents found.\n*---------*"

View File

@@ -138,7 +138,8 @@
for(var/L in border)
var/turf/turf_to_disable = L
SSair.remove_from_active(turf_to_disable) //stop processing turfs along the border to prevent runtimes, we return it in initTemplateBounds()
turf_to_disable.atmos_adjacent_turfs?.Cut()
if(turf_to_disable.atmos_adjacent_turfs)
turf_to_disable.atmos_adjacent_turfs.Cut()
// Accept cached maps, but don't save them automatically - we don't want
// ruins clogging up memory for the whole round.

View File

@@ -57,7 +57,7 @@
if(client && hud_used && hud_used.hud_version != HUD_STYLE_NOHUD)
I.screen_loc = ui_hand_position(get_held_index_of_item(I))
client.screen += I
if(observers?.len)
if(observers && observers.len)
for(var/M in observers)
var/mob/dead/observe = M
if(observe.client && observe.client.eye == src)

View File

@@ -549,7 +549,7 @@ generate/load female uniform sprites matching all previously decided variables
//Get the overlays for this item when it's being worn
//eg: ammo counters, primed grenade flashes, etc.
var/list/worn_overlays = worn_overlays(isinhands, file2use)
if(worn_overlays?.len)
if(worn_overlays && worn_overlays.len)
standing.overlays.Add(worn_overlays)
standing = center_image(standing, isinhands ? inhand_x_dimension : worn_x_dimension, isinhands ? inhand_y_dimension : worn_y_dimension)
@@ -643,7 +643,7 @@ generate/load female uniform sprites matching all previously decided variables
/mob/living/carbon/human/proc/update_observer_view(obj/item/I, inventory)
if(observers?.len)
if(observers && observers.len)
for(var/M in observers)
var/mob/dead/observe = M
if(observe.client && observe.client.eye == src)

View File

@@ -53,7 +53,7 @@
// cultural contamination
if(prob(human_surname_chance))
golem_surname = pick(GLOB.last_names)
else if(special_names?.len && prob(special_name_chance))
else if(special_names && special_names.len && prob(special_name_chance))
golem_surname = pick(special_names)
var/golem_name = "[prefix] [golem_surname]"

View File

@@ -39,7 +39,7 @@
I.screen_loc = null
if(client)
client.screen -= I
if(observers?.len)
if(observers && observers.len)
for(var/M in observers)
var/mob/dead/observe = M
if(observe.client)

View File

@@ -548,7 +548,7 @@
if (cameras)
if (cam?.can_use())
queueAlarm("--- [class] alarm detected in [home.name]! (<A HREF=?src=[REF(src)];switchcamera=[REF(cam)]>[cam.c_tag]</A>)", class)
else if (our_cams?.len)
else if (our_cams && our_cams.len)
var/foo = 0
var/dat2 = ""
for (var/obj/machinery/camera/I in our_cams)

View File

@@ -244,7 +244,7 @@
* * add - whether or not the item is being added, or removed.
*/
/mob/living/silicon/robot/proc/observer_screen_update(obj/item/item_module, add = TRUE)
if(observers?.len)
if(observers && observers.len)
for(var/M in observers)
var/mob/dead/observe = M
if(observe.client && observe.client.eye == src)

View File

@@ -565,7 +565,7 @@ Pass a positive integer as an argument to override a bot's default speed.
calling_ai = caller //Link the AI to the bot!
ai_waypoint = waypoint
if(path?.len) //Ensures that a valid path is calculated!
if(path && path.len) //Ensures that a valid path is calculated!
var/end_area = get_area_name(waypoint)
if(!on)
turn_on() //Saves the AI the hassle of having to activate a bot manually.

View File

@@ -524,7 +524,7 @@
/mob/living/simple_animal/bot/mulebot/call_bot()
..()
if(path?.len)
if(path && path.len)
target = ai_waypoint //Target is the end point of the path, the waypoint set by the AI.
destination = get_area_name(target, TRUE)
pathset = 1 //Indicates the AI's custom path is initialized.

View File

@@ -262,12 +262,12 @@
set waitfor = FALSE
if(speak_chance)
if(prob(speak_chance) || override)
if(speak?.len)
if((emote_hear?.len) || (emote_see?.len))
if(speak && speak.len)
if((emote_hear && emote_hear.len) || (emote_see && emote_see.len))
var/length = speak.len
if(emote_hear?.len)
if(emote_hear && emote_hear.len)
length += emote_hear.len
if(emote_see?.len)
if(emote_see && emote_see.len)
length += emote_see.len
var/randomValue = rand(1,length)
if(randomValue <= speak.len)
@@ -281,11 +281,11 @@
else
say(pick(speak), forced = "poly")
else
if(!(emote_hear?.len) && (emote_see?.len))
if(!(emote_hear && emote_hear.len) && (emote_see && emote_see.len))
manual_emote(pick(emote_see))
if((emote_hear?.len) && !(emote_see?.len))
if((emote_hear && emote_hear.len) && !(emote_see && emote_see.len))
manual_emote(pick(emote_hear))
if((emote_hear?.len) && (emote_see?.len))
if((emote_hear && emote_hear.len) && (emote_see && emote_see.len))
var/length = emote_hear.len + emote_see.len
var/pick = rand(1,length)
if(pick <= emote_see.len)

View File

@@ -32,7 +32,7 @@
progressbars = null
for (var/alert in alerts)
clear_alert(alert, TRUE)
if(observers?.len)
if(observers && observers.len)
for(var/M in observers)
var/mob/dead/observe = M
observe.reset_perspective(null)

View File

@@ -172,7 +172,7 @@
else
last_message = null
return TRUE
if(channel?.messages?.len)
if(channel?.messages && channel?.messages.len)
ui_header = last_message == channel.messages[length(channel.messages)] ? "ntnrc_idle.gif" : "ntnrc_new.gif"
else
ui_header = "ntnrc_idle.gif"

View File

@@ -80,7 +80,7 @@
//see if there's a surplus of power remaining in the powernet and stores unused power in the SMES
netexcess = avail - load
if(netexcess > 100 && nodes?.len) // if there was excess power last cycle
if(netexcess > 100 && nodes && nodes.len) // if there was excess power last cycle
for(var/obj/machinery/power/smes/S in nodes) // find the SMESes in the network
S.restore() // and restore some of the power that was used

View File

@@ -96,7 +96,7 @@
if(!ismovable(religious_tool))
CRASH("[name]'s perform_rite had a movable atom that has somehow turned into a non-movable!")
var/atom/movable/movable_reltool = religious_tool
if(!movable_reltool?.buckled_mobs?.len)
if(!(movable_reltool?.buckled_mobs && movable_reltool?.buckled_mobs.len))
return FALSE
var/mob/living/carbon/human/human2borg
for(var/i in movable_reltool.buckled_mobs)

View File

@@ -282,7 +282,7 @@
for(var/obj/item/card/id/ID in src)
qdel(ID)
if(authorized?.len)
if(authorized && authorized.len)
authorized.Cut()
authorized = null

View File

@@ -48,7 +48,7 @@
var/mob/M = target
if(M.anti_magic_check(check_antimagic, check_holy))
return FALSE
if(ignored_factions?.len && faction_check(M.faction,ignored_factions))
if(ignored_factions && ignored_factions.len && faction_check(M.faction,ignored_factions))
return FALSE

View File

@@ -203,7 +203,7 @@
data["choiceB"] = ""
if(user && completed)
var/list/L = power_lottery[user]
if(L?.len)
if(L && L.len)
data["used"] = FALSE
data["choiceA"] = L[1]
data["choiceB"] = L[2]

View File

@@ -34,7 +34,9 @@
CHECK_OUTFIT_SLOT(r_pocket, ITEM_SLOT_RPOCKET)
if (outfit.backpack_contents || outfit.box)
var/list/backpack_contents = outfit.backpack_contents?.Copy()
var/list/backpack_contents = null
if(outfit.backpack_contents)
backpack_contents = outfit.backpack_contents.Copy()
if (outfit.box)
if (!backpack_contents)
backpack_contents = list()