-
Notifications
You must be signed in to change notification settings - Fork 290
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
Add separate keybind for selecting which gun ammo is used by default #1660
Add separate keybind for selecting which gun ammo is used by default #1660
Conversation
src/player.cpp
Outdated
@@ -2451,32 +2451,35 @@ bool player::list_ammo( const item &base, std::vector<item::reload_option> &ammo | |||
bool ammo_match_found = false; | |||
int ammo_search_range = is_mounted() ? -1 : 1; | |||
for( const auto e : opts ) { | |||
for( item_location &ammo : find_ammo( *e, empty, ammo_search_range ) ) { | |||
for( item_location &ammo : find_ammo( *e, empty_mags, ammo_search_range ) ) { |
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.
If possible, it would be good to make const item_location&
.
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.
Huh, looks like it was non-const to allow move-initialization of item_location
for item::reload_option
a few lines down, except item::reload_option
's constructor takes a const item_location&
, so the move does nothing.
Removed that move and changed ammo
here to const item_location&
.
src/player.cpp
Outdated
// don't try to unload frozen liquids | ||
if( ammo->is_watertight_container() && ammo->contents_made_of( SOLID ) ) { | ||
continue; | ||
} | ||
auto id = ( ammo->is_ammo_container() || ammo->is_container() ) | ||
? ammo->contents.front().typeId() | ||
: ammo->typeId(); | ||
if( e->can_reload_with( id ) ) { | ||
bool can_reload_with = e->can_reload_with( id ); |
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.
const
?
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.
Consting primitives is a bit of an overkill, except where it really needs to be clear that this variable won't change.
Ideally, all primitives would be treated as const, except in cases where they obviously have to change (iteration, accumulator variable etc.).
Summary
SUMMARY: Interface "Add separate keybind for selecting which gun ammo is used by default"
Purpose of change
Fixes #1352
When pressing
F
to change gun mode if the gun has only 1 mode, and it's eitherRELOAD_AND_SHOOT
(slings, bows) orRELOAD_ONE
(shotguns, revolvers), the game will instead try to select default ammo to use.There are a couple problems with this:
Kel-Tec KSG
), it has a second firing mode, so the player loses ability to select default ammo.Describe the solution
F
key.Now, if the player tries to switch firing mode, and the gun has only 1 mode, it'll say so.
Describe alternatives you've considered
Not adding yet another keybind, and instead do either of:
RELOAD_AND_SHOOT
guns, as they are the main use case.RELOAD_ONE
guns and instead go straight to default ammo selection menu.Testing
Marked some ammo as default using the new key or from target ui, tried reloading various shotguns and firing bows.