Skip to content

Commit

Permalink
Fix a crash when using chop tree zones (#3016)
Browse files Browse the repository at this point in the history
  • Loading branch information
joveeater authored Jul 14, 2023
1 parent f9effce commit 522002b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/activity_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4232,10 +4232,17 @@ void activity_handlers::chop_tree_finish( player_activity *act, player *p )
act->set_to_null();

// Quality of tool used and assistants can together both reduce intensity of work.
if( act->targets.empty() ) {
debugmsg( "woodcutting item location not set" );
resume_for_multi_activities( *p );
return;
}

item_location &loc = act->targets[ 0 ];
item *it = loc.get_item();
if( it == nullptr ) {
debugmsg( "woodcutting item location lost" );
resume_for_multi_activities( *p );
return;
}

Expand Down
2 changes: 2 additions & 0 deletions src/activity_item_handling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2453,10 +2453,12 @@ static bool chop_tree_activity( player &p, const tripoint &src_loc )
const ter_id ter = here.ter( src_loc );
if( here.has_flag( flag_TREE, src_loc ) ) {
p.assign_activity( ACT_CHOP_TREE, moves, -1, p.get_item_position( best_qual ) );
p.activity.targets.push_back( item_location( p, best_qual ) );
p.activity.placement = here.getabs( src_loc );
return true;
} else if( ter == t_trunk || ter == t_stump ) {
p.assign_activity( ACT_CHOP_LOGS, moves, -1, p.get_item_position( best_qual ) );
p.activity.targets.push_back( item_location( p, best_qual ) );
p.activity.placement = here.getabs( src_loc );
return true;
}
Expand Down

0 comments on commit 522002b

Please sign in to comment.