From ad5a944c8a49655f9f90aa15b2c45604ecb1f2c0 Mon Sep 17 00:00:00 2001 From: CHOMPStation2StaffMirrorBot <94713762+CHOMPStation2StaffMirrorBot@users.noreply.github.com> Date: Sat, 29 Nov 2025 22:05:21 -0700 Subject: [PATCH] [MIRROR] Mech construction fix and unittest (#12062) Co-authored-by: Will <7099514+Willburd@users.noreply.github.com> Co-authored-by: C.L. --- .../helper_datums/construction_datum.dm | 3 +- code/game/mecha/mecha_construction_paths.dm | 28 +++++++++---------- .../game/mecha/mecha_construction_paths_ch.dm | 2 +- .../micro/mecha_construction_paths_vr.dm | 6 ++-- code/modules/unit_tests/_unit_tests.dm | 1 + code/modules/unit_tests/construction_tests.dm | 11 ++++++++ code/modules/xenobio/items/weapons_vr.dm | 3 +- code/modules/xenobio/machinery/processor.dm | 3 +- .../game/mecha/mecha_construction_paths.dm | 4 +-- 9 files changed, 38 insertions(+), 23 deletions(-) create mode 100644 code/modules/unit_tests/construction_tests.dm diff --git a/code/datums/helper_datums/construction_datum.dm b/code/datums/helper_datums/construction_datum.dm index 6e07bc262a..37cf1fd2aa 100644 --- a/code/datums/helper_datums/construction_datum.dm +++ b/code/datums/helper_datums/construction_datum.dm @@ -74,7 +74,8 @@ /datum/construction/proc/spawn_result() if(result) - SEND_GLOBAL_SIGNAL(COMSIG_GLOB_MECH_CONSTRUCTED, new result(get_turf(holder))) + var/atom/spawned_construct = new result(get_turf(holder)) + SEND_GLOBAL_SIGNAL(COMSIG_GLOB_MECH_CONSTRUCTED, spawned_construct) spawn() qdel(holder) return diff --git a/code/game/mecha/mecha_construction_paths.dm b/code/game/mecha/mecha_construction_paths.dm index 5029c68ed1..0a034ae119 100644 --- a/code/game/mecha/mecha_construction_paths.dm +++ b/code/game/mecha/mecha_construction_paths.dm @@ -99,7 +99,7 @@ /datum/construction/reversible/mecha/ripley - result = "/obj/mecha/working/ripley" + result = /obj/mecha/working/ripley steps = list( //1 list("key"=IS_WELDER, @@ -307,7 +307,7 @@ /datum/construction/reversible/mecha/gygax - result = "/obj/mecha/combat/gygax" + result = /obj/mecha/combat/gygax steps = list( //1 list("key"=IS_WELDER, @@ -589,7 +589,7 @@ /datum/construction/reversible/mecha/serenity - result = "/obj/mecha/combat/gygax/serenity" + result = /obj/mecha/combat/gygax/serenity steps = list( //1 list("key"=IS_WELDER, @@ -872,7 +872,7 @@ /datum/construction/reversible/mecha/firefighter - result = "/obj/mecha/working/ripley/firefighter" + result = /obj/mecha/working/ripley/firefighter steps = list( //1 list("key"=IS_WELDER, @@ -1092,7 +1092,7 @@ /datum/construction/reversible/mecha/durand - result = "/obj/mecha/combat/durand" + result = /obj/mecha/combat/durand steps = list( //1 list("key"=IS_WELDER, @@ -1374,7 +1374,7 @@ /datum/construction/reversible/mecha/odysseus - result = "/obj/mecha/medical/odysseus" + result = /obj/mecha/medical/odysseus steps = list( //1 list("key"=IS_WELDER, @@ -1554,7 +1554,7 @@ // Phazon ////////////////////// /datum/construction/mecha/phazon_chassis - result = "/obj/mecha/combat/phazon" + result = /obj/mecha/combat/phazon steps = list(list("key"=/obj/item/mecha_parts/part/phazon_torso),//1 list("key"=/obj/item/mecha_parts/part/phazon_left_arm),//2 list("key"=/obj/item/mecha_parts/part/phazon_right_arm),//3 @@ -1583,7 +1583,7 @@ return /datum/construction/reversible/mecha/phazon - result = "/obj/mecha/combat/phazon" + result = /obj/mecha/combat/phazon steps = list( //1 list("key"=IS_WELDER, @@ -1833,7 +1833,7 @@ // Janus ////////////////////// /datum/construction/mecha/janus_chassis - result = "/obj/mecha/combat/phazon/janus" + result = /obj/mecha/combat/phazon/janus steps = list(list("key"=/obj/item/mecha_parts/part/janus_torso),//1 list("key"=/obj/item/mecha_parts/part/janus_left_arm),//2 list("key"=/obj/item/mecha_parts/part/janus_right_arm),//3 @@ -1862,7 +1862,7 @@ return /datum/construction/reversible/mecha/janus - result = "/obj/mecha/combat/phazon/janus" + result = /obj/mecha/combat/phazon/janus steps = list( //1 list("key"=IS_WELDER, @@ -2138,7 +2138,7 @@ // Pinnace ////////////////////// /datum/construction/mecha/fighter/pinnace_chassis - result = "/obj/mecha/combat/fighter/pinnace" + result = /obj/mecha/combat/fighter/pinnace steps = list(list("key"=/obj/item/mecha_parts/fighter/part/pinnace_core),//1 list("key"=/obj/item/mecha_parts/fighter/part/pinnace_cockpit),//2 list("key"=/obj/item/mecha_parts/fighter/part/pinnace_main_engine),//3 @@ -2168,7 +2168,7 @@ return /datum/construction/reversible/mecha/fighter/pinnace - result = "/obj/mecha/combat/fighter/pinnace" + result = /obj/mecha/combat/fighter/pinnace steps = list( //1 list("key"=IS_WELDER, @@ -2421,7 +2421,7 @@ // Baron ////////////////////// /datum/construction/mecha/fighter/baron_chassis - result = "/obj/mecha/combat/fighter/baron" + result = /obj/mecha/combat/fighter/baron steps = list(list("key"=/obj/item/mecha_parts/fighter/part/baron_core),//1 list("key"=/obj/item/mecha_parts/fighter/part/baron_cockpit),//2 list("key"=/obj/item/mecha_parts/fighter/part/baron_main_engine),//3 @@ -2451,7 +2451,7 @@ return /datum/construction/reversible/mecha/fighter/baron - result = "/obj/mecha/combat/fighter/baron" + result = /obj/mecha/combat/fighter/baron steps = list( //1 list("key"=IS_WELDER, diff --git a/code/game/mecha/mecha_construction_paths_ch.dm b/code/game/mecha/mecha_construction_paths_ch.dm index d7b9d3c805..8dc6f788ef 100644 --- a/code/game/mecha/mecha_construction_paths_ch.dm +++ b/code/game/mecha/mecha_construction_paths_ch.dm @@ -28,7 +28,7 @@ /datum/construction/reversible/mecha/scarab - result = "/obj/mecha/combat/scarab" + result = /obj/mecha/combat/scarab steps = list( //1 list("key"=IS_WELDER, diff --git a/code/game/mecha/micro/mecha_construction_paths_vr.dm b/code/game/mecha/micro/mecha_construction_paths_vr.dm index 54c68d716b..badd649618 100644 --- a/code/game/mecha/micro/mecha_construction_paths_vr.dm +++ b/code/game/mecha/micro/mecha_construction_paths_vr.dm @@ -29,7 +29,7 @@ /datum/construction/reversible/mecha/polecat - result = "/obj/mecha/micro/sec/polecat" + result = /obj/mecha/micro/sec/polecat steps = list( //1 list("key"=IS_WELDER, @@ -308,7 +308,7 @@ /datum/construction/reversible/mecha/gopher - result = "/obj/mecha/micro/utility/gopher" + result = /obj/mecha/micro/utility/gopher steps = list( //1 list("key"=IS_WELDER, @@ -514,7 +514,7 @@ /datum/construction/reversible/mecha/weasel - result = "/obj/mecha/micro/sec/weasel" + result = /obj/mecha/micro/sec/weasel steps = list( //1 list("key"=IS_WELDER, diff --git a/code/modules/unit_tests/_unit_tests.dm b/code/modules/unit_tests/_unit_tests.dm index 1869a4b56c..dfafa724fd 100644 --- a/code/modules/unit_tests/_unit_tests.dm +++ b/code/modules/unit_tests/_unit_tests.dm @@ -91,6 +91,7 @@ #include "autowiki.dm" //#include "clothing_tests.dm" // FIXME #include "component_tests.dm" +#include "construction_tests.dm" #include "cosmetic_tests.dm" #include "dcs_check_list_arguments.dm" #include "dcs_get_id_from_elements.dm" diff --git a/code/modules/unit_tests/construction_tests.dm b/code/modules/unit_tests/construction_tests.dm new file mode 100644 index 0000000000..d848041583 --- /dev/null +++ b/code/modules/unit_tests/construction_tests.dm @@ -0,0 +1,11 @@ +/datum/unit_test/mech_construction/Run() + var/failed = FALSE + for(var/datum/construction/C as anything in subtypesof(/datum/construction)) + // We check for null, as null is legal here... For now... Mech construction needs a full refactor to make them unittest-able in a not ugly way. + if(!C.result) + continue + if(!ispath(C.result)) + TEST_NOTICE(src, "[C.type]: Mech Construction - Had invalid result \"[C.result]\", must be a path.") + failed = TRUE + if(failed) + TEST_FAIL("Mech Construction - A construction datum had incorrect data.") diff --git a/code/modules/xenobio/items/weapons_vr.dm b/code/modules/xenobio/items/weapons_vr.dm index 9b662fed3b..64b76cc82f 100644 --- a/code/modules/xenobio/items/weapons_vr.dm +++ b/code/modules/xenobio/items/weapons_vr.dm @@ -112,7 +112,8 @@ while(S.cores) playsound(src, 'sound/machines/juicer.ogg', 25, 1) if(do_after(user, 15, target = src)) - SEND_GLOBAL_SIGNAL(COMSIG_GLOB_HARVEST_SLIME_CORE, new S.coretype(get_turf(AM))) + var/atom/new_core = new S.coretype(get_turf(AM)) + SEND_GLOBAL_SIGNAL(COMSIG_GLOB_HARVEST_SLIME_CORE, new_core) playsound(src, 'sound/effects/splat.ogg', 50, 1) S.cores-- qdel(S) diff --git a/code/modules/xenobio/machinery/processor.dm b/code/modules/xenobio/machinery/processor.dm index 1ad5dc742a..8fac480b24 100644 --- a/code/modules/xenobio/machinery/processor.dm +++ b/code/modules/xenobio/machinery/processor.dm @@ -82,7 +82,8 @@ if(istype(AM, /mob/living/simple_mob/slime)) var/mob/living/simple_mob/slime/S = AM while(S.cores) - SEND_GLOBAL_SIGNAL(COMSIG_GLOB_HARVEST_SLIME_CORE, new S.coretype(get_turf(src))) + var/atom/new_core = new S.coretype(get_turf(src)) + SEND_GLOBAL_SIGNAL(COMSIG_GLOB_HARVEST_SLIME_CORE, new_core) playsound(src, 'sound/effects/splat.ogg', 50, 1) S.cores-- sleep(1 SECOND) diff --git a/modular_chomp/code/game/mecha/mecha_construction_paths.dm b/modular_chomp/code/game/mecha/mecha_construction_paths.dm index d4a4980064..f1855672e1 100644 --- a/modular_chomp/code/game/mecha/mecha_construction_paths.dm +++ b/modular_chomp/code/game/mecha/mecha_construction_paths.dm @@ -1,6 +1,6 @@ //Hades Construction// /datum/construction/mecha/hades_chassis - result = "/obj/mecha/combat/hades" + result = /obj/mecha/combat/hades steps = list(list("key"=/obj/item/mecha_parts/part/hades_torso),//1 list("key"=/obj/item/mecha_parts/part/hades_left_arm),//2 list("key"=/obj/item/mecha_parts/part/hades_right_arm),//3 @@ -29,7 +29,7 @@ return /datum/construction/reversible/mecha/hades - result = "/obj/mecha/combat/phazon" + result = /obj/mecha/combat/phazon steps = list( //1 list("key"=IS_WELDER,