Skip to content

Commit

Permalink
Fix appliance construction errors with debug hammerspace (#55811)
Browse files Browse the repository at this point in the history
* Fix appliance construction errors with debug hammerspace

* Rename `is_app` variable

Co-authored-by: Zhilkin Serg <[email protected]>
  • Loading branch information
dseguin and ZhilkinSerg authored Mar 9, 2022
1 parent 08f7884 commit 97843a3
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/construction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<item> 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<item> 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<std::vector<item_comp> > &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 );
Expand Down

0 comments on commit 97843a3

Please sign in to comment.