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 crash when opening action menu with guns in inventory #39408

Merged
merged 1 commit into from
Apr 9, 2020

Conversation

Qrox
Copy link
Contributor

@Qrox Qrox commented Apr 9, 2020

Summary

SUMMARY: Bugfixes "Fix crash when opening action menu with guns in inventory"

Purpose of change

Fixes #39403. item::get_use calls visit_items, which ignores the item content if it is a gun or magazine, whereas item::get_usable_item calls contents.visit_contents, which iterates over the item content regardless of the item type. So when initializing the action menu, item::get_usable_item returns the item content if it has the wanted use action, but item::get_use returns null if the item is a gun. Dereferencing the return value causes the game to crash.

Describe the solution

Use visit_items in item::get_usable_item so content of guns and magazines are ignored.

Testing

Loaded the attached save from #39403, opened item action menu, and the crash no longer happened.

@Qrox Qrox mentioned this pull request Apr 9, 2020
@curstwist curstwist added <Bugfix> This is a fix for a bug (or closes open issue) Info / User Interface Game - player communication, menus, etc. [C++] Changes (can be) made in C++. Previously named `Code` labels Apr 9, 2020
@ZhilkinSerg ZhilkinSerg merged commit afed3a2 into CleverRaven:master Apr 9, 2020
@Qrox Qrox deleted the fix-action-menu-crash branch April 9, 2020 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
<Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Info / User Interface Game - player communication, menus, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Segmentation fault after opening the list of actions
3 participants