From a27fbf866ba612d16883630f7860426f5feeb273 Mon Sep 17 00:00:00 2001 From: Brambor Date: Tue, 17 Sep 2024 15:36:01 +0200 Subject: [PATCH 01/14] remove parameter avatar from game_menus::inv::pickup --- src/activity_actor.cpp | 2 +- src/game.cpp | 6 +++--- src/game_inventory.cpp | 11 ++++++----- src/game_inventory.h | 4 ++-- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/activity_actor.cpp b/src/activity_actor.cpp index 55606f3f2eff0..681728dc7b6be 100644 --- a/src/activity_actor.cpp +++ b/src/activity_actor.cpp @@ -6348,7 +6348,7 @@ void pickup_menu_activity_actor::do_turn( player_activity &, Character &who ) std::optional p( where ); std::vector s( selection ); who.cancel_activity(); - who.pick_up( game_menus::inv::pickup( *who.as_avatar(), p, s ) ); + who.pick_up( game_menus::inv::pickup( p, s ) ); } void pickup_menu_activity_actor::serialize( JsonOut &jsout ) const diff --git a/src/game.cpp b/src/game.cpp index 3710b2003e692..d7f999d339b9d 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -6023,13 +6023,13 @@ void game::pickup() return; } // Pick up items only from the selected tile - u.pick_up( game_menus::inv::pickup( u, *where_ ) ); + u.pick_up( game_menus::inv::pickup( *where_ ) ); } void game::pickup_all() { // Pick up items from current and all adjacent tiles - u.pick_up( game_menus::inv::pickup( u ) ); + u.pick_up( game_menus::inv::pickup() ); } void game::pickup( const tripoint &p ) @@ -6046,7 +6046,7 @@ void game::pickup( const tripoint_bub_ms &p ) add_draw_callback( hilite_cb ); // Pick up items only from the selected tile - u.pick_up( game_menus::inv::pickup( u, p ) ); + u.pick_up( game_menus::inv::pickup( p ) ); } //Shift player by one tile, look_around(), then restore previous position. diff --git a/src/game_inventory.cpp b/src/game_inventory.cpp index a7d3c42e5d054..62178469023f5 100644 --- a/src/game_inventory.cpp +++ b/src/game_inventory.cpp @@ -2206,9 +2206,10 @@ drop_locations game_menus::inv::multidrop( Character &you ) return inv_s.execute(); } -drop_locations game_menus::inv::pickup( avatar &you, - const std::optional &target, const std::vector &selection ) +drop_locations game_menus::inv::pickup( const std::optional &target, + const std::vector &selection ) { + avatar &you = get_avatar(); pickup_inventory_preset preset( you, /*skip_wield_check=*/true, /*ignore_liquidcont=*/true ); preset.save_state = &pickup_ui_default_state; @@ -2239,14 +2240,14 @@ drop_locations game_menus::inv::pickup( avatar &you, return pick_s.execute(); } -drop_locations game_menus::inv::pickup( avatar &you, - const std::optional &target, const std::vector &selection ) +drop_locations game_menus::inv::pickup( const std::optional &target, + const std::vector &selection ) { std::optional tmp; if( target.has_value() ) { tmp = target.value().raw(); } - return game_menus::inv::pickup( you, tmp, selection ); + return game_menus::inv::pickup( tmp, selection ); } class smokable_selector_preset : public inventory_selector_preset diff --git a/src/game_inventory.h b/src/game_inventory.h index 31307bf6e3fc4..685c419b67e62 100644 --- a/src/game_inventory.h +++ b/src/game_inventory.h @@ -88,9 +88,9 @@ drop_locations multidrop( Character &you ); */ // TODO: Get rid of untyped overload. Restore the target default while doing so (removed // to allow profiles to be distinguished. -drop_locations pickup( avatar &you, const std::optional &target = std::nullopt, +drop_locations pickup( const std::optional &target = std::nullopt, const std::vector &selection = {} ); -drop_locations pickup( avatar &you, const std::optional &target, +drop_locations pickup( const std::optional &target, const std::vector &selection = {} ); drop_locations smoke_food( Character &you, units::volume total_capacity, From 696b450ea847292c458dd881d6bdf7e9e9873de5 Mon Sep 17 00:00:00 2001 From: Brambor Date: Tue, 17 Sep 2024 15:44:12 +0200 Subject: [PATCH 02/14] remove parameter avatar from game_menus::inv::common --- src/game.cpp | 2 +- src/game_inventory.cpp | 6 ++++-- src/game_inventory.h | 4 ++-- src/handle_action.cpp | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index d7f999d339b9d..8e2994318a17e 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -2327,7 +2327,7 @@ int game::inventory_item_menu( item_location locThisItem, break; case 'o': if( oThisItem.is_container() && oThisItem.num_item_stacks() > 0 ) { - game_menus::inv::common( locThisItem, u ); + game_menus::inv::common( locThisItem ); } break; case '=': diff --git a/src/game_inventory.cpp b/src/game_inventory.cpp index 62178469023f5..2b7de5d9d961c 100644 --- a/src/game_inventory.cpp +++ b/src/game_inventory.cpp @@ -244,8 +244,9 @@ static drop_locations inv_internal_multi( Character &u, const inventory_selector return inv_s.execute(); } -void game_menus::inv::common( avatar &you ) +void game_menus::inv::common() { + avatar &you = get_avatar(); // Return to inventory menu on those inputs static const std::set loop_options = { { '\0', '=', 'f', '<', '>'}}; @@ -283,8 +284,9 @@ void game_menus::inv::common( avatar &you ) } while( loop_options.count( res ) != 0 ); } -void game_menus::inv::common( item_location &loc, avatar &you ) +void game_menus::inv::common( item_location &loc ) { + avatar &you = get_avatar(); // Return to inventory menu on those inputs static const std::set loop_options = { { '\0', '=', 'f' } }; diff --git a/src/game_inventory.h b/src/game_inventory.h index 685c419b67e62..51c136a323001 100644 --- a/src/game_inventory.h +++ b/src/game_inventory.h @@ -60,8 +60,8 @@ drop_locations titled_multi_filter_menu( const item_location_filter &filter, Cha */ /*@{*/ -void common( avatar &you ); -void common( item_location &loc, avatar &you ); +void common(); +void common( item_location &loc ); void compare( avatar &you, const std::optional &offset ); void reassign_letter( avatar &you, item &it ); void swap_letters( avatar &you ); diff --git a/src/handle_action.cpp b/src/handle_action.cpp index 7c6f06187ce81..676fa948413cf 100644 --- a/src/handle_action.cpp +++ b/src/handle_action.cpp @@ -2448,7 +2448,7 @@ bool game::do_regular_action( action_id &act, avatar &player_character, break; case ACTION_INVENTORY: - game_menus::inv::common( player_character ); + game_menus::inv::common(); break; case ACTION_COMPARE: From 109b51bf0461596d2873b7d50b0c36551ef87234 Mon Sep 17 00:00:00 2001 From: Brambor Date: Tue, 17 Sep 2024 15:47:15 +0200 Subject: [PATCH 03/14] remove parameter avatar from game_menus::inv::compare --- src/game.cpp | 2 +- src/game_inventory.cpp | 3 ++- src/game_inventory.h | 2 +- src/handle_action.cpp | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index 8e2994318a17e..68c34c9304d35 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -8414,7 +8414,7 @@ game::vmenu_ret game::list_items( const std::vector &item_list ) do { bool recalc_unread = false; if( action == "COMPARE" && activeItem ) { - game_menus::inv::compare( u, active_pos ); + game_menus::inv::compare( active_pos ); recalc_unread = highlight_unread_items; } else if( action == "FILTER" ) { ui.invalidate_ui(); diff --git a/src/game_inventory.cpp b/src/game_inventory.cpp index 2b7de5d9d961c..ccfde2a4c13f7 100644 --- a/src/game_inventory.cpp +++ b/src/game_inventory.cpp @@ -2403,8 +2403,9 @@ bool game_menus::inv::compare_items( const item &first, const item &second, return action == "CONFIRM"; } -void game_menus::inv::compare( avatar &you, const std::optional &offset ) +void game_menus::inv::compare( const std::optional &offset ) { + avatar &you = get_avatar(); you.inv->restack( you ); inventory_compare_selector inv_s( you ); diff --git a/src/game_inventory.h b/src/game_inventory.h index 51c136a323001..120a2775574a0 100644 --- a/src/game_inventory.h +++ b/src/game_inventory.h @@ -62,7 +62,7 @@ drop_locations titled_multi_filter_menu( const item_location_filter &filter, Cha void common(); void common( item_location &loc ); -void compare( avatar &you, const std::optional &offset ); +void compare( const std::optional &offset ); void reassign_letter( avatar &you, item &it ); void swap_letters( avatar &you ); diff --git a/src/handle_action.cpp b/src/handle_action.cpp index 676fa948413cf..ac02207a675f5 100644 --- a/src/handle_action.cpp +++ b/src/handle_action.cpp @@ -2452,7 +2452,7 @@ bool game::do_regular_action( action_id &act, avatar &player_character, break; case ACTION_COMPARE: - game_menus::inv::compare( player_character, std::nullopt ); + game_menus::inv::compare( std::nullopt ); break; case ACTION_ORGANIZE: From 0090221612c44e1f27f8aa42ad0edc64204b6d90 Mon Sep 17 00:00:00 2001 From: Brambor Date: Tue, 17 Sep 2024 16:07:27 +0200 Subject: [PATCH 04/14] remove parameter avatar from game_menus::inv::reassign_letter --- src/game.cpp | 2 +- src/game_inventory.cpp | 5 +++-- src/game_inventory.h | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index 68c34c9304d35..2ef3660ef6069 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -2331,7 +2331,7 @@ int game::inventory_item_menu( item_location locThisItem, } break; case '=': - game_menus::inv::reassign_letter( u, oThisItem ); + game_menus::inv::reassign_letter( oThisItem ); break; case KEY_PPAGE: iScrollPos -= iScrollHeight; diff --git a/src/game_inventory.cpp b/src/game_inventory.cpp index ccfde2a4c13f7..930d1b7555cab 100644 --- a/src/game_inventory.cpp +++ b/src/game_inventory.cpp @@ -2437,8 +2437,9 @@ void game_menus::inv::compare( const std::optional &offset ) } while( true ); } -void game_menus::inv::reassign_letter( avatar &you, item &it ) +void game_menus::inv::reassign_letter( item &it ) { + avatar &you = get_avatar(); while( true ) { const int invlet = popup_getkey( _( "Enter new letter. Press SPACE to clear a manually-assigned letter, ESCAPE to cancel." ) ); @@ -2496,7 +2497,7 @@ void game_menus::inv::swap_letters( avatar &you ) break; } - reassign_letter( you, *loc ); + reassign_letter( *loc ); } } diff --git a/src/game_inventory.h b/src/game_inventory.h index 120a2775574a0..dadeab5eb58d1 100644 --- a/src/game_inventory.h +++ b/src/game_inventory.h @@ -63,7 +63,7 @@ drop_locations titled_multi_filter_menu( const item_location_filter &filter, Cha void common(); void common( item_location &loc ); void compare( const std::optional &offset ); -void reassign_letter( avatar &you, item &it ); +void reassign_letter( item &it ); void swap_letters( avatar &you ); /** From c95fc8cd8dbcb78f6b60743135856aa7a5fba734 Mon Sep 17 00:00:00 2001 From: Brambor Date: Tue, 17 Sep 2024 16:10:36 +0200 Subject: [PATCH 05/14] remove parameter avatar from game_menus::inv::swap_letters --- src/game_inventory.cpp | 3 ++- src/game_inventory.h | 2 +- src/handle_action.cpp | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/game_inventory.cpp b/src/game_inventory.cpp index 930d1b7555cab..678e88141ada2 100644 --- a/src/game_inventory.cpp +++ b/src/game_inventory.cpp @@ -2462,8 +2462,9 @@ void game_menus::inv::reassign_letter( item &it ) } } -void game_menus::inv::swap_letters( avatar &you ) +void game_menus::inv::swap_letters() { + avatar &you = get_avatar(); you.inv->restack( you ); inventory_pick_selector inv_s( you ); diff --git a/src/game_inventory.h b/src/game_inventory.h index dadeab5eb58d1..f7dd0a0d914c8 100644 --- a/src/game_inventory.h +++ b/src/game_inventory.h @@ -64,7 +64,7 @@ void common(); void common( item_location &loc ); void compare( const std::optional &offset ); void reassign_letter( item &it ); -void swap_letters( avatar &you ); +void swap_letters(); /** * Compares two items, if confirm_message isn't empty then it will be printed diff --git a/src/handle_action.cpp b/src/handle_action.cpp index ac02207a675f5..f7bf682d3b10a 100644 --- a/src/handle_action.cpp +++ b/src/handle_action.cpp @@ -2456,7 +2456,7 @@ bool game::do_regular_action( action_id &act, avatar &player_character, break; case ACTION_ORGANIZE: - game_menus::inv::swap_letters( player_character ); + game_menus::inv::swap_letters(); break; case ACTION_USE: From fff2d248ee40180514565c46750f00ddde1e20a5 Mon Sep 17 00:00:00 2001 From: Brambor Date: Tue, 17 Sep 2024 16:23:55 +0200 Subject: [PATCH 06/14] remove parameter avatar from game_menus::inv::consume* --- src/activity_handlers.cpp | 8 ++++---- src/game.cpp | 2 +- src/game_inventory.cpp | 12 ++++++++---- src/game_inventory.h | 8 ++++---- src/handle_action.cpp | 8 ++++---- 5 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/activity_handlers.cpp b/src/activity_handlers.cpp index a2eddff3a7c37..4b3fe2116ae6d 100644 --- a/src/activity_handlers.cpp +++ b/src/activity_handlers.cpp @@ -2809,27 +2809,27 @@ void activity_handlers::eat_menu_do_turn( player_activity *, Character *you ) } avatar &player_character = get_avatar(); - avatar_action::eat_or_use( player_character, game_menus::inv::consume( player_character ) ); + avatar_action::eat_or_use( player_character, game_menus::inv::consume() ); } void activity_handlers::consume_food_menu_do_turn( player_activity *, Character * ) { avatar &player_character = get_avatar(); - item_location loc = game_menus::inv::consume_food( player_character ); + item_location loc = game_menus::inv::consume_food(); avatar_action::eat( player_character, loc ); } void activity_handlers::consume_drink_menu_do_turn( player_activity *, Character * ) { avatar &player_character = get_avatar(); - item_location loc = game_menus::inv::consume_drink( player_character ); + item_location loc = game_menus::inv::consume_drink(); avatar_action::eat( player_character, loc ); } void activity_handlers::consume_meds_menu_do_turn( player_activity *, Character * ) { avatar &player_character = get_avatar(); - avatar_action::eat_or_use( player_character, game_menus::inv::consume_meds( player_character ) ); + avatar_action::eat_or_use( player_character, game_menus::inv::consume_meds() ); } void activity_handlers::view_recipe_do_turn( player_activity *act, Character *you ) diff --git a/src/game.cpp b/src/game.cpp index 2ef3660ef6069..ab63bc8e50eb2 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -2238,7 +2238,7 @@ int game::inventory_item_menu( item_location locThisItem, if( !locThisItem.get_item()->is_container() ) { avatar_action::eat( u, locThisItem ); } else { - avatar_action::eat_or_use( u, game_menus::inv::consume( u, locThisItem ) ); + avatar_action::eat_or_use( u, game_menus::inv::consume( locThisItem ) ); } break; case 'W': { diff --git a/src/game_inventory.cpp b/src/game_inventory.cpp index 678e88141ada2..6235b26f2f18e 100644 --- a/src/game_inventory.cpp +++ b/src/game_inventory.cpp @@ -1001,8 +1001,9 @@ static std::string get_consume_needs_hint( Character &you ) return hint; } -item_location game_menus::inv::consume( avatar &you, const item_location &loc ) +item_location game_menus::inv::consume( const item_location &loc ) { + avatar &you = get_avatar(); static item_location container_location; if( !you.has_activity( ACT_EAT_MENU ) ) { you.assign_activity( ACT_EAT_MENU ); @@ -1032,8 +1033,9 @@ class comestible_filtered_inventory_preset : public comestible_inventory_preset bool( *predicate )( const item &it ); }; -item_location game_menus::inv::consume_food( avatar &you ) +item_location game_menus::inv::consume_food() { + avatar &you = get_avatar(); if( !you.has_activity( ACT_CONSUME_FOOD_MENU ) ) { you.assign_activity( ACT_CONSUME_FOOD_MENU ); } @@ -1048,8 +1050,9 @@ item_location game_menus::inv::consume_food( avatar &you ) get_consume_needs_hint( you ) ); } -item_location game_menus::inv::consume_drink( avatar &you ) +item_location game_menus::inv::consume_drink() { + avatar &you = get_avatar(); if( !you.has_activity( ACT_CONSUME_DRINK_MENU ) ) { you.assign_activity( ACT_CONSUME_DRINK_MENU ); } @@ -1064,8 +1067,9 @@ item_location game_menus::inv::consume_drink( avatar &you ) get_consume_needs_hint( you ) ); } -item_location game_menus::inv::consume_meds( avatar &you ) +item_location game_menus::inv::consume_meds() { + avatar &you = get_avatar(); if( !you.has_activity( ACT_CONSUME_MEDS_MENU ) ) { you.assign_activity( ACT_CONSUME_MEDS_MENU ); } diff --git a/src/game_inventory.h b/src/game_inventory.h index f7dd0a0d914c8..6d4f232da10c7 100644 --- a/src/game_inventory.h +++ b/src/game_inventory.h @@ -100,13 +100,13 @@ drop_locations smoke_food( Character &you, units::volume total_capacity, * Consume an item via a custom menu. * If item_location is provided then consume only from the contents of that container. */ -item_location consume( avatar &you, const item_location &loc = item_location() ); +item_location consume( const item_location &loc = item_location() ); /** Consuming a food item via a custom menu. */ -item_location consume_food( avatar &you ); +item_location consume_food(); /** Consuming a drink item via a custom menu. */ -item_location consume_drink( avatar &you ); +item_location consume_drink(); /** Consuming a medication item via a custom menu. */ -item_location consume_meds( avatar &you ); +item_location consume_meds(); /** Choosing a container for liquid. */ item_location container_for( Character &you, const item &liquid, int radius = 0, const item *avoid = nullptr ); diff --git a/src/handle_action.cpp b/src/handle_action.cpp index f7bf682d3b10a..7b2f5ce2cc4fd 100644 --- a/src/handle_action.cpp +++ b/src/handle_action.cpp @@ -1885,17 +1885,17 @@ void game::open_consume_item_menu() avatar &player_character = get_avatar(); switch( as_m.ret ) { case 0: { - item_location loc = game_menus::inv::consume_food( player_character ); + item_location loc = game_menus::inv::consume_food(); avatar_action::eat( player_character, loc ); break; } case 1: { - item_location loc = game_menus::inv::consume_drink( player_character ); + item_location loc = game_menus::inv::consume_drink(); avatar_action::eat( player_character, loc ); break; } case 2: - avatar_action::eat_or_use( player_character, game_menus::inv::consume_meds( player_character ) ); + avatar_action::eat_or_use( player_character, game_menus::inv::consume_meds() ); break; default: break; @@ -2479,7 +2479,7 @@ bool game::do_regular_action( action_id &act, avatar &player_character, case ACTION_EAT: if( !avatar_action::eat_here( player_character ) ) { - avatar_action::eat_or_use( player_character, game_menus::inv::consume( player_character ) ); + avatar_action::eat_or_use( player_character, game_menus::inv::consume() ); } break; From 72ca15a9d237dee65897ad4d92a8b7847e53a7ab Mon Sep 17 00:00:00 2001 From: Brambor Date: Tue, 17 Sep 2024 16:28:07 +0200 Subject: [PATCH 07/14] remove parameter avatar from game_menus::inv::steal --- src/game_inventory.cpp | 8 ++++---- src/game_inventory.h | 2 +- src/melee.cpp | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/game_inventory.cpp b/src/game_inventory.cpp index 6235b26f2f18e..ca6b1f57eddc9 100644 --- a/src/game_inventory.cpp +++ b/src/game_inventory.cpp @@ -1659,8 +1659,8 @@ drop_locations game_menus::inv::ebooksave( Character &who, item_location &ereade class steal_inventory_preset : public pickup_inventory_preset { public: - steal_inventory_preset( const avatar &you, const Character &victim ) : - pickup_inventory_preset( you ), victim( victim ) {} + explicit steal_inventory_preset( const Character &victim ) : + pickup_inventory_preset( get_avatar() ), victim( victim ) {} bool is_shown( const item_location &loc ) const override { return !victim.is_worn( *loc ) && victim.get_wielded_item() != loc; @@ -1670,9 +1670,9 @@ class steal_inventory_preset : public pickup_inventory_preset const Character &victim; }; -item_location game_menus::inv::steal( avatar &you, Character &victim ) +item_location game_menus::inv::steal( Character &victim ) { - return inv_internal( victim, steal_inventory_preset( you, victim ), + return inv_internal( victim, steal_inventory_preset( victim ), string_format( _( "Steal from %s" ), victim.get_name() ), -1, string_format( _( "%s's inventory is empty." ), victim.get_name() ) ); } diff --git a/src/game_inventory.h b/src/game_inventory.h index 6d4f232da10c7..c68104a245496 100644 --- a/src/game_inventory.h +++ b/src/game_inventory.h @@ -125,7 +125,7 @@ item_location ebookread( Character &you, item_location &ereader ); /** Select books to save to E-Book reader menu. */ drop_locations ebooksave( Character &who, item_location &ereader ); /** Menu for stealing stuff. */ -item_location steal( avatar &you, Character &victim ); +item_location steal( Character &victim ); /** Item activation menu. */ item_location use( avatar &you ); /** Item wielding/unwielding menu. */ diff --git a/src/melee.cpp b/src/melee.cpp index 2391a27432c47..28b18c07c2bab 100644 --- a/src/melee.cpp +++ b/src/melee.cpp @@ -2862,7 +2862,7 @@ void avatar::steal( npc &target ) return; } - item_location loc = game_menus::inv::steal( *this, target ); + item_location loc = game_menus::inv::steal( target ); if( !loc ) { return; } From 424df052f2e5638a8496a0f12dc63b5535f2abb3 Mon Sep 17 00:00:00 2001 From: Brambor Date: Tue, 17 Sep 2024 16:32:30 +0200 Subject: [PATCH 08/14] remove parameter avatar from game_menus::inv::use --- src/avatar_action.cpp | 2 +- src/game_inventory.cpp | 8 ++++---- src/game_inventory.h | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/avatar_action.cpp b/src/avatar_action.cpp index 36d3aaab7cd98..6abeb45efaac7 100644 --- a/src/avatar_action.cpp +++ b/src/avatar_action.cpp @@ -1134,7 +1134,7 @@ void avatar_action::use_item( avatar &you, item_location &loc, std::string const bool use_in_place = false; if( !loc ) { - loc = game_menus::inv::use( you ); + loc = game_menus::inv::use(); if( !loc ) { add_msg( _( "Never mind." ) ); diff --git a/src/game_inventory.cpp b/src/game_inventory.cpp index ca6b1f57eddc9..fd10f8cdb84cf 100644 --- a/src/game_inventory.cpp +++ b/src/game_inventory.cpp @@ -1086,8 +1086,8 @@ item_location game_menus::inv::consume_meds() class activatable_inventory_preset : public pickup_inventory_preset { public: - explicit activatable_inventory_preset( const Character &you ) : pickup_inventory_preset( you ), - you( you ) { + explicit activatable_inventory_preset() : pickup_inventory_preset( get_avatar() ), + you( get_avatar() ) { _collate_entries = true; if( get_option( "INV_USE_ACTION_NAMES" ) ) { append_cell( [ this ]( const item_location & loc ) { @@ -1189,9 +1189,9 @@ class activatable_inventory_preset : public pickup_inventory_preset const Character &you; }; -item_location game_menus::inv::use( avatar &you ) +item_location game_menus::inv::use() { - return inv_internal( you, activatable_inventory_preset( you ), + return inv_internal( get_avatar(), activatable_inventory_preset(), _( "Use item" ), 1, _( "You don't have any items you can use." ) ); } diff --git a/src/game_inventory.h b/src/game_inventory.h index c68104a245496..51c45f380f692 100644 --- a/src/game_inventory.h +++ b/src/game_inventory.h @@ -127,7 +127,7 @@ drop_locations ebooksave( Character &who, item_location &ereader ); /** Menu for stealing stuff. */ item_location steal( Character &victim ); /** Item activation menu. */ -item_location use( avatar &you ); +item_location use(); /** Item wielding/unwielding menu. */ item_location wield( avatar &you ); /** Item wielding/unwielding menu. */ From 469cfed4826fd0893311d2d8a78aedba991889cd Mon Sep 17 00:00:00 2001 From: Brambor Date: Tue, 17 Sep 2024 16:58:33 +0200 Subject: [PATCH 09/14] remove unused holster_inventory_preset - unused since #39406 commit 5383aaf6ebafab59d15e1 --- src/game_inventory.cpp | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/game_inventory.cpp b/src/game_inventory.cpp index fd10f8cdb84cf..2d34963b226e1 100644 --- a/src/game_inventory.cpp +++ b/src/game_inventory.cpp @@ -1782,22 +1782,6 @@ item_location game_menus::inv::wield( avatar &you ) _( "You have nothing to wield." ) ); } -class holster_inventory_preset: public weapon_inventory_preset -{ - public: - holster_inventory_preset( const Character &you, const holster_actor &actor, const item &holster ) : - weapon_inventory_preset( you ), actor( actor ), holster( holster ) { - } - - bool is_shown( const item_location &loc ) const override { - return actor.can_holster( holster, *loc ); - } - - private: - const holster_actor &actor; - const item &holster; -}; - drop_locations game_menus::inv::holster( avatar &you, const item_location &holster ) { const std::string holster_name = holster->tname( 1, false ); From 6b48c5ad6bb9dac186d8619dc83a6805132ff25b Mon Sep 17 00:00:00 2001 From: Brambor Date: Tue, 17 Sep 2024 17:03:19 +0200 Subject: [PATCH 10/14] remove parameter avatar from game_menus::inv::wield --- src/game.cpp | 2 +- src/game_inventory.cpp | 4 ++-- src/game_inventory.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index ab63bc8e50eb2..9cb3dc7f7d96e 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -10011,7 +10011,7 @@ void game::wield( item_location loc ) void game::wield() { - item_location loc = game_menus::inv::wield( u ); + item_location loc = game_menus::inv::wield(); if( loc ) { wield( loc ); diff --git a/src/game_inventory.cpp b/src/game_inventory.cpp index 2d34963b226e1..44e521b78f6a7 100644 --- a/src/game_inventory.cpp +++ b/src/game_inventory.cpp @@ -1776,9 +1776,9 @@ class weapon_inventory_preset: public inventory_selector_preset const Character &you; }; -item_location game_menus::inv::wield( avatar &you ) +item_location game_menus::inv::wield() { - return inv_internal( you, weapon_inventory_preset( you ), _( "Wield item" ), 1, + return inv_internal( get_avatar(), weapon_inventory_preset( get_avatar() ), _( "Wield item" ), 1, _( "You have nothing to wield." ) ); } diff --git a/src/game_inventory.h b/src/game_inventory.h index 51c45f380f692..a7060d03fd4f5 100644 --- a/src/game_inventory.h +++ b/src/game_inventory.h @@ -129,7 +129,7 @@ item_location steal( Character &victim ); /** Item activation menu. */ item_location use(); /** Item wielding/unwielding menu. */ -item_location wield( avatar &you ); +item_location wield(); /** Item wielding/unwielding menu. */ drop_locations holster( avatar &you, const item_location &holster ); void insert_items( avatar &you, item_location &holster ); From 8e26c2b4e146c39ed23615e49be5d926ac9ab0a2 Mon Sep 17 00:00:00 2001 From: Brambor Date: Tue, 17 Sep 2024 17:05:40 +0200 Subject: [PATCH 11/14] remove parameter avatar from game_menus::inv::holster --- src/game_inventory.cpp | 5 +++-- src/game_inventory.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/game_inventory.cpp b/src/game_inventory.cpp index 44e521b78f6a7..ac19f4b42573e 100644 --- a/src/game_inventory.cpp +++ b/src/game_inventory.cpp @@ -1782,8 +1782,9 @@ item_location game_menus::inv::wield() _( "You have nothing to wield." ) ); } -drop_locations game_menus::inv::holster( avatar &you, const item_location &holster ) +drop_locations game_menus::inv::holster( const item_location &holster ) { + avatar &you = get_avatar(); const std::string holster_name = holster->tname( 1, false ); const use_function *use = holster->type->get_use( "holster" ); const holster_actor *actor = use == nullptr ? nullptr : dynamic_cast @@ -1819,7 +1820,7 @@ void game_menus::inv::insert_items( avatar &you, item_location &holster ) holster->type_name() ); return; } - drop_locations holstered_list = game_menus::inv::holster( you, holster ); + drop_locations holstered_list = game_menus::inv::holster( holster ); if( !holstered_list.empty() ) { you.assign_activity( insert_item_activity_actor( holster, holstered_list ) ); diff --git a/src/game_inventory.h b/src/game_inventory.h index a7060d03fd4f5..11141f9fdb6ad 100644 --- a/src/game_inventory.h +++ b/src/game_inventory.h @@ -131,7 +131,7 @@ item_location use(); /** Item wielding/unwielding menu. */ item_location wield(); /** Item wielding/unwielding menu. */ -drop_locations holster( avatar &you, const item_location &holster ); +drop_locations holster( const item_location &holster ); void insert_items( avatar &you, item_location &holster ); drop_locations unload_container( avatar &you ); /** Choosing a gun to saw down it's barrel. */ From f5f561458c57a99291c61bf5dae690918caad19d Mon Sep 17 00:00:00 2001 From: Brambor Date: Tue, 17 Sep 2024 17:07:59 +0200 Subject: [PATCH 12/14] remove parameter avatar from game_menus::inv::insert_items --- src/game.cpp | 4 ++-- src/game_inventory.cpp | 3 ++- src/game_inventory.h | 2 +- src/iuse_actor.cpp | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index 9cb3dc7f7d96e..54fdc7ca0a768 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -2322,7 +2322,7 @@ int game::inventory_item_menu( item_location locThisItem, } case 'i': if( oThisItem.is_container() ) { - game_menus::inv::insert_items( u, locThisItem ); + game_menus::inv::insert_items( locThisItem ); } break; case 'o': @@ -9044,7 +9044,7 @@ void game::insert_item() return; } - game_menus::inv::insert_items( u, item_loc ); + game_menus::inv::insert_items( item_loc ); } void game::unload_container() diff --git a/src/game_inventory.cpp b/src/game_inventory.cpp index ac19f4b42573e..c0e621228636f 100644 --- a/src/game_inventory.cpp +++ b/src/game_inventory.cpp @@ -1810,8 +1810,9 @@ drop_locations game_menus::inv::holster( const item_location &holster ) return insert_menu.execute(); } -void game_menus::inv::insert_items( avatar &you, item_location &holster ) +void game_menus::inv::insert_items( item_location &holster ) { + avatar &you = get_avatar(); if( holster->will_spill_if_unsealed() && holster.where() != item_location::type::map && !you.is_wielding( *holster ) ) { diff --git a/src/game_inventory.h b/src/game_inventory.h index 11141f9fdb6ad..0b7ff49d0d118 100644 --- a/src/game_inventory.h +++ b/src/game_inventory.h @@ -132,7 +132,7 @@ item_location use(); item_location wield(); /** Item wielding/unwielding menu. */ drop_locations holster( const item_location &holster ); -void insert_items( avatar &you, item_location &holster ); +void insert_items( item_location &holster ); drop_locations unload_container( avatar &you ); /** Choosing a gun to saw down it's barrel. */ item_location saw_barrel( Character &you, item &tool ); diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index e3e49a89ba2e0..ae00a5b1b8170 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -2621,7 +2621,7 @@ std::optional holster_actor::use( Character *you, item &it, const tripoint // iuse_actor really needs to work with item_location item_location item_loc = form_loc( *you, p, it ); - game_menus::inv::insert_items( *you->as_avatar(), item_loc ); + game_menus::inv::insert_items( item_loc ); } return 0; From 0c33533a33d6dcb40faea79c0717edaf8c712897 Mon Sep 17 00:00:00 2001 From: Brambor Date: Tue, 17 Sep 2024 17:09:38 +0200 Subject: [PATCH 13/14] remove parameter avatar from game_menus::inv::unload_container --- src/game.cpp | 2 +- src/game_inventory.cpp | 3 ++- src/game_inventory.h | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index 54fdc7ca0a768..71a17ca1e64e3 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -9050,7 +9050,7 @@ void game::insert_item() void game::unload_container() { if( const std::optional pnt = choose_adjacent( _( "Unload where?" ) ) ) { - u.drop( game_menus::inv::unload_container( u ), *pnt ); + u.drop( game_menus::inv::unload_container(), *pnt ); } } diff --git a/src/game_inventory.cpp b/src/game_inventory.cpp index c0e621228636f..10dc9a94fc907 100644 --- a/src/game_inventory.cpp +++ b/src/game_inventory.cpp @@ -1841,8 +1841,9 @@ static bool valid_unload_container( const item_location &container ) && !container->contains_no_solids(); } -drop_locations game_menus::inv::unload_container( avatar &you ) +drop_locations game_menus::inv::unload_container() { + avatar &you = get_avatar(); inventory_filter_preset unload_preset( valid_unload_container ); inventory_drop_selector insert_menu( you, unload_preset, _( "CONTAINERS TO UNLOAD" ), diff --git a/src/game_inventory.h b/src/game_inventory.h index 0b7ff49d0d118..1cc3fd0bf1b0c 100644 --- a/src/game_inventory.h +++ b/src/game_inventory.h @@ -133,7 +133,7 @@ item_location wield(); /** Item wielding/unwielding menu. */ drop_locations holster( const item_location &holster ); void insert_items( item_location &holster ); -drop_locations unload_container( avatar &you ); +drop_locations unload_container(); /** Choosing a gun to saw down it's barrel. */ item_location saw_barrel( Character &you, item &tool ); /** Choosing a gun to saw down its barrel. */ From 86dc093d7eca87da6f420fe5d4fea6b634f64872 Mon Sep 17 00:00:00 2001 From: Brambor Date: Tue, 17 Sep 2024 17:14:23 +0200 Subject: [PATCH 14/14] remove parameter avatar from game_menus::inv::take_off --- src/game_inventory.cpp | 10 +++++----- src/game_inventory.h | 3 +-- src/handle_action.cpp | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/game_inventory.cpp b/src/game_inventory.cpp index 10dc9a94fc907..0308f9b97a0b2 100644 --- a/src/game_inventory.cpp +++ b/src/game_inventory.cpp @@ -435,8 +435,8 @@ item_location game_menus::inv::wear( Character &you, const bodypart_id &bp ) class take_off_inventory_preset: public armor_inventory_preset { public: - take_off_inventory_preset( Character &you, const std::string &color ) : - armor_inventory_preset( you, color ) + explicit take_off_inventory_preset( const std::string &color ) : + armor_inventory_preset( get_avatar(), color ) {} bool is_shown( const item_location &loc ) const override { @@ -454,10 +454,10 @@ class take_off_inventory_preset: public armor_inventory_preset } }; -item_location game_menus::inv::take_off( avatar &you ) +item_location game_menus::inv::take_off() { - return inv_internal( you, take_off_inventory_preset( you, "color_red" ), _( "Take off item" ), 1, - _( "You're not wearing anything." ) ); + return inv_internal( get_avatar(), take_off_inventory_preset( "color_red" ), _( "Take off item" ), + 1, _( "You're not wearing anything." ) ); } item_location game::inv_map_splice( const item_filter &filter, const std::string &title, int radius, diff --git a/src/game_inventory.h b/src/game_inventory.h index 1cc3fd0bf1b0c..cc8e6ad8036fa 100644 --- a/src/game_inventory.h +++ b/src/game_inventory.h @@ -14,7 +14,6 @@ class Character; struct tripoint; -class avatar; class repair_item_actor; class salvage_actor; @@ -146,7 +145,7 @@ item_location veh_tool_attach( Character &you, const std::string &vp_name, /** Choose item to wear. */ item_location wear( Character &you, const bodypart_id &bp = bodypart_id( "bp_null" ) ); /** Choose item to take off. */ -item_location take_off( avatar &you ); +item_location take_off(); /** Item cut up menu. */ item_location salvage( Character &you, const salvage_actor *actor ); /** Repair menu. */ diff --git a/src/handle_action.cpp b/src/handle_action.cpp index 7b2f5ce2cc4fd..c9282f7476b27 100644 --- a/src/handle_action.cpp +++ b/src/handle_action.cpp @@ -1624,7 +1624,7 @@ static void wear() static void takeoff() { avatar &player_character = get_avatar(); - item_location loc = game_menus::inv::take_off( player_character ); + item_location loc = game_menus::inv::take_off(); if( loc ) { player_character.takeoff( loc.obtain( player_character ) );