diff --git a/src/activity_item_handling.cpp b/src/activity_item_handling.cpp index fbbc50579b79a..e411af9ec737b 100644 --- a/src/activity_item_handling.cpp +++ b/src/activity_item_handling.cpp @@ -668,6 +668,15 @@ void activity_on_turn_pickup() return; } + // If the player moves while picking up (ie: in a moving vehicle) cancel the activity, only populate coords when grabbing from the ground + if( g->u.activity.coords.size() > 0 && g->u.activity.coords.at( 0 ) != g->u.pos() ) { + g->u.cancel_activity(); + if( g->u.is_player() ) { + g->u.add_msg_if_player( _( "Moving cancelled auto-pickup." ) ); + } + return; + } + // Auto_resume implies autopickup. const bool autopickup = g->u.activity.auto_resume; diff --git a/src/advanced_inv.cpp b/src/advanced_inv.cpp index a5268b4724617..1e89097be0b4d 100644 --- a/src/advanced_inv.cpp +++ b/src/advanced_inv.cpp @@ -1354,6 +1354,7 @@ bool advanced_inventory::move_all_items( bool nested_call ) } else { if( dpane.get_area() == AIM_INVENTORY || dpane.get_area() == AIM_WORN ) { g->u.assign_activity( activity_id( "ACT_PICKUP" ) ); + g->u.activity.coords.push_back( g->u.pos() ); } else { // Vehicle and map destinations are handled the same. // Check first if the destination area still have enough room for moving all. @@ -1729,6 +1730,7 @@ void advanced_inventory::display() if( destarea == AIM_INVENTORY ) { g->u.assign_activity( activity_id( "ACT_PICKUP" ) ); + g->u.activity.coords.push_back( g->u.pos() ); } else if( destarea == AIM_WORN ) { g->u.assign_activity( activity_id( "ACT_WEAR" ) ); } else { // Vehicle and map destinations are handled similarly. diff --git a/src/pickup.cpp b/src/pickup.cpp index e93daba63854d..7f3f15ce0ef18 100644 --- a/src/pickup.cpp +++ b/src/pickup.cpp @@ -509,6 +509,7 @@ void Pickup::pick_up( const tripoint &p, int min, from_where get_items_from ) g->u.activity.targets.emplace_back( vehicle_cursor( *veh, cargo_part ), &*here.front() ); } else { g->u.activity.targets.emplace_back( map_cursor( p ), &*here.front() ); + g->u.activity.coords.push_back( g->u.pos() ); } // auto-pickup means pick up all. g->u.activity.values.push_back( 0 ); @@ -990,6 +991,7 @@ void Pickup::pick_up( const tripoint &p, int min, from_where get_items_from ) // At this point we've selected our items, register an activity to pick them up. g->u.assign_activity( activity_id( "ACT_PICKUP" ) ); + g->u.activity.coords.push_back( g->u.pos() ); if( min == -1 ) { // Auto pickup will need to auto resume since there can be several of them on the stack. g->u.activity.auto_resume = true;