Skip to content

Commit 2f51ef6

Browse files
committed
fix Start Vehicle Construction cancelling
1 parent af81efe commit 2f51ef6

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

src/character.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3733,7 +3733,8 @@ class Character : public Creature, public visitable
37333733
// Selects one entry in components using select_item_component and consumes those items.
37343734
std::list<item> consume_items( const std::vector<item_comp> &components, int batch = 1,
37353735
const std::function<bool( const item & )> &filter = return_true<item>,
3736-
const std::function<bool( const itype_id & )> &select_ind = return_false<itype_id> );
3736+
const std::function<bool( const itype_id & )> &select_ind = return_false<itype_id>,
3737+
const bool can_cancel = false );
37373738
bool consume_software_container( const itype_id &software_id );
37383739
comp_selection<tool_comp>
37393740
select_tool_component( const std::vector<tool_comp> &tools, int batch, read_only_visitable &map_inv,

src/construction.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1313,7 +1313,11 @@ void place_construction( std::vector<construction_group_str_id> const &groups )
13131313
} else {
13141314
// Use up the components
13151315
for( const std::vector<item_comp> &it : con.requirements->get_components() ) {
1316-
std::list<item> tmp = player_character.consume_items( it, 1, is_crafting_component );
1316+
std::list<item> tmp = player_character.consume_items( it, 1, is_crafting_component,
1317+
return_false<itype_id>, true );
1318+
if( tmp.empty() ) {
1319+
return;
1320+
}
13171321
used.splice( used.end(), tmp );
13181322
}
13191323
}

src/crafting.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2192,11 +2192,13 @@ In that case, consider using select_item_component with 1 pre-created map invent
21922192
to consume_items */
21932193
std::list<item> Character::consume_items( const std::vector<item_comp> &components, int batch,
21942194
const std::function<bool( const item & )> &filter,
2195-
const std::function<bool( const itype_id & )> &select_ind )
2195+
const std::function<bool( const itype_id & )> &select_ind,
2196+
const bool can_cancel )
21962197
{
21972198
inventory map_inv;
21982199
map_inv.form_from_map( pos_bub(), PICKUP_RANGE, this );
2199-
comp_selection<item_comp> sel = select_item_component( components, batch, map_inv, false, filter );
2200+
comp_selection<item_comp> sel = select_item_component( components, batch, map_inv, can_cancel,
2201+
filter );
22002202
return consume_items( sel, batch, filter, select_ind( sel.comp.type ) );
22012203
}
22022204

0 commit comments

Comments
 (0)