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

Not to try to reload a gun without default ammo type defined #73714

Conversation

osuphobia
Copy link
Contributor

Summary

Bugfixes "Not to try to reload a gun without default ammo type defined"

Purpose of change

When using guns that don't have default ammo type defined and must be used with an extra bore gunmod, don't try to reload one without a bore attached.
Close #71754

Describe the solution

Added item_location::can_reload_with to check if the gun has default ammo type defined.

Describe alternatives you've considered

Tried to modify item::can_reload_with, but looks like it's hard to get parent item without item_location known. find_parent didn't work.

Testing

Create a new world without this patch, spawn a desert eagle that has no bore by default, sees that you can reload it with an empty mag, and then reload the gun with .44 Magnum.
Save and quit, apply the batch and load the save, and now you can no longer reload the bald gun. Attach a .44 conversion kit to the gun, then you can reload it as normal.

Additional context

With this PR and #73043 merged, #71754 should be totally fixed.

@github-actions github-actions bot added Info / User Interface Game - player communication, menus, etc. Code: Tests Measurement, self-control, statistics, balancing. [C++] Changes (can be) made in C++. Previously named `Code` Items: Ammo / Guns Ammunition for all kinds of weapons and these weapons themselves <Bugfix> This is a fix for a bug (or closes open issue) labels May 12, 2024
src/item_location.cpp Outdated Show resolved Hide resolved
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@github-actions github-actions bot added json-styled JSON lint passed, label assigned by github actions astyled astyled PR, label is assigned by github actions labels May 12, 2024
@dseguin dseguin merged commit 46926a4 into CleverRaven:master May 12, 2024
25 checks passed
@osuphobia osuphobia deleted the Should-not-reload-a-gun-without-ammo-defined branch May 13, 2024 01:15
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Code: Tests Measurement, self-control, statistics, balancing. Info / User Interface Game - player communication, menus, etc. Items: Ammo / Guns Ammunition for all kinds of weapons and these weapons themselves json-styled JSON lint passed, label assigned by github actions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Segfault when reloading a gun with a mag but without conversion kit
2 participants