From 2ba40403a0cb990e5db467b5f2c248f079e7912e Mon Sep 17 00:00:00 2001 From: Ghom <42542238+Ghommie@users.noreply.github.com> Date: Sun, 17 Mar 2024 16:08:01 +0100 Subject: [PATCH] Fixing cargo. (#82036) ## About The Pull Request I borked carg with my black market refactor, and nobody really noticed because we don't have a unit test to detect the issue. This PR is aimed to fix #81987 and prevent similar accidents in the future. ## Why It's Good For The Game See above. ## Changelog :cl: fix: FIXED CARGO EXPORTS! /:cl: --- code/modules/cargo/exports.dm | 2 +- code/modules/unit_tests/_unit_tests.dm | 1 + code/modules/unit_tests/cargo_selling.dm | 34 ++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 code/modules/unit_tests/cargo_selling.dm diff --git a/code/modules/cargo/exports.dm b/code/modules/cargo/exports.dm index 224a27062f5..171adc0e096 100644 --- a/code/modules/cargo/exports.dm +++ b/code/modules/cargo/exports.dm @@ -90,7 +90,7 @@ Then the player gets the profit from selling his own wasted time. if(dry_run && !export.scannable) external_report.all_contents_scannable = FALSE break - sold = export.sell_object(exported_atom, exported_atom, dry_run, apply_elastic) + sold = export.sell_object(exported_atom, external_report, dry_run, apply_elastic) external_report.exported_atoms += " [exported_atom.name]" break return sold diff --git a/code/modules/unit_tests/_unit_tests.dm b/code/modules/unit_tests/_unit_tests.dm index 46b2470d647..2e186407748 100644 --- a/code/modules/unit_tests/_unit_tests.dm +++ b/code/modules/unit_tests/_unit_tests.dm @@ -108,6 +108,7 @@ #include "cable_powernets.dm" #include "card_mismatch.dm" #include "cardboard_cutouts.dm" +#include "cargo_selling.dm" #include "chain_pull_through_space.dm" #include "changeling.dm" #include "chat_filter.dm" diff --git a/code/modules/unit_tests/cargo_selling.dm b/code/modules/unit_tests/cargo_selling.dm new file mode 100644 index 00000000000..31d90505bdf --- /dev/null +++ b/code/modules/unit_tests/cargo_selling.dm @@ -0,0 +1,34 @@ +/// Makes sure exports work and things can be sold +/datum/unit_test/cargo_selling + +/obj/item/cargo_unit_test_container + +/obj/item/cargo_unit_test_container/Initialize(mapload) + . = ..() + new /obj/item/cargo_unit_test_content(src) + +/obj/item/cargo_unit_test_content + +/datum/export/cargo_unit_test_container + cost = PAYCHECK_LOWER + export_types = list(/obj/item/cargo_unit_test_container) + +/datum/export/cargo_unit_test_content + cost = PAYCHECK_COMMAND + export_types = list(/obj/item/cargo_unit_test_content) + +/datum/unit_test/cargo_selling/Run() + var/obj/item/cargo_unit_test_container/box = allocate(/obj/item/cargo_unit_test_container) + var/obj/item/cargo_unit_test_container/box_skip_content = allocate(/obj/item/cargo_unit_test_container) + + var/datum/export_report/report_one = export_item_and_contents(box, apply_elastic = FALSE) + if(isnull(report_one)) + TEST_FAIL("called 'export_item_and_contents', but no export report was returned.") + var/value = counterlist_sum(report_one.total_value) + TEST_ASSERT_EQUAL(value, PAYCHECK_LOWER + PAYCHECK_COMMAND, "'export_item_and_contents' value didn't match expected value") + + var/datum/export_report/report_two = export_single_item(box_skip_content, apply_elastic = FALSE) + if(isnull(report_two)) + TEST_FAIL("called 'export_single_item', but no export report was returned.") + value = counterlist_sum(report_two.total_value) + TEST_ASSERT_EQUAL(value, PAYCHECK_LOWER, "'export_single_item' value didn't match expected value")