[MIRROR] Converts all A && A.B into A?.B (#1292)

* Converts A && A.B into A?.B (#54342)

Implements the ?. operator, replacing code like A && A.B with A?.B

BYOND Ref:
When reading A?.B, it's equivalent to A && A.B except that A is only evaluated once, even if it's a complex expression like a proc call.

* Converts all A && A.B into A?.B

Co-authored-by: ZeWaka <zewakagamer@gmail.com>
This commit is contained in:
SkyratBot
2020-10-13 23:19:25 +02:00
committed by GitHub
co-authored by ZeWaka
parent ce11cae6b7
commit b8d9874c27
214 changed files with 377 additions and 377 deletions
+1 -1
View File
@@ -8,7 +8,7 @@
/obj/effect/spawner/bundle/Initialize(mapload)
..()
if(items && items.len)
if(items?.len)
for(var/path in items)
new path(loc)
return INITIALIZE_HINT_QDEL
@@ -9,7 +9,7 @@
/obj/effect/spawner/lootdrop/Initialize(mapload)
..()
if(loot && loot.len)
if(loot?.len)
var/loot_spawned = 0
while((lootcount-loot_spawned) && loot.len)
var/lootspawn = pickweight(loot)
@@ -10,7 +10,7 @@ again.
/obj/effect/spawner/structure/Initialize()
. = ..()
if(spawn_list && spawn_list.len)
if(spawn_list?.len)
for(var/I in spawn_list)
new I(get_turf(src))
return INITIALIZE_HINT_QDEL
+1 -1
View File
@@ -362,7 +362,7 @@ GLOBAL_VAR_INIT(embedpocalypse, FALSE) // if true, all items will be able to emb
else
to_chat(user, "<span class='warning'>You burn your hand on [src]!</span>")
var/obj/item/bodypart/affecting = C.get_bodypart("[(user.active_hand_index % 2 == 0) ? "r" : "l" ]_arm")
if(affecting && affecting.receive_damage( 0, 5 )) // 5 burn damage
if(affecting?.receive_damage( 0, 5 )) // 5 burn damage
C.update_damage_overlays()
return
+1 -1
View File
@@ -182,7 +182,7 @@ RSF
var/mob/living/silicon/robot/P = null
if(iscyborg(user))
P = user
if(((obj_flags & EMAGGED) || (P && P.emagged)) && !toxin)
if(((obj_flags & EMAGGED) || (P?.emagged)) && !toxin)
toxin = TRUE
to_dispense = /obj/item/reagent_containers/food/snacks/cookie/sleepy
to_chat(user, "<span class='alert'>Cookie Synthesizer hacked.</span>")
+1 -1
View File
@@ -122,7 +122,7 @@
. += TT.blueprint_data
/obj/item/areaeditor/blueprints/proc/set_viewer(mob/user, message = "")
if(user && user.client)
if(user?.client)
if(viewing)
clear_viewer()
viewing = user.client
+1 -1
View File
@@ -196,7 +196,7 @@
return ..()
/obj/structure/chrono_field/Destroy()
if(gun && gun.field_check(src))
if(gun?.field_check(src))
gun.field_disconnect(src)
return ..()
+3 -3
View File
@@ -277,7 +277,7 @@ CIGARETTE PACKETS ARE IN FANCY.DM
qdel(src)
return
open_flame()
if((reagents && reagents.total_volume) && (nextdragtime <= world.time))
if((reagents?.total_volume) && (nextdragtime <= world.time))
nextdragtime = world.time + dragtime SECONDS
handle_reagents()
@@ -548,7 +548,7 @@ CIGARETTE PACKETS ARE IN FANCY.DM
STOP_PROCESSING(SSobj, src)
return
open_flame()
if(reagents && reagents.total_volume) // check if it has any reagents at all
if(reagents?.total_volume) // check if it has any reagents at all
handle_reagents()
@@ -1004,5 +1004,5 @@ CIGARETTE PACKETS ARE IN FANCY.DM
qdel(src)
return
if(reagents && reagents.total_volume)
if(reagents?.total_volume)
hand_reagents()
+1 -1
View File
@@ -356,7 +356,7 @@ GLOBAL_LIST_EMPTY(PDAs)
dat += "</ul>"
if (count == 0)
dat += "None detected.<br>"
else if(cartridge && cartridge.spam_enabled)
else if(cartridge?.spam_enabled)
dat += "<a href='byond://?src=[REF(src)];choice=MessageAll'>Send To All</a>"
if(6)
dat += "<h4>[PDAIMG(mail)] ExperTrak® Skill Tracker V4.26.2</h4>"
@@ -142,7 +142,7 @@
return html
/obj/item/camera_bug/proc/get_seens()
if(current && current.can_use())
if(current?.can_use())
var/list/seen = current.can_see()
return seen
+1 -1
View File
@@ -131,7 +131,7 @@
if(detect_state)
return
var/datum/camerachunk/chunk = GLOB.cameranet.chunkGenerated(our_turf.x, our_turf.y, our_turf.z)
if(chunk && chunk.seenby.len)
if(chunk?.seenby.len)
for(var/mob/camera/ai_eye/A in chunk.seenby)
if(!A.ai_detector_visible)
continue
+1 -1
View File
@@ -44,7 +44,7 @@
/obj/item/dualsaber/proc/on_wield(obj/item/source, mob/living/carbon/user)
SIGNAL_HANDLER
if(user && user.has_dna())
if(user?.has_dna())
if(user.dna.check_mutation(HULK))
to_chat(user, "<span class='warning'>You lack the grace to wield this!</span>")
return COMPONENT_TWOHANDED_BLOCK_WIELD
+1 -1
View File
@@ -57,7 +57,7 @@
else
location = get_turf(src)
if(location)
if(directional && target && target.density)
if(directional && target?.density)
var/turf/T = get_step(location, aim_dir)
explosion(get_step(T, aim_dir), boom_sizes[1], boom_sizes[2], boom_sizes[3])
else
+1 -1
View File
@@ -634,7 +634,7 @@
if (!on)
return
if (is_type_in_typecache(target, ovens))
if (held_sausage && held_sausage.roasted)
if (held_sausage?.roasted)
to_chat("<span class='warning'>Your [held_sausage] has already been cooked!</span>")
return
if (istype(target, /obj/singularity) && get_dist(user, target) < 10)
+1 -1
View File
@@ -133,7 +133,7 @@
var/crewmember_name = "Unknown"
if(H.wear_id)
var/obj/item/card/id/I = H.wear_id.GetID()
if(I && I.registered_name)
if(I?.registered_name)
crewmember_name = I.registered_name
while(crewmember_name in name_counts)
+2 -2
View File
@@ -58,7 +58,7 @@
new type(loc, max_amount, FALSE)
if(!merge_type)
merge_type = type
if(custom_materials && custom_materials.len)
if(custom_materials?.len)
mats_per_unit = list()
var/in_process_mat_list = custom_materials.Copy()
for(var/i in custom_materials)
@@ -242,7 +242,7 @@
O.setDir(usr.dir)
use(R.req_amount * multiplier)
if(R.applies_mats && custom_materials && custom_materials.len)
if(R.applies_mats && custom_materials?.len)
var/list/used_materials = list()
for(var/i in custom_materials)
used_materials[SSmaterials.GetMaterialRef(i)] = R.req_amount / R.res_amount * (MINERAL_MATERIAL_AMOUNT / custom_materials.len)
@@ -12,7 +12,7 @@
/obj/item/stack/telecrystal/attack(mob/target, mob/user)
if(target == user) //You can't go around smacking people with crystals to find out if they have an uplink or not.
for(var/obj/item/implant/uplink/I in target)
if(I && I.imp_in)
if(I?.imp_in)
var/datum/component/uplink/hidden_uplink = I.GetComponent(/datum/component/uplink)
if(hidden_uplink)
hidden_uplink.telecrystals += amount
+1 -1
View File
@@ -42,7 +42,7 @@
return cell
/obj/item/melee/baton/suicide_act(mob/user)
if(cell && cell.charge && turned_on)
if(cell?.charge && turned_on)
user.visible_message("<span class='suicide'>[user] is putting the live [name] in [user.p_their()] mouth! It looks like [user.p_theyre()] trying to commit suicide!</span>")
. = (FIRELOSS)
attack(user,user)
+1 -1
View File
@@ -442,7 +442,7 @@
* * target: optional arg used in Mech PvP battles (if used, attacker is target's toy)
*/
/obj/item/toy/prize/proc/check_battle_start(mob/living/carbon/user, obj/item/toy/prize/attacker, mob/living/carbon/target)
if(attacker && attacker.in_combat)
if(attacker?.in_combat)
to_chat(user, "<span class='notice'>[target?target.p_their() : "Your" ] [attacker.name] is in combat.</span>")
target?.to_chat(target, "<span class='notice'>Your [attacker.name] is in combat.</span>")
return FALSE
+2 -2
View File
@@ -285,7 +285,7 @@
/obj/structure/sign/painting/update_icon_state()
. = ..()
if(C && C.generated_icon)
if(C?.generated_icon)
icon_state = "frame-overlay"
else
icon_state = "frame-empty"
@@ -293,7 +293,7 @@
/obj/structure/sign/painting/update_overlays()
. = ..()
if(C && C.generated_icon)
if(C?.generated_icon)
var/mutable_appearance/MA = mutable_appearance(C.generated_icon)
MA.pixel_x = C.framed_offset_x
MA.pixel_y = C.framed_offset_y
@@ -35,7 +35,7 @@
"<span class='notice'>You struggle to break free from the gelatinous resin... (Stay still for two minutes.)</span>",\
"<span class='hear'>You hear squelching...</span>")
if(!do_after(M, 1200, target = src))
if(M && M.buckled)
if(M?.buckled)
to_chat(M, "<span class='warning'>You fail to unbuckle yourself!</span>")
return
if(!M.buckled)
+1 -1
View File
@@ -51,7 +51,7 @@
else if(open || broken)
if(istype(I, /obj/item/fireaxe) && !fireaxe)
var/obj/item/fireaxe/F = I
if(F && F.wielded)
if(F?.wielded)
to_chat(user, "<span class='warning'>Unwield the [F.name] first.</span>")
return
if(!user.transferItemToLoc(F, src))
+1 -1
View File
@@ -48,7 +48,7 @@
/obj/structure/flora/tree/pine/Initialize()
. = ..()
if(islist(icon_states && icon_states.len))
if(islist(icon_states?.len))
icon_state = pick(icon_states)
/obj/structure/flora/tree/pine/xmas
@@ -102,7 +102,7 @@
"<span class='notice'>[user] is trying to pull you off [src], opening up fresh wounds!</span>",\
"<span class='hear'>You hear a squishy wet noise.</span>")
if(!do_after(user, 300, target = src))
if(M && M.buckled)
if(M?.buckled)
M.visible_message("<span class='notice'>[user] fails to free [M]!</span>",\
"<span class='notice'>[user] fails to pull you off of [src].</span>")
return
@@ -113,7 +113,7 @@
"<span class='hear'>You hear a wet squishing noise..</span>")
M.adjustBruteLoss(30)
if(!do_after(M, 1200, target = src))
if(M && M.buckled)
if(M?.buckled)
to_chat(M, "<span class='warning'>You fail to free yourself!</span>")
return
if(!M.buckled)
+1 -1
View File
@@ -65,7 +65,7 @@
if(!M.ventcrawler && M.mob_size != MOB_SIZE_TINY)
return FALSE
var/atom/movable/M = caller
if(M && M.pulling)
if(M?.pulling)
return CanAStarPass(ID, to_dir, M.pulling)
return TRUE //diseases, stings, etc can pass