diff --git a/src/activity_handlers.cpp b/src/activity_handlers.cpp index d717c83dd50d6..a0fb77f0ff72c 100644 --- a/src/activity_handlers.cpp +++ b/src/activity_handlers.cpp @@ -2634,20 +2634,19 @@ void activity_handlers::craft_do_turn( player_activity *act, player *p ) if( !craft->is_craft() ) { debugmsg( "ACT_CRAFT target '%s' is not a craft. Aborting ACT_CRAFT.", craft->tname() ); - act->set_to_null(); + p->cancel_activity(); return; } if( !p->has_item( *craft ) ) { p->add_msg_if_player( "%s no longer has the target '%s.' Aborting ACT_CRAFT.", p->disp_name(), craft->tname() ); - act->set_to_null(); + p->cancel_activity(); return; } const recipe &rec = craft->get_making(); const float crafting_speed = p->crafting_speed_multiplier( rec, true ); const bool is_long = act->values[0]; - act->set_to_null(); if( crafting_speed <= 0.0f ) { if( p->lighting_craft_speed_multiplier( rec ) <= 0.0f ) { @@ -2655,6 +2654,7 @@ void activity_handlers::craft_do_turn( player_activity *act, player *p ) } else { p->add_msg_if_player( m_bad, _( "You are too frustrated to continue and just give up." ) ); } + p->cancel_activity(); return; } if( calendar::once_every( 1_hours ) && crafting_speed < 0.75f ) { @@ -2666,6 +2666,7 @@ void activity_handlers::craft_do_turn( player_activity *act, player *p ) p->set_moves( 0 ); if( craft->item_counter >= rec.time ) { + p->cancel_activity(); item craft_copy = p->i_rem( craft ); p->complete_craft( craft_copy ); if( is_long ) { @@ -2673,10 +2674,6 @@ void activity_handlers::craft_do_turn( player_activity *act, player *p ) p->last_craft->execute(); } } - } else { - p->assign_activity( activity_id( "ACT_CRAFT" ) ); - p->activity.targets.push_back( item_location( *p, craft ) ); - p->activity.values.push_back( is_long ); } } diff --git a/src/consumption.cpp b/src/consumption.cpp index 422a1616ec30a..97861afdd64d2 100644 --- a/src/consumption.cpp +++ b/src/consumption.cpp @@ -425,6 +425,10 @@ ret_val player::can_eat( const item &food ) const return ret_val::make_failure( _( "That doesn't look edible." ) ); } + if( food.is_craft() ) { + return ret_val::make_failure( _( "That doesn't look edible in its current form." ) ); + } + if( food.item_tags.count( "DIRTY" ) ) { return ret_val::make_failure( _( "This is full of dirt after being on the ground." ) ); diff --git a/src/game_inventory.cpp b/src/game_inventory.cpp index 100bc5903d331..b6c22c757be3f 100644 --- a/src/game_inventory.cpp +++ b/src/game_inventory.cpp @@ -500,7 +500,8 @@ class comestible_inventory_preset : public inventory_selector_preset const islot_comestible &get_edible_comestible( const item &it ) const { if( it.is_comestible() && p.can_eat( it ).success() ) { - return *it.get_comestible(); + // Ok since can_eat() returns false if is_craft() is true + return *it.type->comestible; } static const islot_comestible dummy {}; return dummy; diff --git a/src/item.cpp b/src/item.cpp index 1599a2cbf902e..36e9c4efb1fb9 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -7854,7 +7854,7 @@ const recipe &item::get_making() const return *making; } -cata::optional item::get_comestible() const +const cata::optional &item::get_comestible() const { return is_craft() ? find_type( making->result() )->comestible : type->comestible; diff --git a/src/item.h b/src/item.h index b97c101fb5141..f2e767c2f0c21 100644 --- a/src/item.h +++ b/src/item.h @@ -1814,7 +1814,7 @@ class item : public visitable const recipe &get_making() const; - cata::optional get_comestible() const; + const cata::optional &get_comestible() const; private: /**