mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-07-20 04:17:33 +01:00
Make two lists lazy (#3435)
Makes the accessories list on uniforms and the shockedby list on doors lazy, as well as reduces the number of add_overlay() calls by airlocks.
This commit is contained in:
@@ -533,10 +533,10 @@ About the new airlock wires panel:
|
||||
src.electrified_until = 0
|
||||
else if(duration) //electrify door for the given duration seconds
|
||||
if(usr)
|
||||
shockedby += text("\[[time_stamp()]\] - [usr](ckey:[usr.ckey])")
|
||||
LAZYADD(shockedby, "\[[time_stamp()]\] - [usr](ckey:[usr.ckey])")
|
||||
usr.attack_log += text("\[[time_stamp()]\] <font color='red'>Electrified the [name] at [x] [y] [z]</font>")
|
||||
else
|
||||
shockedby += text("\[[time_stamp()]\] - EMP)")
|
||||
LAZYADD(shockedby, "\[[time_stamp()]\] - EMP)")
|
||||
message = "The door is now electrified [duration == -1 ? "permanently" : "for [duration] second\s"]."
|
||||
src.electrified_until = duration == -1 ? -1 : world.time + SecondsToTicks(duration)
|
||||
if (electrified_until > 0)
|
||||
@@ -593,6 +593,7 @@ About the new airlock wires panel:
|
||||
if (QDELING(src))
|
||||
return
|
||||
cut_overlays()
|
||||
var/list/new_overlays = list()
|
||||
if(density)
|
||||
if(locked && lights && src.arePowerSystemsOn())
|
||||
icon_state = "door_locked"
|
||||
@@ -606,23 +607,23 @@ About the new airlock wires panel:
|
||||
has_set_boltlight = FALSE
|
||||
if(p_open || welded)
|
||||
if(p_open)
|
||||
add_overlay("panel_open")
|
||||
new_overlays += "panel_open"
|
||||
if (!(stat & NOPOWER))
|
||||
if(stat & BROKEN)
|
||||
add_overlay("sparks_broken")
|
||||
new_overlays += "sparks_broken"
|
||||
else if (health < maxhealth * 3/4)
|
||||
add_overlay("sparks_damaged")
|
||||
new_overlays += "sparks_damaged"
|
||||
if(welded)
|
||||
add_overlay("welded")
|
||||
new_overlays += "welded"
|
||||
else if (health < maxhealth * 3/4 && !(stat & NOPOWER))
|
||||
add_overlay("sparks_damaged")
|
||||
new_overlays += "sparks_damaged"
|
||||
|
||||
if (hatch_image)
|
||||
if (hatchstate)
|
||||
hatch_image.icon_state = "[hatchstyle]_open"
|
||||
else
|
||||
hatch_image.icon_state = hatchstyle
|
||||
add_overlay(hatch_image)
|
||||
new_overlays += hatch_image
|
||||
else
|
||||
if(p_open && panel_visible_while_open)
|
||||
icon_state = "o_door_open"
|
||||
@@ -635,7 +636,7 @@ About the new airlock wires panel:
|
||||
set_light(0)
|
||||
has_set_boltlight = FALSE
|
||||
|
||||
update_above()
|
||||
add_overlay(new_overlays)
|
||||
|
||||
/obj/machinery/door/airlock/do_animate(animation)
|
||||
switch(animation)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
/obj/machinery/door/airlock
|
||||
var/id_tag
|
||||
var/frequency
|
||||
var/tmp/shockedby = list()
|
||||
var/tmp/shockedby
|
||||
var/tmp/datum/radio_frequency/radio_connection
|
||||
var/tmp/cur_command = null //the command the door is currently attempting to complete
|
||||
var/tmp/waiting_for_roundstart
|
||||
|
||||
@@ -375,7 +375,7 @@ var/list/global/slot_flags_enumeration = list(
|
||||
H << "<span class='warning'>You need a jumpsuit before you can attach this [name].</span>"
|
||||
return 0
|
||||
var/obj/item/clothing/under/uniform = H.w_uniform
|
||||
if(uniform.accessories.len && !uniform.can_attach_accessory(src))
|
||||
if(LAZYLEN(uniform.accessories) && !uniform.can_attach_accessory(src))
|
||||
if (!disable_warning)
|
||||
H << "<span class='warning'>You already have an accessory of this type attached to your [uniform].</span>"
|
||||
return 0
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
var/list/species_restricted = null //Only these species can wear this kit.
|
||||
var/gunshot_residue //Used by forensics.
|
||||
|
||||
var/list/accessories = list()
|
||||
var/list/accessories
|
||||
var/list/valid_accessory_slots
|
||||
var/list/restricted_accessory_slots
|
||||
|
||||
@@ -537,7 +537,7 @@ BLIND // can't see anything
|
||||
|
||||
|
||||
/obj/item/clothing/under/attack_hand(var/mob/user)
|
||||
if(accessories && accessories.len)
|
||||
if(LAZYLEN(accessories))
|
||||
..()
|
||||
if ((ishuman(usr) || issmall(usr)) && src.loc == user)
|
||||
return
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
.=1
|
||||
else
|
||||
return 0
|
||||
if(accessories.len && restricted_accessory_slots && (A.slot in restricted_accessory_slots))
|
||||
if(LAZYLEN(accessories) && restricted_accessory_slots && (A.slot in restricted_accessory_slots))
|
||||
for(var/obj/item/clothing/accessory/AC in accessories)
|
||||
if (AC.slot == A.slot)
|
||||
return 0
|
||||
@@ -24,7 +24,7 @@
|
||||
user << "<span class='warning'>You cannot attach more accessories of this type to [src].</span>"
|
||||
return
|
||||
|
||||
if(accessories.len)
|
||||
if(LAZYLEN(accessories))
|
||||
for(var/obj/item/clothing/accessory/A in accessories)
|
||||
A.attackby(I, user)
|
||||
return
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
/obj/item/clothing/attack_hand(var/mob/user)
|
||||
//only forward to the attached accessory if the clothing is equipped (not in a storage)
|
||||
if(accessories.len && src.loc == user)
|
||||
if(LAZYLEN(accessories) && src.loc == user)
|
||||
for(var/obj/item/clothing/accessory/A in accessories)
|
||||
A.attack_hand(user)
|
||||
return
|
||||
@@ -60,12 +60,12 @@
|
||||
|
||||
/obj/item/clothing/examine(var/mob/user)
|
||||
..(user)
|
||||
if(accessories.len)
|
||||
if(LAZYLEN(accessories))
|
||||
for(var/obj/item/clothing/accessory/A in accessories)
|
||||
user << "\A [A] is attached to it."
|
||||
|
||||
/obj/item/clothing/proc/attach_accessory(mob/user, obj/item/clothing/accessory/A)
|
||||
accessories += A
|
||||
LAZYADD(accessories, A)
|
||||
A.on_attached(src, user)
|
||||
src.verbs |= /obj/item/clothing/proc/removetie_verb
|
||||
update_clothing_icon()
|
||||
@@ -75,7 +75,7 @@
|
||||
return
|
||||
|
||||
A.on_removed(user)
|
||||
accessories -= A
|
||||
LAZYREMOVE(accessories, A)
|
||||
update_clothing_icon()
|
||||
|
||||
/obj/item/clothing/proc/removetie_verb()
|
||||
@@ -84,18 +84,18 @@
|
||||
set src in usr
|
||||
if(!istype(usr, /mob/living)) return
|
||||
if(usr.stat) return
|
||||
if(!accessories.len) return
|
||||
if(!LAZYLEN(accessories)) return
|
||||
var/obj/item/clothing/accessory/A
|
||||
if(accessories.len > 1)
|
||||
if(LAZYLEN(accessories) > 1)
|
||||
A = input("Select an accessory to remove from [src]") as null|anything in accessories
|
||||
else
|
||||
A = accessories[1]
|
||||
src.remove_accessory(usr,A)
|
||||
if(!accessories.len)
|
||||
if(!LAZYLEN(accessories))
|
||||
src.verbs -= /obj/item/clothing/proc/removetie_verb
|
||||
|
||||
/obj/item/clothing/emp_act(severity)
|
||||
if(accessories.len)
|
||||
if(LAZYLEN(accessories))
|
||||
for(var/obj/item/clothing/accessory/A in accessories)
|
||||
A.emp_act(severity)
|
||||
..()
|
||||
|
||||
@@ -96,7 +96,7 @@
|
||||
H = src
|
||||
else if (istype(src, /obj/item/clothing/under))
|
||||
var/obj/item/clothing/under/S = src
|
||||
if (S.accessories.len)
|
||||
if (LAZYLEN(S.accessories))
|
||||
H = locate() in S.accessories
|
||||
else if (istype(src, /obj/item/clothing/suit/armor/tactical)) // This armor is a snowflake and has an integrated holster.
|
||||
var/obj/item/clothing/suit/armor/tactical/tacticool = src
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
var/tie_msg
|
||||
if(istype(w_uniform,/obj/item/clothing/under))
|
||||
var/obj/item/clothing/under/U = w_uniform
|
||||
if(U.accessories.len)
|
||||
if(LAZYLEN(U.accessories))
|
||||
tie_msg += ". Attached to it is [lowertext(english_list(U.accessories))]"
|
||||
|
||||
if(w_uniform.blood_DNA)
|
||||
|
||||
@@ -298,7 +298,7 @@
|
||||
if(legcuffed)
|
||||
dat += "<BR><A href='?src=\ref[src];item=[slot_legcuffed]'>Legcuffed</A>"
|
||||
|
||||
if(suit && suit.accessories.len)
|
||||
if(suit && LAZYLEN(suit.accessories))
|
||||
dat += "<BR><A href='?src=\ref[src];item=tie'>Remove accessory</A>"
|
||||
dat += "<BR><A href='?src=\ref[src];item=splints'>Remove splints</A>"
|
||||
dat += "<BR><A href='?src=\ref[src];item=pockets'>Empty pockets</A>"
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
return 1
|
||||
if("tie")
|
||||
var/obj/item/clothing/under/suit = w_uniform
|
||||
if(!istype(suit) || !suit.accessories.len)
|
||||
if(!istype(suit) || !LAZYLEN(suit.accessories))
|
||||
return 0
|
||||
var/obj/item/clothing/accessory/A = suit.accessories[1]
|
||||
if(!istype(A))
|
||||
@@ -50,9 +50,7 @@
|
||||
user.visible_message("<span class='danger'>\The [user] tears off \the [A] from [src]'s [suit.name]!</span>")
|
||||
attack_log += "\[[time_stamp()]\] <font color='orange'>Has had \the [A] removed by [user.name] ([user.ckey])</font>"
|
||||
user.attack_log += "\[[time_stamp()]\] <font color='red'>Attempted to remove [name]'s ([ckey]) [A.name]</font>"
|
||||
A.on_removed(user)
|
||||
suit.accessories -= A
|
||||
update_inv_w_uniform()
|
||||
suit.remove_accessory(user, A)
|
||||
return 1
|
||||
|
||||
// Are we placing or stripping?
|
||||
|
||||
@@ -535,7 +535,7 @@ There are several things that need to be remembered:
|
||||
//accessories
|
||||
if (istype(w_uniform, /obj/item/clothing/under))//Prevent runtime errors with unusual objects
|
||||
var/obj/item/clothing/under/under = w_uniform
|
||||
if(under.accessories.len)
|
||||
if(LAZYLEN(under.accessories))
|
||||
if (!ovr)
|
||||
ovr = list(standing)
|
||||
|
||||
@@ -871,9 +871,10 @@ There are several things that need to be remembered:
|
||||
|
||||
// Accessories - copied from uniform, BOILERPLATE because fuck this system.
|
||||
var/obj/item/clothing/suit/suit = wear_suit
|
||||
if(istype(suit) && suit.accessories.len)
|
||||
if(istype(suit) && LAZYLEN(suit.accessories))
|
||||
if (!ovr)
|
||||
ovr = list(standing)
|
||||
|
||||
for(var/obj/item/clothing/accessory/A in suit.accessories)
|
||||
ovr += A.get_mob_overlay()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user