Skip to content

Commit

Permalink
Fix several prying/picking tools bugs (cataclysmbnteam#2135)
Browse files Browse the repository at this point in the history
* fix 'manholes and coffins unselectable in examine'

* fix wearable items not taken into account for lockpicking or prying

* fix 'Examine auto-lockpick action asks for a direction'

* clang tidy

* remove hack

* fix fix
  • Loading branch information
leoCottret authored Oct 31, 2022
1 parent 8c20f74 commit 8d367e5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 15 deletions.
1 change: 1 addition & 0 deletions data/json/furniture_and_terrain/furniture-storage.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"move_cost_mod": -1,
"coverage": 40,
"required_str": 14,
"examine_action": "locked_object",
"flags": [
"TRANSPARENT",
"CONTAINER",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
"color": "dark_gray",
"move_cost": 2,
"flags": [ "TRANSPARENT" ],
"examine_action": "locked_object",
"pry": {
"success_message": "You lift the manhole cover.",
"fail_message": "You pry, but cannot lift the manhole cover.",
Expand Down
19 changes: 6 additions & 13 deletions src/iexamine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1462,13 +1462,9 @@ void iexamine::gunsafe_el( player &p, const tripoint &examp )

static safe_reference<item> find_best_prying_tool( player &p )
{
std::vector<item *> prying_items = p.items_with( [&p]( const item & it ) {
// Don't search for worn items such as hairpins
if( p.get_item_position( &it ) >= -1 ) {
item temporary_item( it.type );
return temporary_item.has_quality( quality_id( "PRY" ), 1 );
}
return false;
std::vector<item *> prying_items = p.items_with( []( const item & it ) {
// we want to get worn items (eg crowbar in toolbelt), so no check on item position
return it.has_quality( quality_id( "PRY" ), 1 );
} );

// Sort by their quality level.
Expand All @@ -1486,12 +1482,9 @@ static safe_reference<item> find_best_prying_tool( player &p )

static safe_reference<item> find_best_lock_picking_tool( player &p )
{
std::vector<item *> picklocks = p.items_with( [&p]( const item & it ) {
// Don't search for worn items such as hairpins
if( p.get_item_position( &it ) >= -1 ) {
return it.type->get_use( "picklock" ) != nullptr;
}
return false;
std::vector<item *> picklocks = p.items_with( []( const item & it ) {
// we want to get worn items (eg hairpin), so no check on item position
return it.type->get_use( "picklock" ) != nullptr;
} );

// Sort by their picklock level.
Expand Down
4 changes: 2 additions & 2 deletions src/iuse_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1144,7 +1144,7 @@ void pick_lock_actor::load( const JsonObject &obj )
pick_quality = obj.get_int( "pick_quality" );
}

int pick_lock_actor::use( player &p, item &it, bool, const tripoint & ) const
int pick_lock_actor::use( player &p, item &it, bool, const tripoint &t ) const
{
if( p.is_npc() ) {
return 0;
Expand All @@ -1166,7 +1166,7 @@ int pick_lock_actor::use( player &p, item &it, bool, const tripoint & ) const
return is_allowed;
};

const cata::optional<tripoint> pnt_ = choose_adjacent_highlight(
const cata::optional<tripoint> pnt_ = ( t != p.pos() ) ? t : choose_adjacent_highlight(
_( "Use your lockpick where?" ), _( "There is nothing to lockpick nearby." ), f, false );
if( !pnt_ ) {
return 0;
Expand Down

0 comments on commit 8d367e5

Please sign in to comment.