Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix several prying/picking tools bugs #2135

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1145,7 +1145,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 @@ -1167,7 +1167,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