From 0ba2d473bdd330c4fbbe85c6ecf9bfdcd41a3652 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Fri, 6 Jan 2023 17:31:25 +0100 Subject: [PATCH] [MIRROR] datum stock part fixes [MDB IGNORE] (#18537) * datum stock part fixes (#72467) ## About The Pull Request The issues 1. RPED is not converting `obj/item/stock_parts/scanning_module` into `datum/stock_part/scanning_module` before adding it into the constructable frame's `component_parts `causing any for loop construct like ``` for(var/datum/stock_part/scanning_module/scanning_module in component_parts) //do stuff ``` to fail for example in the BEPIS machine https://user-images.githubusercontent.com/110812394/210534328-35317784-2f55-482a-b50f-8bdea0c8cd66.mp4 2. You can add infinite amount of scanning modules to an constructable machine frame. Even if that that machine requires just 1 scanning module(say for anomaly refinery) you can keep on adding scanning modules to that frame forever. Happens only when you manually put the part in by hand https://user-images.githubusercontent.com/110812394/210534406-0c2b7f3d-31c7-4271-9d21-b902fda432e0.mp4 ## Why It's Good For The Game This fixes the above mentioned bugs ## Changelog :cl: fix: check for stock parts that can be added to a machine frame by hand fix: RPED converts stock parts into datum parts before inserting it into a machine frame only if possible. e.g. for scanning modules /:cl: * datum stock part fixes Co-authored-by: SyncIt21 <110812394+SyncIt21@users.noreply.github.com> --- code/game/machinery/constructable_frame.dm | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/code/game/machinery/constructable_frame.dm b/code/game/machinery/constructable_frame.dm index fdc6b6650d1..d85c925096e 100644 --- a/code/game/machinery/constructable_frame.dm +++ b/code/game/machinery/constructable_frame.dm @@ -289,14 +289,22 @@ if(QDELETED(incoming_stack)) break if(!QDELETED(part)) //If we're a stack and we merged we might not exist anymore - components += part - part.forceMove(src) + var/stock_part_datum = GLOB.stock_part_datums_per_object[part.type] + if (!isnull(stock_part_datum)) + components += stock_part_datum + qdel(part) + else + components += part + part.forceMove(src) to_chat(user, span_notice("You add [part] to [src].")) if(added_components.len) replacer.play_rped_sound() return for(var/stock_part_base in req_components) + if (req_components[stock_part_base] == 0) + continue + var/stock_part_path if (ispath(stock_part_base, /obj/item)) @@ -308,9 +316,6 @@ stack_trace("Bad stock part in req_components: [stock_part_base]") continue - if (req_components[stock_part_path] == 0) - continue - if (!istype(P, stock_part_path)) continue