Skip to content

Commit

Permalink
Merge pull request #42077 from Trioct/fix-item-deletion
Browse files Browse the repository at this point in the history
Fix some item deletion bugs
  • Loading branch information
kevingranade authored Jul 14, 2020
2 parents 322725a + 533483b commit 6486441
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2330,11 +2330,11 @@ std::vector<item_location> Character::nearby( const
item_pocket *Character::best_pocket( const item &it, const item *avoid )
{
item_pocket *ret = nullptr;
if( &weapon != avoid ) {
if( &weapon != &it && &weapon != avoid ) {
ret = weapon.best_pocket( it );
}
for( item &worn_it : worn ) {
if( &worn_it == avoid ) {
if( &worn_it == &it || &worn_it == avoid ) {
continue;
}
item_pocket *internal_pocket = worn_it.best_pocket( it );
Expand Down
16 changes: 5 additions & 11 deletions src/monexamine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,11 +363,8 @@ void monexamine::insert_battery( monster &z )
return;
}
item *bat_item = bat_inv[index - 1];
int item_pos = player_character.get_item_position( bat_item );
if( item_pos != INT_MIN ) {
z.battery_item = cata::make_value<item>( *bat_item );
player_character.i_rem( item_pos );
}
z.battery_item = cata::make_value<item>( *bat_item );
player_character.i_rem( bat_item );
}

bool monexamine::mech_hack( monster &z )
Expand Down Expand Up @@ -739,12 +736,9 @@ void monexamine::tie_or_untie( monster &z )
return;
}
item *rope_item = rope_inv[index - 1];
int item_pos = player_character.get_item_position( rope_item );
if( item_pos != INT_MIN ) {
z.tied_item = cata::make_value<item>( *rope_item );
player_character.i_rem( item_pos );
z.add_effect( effect_tied, 1_turns, num_bp, true );
}
z.tied_item = cata::make_value<item>( *rope_item );
player_character.i_rem( rope_item );
z.add_effect( effect_tied, 1_turns, num_bp, true );
}
}

Expand Down

0 comments on commit 6486441

Please sign in to comment.