From 97843a368a66b523c3e5440443d8603208df536a Mon Sep 17 00:00:00 2001 From: David Seguin Date: Wed, 9 Mar 2022 00:51:45 -0500 Subject: [PATCH] Fix appliance construction errors with debug hammerspace (#55811) * Fix appliance construction errors with debug hammerspace * Rename `is_app` variable Co-authored-by: Zhilkin Serg --- src/construction.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/construction.cpp b/src/construction.cpp index 92db01b315325..fa00854046794 100644 --- a/src/construction.cpp +++ b/src/construction.cpp @@ -1003,10 +1003,24 @@ void place_construction( const construction_group_str_id &group ) if( here.tr_at( pnt ).is_null() ) { here.trap_set( pnt, tr_unfinished_construction ); } + const bool is_appliance = con.category == construction_category_APPLIANCE; // Use up the components for( const auto &it : con.requirements->get_components() ) { - std::list tmp = player_character.consume_items( it, 1, is_crafting_component ); - used.splice( used.end(), tmp ); + if( is_appliance && player_character.has_trait( trait_DEBUG_HS ) ) { + // appliances require a base item in the construction + used.emplace_back( item( it.front().type ) ); + } else { + std::list tmp = player_character.consume_items( it, 1, is_crafting_component ); + used.splice( used.end(), tmp ); + } + } + // If player has debug hammerspace while building an appliance, they won't get + // the appliance they want unless lastconsumed points to the appliance's base itype + if( is_appliance && player_character.has_trait( trait_DEBUG_HS ) ) { + const std::vector > &comp_list = con.requirements->get_components(); + if( !comp_list.empty() && !comp_list.front().empty() ) { + player_character.lastconsumed = comp_list.front().front().type; + } } pc.components = used; here.partial_con_set( pnt, pc );