Skip to content

Commit

Permalink
change Character::change_side parameter to item_location
Browse files Browse the repository at this point in the history
  • Loading branch information
KorGgenT committed Dec 17, 2019
1 parent c762b5d commit 1de9623
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 24 deletions.
8 changes: 3 additions & 5 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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." ),
Expand All @@ -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<encumbrance_data, num_bp> &vals,
Expand Down
2 changes: 1 addition & 1 deletion src/character.h
Original file line number Diff line number Diff line change
Expand Up @@ -1505,7 +1505,7 @@ class Character : public Creature, public visitable<Character>

/** 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.) */
Expand Down
18 changes: 1 addition & 17 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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();
Expand Down
1 change: 0 additions & 1 deletion src/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 1de9623

Please sign in to comment.