From a87e89a1511cf7dc16a3ed9833a8a706a33c14f6 Mon Sep 17 00:00:00 2001 From: KheirFerrum <102964889+KheirFerrum@users.noreply.github.com> Date: Mon, 22 Apr 2024 22:52:37 +0100 Subject: [PATCH] fix: Construction Recipe check for components same as tool fixed. (#4514) Adds additional check to check_enough_material. --- src/requirements.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/requirements.cpp b/src/requirements.cpp index 4e20d972a375..96077deac712 100644 --- a/src/requirements.cpp +++ b/src/requirements.cpp @@ -878,7 +878,14 @@ bool requirement_data::check_enough_materials( const item_comp &comp, const inve } const int cnt = std::abs( comp.count ) * batch; const tool_comp *tq = find_by_type( tools, comp.type ); - if( tq != nullptr && tq->available == available_status::a_true ) { + // First check is that the use case is the same (soldering iron charges + // being used in tools but the item itself being used as a component) + // If it isn't count_by_charges() any loaded versions are not considered + // valid components + // Second check is just that the tool has been considered valid, + // so must be offset when you count how much is available. + if( tq != nullptr && comp.type->count_by_charges() == tq->by_charges() && + tq->available == available_status::a_true ) { // The very same item type is also needed as tool! // Use charges of it, or use it by count? const int tc = tq->by_charges() ? 1 : std::abs( tq->count );