From 1de96235b3f7ddfa611d4958aebfcbb5c9d98f8b Mon Sep 17 00:00:00 2001 From: KorGgenT Date: Sat, 14 Dec 2019 11:39:32 -0500 Subject: [PATCH] change Character::change_side parameter to item_location --- src/character.cpp | 8 +++----- src/character.h | 2 +- src/game.cpp | 18 +----------------- src/game.h | 1 - 4 files changed, 5 insertions(+), 24 deletions(-) diff --git a/src/character.cpp b/src/character.cpp index 68485c3f1dbcf..1809eff252d45 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -2603,11 +2603,9 @@ bool Character::change_side( item &it, bool interactive ) return true; } -bool Character::change_side( int pos, bool interactive ) +bool Character::change_side( item_location &loc, bool interactive ) { - item &it( i_at( pos ) ); - - if( !is_worn( it ) ) { + if( !loc || !is_worn( *loc ) ) { if( interactive ) { add_msg_player_or_npc( m_info, _( "You are not wearing that item." ), @@ -2616,7 +2614,7 @@ bool Character::change_side( int pos, bool interactive ) return false; } - return change_side( it, interactive ); + return change_side( *loc, interactive ); } static void layer_item( std::array &vals, diff --git a/src/character.h b/src/character.h index 84f228e9be0ca..02610eeb724de 100644 --- a/src/character.h +++ b/src/character.h @@ -1505,7 +1505,7 @@ class Character : public Creature, public visitable /** Swap side on which item is worn; returns false on fail. If interactive is false, don't alert player or drain moves */ bool change_side( item &it, bool interactive = true ); - bool change_side( int pos, bool interactive = true ); + bool change_side( item_location &loc, bool interactive = true ); /** Used to determine player feedback on item use for the inventory code. * rates usability lower for non-tools (books, etc.) */ diff --git a/src/game.cpp b/src/game.cpp index a5df20ff55c33..46f0e37b1fa7d 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -2089,7 +2089,7 @@ int game::inventory_item_menu( int pos, int iStartX, int iWidth, avatar_action::plthrow( u, pos ); break; case 'c': - change_side( pos ); + u.change_side( locThisItem ); break; case 'T': u.takeoff( oThisItem ); @@ -8336,22 +8336,6 @@ void game::butcher() } } -void game::change_side( int pos ) -{ - if( pos == INT_MIN ) { - auto filter = [&]( const item & it ) { - return u.is_worn( it ) && it.is_sided(); - }; - pos = u.get_item_position( game_menus::inv::titled_filter_menu( filter, u, - _( "Change side for item" ), _( "You don't have sided items worn." ) ).get_item() ); - } - if( pos == INT_MIN ) { - add_msg( _( "Never mind." ) ); - return; - } - u.change_side( pos ); -} - void game::reload( item_location &loc, bool prompt, bool empty ) { item *it = loc.get_item(); diff --git a/src/game.h b/src/game.h index e3bee9492d814..f91ad8e31585c 100644 --- a/src/game.h +++ b/src/game.h @@ -769,7 +769,6 @@ class game void butcher(); // Butcher a corpse 'B' - void change_side( int pos = INT_MIN ); // Change the side on which an item is worn 'c' void reload( item_location &loc, bool prompt = false, bool empty = true ); void mend( int pos = INT_MIN ); public: