Convert clothing to initialize (#3263)

changes:

Converted all clothing types to Initialize.
Added some missing destroys to some custom items.
Char setup now forcibly initializes the mannequin's contents if SSatoms has not finished yet.
/obj/item/clothing/under no longer does in icon_states() in New().
This commit is contained in:
Lohikar
2017-08-13 15:32:07 -05:00
committed by Erki
parent d1c3a58c87
commit b8bb48ef76
16 changed files with 112 additions and 79 deletions

View File

@@ -54,6 +54,7 @@
var/list/human_socks_cache = list() var/list/human_socks_cache = list()
// This is an assoc list of all icon states in `icons/mob/collar.dmi`, used by human update-icons. // This is an assoc list of all icon states in `icons/mob/collar.dmi`, used by human update-icons.
var/list/collar_states var/list/collar_states
var/list/uniform_states
/datum/controller/subsystem/icon_cache/New() /datum/controller/subsystem/icon_cache/New()
NEW_SS_GLOBAL(SSicon_cache) NEW_SS_GLOBAL(SSicon_cache)
@@ -62,3 +63,8 @@
collar_states = list() collar_states = list()
for (var/i in icon_states('icons/mob/collar.dmi')) for (var/i in icon_states('icons/mob/collar.dmi'))
collar_states[i] = TRUE collar_states[i] = TRUE
/datum/controller/subsystem/icon_cache/proc/setup_uniform_mappings()
uniform_states = list()
for (var/i in icon_states('icons/mob/uniform.dmi'))
uniform_states[i] = TRUE

View File

@@ -119,6 +119,17 @@ var/datum/controller/subsystem/atoms/SSatoms
return QDELETED(A) return QDELETED(A)
/datum/controller/subsystem/atoms/proc/ForceInitializeContents(atom/A)
var/list/mload_args = list(TRUE)
var/loaded = 0
for (var/thing in A)
var/atom/movable/AM = thing
if (!AM.initialized)
InitAtom(AM, mload_args)
++loaded
log_debug("atoms: force-loaded [loaded] out of [A.contents.len] atoms in [A].")
/datum/controller/subsystem/atoms/proc/InitLog() /datum/controller/subsystem/atoms/proc/InitLog()
. = "" . = ""
for(var/path in BadInitializeCalls) for(var/path in BadInitializeCalls)

View File

@@ -55,8 +55,8 @@
origin_tech = list(TECH_ILLEGAL = 3) origin_tech = list(TECH_ILLEGAL = 3)
var/global/list/clothing_choices var/global/list/clothing_choices
/obj/item/clothing/under/chameleon/New() /obj/item/clothing/under/chameleon/Initialize()
..() . = ..()
if(!clothing_choices) if(!clothing_choices)
var/blocked = list(src.type, /obj/item/clothing/under/gimmick, /obj/item/clothing/under/rank/centcom_officer/bst)//Prevent infinite loops and bad jumpsuits. var/blocked = list(src.type, /obj/item/clothing/under/gimmick, /obj/item/clothing/under/rank/centcom_officer/bst)//Prevent infinite loops and bad jumpsuits.
clothing_choices = generate_chameleon_choices(/obj/item/clothing/under, blocked) clothing_choices = generate_chameleon_choices(/obj/item/clothing/under, blocked)
@@ -92,8 +92,8 @@
body_parts_covered = 0 body_parts_covered = 0
var/global/list/clothing_choices var/global/list/clothing_choices
/obj/item/clothing/head/chameleon/New() /obj/item/clothing/head/chameleon/Initialize()
..() . = ..()
if(!clothing_choices) if(!clothing_choices)
var/blocked = list(src.type, /obj/item/clothing/head/justice,)//Prevent infinite loops and bad hats. var/blocked = list(src.type, /obj/item/clothing/head/justice,)//Prevent infinite loops and bad hats.
clothing_choices = generate_chameleon_choices(/obj/item/clothing/head, blocked) clothing_choices = generate_chameleon_choices(/obj/item/clothing/head, blocked)
@@ -128,8 +128,8 @@
origin_tech = list(TECH_ILLEGAL = 3) origin_tech = list(TECH_ILLEGAL = 3)
var/global/list/clothing_choices var/global/list/clothing_choices
/obj/item/clothing/suit/chameleon/New() /obj/item/clothing/suit/chameleon/Initialize()
..() . = ..()
if(!clothing_choices) if(!clothing_choices)
var/blocked = list(src.type, /obj/item/clothing/suit/cyborg_suit, /obj/item/clothing/suit/justice, /obj/item/clothing/suit/greatcoat) var/blocked = list(src.type, /obj/item/clothing/suit/cyborg_suit, /obj/item/clothing/suit/justice, /obj/item/clothing/suit/greatcoat)
clothing_choices = generate_chameleon_choices(/obj/item/clothing/suit, blocked) clothing_choices = generate_chameleon_choices(/obj/item/clothing/suit, blocked)
@@ -163,8 +163,8 @@
origin_tech = list(TECH_ILLEGAL = 3) origin_tech = list(TECH_ILLEGAL = 3)
var/global/list/clothing_choices var/global/list/clothing_choices
/obj/item/clothing/shoes/chameleon/New() /obj/item/clothing/shoes/chameleon/Initialize()
..() . = ..()
if(!clothing_choices) if(!clothing_choices)
var/blocked = list(src.type, /obj/item/clothing/shoes/syndigaloshes, /obj/item/clothing/shoes/cyborg, /obj/item/clothing/shoes/black/bst)//prevent infinite loops and bad shoes. var/blocked = list(src.type, /obj/item/clothing/shoes/syndigaloshes, /obj/item/clothing/shoes/cyborg, /obj/item/clothing/shoes/black/bst)//prevent infinite loops and bad shoes.
clothing_choices = generate_chameleon_choices(/obj/item/clothing/shoes, blocked) clothing_choices = generate_chameleon_choices(/obj/item/clothing/shoes, blocked)
@@ -242,8 +242,8 @@
origin_tech = list(TECH_ILLEGAL = 3) origin_tech = list(TECH_ILLEGAL = 3)
var/global/list/clothing_choices var/global/list/clothing_choices
/obj/item/clothing/gloves/chameleon/New() /obj/item/clothing/gloves/chameleon/Initialize()
..() . = ..()
if(!clothing_choices) if(!clothing_choices)
var/blocked = list(src.type, /obj/item/clothing/gloves/swat/bst) var/blocked = list(src.type, /obj/item/clothing/gloves/swat/bst)
clothing_choices = generate_chameleon_choices(/obj/item/clothing/gloves, blocked) clothing_choices = generate_chameleon_choices(/obj/item/clothing/gloves, blocked)
@@ -278,8 +278,8 @@
origin_tech = list(TECH_ILLEGAL = 3) origin_tech = list(TECH_ILLEGAL = 3)
var/global/list/clothing_choices var/global/list/clothing_choices
/obj/item/clothing/mask/chameleon/New() /obj/item/clothing/mask/chameleon/Initialize()
..() . = ..()
if(!clothing_choices) if(!clothing_choices)
clothing_choices = generate_chameleon_choices(/obj/item/clothing/mask, list(src.type)) clothing_choices = generate_chameleon_choices(/obj/item/clothing/mask, list(src.type))
@@ -313,8 +313,8 @@
origin_tech = list(TECH_ILLEGAL = 3) origin_tech = list(TECH_ILLEGAL = 3)
var/list/global/clothing_choices var/list/global/clothing_choices
/obj/item/clothing/glasses/chameleon/New() /obj/item/clothing/glasses/chameleon/Initialize()
..() . = ..()
if(!clothing_choices) if(!clothing_choices)
var/blocked = list(src.type, /obj/item/clothing/glasses/sunglasses/bst) var/blocked = list(src.type, /obj/item/clothing/glasses/sunglasses/bst)
clothing_choices = generate_chameleon_choices(/obj/item/clothing/glasses, blocked) clothing_choices = generate_chameleon_choices(/obj/item/clothing/glasses, blocked)

View File

@@ -543,18 +543,20 @@ BLIND // can't see anything
return return
..() ..()
/obj/item/clothing/under/New() /obj/item/clothing/under/Initialize()
..() . = ..()
if(worn_state) if(worn_state)
if(!item_state_slots) LAZYINITLIST(item_state_slots)
item_state_slots = list()
item_state_slots[slot_w_uniform_str] = worn_state item_state_slots[slot_w_uniform_str] = worn_state
else else
worn_state = icon_state worn_state = icon_state
//autodetect rollability //autodetect rollability
if(rolled_down < 0) if(rolled_down < 0)
if((worn_state + "_d_s") in icon_states('icons/mob/uniform.dmi')) if (!SSicon_cache.uniform_states)
SSicon_cache.setup_uniform_mappings()
if (SSicon_cache.uniform_states["[worn_state]_d_s"])
rolled_down = 0 rolled_down = 0
/obj/item/clothing/under/proc/update_rolldown_status() /obj/item/clothing/under/proc/update_rolldown_status()
@@ -721,6 +723,6 @@ BLIND // can't see anything
usr << "<span class='notice'>You roll down your [src]'s sleeves.</span>" usr << "<span class='notice'>You roll down your [src]'s sleeves.</span>"
update_clothing_icon() update_clothing_icon()
/obj/item/clothing/under/rank/New() /obj/item/clothing/under/rank/Initialize()
sensor_mode = pick(0,1,2,3) sensor_mode = pick(0,1,2,3)
..() . = ..()

View File

@@ -152,13 +152,13 @@
var/hat_color var/hat_color
contained_sprite = 1 contained_sprite = 1
/obj/item/clothing/head/det/technicolor/New() /obj/item/clothing/head/det/technicolor/Initialize()
if(prob(5)) if(prob(5))
var/list/colors = list("yellow"=2,"red"=1,"white"=1,"orange"=1,"purple"=1,"green"=1,"blue"=1 ) var/list/colors = list("yellow"=2,"red"=1,"white"=1,"orange"=1,"purple"=1,"green"=1,"blue"=1 )
var/color = pickweight(colors) var/color = pickweight(colors)
icon_state = "hat_detective_[color]" icon_state = "hat_detective_[color]"
item_state = "hat_detective_[color]" item_state = "hat_detective_[color]"
..() . = ..()
/obj/item/clothing/head/det/technicolor/attackby(obj/item/weapon/O as obj, mob/user as mob) /obj/item/clothing/head/det/technicolor/attackby(obj/item/weapon/O as obj, mob/user as mob)
if(istype(O, /obj/item/weapon/reagent_containers/glass/paint)) if(istype(O, /obj/item/weapon/reagent_containers/glass/paint))

View File

@@ -16,8 +16,8 @@
item_state = null item_state = null
w_class = 1 w_class = 1
/obj/item/clothing/mask/muzzle/New() /obj/item/clothing/mask/muzzle/Initialize()
..() . = ..()
say_messages = list("Mmfph!", "Mmmf mrrfff!", "Mmmf mnnf!") say_messages = list("Mmfph!", "Mmmf mrrfff!", "Mmmf mnnf!")
say_verbs = list("mumbles", "says") say_verbs = list("mumbles", "says")
@@ -116,8 +116,8 @@
w_class = 2 w_class = 2
siemens_coefficient = 0.9 siemens_coefficient = 0.9
/obj/item/clothing/mask/horsehead/New() /obj/item/clothing/mask/horsehead/Initialize()
..() . = ..()
// The horse mask doesn't cause voice changes by default, the wizard spell changes the flag as necessary // The horse mask doesn't cause voice changes by default, the wizard spell changes the flag as necessary
say_messages = list("NEEIIGGGHHHH!", "NEEEIIIIGHH!", "NEIIIGGHH!", "HAAWWWWW!", "HAAAWWW!") say_messages = list("NEEIIGGGHHHH!", "NEEEIIIIGHH!", "NEIIIGGHH!", "HAAWWWWW!", "HAAAWWW!")
say_verbs = list("whinnies", "neighs", "says") say_verbs = list("whinnies", "neighs", "says")
@@ -131,7 +131,8 @@
body_parts_covered = 0 body_parts_covered = 0
var/mob/eye/aiEye/eye var/mob/eye/aiEye/eye
/obj/item/clothing/mask/ai/New() /obj/item/clothing/mask/ai/Initialize()
. = ..()
eye = new(src) eye = new(src)
/obj/item/clothing/mask/ai/equipped(var/mob/user, var/slot) /obj/item/clothing/mask/ai/equipped(var/mob/user, var/slot)

View File

@@ -26,6 +26,6 @@
changer.voice = voice changer.voice = voice
usr << "<span class='notice'>You are now mimicking <B>[changer.voice]</B>.</span>" usr << "<span class='notice'>You are now mimicking <B>[changer.voice]</B>.</span>"
/obj/item/clothing/mask/gas/voice/New() /obj/item/clothing/mask/gas/voice/Initialize()
..() . = ..()
changer = new(src) changer = new(src)

View File

@@ -19,9 +19,9 @@
var/burn_damage = 0 // Specifically burn damage. var/burn_damage = 0 // Specifically burn damage.
var/base_name // Used to keep the original name safe while we apply modifiers. var/base_name // Used to keep the original name safe while we apply modifiers.
/obj/item/clothing/suit/space/New() /obj/item/clothing/suit/space/Initialize()
..() . = ..()
base_name = "[name]" base_name = name
//Some simple descriptors for breaches. Global because lazy, TODO: work out a better way to do this. //Some simple descriptors for breaches. Global because lazy, TODO: work out a better way to do this.

View File

@@ -13,8 +13,8 @@
var/pocket_size = 2 var/pocket_size = 2
var/pocket_total = null//This will be calculated, unless specifically overidden var/pocket_total = null//This will be calculated, unless specifically overidden
/obj/item/clothing/suit/armor/New() /obj/item/clothing/suit/armor/Initialize()
..() . = ..()
pockets = new /obj/item/weapon/storage/internal(src) pockets = new /obj/item/weapon/storage/internal(src)
pockets.storage_slots = pocket_slots //two slots pockets.storage_slots = pocket_slots //two slots
pockets.max_w_class = pocket_size //fit only pocket sized items pockets.max_w_class = pocket_size //fit only pocket sized items
@@ -25,8 +25,7 @@
/obj/item/clothing/suit/armor/Destroy() /obj/item/clothing/suit/armor/Destroy()
if (pockets) if (pockets)
qdel(pockets) QDEL_NULL(pockets)
pockets = null
return ..() return ..()
/obj/item/clothing/suit/armor/attack_hand(mob/user as mob) /obj/item/clothing/suit/armor/attack_hand(mob/user as mob)
@@ -253,12 +252,12 @@
siemens_coefficient = 0.5 siemens_coefficient = 0.5
var/obj/item/clothing/accessory/holster/holster var/obj/item/clothing/accessory/holster/holster
/obj/item/clothing/suit/armor/tactical/New() /obj/item/clothing/suit/armor/tactical/Initialize()
..() . = ..()
holster = new() holster = new()
holster.on_attached(src) //its inside a suit, we set this so it can be drawn from holster.on_attached(src) //its inside a suit, we set this so it can be drawn from
QDEL_NULL(pockets) //Tactical armour has internal holster instead of pockets, so we null this out QDEL_NULL(pockets) //Tactical armour has internal holster instead of pockets, so we null this out
overlays.Cut() // Remove the holster's overlay. cut_overlays() // Remove the holster's overlay.
/obj/item/clothing/suit/armor/tactical/attackby(obj/item/W as obj, mob/user as mob) /obj/item/clothing/suit/armor/tactical/attackby(obj/item/W as obj, mob/user as mob)
..() ..()
@@ -336,8 +335,8 @@
allowed = list(/obj/item/weapon/gun,/obj/item/weapon/reagent_containers/spray/pepper,/obj/item/ammo_magazine,/obj/item/ammo_casing,/obj/item/weapon/melee/baton,/obj/item/weapon/handcuffs,/obj/item/device/flashlight) allowed = list(/obj/item/weapon/gun,/obj/item/weapon/reagent_containers/spray/pepper,/obj/item/ammo_magazine,/obj/item/ammo_casing,/obj/item/weapon/melee/baton,/obj/item/weapon/handcuffs,/obj/item/device/flashlight)
siemens_coefficient = 0.5 siemens_coefficient = 0.5
/obj/item/clothing/suit/storage/vest/New() /obj/item/clothing/suit/storage/vest/Initialize()
..() . = ..()
pockets.storage_slots = 2 //two slots pockets.storage_slots = 2 //two slots
/obj/item/clothing/suit/storage/vest/officer /obj/item/clothing/suit/storage/vest/officer

View File

@@ -131,13 +131,13 @@
var/suit_color var/suit_color
contained_sprite = 1 contained_sprite = 1
/obj/item/clothing/suit/storage/det_trench/technicolor/New() /obj/item/clothing/suit/storage/det_trench/technicolor/Initialize()
if(prob(5)) if(prob(5))
var/list/colors = list("yellow"=2,"red"=1,"white"=1,"orange"=1,"purple"=1,"green"=1,"blue"=1 ) var/list/colors = list("yellow"=2,"red"=1,"white"=1,"orange"=1,"purple"=1,"green"=1,"blue"=1 )
var/color = pickweight(colors) var/color = pickweight(colors)
icon_state = "suit_detective_[color]" icon_state = "suit_detective_[color]"
item_state = "suit_detective_[color]" item_state = "suit_detective_[color]"
..() . = ..()
/obj/item/clothing/suit/storage/det_trench/technicolor/attackby(obj/item/weapon/O as obj, mob/user as mob) /obj/item/clothing/suit/storage/det_trench/technicolor/attackby(obj/item/weapon/O as obj, mob/user as mob)
if(istype(O, /obj/item/weapon/reagent_containers/glass/paint)) if(istype(O, /obj/item/weapon/reagent_containers/glass/paint))

View File

@@ -1,8 +1,8 @@
/obj/item/clothing/suit/storage /obj/item/clothing/suit/storage
var/obj/item/weapon/storage/internal/pockets var/obj/item/weapon/storage/internal/pockets
/obj/item/clothing/suit/storage/New() /obj/item/clothing/suit/storage/Initialize()
..() . = ..()
pockets = new/obj/item/weapon/storage/internal(src) pockets = new/obj/item/weapon/storage/internal(src)
pockets.storage_slots = 2 //two slots pockets.storage_slots = 2 //two slots
pockets.max_w_class = 2 //fit only pocket sized items pockets.max_w_class = 2 //fit only pocket sized items
@@ -58,15 +58,15 @@
update_clothing_icon() //so our overlays update update_clothing_icon() //so our overlays update
/obj/item/clothing/suit/storage/vest/merc/New() /obj/item/clothing/suit/storage/vest/merc/Initialize()
..() . = ..()
pockets = new/obj/item/weapon/storage/internal(src) pockets = new/obj/item/weapon/storage/internal(src)
pockets.storage_slots = 4 pockets.storage_slots = 4
pockets.max_w_class = 2 pockets.max_w_class = 2
pockets.max_storage_space = 8 pockets.max_storage_space = 8
/obj/item/clothing/suit/storage/vest/hos/New() /obj/item/clothing/suit/storage/vest/hos/Initialize()
..() . = ..()
pockets = new/obj/item/weapon/storage/internal(src) pockets = new/obj/item/weapon/storage/internal(src)
pockets.storage_slots = 4 pockets.storage_slots = 4
pockets.max_w_class = 2 pockets.max_w_class = 2

View File

@@ -7,8 +7,8 @@
var/obj/item/weapon/storage/internal/hold var/obj/item/weapon/storage/internal/hold
w_class = 3.0 w_class = 3.0
/obj/item/clothing/accessory/storage/New() /obj/item/clothing/accessory/storage/Initialize()
..() . = ..()
hold = new/obj/item/weapon/storage/internal(src) hold = new/obj/item/weapon/storage/internal(src)
hold.storage_slots = slots hold.storage_slots = slots
hold.max_storage_space = 12 hold.max_storage_space = 12
@@ -96,14 +96,16 @@
icon_state = "unathiharness2" icon_state = "unathiharness2"
slots = 2 slots = 2
/obj/item/clothing/accessory/storage/knifeharness/New() /obj/item/clothing/accessory/storage/knifeharness/Initialize()
..() . = ..()
hold.max_storage_space = 4 hold.max_storage_space = 4
hold.can_hold = list(/obj/item/weapon/material/hatchet/unathiknife,\ hold.can_hold = list(
/obj/item/weapon/material/kitchen/utensil/knife,\ /obj/item/weapon/material/hatchet/unathiknife,
/obj/item/weapon/material/kitchen/utensil/knife/plastic,\ /obj/item/weapon/material/kitchen/utensil/knife,
/obj/item/weapon/material/knife,\ /obj/item/weapon/material/kitchen/utensil/knife/plastic,
/obj/item/weapon/material/knife/ritual) /obj/item/weapon/material/knife,
/obj/item/weapon/material/knife/ritual
)
new /obj/item/weapon/material/hatchet/unathiknife(hold) new /obj/item/weapon/material/hatchet/unathiknife(hold)
new /obj/item/weapon/material/hatchet/unathiknife(hold) new /obj/item/weapon/material/hatchet/unathiknife(hold)

View File

@@ -67,9 +67,13 @@ All custom items with worn sprites must follow the contained sprite system: http
contained_sprite = TRUE contained_sprite = TRUE
var/obj/item/weapon/disk/chip var/obj/item/weapon/disk/chip
/obj/item/clothing/glasses/fluff/nebula_glasses/New() /obj/item/clothing/glasses/fluff/nebula_glasses/Initialize()
. = ..()
chip = new /obj/item/weapon/disk/fluff/nebula_chip() chip = new /obj/item/weapon/disk/fluff/nebula_chip()
..()
/obj/item/clothing/glasses/fluff/nebula_glasses/Destroy()
QDEL_NULL(chip)
return ..()
/obj/item/clothing/glasses/fluff/nebula_glasses/attack_self(mob/user as mob) /obj/item/clothing/glasses/fluff/nebula_glasses/attack_self(mob/user as mob)
if(chip) if(chip)
@@ -847,13 +851,16 @@ All custom items with worn sprites must follow the contained sprite system: http
icon_state = "ikrad_beret" icon_state = "ikrad_beret"
item_state = "ikrad_beret" item_state = "ikrad_beret"
contained_sprite = TRUE contained_sprite = TRUE
var/letter var/obj/item/fluff/ikrad_letter/letter
/obj/item/clothing/head/beret/engineering/fluff/ikrad_beret/New() /obj/item/clothing/head/beret/engineering/fluff/ikrad_beret/Initialize()
..() . = ..()
var/obj/item/fluff/ikrad_letter/hat_letter = new(src) letter = new(src)
letter = hat_letter letter.attack_self()
hat_letter.attack_self()
/obj/item/clothing/head/beret/engineering/fluff/ikrad_beret/Destroy()
QDEL_NULL(letter)
return ..()
/obj/item/clothing/head/beret/engineering/fluff/ikrad_beret/attack_self(var/mob/user) /obj/item/clothing/head/beret/engineering/fluff/ikrad_beret/attack_self(var/mob/user)
if(letter) if(letter)

View File

@@ -38,11 +38,11 @@ var/const/MAX_ACTIVE_TIME = 400
if(hit_zone == "head") if(hit_zone == "head")
Attach(target) Attach(target)
/obj/item/clothing/mask/facehugger/New() /obj/item/clothing/mask/facehugger/Initialize()
if(config.aliens_allowed) if(config.aliens_allowed)
..() . = ..()
else else
qdel(src) . = INITIALIZE_HINT_QDEL
/obj/item/clothing/mask/facehugger/examine(mob/user) /obj/item/clothing/mask/facehugger/examine(mob/user)
..(user) ..(user)

View File

@@ -226,6 +226,10 @@ datum/preferences
SSjobs.EquipCustomDeferred(mannequin, src, leftovers, used_slots) SSjobs.EquipCustomDeferred(mannequin, src, leftovers, used_slots)
if (!SSATOMS_IS_PROBABLY_DONE)
SSatoms.ForceInitializeContents(mannequin)
mannequin.regenerate_icons()
else
mannequin.update_icons() mannequin.update_icons()
/datum/preferences/proc/update_preview_icon() /datum/preferences/proc/update_preview_icon()

View File

@@ -24,7 +24,8 @@
var/last_twitch = 0 var/last_twitch = 0
var/max_stored_messages = 100 var/max_stored_messages = 100
/obj/item/clothing/mask/gas/poltergeist/New() /obj/item/clothing/mask/gas/poltergeist/Initialize()
. = ..()
START_PROCESSING(SSprocessing, src) START_PROCESSING(SSprocessing, src)
listening_objects += src listening_objects += src