Files
Bubberstation/code/modules/unit_tests/closets.dm
Seth Scherer 284827ff66 Fixes a closet harddel (#69889)
* Fixes a closet harddel
PopulateContents is called in init which means that the closet is being
qdelled but it's contents are not being properly removed when the
prob(1) is called and it returns the qdel hint. This returns the qdel
hint BEFORE parents init is called to stop this from happening

* okay im just stupid

* moves it

* Update code/modules/unit_tests/closets.dm

Co-authored-by: ShizCalev <ShizCalev@users.noreply.github.com>

* Update code/modules/unit_tests/closets.dm

Co-authored-by: ShizCalev <ShizCalev@users.noreply.github.com>
2022-09-14 14:39:18 -04:00

26 lines
1.4 KiB
Plaintext

/// Checks that the length of the initial contents of a closet doesn't exceed its storage capacity.
/// Also checks that nothing inside that isn't immediate is a steal objective.
/datum/unit_test/closets
/datum/unit_test/closets/Run()
var/list/all_closets = subtypesof(/obj/structure/closet)
//Supply pods. They are sent, crashed, opened and never closed again. They also cause exceptions in nullspace.
all_closets -= typesof(/obj/structure/closet/supplypod)
for(var/closet_type in all_closets)
var/obj/structure/closet/closet = allocate(closet_type)
if(istype(closet_type, /obj/structure/closet/emcloset) && QDELETED(closet)) // this is here because the emcloset subtype has a chance of returning a qdel hint on initialize
continue
// Copy is necessary otherwise closet.contents - immediate_contents returns an empty list
var/list/immediate_contents = closet.contents.Copy()
closet.PopulateContents()
var/contents_len = length(closet.contents)
if(contents_len > closet.storage_capacity)
TEST_FAIL("Initial Contents of [closet.type] ([contents_len]) exceed its storage capacity ([closet.storage_capacity]).")
for (var/obj/item/item in closet.contents - immediate_contents)
if (item.type in GLOB.steal_item_handler.objectives_by_path)
TEST_FAIL("[closet_type] contains a steal objective [item.type] in PopulateContents(). Move it to populate_contents_immediate().")