Fixing issues with contents of some coded or mapped closets exceeding their storage capacity (#62221)

This commit is contained in:
Ghom
2021-10-20 23:06:20 -07:00
committed by GitHub
parent 0cfb68cd52
commit bc9d83be44
6 changed files with 28 additions and 19 deletions
@@ -67,7 +67,7 @@
/obj/structure/closet/Initialize(mapload)
if(mapload && !opened) // if closed, any item at the crate's loc is put in the contents
addtimer(CALLBACK(src, .proc/take_contents), 0)
addtimer(CALLBACK(src, .proc/take_contents, TRUE), 0)
. = ..()
update_appearance()
PopulateContents()
@@ -227,14 +227,16 @@
if(throwing)
throwing.finalize(FALSE)
/obj/structure/closet/proc/take_contents()
var/atom/L = drop_location()
if(!L)
/obj/structure/closet/proc/take_contents(mapload = FALSE)
var/atom/location = drop_location()
if(!location)
return
for(var/atom/movable/AM in L)
if(AM != src && insert(AM) == LOCKER_FULL) // limit reached
for(var/atom/movable/AM in location)
if(AM != src && insert(AM, mapload) == LOCKER_FULL) // limit reached
if(mapload) // Yea, it's a mapping issue. Blame mappers.
WARNING("Closet storage capacity of [type] exceeded on mapload at [AREACOORD(src)]")
break
for(var/i in reverse_range(L.get_all_contents()))
for(var/i in reverse_range(location.get_all_contents()))
var/atom/movable/thing = i
SEND_SIGNAL(thing, COMSIG_TRY_STORAGE_HIDE_ALL)
@@ -259,9 +261,12 @@
/obj/structure/closet/proc/after_open(mob/living/user, force = FALSE)
return
/obj/structure/closet/proc/insert(atom/movable/inserted)
/obj/structure/closet/proc/insert(atom/movable/inserted, mapload = FALSE)
if(length(contents) >= storage_capacity)
return LOCKER_FULL
if(!mapload)
return LOCKER_FULL
//For maploading, we only return LOCKER_FULL if the movable was otherwise insertable. This way we can avoid logging false flags.
return insertion_allowed(inserted) ? LOCKER_FULL : FALSE
if(!insertion_allowed(inserted))
return FALSE
if(SEND_SIGNAL(src, COMSIG_CLOSET_INSERT, inserted) & COMPONENT_CLOSET_INSERT_INTERRUPT)
@@ -95,6 +95,7 @@
/obj/structure/closet/syndicate/resources/everything
desc = "It's an emergency storage closet for repairs."
storage_capacity = 60 // This is gonna be used for debug.
/obj/structure/closet/syndicate/resources/everything/PopulateContents()
var/list/resources = list(
@@ -163,8 +163,6 @@
icon_door = "mixed"
/obj/structure/closet/wardrobe/mixed/PopulateContents()
if(prob(40))
new /obj/item/clothing/suit/jacket(src)
if(prob(40))
new /obj/item/clothing/suit/jacket(src)
new /obj/item/clothing/under/color/white(src)
@@ -187,13 +185,8 @@
new /obj/item/clothing/under/color/jumpskirt/teal(src)
new /obj/item/clothing/under/color/lightpurple(src)
new /obj/item/clothing/under/color/jumpskirt/lightpurple(src)
new /obj/item/clothing/under/color/green(src)
new /obj/item/clothing/under/color/jumpskirt/green(src)
new /obj/item/clothing/mask/bandana/red(src)
new /obj/item/clothing/mask/bandana/red(src)
new /obj/item/clothing/mask/bandana/blue(src)
new /obj/item/clothing/mask/bandana/blue(src)
new /obj/item/clothing/mask/bandana/gold(src)
new /obj/item/clothing/mask/bandana/gold(src)
new /obj/item/clothing/shoes/sneakers/black(src)
new /obj/item/clothing/shoes/sneakers/brown(src)