Skip to content

Commit

Permalink
Only stop hauling when all hauled items are picked up
Browse files Browse the repository at this point in the history
  • Loading branch information
Qrox authored and kevingranade committed Jan 24, 2021
1 parent d46d2b6 commit 1319073
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 11 additions & 3 deletions src/activity_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1002,19 +1002,27 @@ std::unique_ptr<activity_actor> move_items_activity_actor::deserialize( JsonIn &
return actor.clone();
}

static void cancel_pickup( Character &who )
{
who.cancel_activity();
if( who.is_hauling() && !get_map().has_items( who.pos() ) ) {
who.stop_hauling();
}
}

void pickup_activity_actor::do_turn( player_activity &, Character &who )
{
// If we don't have target items bail out
if( target_items.empty() ) {
who.cancel_activity();
cancel_pickup( who );
return;
}

// If the player moves while picking up (i.e.: in a moving vehicle) cancel
// the activity, only populate starting_pos when grabbing from the ground
if( starting_pos && *starting_pos != who.pos() ) {
who.cancel_activity();
who.add_msg_if_player( _( "Moving canceled auto-pickup." ) );
cancel_pickup( who );
return;
}

Expand All @@ -1027,7 +1035,7 @@ void pickup_activity_actor::do_turn( player_activity &, Character &who )
// If there are items left we ran out of moves, so continue the activity
// Otherwise, we are done.
if( !keep_going || target_items.empty() ) {
who.cancel_activity();
cancel_pickup( who );

if( who.get_value( "THIEF_MODE_KEEP" ) != "YES" ) {
who.set_value( "THIEF_MODE", "THIEF_ASK" );
Expand Down
2 changes: 0 additions & 2 deletions src/handle_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1943,7 +1943,6 @@ bool game::handle_action()
} else if( mouse_target ) {
pickup( *mouse_target );
} else {
player_character.stop_hauling();
pickup();
}
break;
Expand All @@ -1954,7 +1953,6 @@ bool game::handle_action()
} else if( u.has_effect( effect_incorporeal ) ) {
add_msg( m_info, _( "You lack the substance to affect anything." ) );
} else {
player_character.stop_hauling();
pickup_feet();
}
break;
Expand Down

0 comments on commit 1319073

Please sign in to comment.