Skip to content

Commit

Permalink
Merge pull request #78939 from RenechCDDA/avoid_seed_crash
Browse files Browse the repository at this point in the history
Fix crash when zone-harvesting crops with bad data
  • Loading branch information
Maleclypse authored Jan 5, 2025
2 parents b487f51 + 548d4aa commit 0d0be90
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/activity_item_handling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1322,10 +1322,14 @@ static activity_reason_info can_do_activity_there( const activity_id &act, Chara

if( here.has_flag_furn( ter_furn_flag::TFLAG_GROWTH_HARVEST, src_loc ) ) {
map_stack items = here.i_at( src_loc );
const map_stack::iterator seed = std::find_if( items.begin(), items.end(), []( const item & it ) {
const map_stack::iterator seed_iter =
std::find_if( items.begin(), items.end(), []( const item & it ) {
return it.is_seed();
} );
if( seed->has_flag( json_flag_CUT_HARVEST ) ) {
if( seed_iter == items.end() ) {
debugmsg( "Missing seed item at %s", src_loc.to_string() );
return activity_reason_info::fail( do_activity_reason::ALREADY_DONE );
} else if( seed_iter->has_flag( json_flag_CUT_HARVEST ) ) {
// The plant in this location needs a grass cutting tool.
if( you.has_quality( quality_id( qual_GRASS_CUT ), 1 ) ) {
return activity_reason_info::ok( do_activity_reason::NEEDS_CUT_HARVESTING );
Expand Down

0 comments on commit 0d0be90

Please sign in to comment.