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.
This commit is contained in:
ZeWaka
2020-10-13 16:43:53 -03:00
committed by GitHub
parent a92fcb5295
commit 9629feed35
214 changed files with 377 additions and 377 deletions
+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