-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Reload all guns and magazines #28245
Reload all guns and magazines #28245
Conversation
@kevingranade I am still insisting that it has multiple problems. Probably it is not for 0.D. But it is still problem. |
Could we make it so that if all guns and magazines in the inventory are reloaded but there are still empty ones on the ground in the tile you are standing on that it asks if the reload should continue with those? |
56dcff4
to
f852f36
Compare
src/character.cpp
Outdated
{ | ||
std::vector<item_location> reloadables; | ||
|
||
visit_items( [this, &reloadables]( item *node ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
visit_items( [this, &reloadables]( item *node ) { | |
visit_items( [this, &reloadables]( item * node ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gah, these files got astyled while the PR was pending, hopefully this will be the last time I have to deal with that...
src/character.cpp
Outdated
bool reloadable = false; | ||
if( node->is_gun() && !node->magazine_compatible().empty() ) { | ||
reloadable = node->magazine_current() == nullptr || | ||
node->ammo_remaining() < node->ammo_capacity(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
node->ammo_remaining() < node->ammo_capacity(); | |
node->ammo_remaining() < node->ammo_capacity(); |
src/character.cpp
Outdated
} else { | ||
reloadable = ( node->is_magazine() || node->is_bandolier() || | ||
( node->is_gun() && node->magazine_integral() ) ) && | ||
node->ammo_remaining() < node->ammo_capacity(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
node->ammo_remaining() < node->ammo_capacity(); | |
node->ammo_remaining() < node->ammo_capacity(); |
29f25b1
to
331f3b4
Compare
331f3b4
to
b2ff110
Compare
} | ||
GIVEN( "the player also has another gun with ammo" ) { | ||
item &mag2 = dummy.i_add( item( "glockbigmag", 0, 0 ) ); | ||
const cata::optional<islot_magazine> &magazine_type2 = mag2.type->magazine; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Un)surprisingly breaks tests in osxcross-builds:
https://ci.narc.ro/job/Cataclysm-Matrix/Graphics=Curses,Platform=OSX/8648/console
13:04:20 CCACHE_CPP2=1 ccache /usr/local/osxcross/osxcross/target/bin/x86_64-apple-darwin15-clang++ -DRELEASE -DMACOSX -DGIT_VERSION -DBACKTRACE -DLOCALIZE -DUSE_HOME_DIR -ffast-math -O0 -Wall -Wextra -fsigned-char -stdlib=libc++ -Werror -std=c++11 -MMD -MP -mmacosx-version-min=10.7 -I/usr/local/osxcross/libs/gettext/include -I/usr/local/osxcross/libs/ncurses/include -I../src -Wno-unused-variable -Wno-sign-compare -Wno-unknown-pragmas -Wno-parentheses -MMD -MP -Wall -Wextra -c savegame_test.cpp -o obj/savegame_test.o
13:04:21 reloading_test.cpp:263:55: error: unused variable 'magazine_type2' [-Werror,-Wunused-variable]
13:04:21 const cata::optional<islot_magazine> &magazine_type2 = mag2.type->magazine;
13:04:21 ^
13:04:21 1 error generated.
someone said it breaks reload/unload |
Summary
SUMMARY: Features "Reload all guns and magazines in inventory if reload command is repeatedly triggered."
Purpose of change
Streamlines reloading guns and magazines by automatically select guns and magazines to reload instead of requiring the player to go through the inventory for each one.
Describe the solution
Enumerates all reloadable weapons in the player inventory, sorts them into an advantageous order, and then reloads the first valid option.
Reload wielded gun.
First reload a magazine if necessary.
Then load said magazine into gun.
Reload magazines that are compatible with the current gun.
Reload other guns in inventory.
Reload misc magazines in inventory.