diff --git a/src/magic.cpp b/src/magic.cpp index 7f31ebf29860d..eb0402512d3f2 100644 --- a/src/magic.cpp +++ b/src/magic.cpp @@ -1216,11 +1216,8 @@ bool spell::can_cast( const Character &guy ) const return false; } - // only required because crafting_inventory always rebuilds the cache. maybe a const version doesn't write to cache. - Character &guy_inv = const_cast( guy ); - if( !type->spell_components.is_empty() && - !type->spell_components->can_make_with_inventory( guy_inv.crafting_inventory( guy.pos(), 0 ), + !type->spell_components->can_make_with_inventory( guy.crafting_inventory( guy.pos(), 0, false ), return_true ) ) { return false; } @@ -1236,6 +1233,7 @@ void spell::use_components( Character &guy ) const const requirement_data &spell_components = type->spell_components.obj(); // if we're here, we're assuming the Character has the correct components (using can_cast()) inventory map_inv; + map_inv.form_from_map( guy.pos(), 0, &guy, true, false ); for( const std::vector &comp_vec : spell_components.get_components() ) { guy.consume_items( guy.select_item_component( comp_vec, 1, map_inv ), 1 ); } @@ -2777,13 +2775,13 @@ void spellcasting_callback::spell_info_text( const spell &sp, int width ) if( sp.has_components() ) { if( !sp.components().get_components().empty() ) { for( const std::string &line : sp.components().get_folded_components_list( - width - 2, c_light_gray, pc.crafting_inventory(), return_true ) ) { + width - 2, c_light_gray, pc.crafting_inventory( pc.pos(), 0, false ), return_true ) ) { info_txt.emplace_back( line ); } } if( !( sp.components().get_tools().empty() && sp.components().get_qualities().empty() ) ) { for( const std::string &line : sp.components().get_folded_tools_list( - width - 2, c_light_gray, pc.crafting_inventory() ) ) { + width - 2, c_light_gray, pc.crafting_inventory( pc.pos(), 0, false ) ) ) { info_txt.emplace_back( line ); } }