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

Bionic fingerpick fix #39857

Merged
merged 9 commits into from
May 4, 2020
Merged

Bionic fingerpick fix #39857

merged 9 commits into from
May 4, 2020

Conversation

Night-Pryanik
Copy link
Contributor

Summary

SUMMARY: Bugfixes "Bionic fingerpick fix."

Purpose of change

Closes #39740 - Finger Pick CBM Stuck Picking Forever.

Describe the solution

Replaced creating a temporary item and then invoking it with creating a temporary item, placing it into player inventory, assigning activity with this item, and destroying this item immediately after use. Using bionic lockpick will always consume fixed 4 seconds and will always be successful.

Also cancel activity if lockpick item location is lost for some reason.
Also replaced hardcoded list of allowed terrain/furniture within lockpicking actor with check for a newly added PICKABLE flag. Added documentation for this flag.
Also removed several unused consts from activity_handlers.cpp and iexamine.cpp.

Describe alternatives you've considered

Directly use invoke method for a temporary created item - no luck.

Testing

Debug-added bionic lockpicks CBM to my character. Activated it next to a locked gun safe. Spent 4 seconds, opened safe. Also tested mundane lockpicks on the locked gun safe - worked as intended.

Additional context

There is some strange reason activating the bionic fingerpick CBM and then selecting direction brings the bionic UI menu up front. You can activate the same CBM once again, and select direction once again. Lockpicking activity will occur only after you close the bionic UI menu. I couldn't get rid of this behavior, and I don't know if it's related to my changes.

Valiant added 7 commits April 24, 2020 11:26
Also destroy PSEUDO items after use. Also remove unused consts.
Now it temporarily creates a copy of a fake bionic lockpicks item in player inventory, activates activity with this item, and immediately after that removes this item from inventory.
@Night-Pryanik Night-Pryanik added Bionics CBM (Compact Bionic Modules) <Bugfix> This is a fix for a bug (or closes open issue) labels Apr 24, 2020
@ifreund
Copy link
Contributor

ifreund commented Apr 24, 2020

What happens if an activity using the fingerpick gets cancelled? It seems that the pseudo item would live in the player's inventory forever with the current code which could potentially cause issues.

@Pupsi-Mupsi
Copy link
Contributor

Pupsi-Mupsi commented Apr 24, 2020

Well done and thank you!

You may have accidentally deleted this:

static const bionic_id bio_fingerhack( "bio_fingerhack" );

bio_fingerhack != bio_lockpick

grafik

@Night-Pryanik
Copy link
Contributor Author

static const bionic_id bio_fingerhack( "bio_fingerhack" ) isn't used anywhere in activity_handlers.cpp, so I deleted it as well.

…em from player's inventory if activity is canceled mid-way
@Night-Pryanik
Copy link
Contributor Author

What happens if an activity using the fingerpick gets cancelled? It seems that the pseudo item would live in the player's inventory forever with the current code which could potentially cause issues.

Added a special case if lockpicking activity is canceled mid-way: remove fake bionic lockpick.

Comment on lines +9188 to +9195
if( has_activity( ACT_LOCKPICK ) ) {
std::vector<item *> bio_picklocks = g->u.items_with( []( const item & itm ) {
return itm.typeId() == "pseudo_bio_picklock";
} );
if( !bio_picklocks.empty() ) {
g->u.i_rem( bio_picklocks[0] );
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this still seems a little fragile as this wont be run if the activity is stopped using player_activity::set_to_null() for example. I think we could instead set a variable on the activity to indicate that it is using the bionic lockpick. Then we could insert the pseudo item into the player's inventory on completion of the activity if that variable is set. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the activity is stopped using player_activity::set_to_null()

I didn't find any cases which could stop this activity by the means of set_to_null. Could you please list any?

Then we could insert the pseudo item into the player's inventory on completion of the activity if that variable is set.

The item must be inserted prior to completion of activity, not after it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't find any cases which could stop this activity by the means of set_to_null. Could you please list any?

It may very well be fine with the current code. When i said "fragile" i meant likely to break and cause bugs in the future if the code is changed.

The item must be inserted prior to completion of activity, not after it.

This behavior isn't set in stone, it could be changed. One way to do this would be to set the first member of player_activity::str_values to bio_picklock if using the fingerpick and check for that string before checking the targets vector at the start of the finish function. If that string is present, the pseudo item could then be inserted into the players inventory and used instead of the first item_location in the targets vector. In my opinion, such an approach would be less prone to cause problems in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bionics CBM (Compact Bionic Modules) <Bugfix> This is a fix for a bug (or closes open issue)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Finger Pick CBM Stuck Picking Forever
4 participants