From 2d4f21761c851828043b5a512ffb03f423b62a0c Mon Sep 17 00:00:00 2001 From: Angela Graves Date: Fri, 5 Mar 2021 06:41:44 -0600 Subject: [PATCH] Merge pull request #47869 from Jamuro-g/Fix-disassembly-component-display fix disassembly component display --- src/item.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/item.cpp b/src/item.cpp index bf22b5d660e0..2cc0dbfde8c0 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -9503,7 +9503,15 @@ std::vector item::get_uncraft_components() const } else { //Make a new vector of components from the registered components for( const item &component : components ) { - ret.push_back( item_comp( component.typeId(), component.count() ) ); + auto iter = std::find_if( ret.begin(), ret.end(), [component]( item_comp & obj ) { + return obj.type == component.typeId(); + } ); + + if( iter != ret.end() ) { + iter->count += component.count(); + } else { + ret.push_back( item_comp( component.typeId(), component.count() ) ); + } } } return ret;