@@ -60,11 +60,21 @@ using PickupMap = std::map<std::string, ItemCount>;
6060
6161static const zone_type_id zone_type_NO_AUTO_PICKUP ( " NO_AUTO_PICKUP" );
6262
63- // Pickup helper functions
64- static bool pick_one_up ( item_location &loc, int quantity, bool &got_water,
65- PickupMap &mapPickup, bool autopickup );
66-
67- static void show_pickup_message ( const PickupMap &mapPickup );
63+ // helper function for Pickup::autopickup
64+ static void show_pickup_message ( const PickupMap &mapPickup )
65+ {
66+ for ( const auto &entry : mapPickup ) {
67+ if ( entry.second .first .invlet != 0 ) {
68+ add_msg ( _ ( " You pick up: %d %s [%c]" ), entry.second .second ,
69+ entry.second .first .display_name ( entry.second .second ), entry.second .first .invlet );
70+ } else if ( entry.second .first .count_by_charges () ) {
71+ add_msg ( _ ( " You pick up: %s" ), entry.second .first .display_name ( entry.second .second ) );
72+ } else {
73+ add_msg ( _ ( " You pick up: %d %s" ), entry.second .second ,
74+ entry.second .first .display_name ( entry.second .second ) );
75+ }
76+ }
77+ }
6878
6979struct pickup_count {
7080 bool pick = false ;
@@ -199,8 +209,8 @@ bool Pickup::query_thief()
199209}
200210
201211// Returns false if pickup caused a prompt and the player selected to cancel pickup
202- bool pick_one_up ( item_location &loc, int quantity, bool &got_water, PickupMap &mapPickup,
203- bool autopickup )
212+ static bool pick_one_up ( item_location &loc, int quantity, bool &got_water, PickupMap &mapPickup,
213+ bool autopickup, bool &stash_successful )
204214{
205215 Character &player_character = get_player_character ();
206216 int moves_taken = loc.obtain_cost ( player_character, quantity );
@@ -248,6 +258,7 @@ bool pick_one_up( item_location &loc, int quantity, bool &got_water, PickupMap &
248258 } else if ( !player_character.can_pickWeight_partial ( newit, false ) ||
249259 !player_character.can_stash_partial ( newit ) ) {
250260 option = CANCEL;
261+ stash_successful = false ;
251262 } else if ( newit.is_bucket_nonempty () ) {
252263 if ( !autopickup ) {
253264 const std::string &explain = string_format ( _ ( " Can't stash %s while it's not empty" ),
@@ -347,7 +358,7 @@ bool pick_one_up( item_location &loc, int quantity, bool &got_water, PickupMap &
347358}
348359
349360bool Pickup::do_pickup ( std::vector<item_location> &targets, std::vector<int > &quantities,
350- bool autopickup )
361+ bool autopickup, bool &stash_successful )
351362{
352363 bool got_water = false ;
353364 Character &player_character = get_player_character ();
@@ -371,7 +382,7 @@ bool Pickup::do_pickup( std::vector<item_location> &targets, std::vector<int> &q
371382 continue ;
372383 }
373384
374- problem = !pick_one_up ( target, quantity, got_water, mapPickup, autopickup );
385+ problem = !pick_one_up ( target, quantity, got_water, mapPickup, autopickup, stash_successful );
375386 }
376387
377388 if ( !mapPickup.empty () ) {
@@ -495,22 +506,6 @@ void Pickup::autopickup( const tripoint &p )
495506 player_character.activity .auto_resume = true ;
496507}
497508
498- // helper function for Pickup::autopickup
499- void show_pickup_message ( const PickupMap &mapPickup )
500- {
501- for ( const auto &entry : mapPickup ) {
502- if ( entry.second .first .invlet != 0 ) {
503- add_msg ( _ ( " You pick up: %d %s [%c]" ), entry.second .second ,
504- entry.second .first .display_name ( entry.second .second ), entry.second .first .invlet );
505- } else if ( entry.second .first .count_by_charges () ) {
506- add_msg ( _ ( " You pick up: %s" ), entry.second .first .display_name ( entry.second .second ) );
507- } else {
508- add_msg ( _ ( " You pick up: %d %s" ), entry.second .second ,
509- entry.second .first .display_name ( entry.second .second ) );
510- }
511- }
512- }
513-
514509int Pickup::cost_to_move_item ( const Character &who, const item &it )
515510{
516511 // Do not involve inventory capacity, it's not like you put it in backpack
0 commit comments